From d26fd2cfe22ee530a76505c9813183fcbda95ae6 Mon Sep 17 00:00:00 2001 From: Seb Ruiz Date: Thu, 12 Mar 2020 16:26:48 +1100 Subject: [PATCH] Fix KeyError from Rain Delay binary sensor if no key exists on the device status Fixes #7 --- custom_components/bhyve/binary_sensor.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/custom_components/bhyve/binary_sensor.py b/custom_components/bhyve/binary_sensor.py index ba7bc82..157241f 100644 --- a/custom_components/bhyve/binary_sensor.py +++ b/custom_components/bhyve/binary_sensor.py @@ -47,8 +47,8 @@ def _setup(self, device): self._attrs = {} self._available = device.get("is_connected", False) - device_status = device["status"] - rain_delay = device_status["rain_delay"] + device_status = device.get("status", {}) + rain_delay = device_status.get("rain_delay") self._update_device_cb = None self._extract_rain_delay(rain_delay, device_status)