diff --git a/homeassistant/components/sensor/pi_hole.py b/homeassistant/components/sensor/pi_hole.py index c6ffdcaf64c..a578a6bb119 100644 --- a/homeassistant/components/sensor/pi_hole.py +++ b/homeassistant/components/sensor/pi_hole.py @@ -25,7 +25,7 @@ ATTR_QUERIES_TODAY = 'queries_today' DEFAULT_HOST = 'localhost' DEFAULT_METHOD = 'GET' -DEFAULT_NAME = 'Pi-hole' +DEFAULT_NAME = 'Pi-Hole' DEFAULT_SSL = False DEFAULT_VERIFY_SSL = True @@ -59,7 +59,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None): rest.update() if rest.data is None: - _LOGGER.error('Unable to fetch REST data') + _LOGGER.error("Unable to fetch data from Pi-Hole") return False add_devices([PiHoleSensor(hass, rest, name)]) @@ -99,5 +99,8 @@ class PiHoleSensor(Entity): def update(self): """Get the latest data from REST API and updates the state.""" - self.rest.update() - self._state = json.loads(self.rest.data) + try: + self.rest.update() + self._state = json.loads(self.rest.data) + except TypeError: + _LOGGER.error("Unable to fetch data from Pi-Hole")