Change data location from /share to /data; Introduce eval

This commit is contained in:
Max Winterstein
2021-03-06 10:36:41 +01:00
parent 76993f8802
commit b8b3b783c3
6 changed files with 47 additions and 13 deletions

View File

@@ -1,5 +1,9 @@
# Changelog # 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 ## [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) - Update `eufy-ha-mqtt-bridge` to `0.2.11` [Changelog](https://github.com/matijse/eufy-ha-mqtt-bridge/releases)

View File

@@ -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.

View File

@@ -3,7 +3,7 @@ FROM $BUILD_FROM
ARG VERSION=0.2.11 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 source and unpack
ADD "https://github.com/matijse/eufy-ha-mqtt-bridge/archive/${VERSION}.tar.gz" /src.tar.gz ADD "https://github.com/matijse/eufy-ha-mqtt-bridge/archive/${VERSION}.tar.gz" /src.tar.gz

View File

@@ -14,11 +14,7 @@
<a href="https://www.buymeacoffee.com/MaxWinterstein" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" height="41" width="174"></a> <a href="https://www.buymeacoffee.com/MaxWinterstein" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" height="41" width="174"></a>
Based on https://github.com/matijse/eufy-ha-mqtt-bridge. **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! 🚨

View File

@@ -1,6 +1,6 @@
{ {
"name": "Eufy Home Assistant MQTT Bridge", "name": "Eufy Home Assistant MQTT Bridge",
"version": "1.11.0", "version": "1.12.0",
"slug": "eufy-ha-mqtt-bridge", "slug": "eufy-ha-mqtt-bridge",
"image": "maxwinterstein/homeassistant-addon-eufy-ha-mqtt-bridge-{arch}", "image": "maxwinterstein/homeassistant-addon-eufy-ha-mqtt-bridge-{arch}",
"description": "Publish events as MQTT messages", "description": "Publish events as MQTT messages",
@@ -24,7 +24,8 @@
"password": "homeassistant", "password": "homeassistant",
"keepalive": 60 "keepalive": 60
}, },
"log_level": "info" "log_level": "info",
"eval": ""
}, },
"schema": { "schema": {
"eufy": { "eufy": {
@@ -36,9 +37,9 @@
"username": "str?", "username": "str?",
"password": "str?", "password": "str?",
"keepalive": "int?" "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", "stage": "experimental",
"url": "https://github.com/matijse/eufy-ha-mqtt-bridge/", "url": "https://github.com/matijse/eufy-ha-mqtt-bridge/",

View File

@@ -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` export NODE_CONSOLE_LOG_LEVEL=`bashio::config log_level`
bashio::log.info "Symlinking data dir" bashio::log.info "Symlinking data dir"
mkdir -p /share/eufy-ha-mqtt-bridge/data
rm -rf /app/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" bashio::log.info "Generating config.yml from options.json"
echo '# Generated by homeassistant, do not edit!' > /app/data/config.yml 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 json2yml /data/options.json >> /app/data/config.yml
bashio::log.info "Image build with version $(cat /version)" bashio::log.info "Image build with version $(cat /version)"
bashio::log.info "starting original stuff..." bashio::log.info "starting original stuff..."
npm run start npm run start