This commit is contained in:
Paulus Schoutsen 2019-07-31 12:25:30 -07:00
parent da05dfe708
commit 4de97abc3a
2676 changed files with 163166 additions and 140084 deletions

View file

@ -15,9 +15,9 @@ SCAN_INTERVAL = timedelta(seconds=120)
def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up Tahoma controller devices."""
_LOGGER.debug("Setup Tahoma Binary sensor platform")
controller = hass.data[TAHOMA_DOMAIN]['controller']
controller = hass.data[TAHOMA_DOMAIN]["controller"]
devices = []
for device in hass.data[TAHOMA_DOMAIN]['devices']['smoke']:
for device in hass.data[TAHOMA_DOMAIN]["devices"]["smoke"]:
devices.append(TahomaBinarySensor(device, controller))
add_entities(devices, True)
@ -42,8 +42,8 @@ class TahomaBinarySensor(TahomaDevice, BinarySensorDevice):
@property
def device_class(self):
"""Return the class of the device."""
if self.tahoma_device.type == 'rtds:RTDSSmokeSensor':
return 'smoke'
if self.tahoma_device.type == "rtds:RTDSSmokeSensor":
return "smoke"
return None
@property
@ -71,25 +71,23 @@ class TahomaBinarySensor(TahomaDevice, BinarySensorDevice):
def update(self):
"""Update the state."""
self.controller.get_states([self.tahoma_device])
if self.tahoma_device.type == 'rtds:RTDSSmokeSensor':
if self.tahoma_device.active_states['core:SmokeState']\
== 'notDetected':
if self.tahoma_device.type == "rtds:RTDSSmokeSensor":
if self.tahoma_device.active_states["core:SmokeState"] == "notDetected":
self._state = STATE_OFF
else:
self._state = STATE_ON
if 'core:SensorDefectState' in self.tahoma_device.active_states:
if "core:SensorDefectState" in self.tahoma_device.active_states:
# 'lowBattery' for low battery warning. 'dead' for not available.
self._battery = self.tahoma_device.active_states[
'core:SensorDefectState']
self._available = bool(self._battery != 'dead')
self._battery = self.tahoma_device.active_states["core:SensorDefectState"]
self._available = bool(self._battery != "dead")
else:
self._battery = None
self._available = True
if self._state == STATE_ON:
self._icon = "mdi:fire"
elif self._battery == 'lowBattery':
elif self._battery == "lowBattery":
self._icon = "mdi:battery-alert"
else:
self._icon = None