Skip to content

Commit

Permalink
Throwing GatewayException in get_illumination (#831)
Browse files Browse the repository at this point in the history
* Throwing GatewayException in get_illumination

I'm not sure if the GatewayException type is only suitable for SubDevice or is also allowed here, but it is the exception HA expects in this case:
https://github.com/home-assistant/core/blob/985e4e1bd942ef4ab56617a77f59baeec10649c5/homeassistant/components/xiaomi_miio/sensor.py#L320:L325

* Fix black validation
  • Loading branch information
javicalle authored Oct 11, 2020
1 parent 9ec9ac4 commit c4ab5e6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion miio/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,12 @@ def timezone(self):
@command()
def get_illumination(self):
"""Get illumination. In lux?"""
return self.send("get_illumination").pop()
try:
return self.send("get_illumination").pop()
except Exception as ex:
raise GatewayException(
"Got an exception while getting gateway illumination"
) from ex


class GatewayDevice(Device):
Expand Down

0 comments on commit c4ab5e6

Please sign in to comment.