diff --git a/README.md b/README.md index 65ceeb9..02b2de5 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,7 @@ $ snap get -d theengs-gateway "scan-duration": 5, "time-between": 5 }, + "general-presence": 0, "ha": { "discovery": 1, "discovery-device-name": "TheengsGateway", diff --git a/scripts/bin/management-script b/scripts/bin/management-script index 53457e7..40d3b5a 100755 --- a/scripts/bin/management-script +++ b/scripts/bin/management-script @@ -27,6 +27,7 @@ DEFAULT_BINDKEYS="" DEFAULT_IDENTITIES="" DEFAULT_ENABLE_BLE="1" DEFAULT_TRACKER_TIMEOUT="120" +DEFAULT_GENERAL_PRESENCE="0" # ADAPTER adapter() { @@ -647,3 +648,26 @@ previous_tracker_timeout() { set_previous_tracker_timeout() { snapctl set private.tracker-timeout="$1" } + +# GENERAL PRESENCE +general_presence() { + general_presence_enable="$(snapctl get general-presence)" + if [ -z "$general_presence_enable" ]; then + general_presence_enable="$DEFAULT_GENERAL_PRESENCE" + set_general_presence "$general_presence_enable" + set_previous_general_presence "$general_presence_enable" + fi + echo "$general_presence_enable" +} + +set_general_presence() { + snapctl set general-presence="$1" +} + +previous_general_presence() { + snapctl get private.general-presence +} + +set_previous_general_presence() { + snapctl set private.general-presence="$1" +} diff --git a/scripts/bin/theengs-gateway-wrapper b/scripts/bin/theengs-gateway-wrapper index 82fd963..9a348ef 100755 --- a/scripts/bin/theengs-gateway-wrapper +++ b/scripts/bin/theengs-gateway-wrapper @@ -56,5 +56,7 @@ ENABLE_BLE="$(enable_ble)" export ENABLE_BLE TRACKER_TIMEOUT="$(tracker_time)" export TRACKER_TIMEOUT +GENERAL_PRESENCE="$(general_presence)" +export GENERAL_PRESENCE -"$SNAP/bin/TheengsGateway" -H "$HOST" -P "$PORT" -u "$USER" -p "$PASS" -pt "$PUB_TOPIC" -st "$SUB_TOPIC" -sd "$SCAN_DUR" -tb "$TIME_BETWEEN" -ll "$LOG_LEVEL" -Dt "$DISCOVERY_TOPIC" -D "$DISCOVERY" -Dh "$HASS_DISCOVERY" -Dn "$DISCOVERY_DEVICE_NAME" -Df "$DISCOVERY_FILTER" -a "$ADAPTER" -ts "$TIME_SYNC" -tf "$TIME_FORMAT" -prt "$PRESENCE_TOPIC" -pr "$PRESENCE" -Lt "$LWT_TOPIC" -padv "$PUBLISH_ADVDATA" -tls "$ENABLE_TLS" -ws "$ENABLE_WS" -bk "$BINDKEYS" -id "$IDENTITIES" -b "$ENABLE_BLE" -to "$TRACKER_TIMEOUT" +"$SNAP/bin/TheengsGateway" -H "$HOST" -P "$PORT" -u "$USER" -p "$PASS" -pt "$PUB_TOPIC" -st "$SUB_TOPIC" -sd "$SCAN_DUR" -tb "$TIME_BETWEEN" -ll "$LOG_LEVEL" -Dt "$DISCOVERY_TOPIC" -D "$DISCOVERY" -Dh "$HASS_DISCOVERY" -Dn "$DISCOVERY_DEVICE_NAME" -Df "$DISCOVERY_FILTER" -a "$ADAPTER" -ts "$TIME_SYNC" -tf "$TIME_FORMAT" -prt "$PRESENCE_TOPIC" -pr "$PRESENCE" -Lt "$LWT_TOPIC" -padv "$PUBLISH_ADVDATA" -tls "$ENABLE_TLS" -ws "$ENABLE_WS" -bk "$BINDKEYS" -id "$IDENTITIES" -b "$ENABLE_BLE" -to "$TRACKER_TIMEOUT" -Gp "$GENERAL_PRESENCE" diff --git a/snap/hooks/configure b/snap/hooks/configure index 4bf32b4..8b02f85 100644 --- a/snap/hooks/configure +++ b/snap/hooks/configure @@ -415,3 +415,18 @@ handle_tracker_timeout_config() { restart_gateway_if_running } handle_tracker_timeout_config + +handle_general_presence_config() { + general_presence="$(general_presence)" + previous_general_presence="$(previous_general_presence)" + + if [ "$general_presence" = "$previous_general_presence" ]; then + return 0 + fi + + set_general_presence "$general_presence" + set_previous_general_presence "$general_presence" + + restart_gateway_if_running +} +handle_general_presence_config diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index cfde798..2df0341 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -10,7 +10,7 @@ description: | LYWSDCGQ, and Mi Flora. It translates these data into a readable JSON format and pushes those to an MQTT broker. icon: snap/local/logo-Theengs.png -version: 1.3.0 +version: 1.4.0 license: GPL-3.0 contact: koen@vervloesem.eu website: https://github.com/theengs/gateway-snap @@ -28,7 +28,7 @@ parts: theengs-decoder: plugin: python source: https://github.com/theengs/decoder.git - source-tag: v1.6.8 + source-tag: v1.7.0 source-subdir: python override-pull: | craftctl default @@ -52,7 +52,7 @@ parts: - theengs-decoder plugin: python source: https://github.com/theengs/gateway.git - source-tag: v1.3.0 + source-tag: v1.4.0 override-pull: | craftctl default # Don't build Theengs Decoder as a dependency,