diff --git a/miio/gateway.py b/miio/gateway.py index b09516a06..bb35b12a1 100644 --- a/miio/gateway.py +++ b/miio/gateway.py @@ -169,6 +169,7 @@ def discover_devices(self): DeviceType.AqaraMagnet: AqaraMagnet, DeviceType.AqaraSwitchOneChannel: AqaraSwitchOneChannel, DeviceType.AqaraSwitchTwoChannels: AqaraSwitchTwoChannels, + DeviceType.AqaraWallOutlet: AqaraWallOutlet, } devices_raw = self.get_prop("device_list") self._devices = [] @@ -926,3 +927,38 @@ def update(self): self._props.status_ch0 = values[0] self._props.status_ch1 = values[1] self._props.load_power = values[2] + + +class AqaraWallOutlet(SubDevice): + """Subdevice AqaraWallOutlet specific properties and methods""" + + properties = ["channel_0", "load_power"] + + @attr.s(auto_attribs=True) + class props: + """Device specific properties""" + + status: str = None # 'on' / 'off' + load_power: int = None # power consumption in Watt + + @command() + def update(self): + """Update all device properties""" + values = self.get_property_exp(self.properties) + self._props.status = values[0] + self._props.load_power = values[1] + + @command() + def toggle(self): + """Toggle Aqara Wall Outlet""" + return self.send_arg("toggle_plug", ["channel_0", "toggle"]).pop() + + @command() + def on(self): + """Turn on Aqara Wall Outlet""" + return self.send_arg("toggle_plug", ["channel_0", "on"]).pop() + + @command() + def off(self): + """Turn off Aqara Wall Outlet""" + return self.send_arg("toggle_plug", ["channel_0", "off"]).pop()