Fixed typo, Improved away mode trigger mechanism

This commit is contained in:
Maximilian Giller 2024-05-09 02:43:17 +02:00
parent ab249a679d
commit dbf11551c5

View file

@ -7,6 +7,7 @@ from ..hue import hue
refresh_every_seconds: int = 15 # Every x seconds devices are polled again refresh_every_seconds: int = 15 # Every x seconds devices are polled again
trigger_away_after_seconds: int = 60 # After all away-devices are gone for x seconds trigger_away_after_seconds: int = 60 # After all away-devices are gone for x seconds
away_triggered = False
away_devices = ["B2:06:77:EE:A9:0F"] # Max' iPhone away_devices = ["B2:06:77:EE:A9:0F"] # Max' iPhone
macaddresses_to_track = ["B2:06:77:EE:A9:0F"] # Max' iPhone macaddresses_to_track = ["B2:06:77:EE:A9:0F"] # Max' iPhone
@ -30,9 +31,9 @@ def get_all_devices() -> list:
return devices return devices
def get_specific_device(mac_adress: str) -> dict: def get_specific_device(mac_address: str) -> dict:
return fritz_api.call_action( return fritz_api.call_action(
"Hosts", "GetSpecificHostEntry", NewMACAddress=mac_adress "Hosts", "GetSpecificHostEntry", NewMACAddress=mac_address
) )
@ -46,9 +47,13 @@ def check_for_change():
break break
# Execute away mode # Execute away mode
global away_triggered
if all_away: if all_away:
if not away_triggered:
away_triggered = True
hue.in_room_deactivate_lights("Max Zimmer") hue.in_room_deactivate_lights("Max Zimmer")
else:
away_triggered = False
async def track_network_devices(): async def track_network_devices():
global devices_last_online global devices_last_online