Esempio n. 1
0
def check_for_updated_sensors(old, new):
    old_sensors = sensors_to_dict(old)
    new_sensors = sensors_to_dict(new)
    updated_sensors = []

    for sensor_name, sensor in new_sensors.items():
        old_state = old_sensors[sensor_name]["state"]
        if sensor["state"] != old_state:
            updated_sensors.append(sensor)

    return updated_sensors
Esempio n. 2
0
def check_for_new_sensors(old, new):
    old_sensors = sensors_to_dict(old)
    new_sensors = sensors_to_dict(new)
    added_sensors = []

    for sensor_name in new_sensors:
        if sensor_name not in old_sensors:
            added_sensors.append(new_sensors[sensor_name])

    if len(added_sensors) > 0:
        return added_sensors

    return None
Esempio n. 3
0
def check_for_missing_sensors(old, new):
    old_sensors = sensors_to_dict(old)
    new_sensors = sensors_to_dict(new)
    removed_sensors = []

    for sensor_name in old_sensors:
        if sensor_name not in new_sensors:
            removed_sensors.append(old_sensors[sensor_name])

    if len(removed_sensors) > 0:
        return removed_sensors

    return None