mirror of
https://github.com/aljazceru/addons.git
synced 2025-12-18 13:44:20 +01:00
Add HASS configurator to core add-ons (#180)
* Initial commit for HASS configurator * Requested changes * Update Dockerfile * update mechanics like other core add-ons * simplify * Update config.json * Update config.json * Update Dockerfile * Delete configurator.py * Create run.sh * Create map.py * Update and rename hass-configurator/config.json to configurator/config.json * Rename hass-configurator/Dockerfile to configurator/Dockerfile * Update and rename hass-configurator/map.py to configurator/map.py * Rename hass-configurator/run.sh to configurator/run.sh * Update map.py * add image for build * Update Dockerfile
This commit is contained in:
committed by
Pascal Vizeli
parent
d93eec0e66
commit
4e01f98a5b
19
configurator/Dockerfile
Normal file
19
configurator/Dockerfile
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
ARG BUILD_FROM
|
||||||
|
FROM $BUILD_FROM
|
||||||
|
|
||||||
|
# Add env
|
||||||
|
ENV LANG C.UTF-8
|
||||||
|
|
||||||
|
# Setup base
|
||||||
|
ARG BUILD_VERSION
|
||||||
|
RUN apk add --no-cache python3 git curl \
|
||||||
|
&& pip3 install GitPython \
|
||||||
|
&& curl -s -o /configurator.py https://raw.githubusercontent.com/danielperna84/hass-configurator/$BUILD_VERSION/configurator.py \
|
||||||
|
&& sed -i "s/GIT = False/GIT = True/g" /configurator.py \
|
||||||
|
&& apk del curl
|
||||||
|
|
||||||
|
# Copy data
|
||||||
|
COPY map.py run.sh /
|
||||||
|
RUN chmod a+x /run.sh
|
||||||
|
|
||||||
|
CMD ["/run.sh"]
|
||||||
38
configurator/config.json
Normal file
38
configurator/config.json
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
{
|
||||||
|
"name": "Configurator",
|
||||||
|
"version": "0.2.0",
|
||||||
|
"slug": "configurator",
|
||||||
|
"description": "Browser-based configuration file editor for Home Assistant.",
|
||||||
|
"url": "https://home-assistant.io/addons/configurator",
|
||||||
|
"startup": "application",
|
||||||
|
"webui": "http://[HOST]:[PORT:3218]",
|
||||||
|
"boot": "auto",
|
||||||
|
"ports": {
|
||||||
|
"3218/tcp": 3218
|
||||||
|
},
|
||||||
|
"map": ["config:rw", "ssl"],
|
||||||
|
"options": {
|
||||||
|
"homeassistant_api": "http://homeassistant:8123/api",
|
||||||
|
"homeassistant_password": "",
|
||||||
|
"credentials": "admin:secret",
|
||||||
|
"certfile": "fullchain.pem",
|
||||||
|
"keyfile": "privkey.pem",
|
||||||
|
"ssl": false,
|
||||||
|
"allowed_networks": ["192.168.0.0/16"],
|
||||||
|
"banned_ips": ["8.8.8.8"],
|
||||||
|
"ignore_pattern": ["__pycache__"]
|
||||||
|
},
|
||||||
|
"schema": {
|
||||||
|
"homeassistant_api": "url",
|
||||||
|
"homeassistant_password": "str",
|
||||||
|
"credentials": "match(.*:.*)",
|
||||||
|
"certfile": "str",
|
||||||
|
"keyfile": "str",
|
||||||
|
"ssl": "bool",
|
||||||
|
"allowed_networks": ["str"],
|
||||||
|
"banned_ips": ["str"],
|
||||||
|
"ignore_pattern": ["str"]
|
||||||
|
},
|
||||||
|
"image": "homeassistant/{arch}-addon-configurator"
|
||||||
|
}
|
||||||
|
|
||||||
25
configurator/map.py
Normal file
25
configurator/map.py
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
"""Mapping hass.io options.json into configurator config."""
|
||||||
|
import json
|
||||||
|
from pathlib import Path
|
||||||
|
import sys
|
||||||
|
|
||||||
|
hassio_options = Path("/data/options.json")
|
||||||
|
|
||||||
|
# Read hass.io options
|
||||||
|
with hassio_options.open('r') as json_file:
|
||||||
|
options = json.loads(json_file.read())
|
||||||
|
|
||||||
|
configurator = {
|
||||||
|
'BASEPATH': "/config",
|
||||||
|
'HASS_API': options['homeassistant_api'],
|
||||||
|
'HASS_API_PASSWORD': options['homeassistant_password'],
|
||||||
|
'CREDENTIALS': options['credentials'],
|
||||||
|
'SSL_CERTIFICATE': options['certfile'] if options['ssl'] else None,
|
||||||
|
'SSL_KEY': options['keyfile'] if options['ssl'] else None,
|
||||||
|
'ALLOWED_NETWORKS': options['allowed_networks'],
|
||||||
|
'BANNED_IPS': options['banned_ips'],
|
||||||
|
'IGNORE_PATTERN': options['ignore_pattern'],
|
||||||
|
}
|
||||||
|
|
||||||
|
with Path(sys.argv[1]).open('w') as json_file:
|
||||||
|
json_file.write(json.dumps(configurator))
|
||||||
8
configurator/run.sh
Normal file
8
configurator/run.sh
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Map hassio value into hass-configurator options
|
||||||
|
python3 /map.py /tmp/configurator.json
|
||||||
|
|
||||||
|
# Run configurator
|
||||||
|
exec python3 /configurator.py /tmp/configurator.json
|
||||||
Reference in New Issue
Block a user