diff --git a/homeassistant/components/geniushub/__init__.py b/homeassistant/components/geniushub/__init__.py index 4beca61e139..7eb24fa8f95 100644 --- a/homeassistant/components/geniushub/__init__.py +++ b/homeassistant/components/geniushub/__init__.py @@ -63,7 +63,7 @@ async def async_setup(hass, hass_config): hass.async_create_task(async_load_platform( hass, platform, DOMAIN, {}, hass_config)) - if not data._client._api_v1: # pylint: disable=protected-access + if data._client.api_version == 3: # pylint: disable=protected-access for platform in ['sensor', 'binary_sensor']: hass.async_create_task(async_load_platform( hass, platform, DOMAIN, {}, hass_config)) diff --git a/homeassistant/components/geniushub/binary_sensor.py b/homeassistant/components/geniushub/binary_sensor.py index c0f0d90028d..07f8bd5111f 100644 --- a/homeassistant/components/geniushub/binary_sensor.py +++ b/homeassistant/components/geniushub/binary_sensor.py @@ -1,10 +1,10 @@ """Support for Genius Hub binary_sensor devices.""" -from datetime import datetime import logging from homeassistant.components.binary_sensor import BinarySensorDevice from homeassistant.core import callback from homeassistant.helpers.dispatcher import async_dispatcher_connect +from homeassistant.util.dt import utc_from_timestamp from . import DOMAIN @@ -67,9 +67,8 @@ class GeniusBinarySensor(BinarySensorDevice): attrs = {} attrs['assigned_zone'] = self._device.assignedZones[0]['name'] - last_comms = self._device._info_raw['childValues']['lastComms']['val'] # noqa; pylint: disable=protected-access + last_comms = self._device._raw_json['childValues']['lastComms']['val'] # noqa; pylint: disable=protected-access if last_comms != 0: - attrs['last_comms'] = datetime.utcfromtimestamp( - last_comms).isoformat() + attrs['last_comms'] = utc_from_timestamp(last_comms).isoformat() return {**attrs} diff --git a/homeassistant/components/geniushub/manifest.json b/homeassistant/components/geniushub/manifest.json index eff5a65c6b5..98145ea0944 100644 --- a/homeassistant/components/geniushub/manifest.json +++ b/homeassistant/components/geniushub/manifest.json @@ -3,7 +3,7 @@ "name": "Genius Hub", "documentation": "https://www.home-assistant.io/components/geniushub", "requirements": [ - "geniushub-client==0.5.00" + "geniushub-client==0.5.4" ], "dependencies": [], "codeowners": ["@zxdavb"] diff --git a/homeassistant/components/geniushub/sensor.py b/homeassistant/components/geniushub/sensor.py index a52bd2d692f..a14eb4b7a8e 100644 --- a/homeassistant/components/geniushub/sensor.py +++ b/homeassistant/components/geniushub/sensor.py @@ -62,10 +62,13 @@ class GeniusDevice(Entity): @property def icon(self): """Return the icon of the sensor.""" - values = self._device._info_raw['childValues'] # noqa; pylint: disable=protected-access + values = self._device._raw_json['childValues'] # noqa; pylint: disable=protected-access last_comms = utc_from_timestamp(values['lastComms']['val']) - interval = timedelta(seconds=values['WakeUp_Interval']['val']) + if 'WakeUp_Interval' in values: + interval = timedelta(seconds=values['WakeUp_Interval']['val']) + else: + interval = timedelta(minutes=20) if last_comms < utcnow() - interval * 3: return 'mdi:battery-unknown' @@ -100,7 +103,7 @@ class GeniusDevice(Entity): @property def state(self): """Return the state of the sensor.""" - level = self._device.state['batteryLevel'] + level = self._device.state.get('batteryLevel', 255) return level if level != 255 else 0 @property @@ -109,7 +112,7 @@ class GeniusDevice(Entity): attrs = {} attrs['assigned_zone'] = self._device.assignedZones[0]['name'] - last_comms = self._device._info_raw['childValues']['lastComms']['val'] # noqa; pylint: disable=protected-access + last_comms = self._device._raw_json['childValues']['lastComms']['val'] # noqa; pylint: disable=protected-access attrs['last_comms'] = utc_from_timestamp(last_comms).isoformat() return {**attrs} diff --git a/requirements_all.txt b/requirements_all.txt index 6e7346abd83..5dbb63f1384 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -517,7 +517,7 @@ gearbest_parser==1.0.7 geizhals==0.0.9 # homeassistant.components.geniushub -geniushub-client==0.5.00 +geniushub-client==0.5.4 # homeassistant.components.geo_json_events # homeassistant.components.nsw_rural_fire_service_feed