Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade Theengs Gateway to 1.3.0 #24

Merged
merged 1 commit into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ $ snap get -d theengs-gateway
"bindkeys": "",
"ble": {
"adapter": "",
"enable": 1,
"scan-duration": 5,
"time-between": 5
},
Expand Down Expand Up @@ -79,7 +80,8 @@ $ snap get -d theengs-gateway
"presence": {
"topic": "home/TheengsGateway/presence",
"enable": 0
}
},
"tracker-timeout": 120
}
```

Expand Down
48 changes: 48 additions & 0 deletions scripts/bin/management-script
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ DEFAULT_ENABLE_TLS="0"
DEFAULT_ENABLE_WS="0"
DEFAULT_BINDKEYS=""
DEFAULT_IDENTITIES=""
DEFAULT_ENABLE_BLE="1"
DEFAULT_TRACKER_TIMEOUT="120"

# ADAPTER
adapter() {
Expand Down Expand Up @@ -599,3 +601,49 @@ previous_identities() {
set_previous_identities() {
snapctl set private.identities="$1"
}

# ENABLE_BLE
enable_ble() {
enable_ble_enable="$(snapctl get ble.enable)"
if [ -z "$enable_ble_enable" ]; then
enable_ble_enable="$DEFAULT_ENABLE_BLE"
set_enable_ble "$enable_ble_enable"
set_previous_enable_ble "$enable_ble_enable"
fi
echo "$enable_ble_enable"
}

set_enable_ble() {
snapctl set ble.enable="$1"
}

previous_enable_ble() {
snapctl get private.ble.enable
}

set_previous_enable_ble() {
snapctl set private.ble.enable="$1"
}

# TRACKER_TIMEOUT
tracker_time() {
tracker_timeout="$(snapctl get tracker-timeout)"
if [ -z "$tracker_timeout" ]; then
tracker_timeout="$DEFAULT_TRACKER_TIMEOUT"
set_tracker_timeout "$tracker_timeout"
set_previous_tracker_timeout "$tracker_timeout"
fi
echo "$tracker_timeout"
}

set_tracker_timeout() {
snapctl set tracker_timeout="$1"
}

previous_tracker_timeout() {
snapctl get private.tracker-timeout
}

set_previous_tracker_timeout() {
snapctl set private.tracker-timeout="$1"
}
6 changes: 5 additions & 1 deletion scripts/bin/theengs-gateway-wrapper
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,9 @@ BINDKEYS="$(bindkeys)"
export BINDKEYS
IDENTITIES="$(identities)"
export IDENTITIES
ENABLE_BLE="$(enable_ble)"
export ENABLE_BLE
TRACKER_TIMEOUT="$(tracker_time)"
export 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"
"$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"
30 changes: 30 additions & 0 deletions snap/hooks/configure
Original file line number Diff line number Diff line change
Expand Up @@ -385,3 +385,33 @@ handle_identities_config() {
restart_gateway_if_running
}
handle_identities_config

handle_enable_ble_config() {
enable_ble="$(enable_ble)"
previous_enable_ble="$(previous_enable_ble)"

if [ "$enable_ble" = "$previous_enable_ble" ]; then
return 0
fi

set_enable_ble "$enable_ble"
set_previous_enable_ble "$enable_ble"

restart_gateway_if_running
}
handle_enable_ble_config

handle_tracker_timeout_config() {
tracker_time="$(tracker_time)"
previous_tracker_timeout="$(previous_tracker_timeout)"

if [ "$tracker_time" = "$previous_tracker_timeout" ]; then
return 0
fi

set_tracker_timeout "$tracker_time"
set_previous_tracker_timeout "$tracker_time"

restart_gateway_if_running
}
handle_tracker_timeout_config
6 changes: 3 additions & 3 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.2.0
version: 1.3.0
license: GPL-3.0
contact: [email protected]
website: https://github.com/theengs/gateway-snap
Expand All @@ -28,7 +28,7 @@ parts:
theengs-decoder:
plugin: python
source: https://github.com/theengs/decoder.git
source-tag: v1.6.4
source-tag: v1.6.8
source-subdir: python
override-pull: |
craftctl default
Expand All @@ -52,7 +52,7 @@ parts:
- theengs-decoder
plugin: python
source: https://github.com/theengs/gateway.git
source-tag: v1.2.0
source-tag: v1.3.0
override-pull: |
craftctl default
# Don't build Theengs Decoder as a dependency,
Expand Down
Loading