parent
8ffc6c05b7
commit
16a98359c3
|
@ -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))
|
||||
|
|
|
@ -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}
|
||||
|
|
|
@ -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"]
|
||||
|
|
|
@ -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}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue