Skip to content

Commit

Permalink
Gateway: Add AqaraSmartBulbE27 support (#729)
Browse files Browse the repository at this point in the history
* Add AqaraSmartBulbE27 support

Also add untested bind commands to docstring

* fix black styling

* fix flake8
  • Loading branch information
starkillerOG authored Jun 20, 2020
1 parent b0a28f0 commit de28e85
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions miio/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ class Gateway(Device):
* toggle_plug
* remove_all_bind
* list_bind [0]
* bind_page
* bind
* remove_bind
* self.get_prop("used_for_public") # Return the 'used_for_public' status, return value: [0] or [1], probably this has to do with developer mode.
* self.set_prop("used_for_public", state) # Set the 'used_for_public' state, value: 0 or 1, probably this has to do with developer mode.
Expand Down Expand Up @@ -1309,6 +1312,46 @@ class AqaraSmartBulbE27(SubDevice):
_model = "ZNLDP12LM"
_name = "Smart bulb E27"

@attr.s(auto_attribs=True)
class props:
"""Device specific properties."""

status: str = None # 'on' / 'off'
brightness: int = None # in %
color_temp: int = None # cct value from _ctt_min to _ctt_max
cct_min: int = 153
cct_max: int = 500

@command()
def update(self):
"""Update all device properties."""
self._props.brightness = self.send("get_bright").pop()
self._props.color_temp = self.send("get_ct").pop()
if self._props.brightness > 0 and self._props.brightness <= 100:
self._props.status = "on"
else:
self._props.status = "off"

@command()
def on(self):
"""Turn bulb on."""
return self.send_arg("set_power", ["on"]).pop()

@command()
def off(self):
"""Turn bulb off."""
return self.send_arg("set_power", ["off"]).pop()

@command(click.argument("ctt", type=int))
def set_color_temp(self, ctt):
"""Set the color temperature of the bulb ctt_min-ctt_max."""
return self.send_arg("set_ct", [ctt]).pop()

@command(click.argument("brightness", type=int))
def set_brightness(self, brightness):
"""Set the brightness of the bulb 1-100."""
return self.send_arg("set_bright", [brightness]).pop()


class CubeV2(SubDevice):
"""Subdevice CubeV2 specific properties and methods."""
Expand Down

0 comments on commit de28e85

Please sign in to comment.