Skip to content

Commit

Permalink
add AqaraWallOutlet support (#717)
Browse files Browse the repository at this point in the history
* add AqaraWallOutlet support

* black formatting

* add AqaraWallOutlet control capability
  • Loading branch information
starkillerOG authored Jun 6, 2020
1 parent 96c9add commit dd0255c
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions miio/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down Expand Up @@ -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()

0 comments on commit dd0255c

Please sign in to comment.