From db4bb9ccb6cd457c1b2e0792e421e79c6909eb34 Mon Sep 17 00:00:00 2001 From: Alexandre Date: Tue, 24 Jan 2023 16:39:19 +0100 Subject: [PATCH] Allow all options --- enedisgateway2mqtt_dev/README.md | 9 +++---- enedisgateway2mqtt_dev/config.json | 6 ++--- .../rootfs/etc/cont-init.d/99-run.sh | 25 +++++++++---------- 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/enedisgateway2mqtt_dev/README.md b/enedisgateway2mqtt_dev/README.md index f0095033d..a877807fe 100644 --- a/enedisgateway2mqtt_dev/README.md +++ b/enedisgateway2mqtt_dev/README.md @@ -19,8 +19,7 @@ _Thanks to everyone having starred my repo! To star it click on the image below, ## About -Enedisgateway2mqtt use Enedis Gateway API to send data in your MQTT Broker. -See its github for all informations : https://github.com/m4dm4rtig4n/myelectricaldata +MyElectricalData allows an automated access to your Enedis data. See its github for all informations : https://github.com/m4dm4rtig4n/myelectricaldata ## Configuration @@ -31,15 +30,15 @@ Options can be configured through two ways : - Addon options ```yaml -CONFIG_LOCATION: /config/enedisgateway2mqtt/enedisgateway2mqtt.conf # Sets the location of the config.yaml (see below) +CONFIG_LOCATION: /config/myelectricaldata/config.yaml # Sets the location of the config.yaml (see below) mqtt_autodiscover: true # Shows in the log the detail of the mqtt local server (if available). It can then be added to the config.yaml file. TZ: Europe/Paris # Sets a specific timezone ``` - Config.yaml - Everything is configured using the config.yaml file found in /config/enedisgateway2mqtt/enedisgateway2mqtt.conf. + Everything is configured using the config.yaml file found in /config/myelectricaldata/config.yaml. -The complete list of options can be seen here : https://github.com/m4dm4rtig4n/enedisgateway2mqtt#environment-variable +The complete list of options can be seen here : https://github.com/m4dm4rtig4n/myelectricaldata/wiki/03.-Configuration ## Installation diff --git a/enedisgateway2mqtt_dev/config.json b/enedisgateway2mqtt_dev/config.json index 94c102408..46f83773b 100644 --- a/enedisgateway2mqtt_dev/config.json +++ b/enedisgateway2mqtt_dev/config.json @@ -6,13 +6,13 @@ ], "codenotary": "alexandrep.github@gmail.com", "description": "Use Enedis Gateway API to send data in your MQTT Broker (dev channel)", - "image": "ghcr.io/alexbelgium/enedisgateway2mqtt_dev-{arch}", + "image": "ghcr.io/alexbelgium/myelectricaldata_dev-{arch}", "map": [ "config:rw" ], "name": "MyElectricalData Dev", "options": { - "CONFIG_LOCATION": "/config/enedisgateway2mqtt_dev/config.yaml", + "CONFIG_LOCATION": "/config/myelectricaldata_dev/config.yaml", "TZ": "Europe/Paris", "mqtt_autodiscover": true, "verbose": true @@ -35,4 +35,4 @@ "slug": "enedisgateway2mqtt_dev", "url": "https://github.com/alexbelgium/hassio-addons", "version": "0.8.13" -} +} \ No newline at end of file diff --git a/enedisgateway2mqtt_dev/rootfs/etc/cont-init.d/99-run.sh b/enedisgateway2mqtt_dev/rootfs/etc/cont-init.d/99-run.sh index 68eaef97c..7c7b01645 100755 --- a/enedisgateway2mqtt_dev/rootfs/etc/cont-init.d/99-run.sh +++ b/enedisgateway2mqtt_dev/rootfs/etc/cont-init.d/99-run.sh @@ -19,9 +19,14 @@ if [ -f /data/config.yaml ] && [ ! -L /data/config.yaml ]; then mv /data/config.yaml "$CONFIGSOURCE".bak fi -############ -# DATABASE # -############ +######################################################### +# MIGRATION FROM ENEDISGATEWAY2MQTT TO MYELECTRICALDATA # +######################################################### + +if [ -f /config/addons_config/enedisgateway2mqtt_dev/config.yaml ]; then + mv /config/addons_config/enedisgateway2mqtt_dev/* "$(dirname "${CONFIGSOURCE}")"/ + rm -r /config/addons_config/enedisgateway2mqtt_dev +fi # If migration was performed, save file in config folder if [ -f /data/enedisgateway.db.migrate ]; then @@ -31,7 +36,6 @@ fi # If migration was performed, save file in config folder if [ -f /data/cache.db ] && [ ! -f "$DATABASESOURCE" ]; then - if [ -f "$(dirname "${CONFIGSOURCE}")"/enedisgateway.db ]; then mv "$(dirname "${CONFIGSOURCE}")"/enedisgateway.db "$(dirname "${CONFIGSOURCE}")"/enedisgateway.db.bak2; fi mv /data/cache.db "$(dirname "${CONFIGSOURCE}")" fi @@ -40,6 +44,10 @@ if [ -f "$(dirname "${CONFIGSOURCE}")"/enedisgateway.db ]; then mv "$(dirname "${CONFIGSOURCE}")"/enedisgateway.db /data fi +############ +# DATABASE # +############ + # Check if database is here or create symlink if [ -f "$DATABASESOURCE" ]; then # Create symlink if not existing yet @@ -90,13 +98,4 @@ echo " " bashio::log.info "Starting the app" echo " " -# Test mode -TZ=$(bashio::config "TZ") -if [ "$TZ" = "test" ]; then - echo "secret mode found, launching script in /config/test.sh" - cd /config || exit - chmod 777 test.sh - ./test.sh -fi - python -u /app/main.py || bashio::log.fatal "The app has crashed. Are you sure you entered the correct config options?"