From c4ab5e6f63df67e2b30cb0ec8160e85e1df8e63d Mon Sep 17 00:00:00 2001 From: javicalle <31999997+javicalle@users.noreply.github.com> Date: Sun, 11 Oct 2020 02:51:38 +0200 Subject: [PATCH] Throwing GatewayException in get_illumination (#831) * 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 --- miio/gateway.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/miio/gateway.py b/miio/gateway.py index e8d4ee768..96b158852 100644 --- a/miio/gateway.py +++ b/miio/gateway.py @@ -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):