-
Notifications
You must be signed in to change notification settings - Fork 2
devolo Metering Plug
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 metering plug you want to switch - in this snippet called "Light" located in "Office". Then you need to find the property "binary_switch". Since the devolo Metering Plugs only have one switch, you can directly access the first list object and access the state.
metering_plug = homecontrol.devices.get(homecontrol.device_names.get("Light/Office"))
binary_switch = metering_plug.get_property("binary_switch")[0]
print(binary_switch.state)
Let's assume you want to switch the same metering plug 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).
metering_plug = homecontrol.devices.get(homecontrol.device_names.get("Light/Office"))
binary_switch = metering_plug.get_property("binary_switch")[0]
binary_switch.set(state=True)
Let's assume once again you want to switch the same metering plug as in the last chapter. This time you need to find the property "consumption". Since the devolo Metering Plugs 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.
metering_plug = homecontrol.devices.get(homecontrol.device_names.get("Light/Office"))
consumption = metering_plug.get_property("consumption")[0]
print(consumption.current)
print(consumption.current_unit)
print(consumption.total)
print(consumption.total_unit)
print(consumption.total_since)
The voltage is a multi_level_sensor value. So following the by now know path, you have to find that property, can access the first element right away as there is one measuring system and access the value with the corresponding unit.
metering_plug = homecontrol.devices.get(homecontrol.device_names.get("Light/Office"))
voltage = metering_plug.get_property("multi_level_sensor")[0]
print(voltage.value)
print(voltage.unit)