diff --git a/eufy-ha-mqtt-bridge/CHANGELOG.md b/eufy-ha-mqtt-bridge/CHANGELOG.md index 57eba79..659251f 100644 --- a/eufy-ha-mqtt-bridge/CHANGELOG.md +++ b/eufy-ha-mqtt-bridge/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## [1.12.0] - 2021-03-06 +- Introduce new `eval` options +- Do no longer store `/data` inside `share` folder + ## [1.11.0] - 2021-02-15 - Update `eufy-ha-mqtt-bridge` to `0.2.11` [Changelog](https://github.com/matijse/eufy-ha-mqtt-bridge/releases) diff --git a/eufy-ha-mqtt-bridge/DOCS.md b/eufy-ha-mqtt-bridge/DOCS.md new file mode 100644 index 0000000..12c5ef4 --- /dev/null +++ b/eufy-ha-mqtt-bridge/DOCS.md @@ -0,0 +1,32 @@ +# Home Assistant Add-on: Eufy Home Assistant MQTT Bridge + +## Configuration +### `eval` (string) +Allows to pass some bash commands to run every time before the start of the bridge. + +Multi-line commands are possible but must end with `;`. See examples below. + +You might want to disable this after a run. + +*Only use when you know what you are doing!* + + +#### Example: Symlink data dir to `shares` +```yaml +eval: | + bashio::log.info "Symlinking data dir"; + mkdir -p /share/eufy-ha-mqtt-bridge/data; + rm -rf /app/data; + ln -s /share/eufy-ha-mqtt-bridge/data /app; +``` + +#### Example: Export payloads to file +To help adding more devices it is crucial to provide some information, see https://github.com/matijse/eufy-ha-mqtt-bridge/issues/7. + +```yaml +eval: > + sqlite3 -csv /app/data/database.sqlite "SELECT "'*'" FROM push_payloads" > + /share/export.csv +``` + +*Note:* Asterisk must be removed from the double quotes. \ No newline at end of file diff --git a/eufy-ha-mqtt-bridge/Dockerfile b/eufy-ha-mqtt-bridge/Dockerfile index e44a63f..3818dcc 100644 --- a/eufy-ha-mqtt-bridge/Dockerfile +++ b/eufy-ha-mqtt-bridge/Dockerfile @@ -3,7 +3,7 @@ FROM $BUILD_FROM ARG VERSION=0.2.11 -RUN apk add --no-cache nodejs npm make g++ +RUN apk add --no-cache nodejs npm make g++ sqlite # add source and unpack ADD "https://github.com/matijse/eufy-ha-mqtt-bridge/archive/${VERSION}.tar.gz" /src.tar.gz diff --git a/eufy-ha-mqtt-bridge/README.md b/eufy-ha-mqtt-bridge/README.md index 528a069..bcb87f0 100644 --- a/eufy-ha-mqtt-bridge/README.md +++ b/eufy-ha-mqtt-bridge/README.md @@ -14,11 +14,7 @@ Buy Me A Coffee -Based on https://github.com/matijse/eufy-ha-mqtt-bridge. - -Application data will be written to `/share/eufy-ha-mqtt-bridge/` so log and other files can be accessed from other addons, e.g. the `Samba share` addon, or view it at the `Visual Studio Code` add-on. - -🚨 This also contains some plaintext configuration file with login credentials, so take care who can access your files! 🚨 +**Based on https://github.com/matijse/eufy-ha-mqtt-bridge.** diff --git a/eufy-ha-mqtt-bridge/config.json b/eufy-ha-mqtt-bridge/config.json index 45a50dd..eca58e9 100644 --- a/eufy-ha-mqtt-bridge/config.json +++ b/eufy-ha-mqtt-bridge/config.json @@ -1,6 +1,6 @@ { "name": "Eufy Home Assistant MQTT Bridge", - "version": "1.11.0", + "version": "1.12.0", "slug": "eufy-ha-mqtt-bridge", "image": "maxwinterstein/homeassistant-addon-eufy-ha-mqtt-bridge-{arch}", "description": "Publish events as MQTT messages", @@ -24,7 +24,8 @@ "password": "homeassistant", "keepalive": 60 }, - "log_level": "info" + "log_level": "info", + "eval": "" }, "schema": { "eufy": { @@ -36,9 +37,9 @@ "username": "str?", "password": "str?", "keepalive": "int?" - }, - "log_level": "list(error|warn|info|http|verbose|debug|silly)" + "log_level": "list(error|warn|info|http|verbose|debug|silly)", + "eval": "str?" }, "stage": "experimental", "url": "https://github.com/matijse/eufy-ha-mqtt-bridge/", diff --git a/eufy-ha-mqtt-bridge/run.sh b/eufy-ha-mqtt-bridge/run.sh index 0b1d7cf..a5bb3f2 100644 --- a/eufy-ha-mqtt-bridge/run.sh +++ b/eufy-ha-mqtt-bridge/run.sh @@ -4,9 +4,11 @@ bashio::log.info "Exporting log level for nodejs: $(bashio::config log_level)" export NODE_CONSOLE_LOG_LEVEL=`bashio::config log_level` bashio::log.info "Symlinking data dir" -mkdir -p /share/eufy-ha-mqtt-bridge/data rm -rf /app/data -ln -s /share/eufy-ha-mqtt-bridge/data /app # symlink data mount from share +ln -s /data /app + +bashio::log.info "Running 'eval' commands" +eval $(bashio::config eval) bashio::log.info "Generating config.yml from options.json" echo '# Generated by homeassistant, do not edit!' > /app/data/config.yml @@ -14,6 +16,5 @@ echo '# Edit configuration only at the Add-on configuration tab!' >> /app/data/c json2yml /data/options.json >> /app/data/config.yml bashio::log.info "Image build with version $(cat /version)" - bashio::log.info "starting original stuff..." npm run start \ No newline at end of file