Black
This commit is contained in:
1 parent
da05dfe708
commit
4de97abc3a
2676 files changed
+163166
-140084
No files matched your search
@@ -10,17 +10,17 @@ from . import DOMAIN
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
GH_IS_SWITCH = ['Dual Channel Receiver', 'Electric Switch', 'Smart Plug']
|
||||
GH_IS_SWITCH = ["Dual Channel Receiver", "Electric Switch", "Smart Plug"]
|
||||
|
||||
|
||||
async def async_setup_platform(hass, config, async_add_entities,
|
||||
discovery_info=None):
|
||||
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
|
||||
"""Set up the Genius Hub sensor entities."""
|
||||
client = hass.data[DOMAIN]['client']
|
||||
client = hass.data[DOMAIN]["client"]
|
||||
|
||||
devices = [d for d in client.hub.device_objs if d.type is not None]
|
||||
switches = [GeniusBinarySensor(client, d)
|
||||
for d in devices if d.type[:21] in GH_IS_SWITCH]
|
||||
switches = [
|
||||
GeniusBinarySensor(client, d) for d in devices if d.type[:21] in GH_IS_SWITCH
|
||||
]
|
||||
|
||||
async_add_entities(switches)
|
||||
|
||||
@@ -33,10 +33,10 @@ class GeniusBinarySensor(BinarySensorDevice):
|
||||
self._client = client
|
||||
self._device = device
|
||||
|
||||
if device.type[:21] == 'Dual Channel Receiver':
|
||||
self._name = 'Dual Channel Receiver {}'.format(device.id)
|
||||
if device.type[:21] == "Dual Channel Receiver":
|
||||
self._name = "Dual Channel Receiver {}".format(device.id)
|
||||
else:
|
||||
self._name = '{} {}'.format(device.type, device.id)
|
||||
self._name = "{} {}".format(device.type, device.id)
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
"""Set up a listener when this entity is added to HA."""
|
||||
@@ -59,16 +59,18 @@ class GeniusBinarySensor(BinarySensorDevice):
|
||||
@property
|
||||
def is_on(self):
|
||||
"""Return the status of the sensor."""
|
||||
return self._device.state['outputOnOff']
|
||||
return self._device.state["outputOnOff"]
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
"""Return the device state attributes."""
|
||||
attrs = {}
|
||||
attrs['assigned_zone'] = self._device.assignedZones[0]['name']
|
||||
attrs["assigned_zone"] = self._device.assignedZones[0]["name"]
|
||||
|
||||
last_comms = self._device._raw_json['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'] = utc_from_timestamp(last_comms).isoformat()
|
||||
attrs["last_comms"] = utc_from_timestamp(last_comms).isoformat()
|
||||
|
||||
return {**attrs}
|
||||
Reference in new issue
Block a user