Skip to content

Commit

Permalink
Hardcode wakeup_period (#340)
Browse files Browse the repository at this point in the history
* Hardcode wakeup_period

* Bump version
  • Loading branch information
bieniu committed Dec 29, 2023
1 parent ad5ad9e commit 3f55704
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions python_scripts/shellies_discovery_gen2.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""This script adds MQTT discovery support for Shellies Gen2 devices."""
VERSION = "2.24.0"
VERSION = "2.24.1"

ATTR_BATTERY_POWERED = "battery_powered"
ATTR_BINARY_SENSORS = "binary_sensors"
Expand Down Expand Up @@ -37,6 +37,7 @@
ATTR_TEMPERATURE_STEP = "temperature_step"
ATTR_THERMOSTATS = "thermostats"
ATTR_UPDATES = "updates"
ATTR_WAKEUP_PERIOD = "wakeup_period"

BUTTON_MUTE_ALARM = "mute_alarm"
BUTTON_RESTART = "restart"
Expand Down Expand Up @@ -1441,6 +1442,7 @@
SENSOR_WIFI_SIGNAL: DESCRIPTION_SLEEPING_SENSOR_WIFI_SIGNAL,
},
ATTR_MIN_FIRMWARE_DATE: 20230803,
ATTR_WAKEUP_PERIOD: 7200,
},
MODEL_PLUS_I4: {
ATTR_NAME: "Shelly Plus I4",
Expand Down Expand Up @@ -1652,6 +1654,7 @@
SENSOR_WIFI_SIGNAL: DESCRIPTION_SLEEPING_SENSOR_WIFI_SIGNAL,
},
ATTR_MIN_FIRMWARE_DATE: 20230803,
ATTR_WAKEUP_PERIOD: 86400,
},
MODEL_PLUS_WALL_DIMMER: {
ATTR_NAME: "Shelly Plus Wall Dimmer",
Expand Down Expand Up @@ -3002,7 +3005,6 @@ def remove_old_script_versions():

device_name = device_config["sys"]["device"].get(ATTR_NAME)
device_url = f"http://{device_id}.local/"
wakeup_period = device_config["sys"].get("sleep", {}).get("wakeup_period", 0)

if not device_name:
device_name = SUPPORTED_MODELS[model][ATTR_NAME]
Expand All @@ -3029,6 +3031,7 @@ def remove_old_script_versions():
KEY_SUPPORT_URL: "https://github.com/bieniu/ha-shellies-discovery-gen2",
}

wakeup_period = SUPPORTED_MODELS[model].get(ATTR_WAKEUP_PERIOD, 0)
if wakeup_period > 0:
availability = None
expire_after = wakeup_period * 1.2
Expand Down

0 comments on commit 3f55704

Please sign in to comment.