Skip to content

Commit

Permalink
fixes issue with parsing of home automation alert and switch state #111
Browse files Browse the repository at this point in the history
  • Loading branch information
bb-Ricardo committed Nov 8, 2023
1 parent 10d7288 commit d86a337
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions fritzinfluxdb/classes/fritzbox/service_definitions/homeauto.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,23 @@ def get_ha_switch_state(data):
if in_test_mode():
return int((datetime.now().timestamp() - test_start_ts) / 1000) % 2

return "0"+grab(data, "switch.state", fallback="0")
# noinspection PyBroadException
try:
return int(grab(data, "switch.state", fallback="0"))
except Exception:
return 0


def get_ha_alert_state(data):

if in_test_mode():
return int((datetime.now().timestamp() - test_start_ts) / 600) % 2

return "0"+grab(data, "alert.state", fallback="0")
# noinspection PyBroadException
try:
return int(grab(data, "alert.state", fallback="0"))
except Exception:
return 0


def decode_function_bitmask(bitmask: int):
Expand Down

0 comments on commit d86a337

Please sign in to comment.