Black
This commit is contained in:
1 parent
da05dfe708
commit
4de97abc3a
2676 files changed
+163166
-140084
No files matched your search
@@ -5,20 +5,21 @@ import logging
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.components.binary_sensor import BinarySensorDevice
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from . import (DOMAIN, SIGNAL_UPDATE_SMARTY)
|
||||
from . import DOMAIN, SIGNAL_UPDATE_SMARTY
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
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 Smarty Binary Sensor Platform."""
|
||||
smarty = hass.data[DOMAIN]['api']
|
||||
name = hass.data[DOMAIN]['name']
|
||||
smarty = hass.data[DOMAIN]["api"]
|
||||
name = hass.data[DOMAIN]["name"]
|
||||
|
||||
sensors = [AlarmSensor(name, smarty),
|
||||
WarningSensor(name, smarty),
|
||||
BoostSensor(name, smarty)]
|
||||
sensors = [
|
||||
AlarmSensor(name, smarty),
|
||||
WarningSensor(name, smarty),
|
||||
BoostSensor(name, smarty),
|
||||
]
|
||||
|
||||
async_add_entities(sensors, True)
|
||||
|
||||
@@ -55,9 +56,7 @@ class SmartyBinarySensor(BinarySensorDevice):
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
"""Call to update."""
|
||||
async_dispatcher_connect(self.hass,
|
||||
SIGNAL_UPDATE_SMARTY,
|
||||
self._update_callback)
|
||||
async_dispatcher_connect(self.hass, SIGNAL_UPDATE_SMARTY, self._update_callback)
|
||||
|
||||
@callback
|
||||
def _update_callback(self):
|
||||
@@ -70,13 +69,13 @@ class BoostSensor(SmartyBinarySensor):
|
||||
|
||||
def __init__(self, name, smarty):
|
||||
"""Alarm Sensor Init."""
|
||||
super().__init__(name='{} Boost State'.format(name),
|
||||
device_class=None,
|
||||
smarty=smarty)
|
||||
super().__init__(
|
||||
name="{} Boost State".format(name), device_class=None, smarty=smarty
|
||||
)
|
||||
|
||||
def update(self) -> None:
|
||||
"""Update state."""
|
||||
_LOGGER.debug('Updating sensor %s', self._name)
|
||||
_LOGGER.debug("Updating sensor %s", self._name)
|
||||
self._state = self._smarty.boost
|
||||
|
||||
|
||||
@@ -85,13 +84,13 @@ class AlarmSensor(SmartyBinarySensor):
|
||||
|
||||
def __init__(self, name, smarty):
|
||||
"""Alarm Sensor Init."""
|
||||
super().__init__(name='{} Alarm'.format(name),
|
||||
device_class='problem',
|
||||
smarty=smarty)
|
||||
super().__init__(
|
||||
name="{} Alarm".format(name), device_class="problem", smarty=smarty
|
||||
)
|
||||
|
||||
def update(self) -> None:
|
||||
"""Update state."""
|
||||
_LOGGER.debug('Updating sensor %s', self._name)
|
||||
_LOGGER.debug("Updating sensor %s", self._name)
|
||||
self._state = self._smarty.alarm
|
||||
|
||||
|
||||
@@ -100,11 +99,11 @@ class WarningSensor(SmartyBinarySensor):
|
||||
|
||||
def __init__(self, name, smarty):
|
||||
"""Warning Sensor Init."""
|
||||
super().__init__(name='{} Warning'.format(name),
|
||||
device_class='problem',
|
||||
smarty=smarty)
|
||||
super().__init__(
|
||||
name="{} Warning".format(name), device_class="problem", smarty=smarty
|
||||
)
|
||||
|
||||
def update(self) -> None:
|
||||
"""Update state."""
|
||||
_LOGGER.debug('Updating sensor %s', self._name)
|
||||
_LOGGER.debug("Updating sensor %s", self._name)
|
||||
self._state = self._smarty.warning
|
||||
Reference in new issue
Block a user