-
Notifications
You must be signed in to change notification settings - Fork 2
devolo Switch FM
The following snippets assume, that you already created a working instance of HomeControl and an instance of Mydevolo. Please see the page about connecting to the backend for further information.
First you need to find the device UID of the switch you want to switch - in this snippet called "Relay" located in "Office". Then you need to find the property "binary_switch". Since the devolo FM Switches only have one switch, you can directly access the first list object and access the state.
switch_fm = homecontrol.devices.get(homecontrol.device_names.get("Relay/Office"))
binary_switch = switch_fm.get_property("binary_switch")[0]
print(binary_switch.state)Let's assume you want to switch the same switch as in the last chapter. So finding it needs basically the same steps. You can set the binary switch to either True (turn on) or False (turn off).
switch_fm = homecontrol.devices.get(homecontrol.device_names.get("Relay/Office"))
binary_switch = switch_fm.get_property("binary_switch")[0]
binary_switch.set(state=True)Let's assume once again you want to query the same switch as in the last chapter. This time you need to find the property "consumption". Since the devolo FM Switches only have one measuring system, you can directly access the first list object. It will show you the current power consumption including its unit, the total consumption including its unit and the date, this collection was started. This date is of type datetime.
switch_fm = homecontrol.devices.get(homecontrol.device_names.get("Relay/Office"))
consumption = switch_fm.get_property("consumption")[0]
print(consumption.current)
print(consumption.current_unit)
print(consumption.total)
print(consumption.total_unit)
print(consumption.total_since)The devolo FM Switches have two additional binary sensors. To get their states, you have to find the property "binary_sensor". This time, there is more than one sensor in the game, so you cannot simply access the first one. You have to inspect the sensor_type.
switch_fm = homecontrol.devices.get(homecontrol.device_names.get("Relay/Office"))
binary_sensors = switch_fm.get_property("binary_sensors")
for sensor in binary_sensors:
if sensor.sensor_type == "input_i2":
print(sensor.state)
if sensor.sensor_type == "input_i3":
print(sensor.state)The devolo FM Switches have a protection against overloading. This state is also a binary sensor.
switch_fm = homecontrol.devices.get(homecontrol.device_names.get("Relay/Office"))
binary_sensors = switch_fm.get_property("binary_sensors")
for sensor in binary_sensors:
if sensor.sensor_type == "alarm":
print(sensor.state)