fritz_temp_sync/sync_ha_fb.py aktualisiert
This commit is contained in:
parent
f6f46fba8f
commit
89fc6ea73c
@ -22,13 +22,14 @@ async def handle_event(idx: int):
|
|||||||
if entity_id in sensor_mappings.keys() or entity_id in thermostate_mappings.keys():
|
if entity_id in sensor_mappings.keys() or entity_id in thermostate_mappings.keys():
|
||||||
state = await ha.get_device_state(entity_id)
|
state = await ha.get_device_state(entity_id)
|
||||||
new_state = event["data"]["new_state"]
|
new_state = event["data"]["new_state"]
|
||||||
logging.debug(f"received changed state from {entity_id}")
|
logging.info(f"received changed state from {entity_id} {entity_id in thermostate_mappings.keys()} {state['state']}")
|
||||||
if entity_id in thermostate_mappings.keys() and state["state"] != "unavailable":
|
if entity_id in thermostate_mappings.keys() and state["state"] != "unavailable":
|
||||||
therm_temp = new_state["attributes"]["current_temperature"]
|
therm_temp = new_state["attributes"]["current_temperature"]
|
||||||
therm_name = new_state["attributes"]["friendly_name"]
|
therm_name = new_state["attributes"]["friendly_name"]
|
||||||
sensor = thermostate_mappings[entity_id]
|
sensor = thermostate_mappings[entity_id]
|
||||||
sensor_state = await ha.get_device_state(sensor)
|
sensor_state = await ha.get_device_state(sensor)
|
||||||
sensor_temp = round(float(sensor_state["attributes"]["temperature"]) * 2) / 2
|
sensor_temp = round(float(sensor_state["attributes"]["temperature"]) * 2) / 2
|
||||||
|
logger.info(f"temps: {therm_temp} {sensor_temp}")
|
||||||
if therm_temp != sensor_temp:
|
if therm_temp != sensor_temp:
|
||||||
logging.info(f"{therm_name}: {therm_temp}\n{sensor}: {sensor_state['attributes']['temperature']} ({sensor_temp})")
|
logging.info(f"{therm_name}: {therm_temp}\n{sensor}: {sensor_state['attributes']['temperature']} ({sensor_temp})")
|
||||||
fb.correct_offset(therm_name, sensor_temp)
|
fb.correct_offset(therm_name, sensor_temp)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user