Skip to content

Commit

Permalink
Throwing GatewayException in get_illumination (rytilahti#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 and swim2sun committed Oct 13, 2020
1 parent a37e4c6 commit da9be70
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 da9be70

Please sign in to comment.