Black
This commit is contained in:
1 parent
da05dfe708
commit
4de97abc3a
2676 files changed
+163166
-140084
No files matched your search
@@ -12,10 +12,13 @@ from . import DATA_RAINCLOUD, ICON_MAP, SENSORS, RainCloudEntity
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
vol.Optional(CONF_MONITORED_CONDITIONS, default=list(SENSORS)):
|
||||
vol.All(cv.ensure_list, [vol.In(SENSORS)]),
|
||||
})
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||
{
|
||||
vol.Optional(CONF_MONITORED_CONDITIONS, default=list(SENSORS)): vol.All(
|
||||
cv.ensure_list, [vol.In(SENSORS)]
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
@@ -24,10 +27,8 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
|
||||
sensors = []
|
||||
for sensor_type in config.get(CONF_MONITORED_CONDITIONS):
|
||||
if sensor_type == 'battery':
|
||||
sensors.append(
|
||||
RainCloudSensor(raincloud.controller.faucet,
|
||||
sensor_type))
|
||||
if sensor_type == "battery":
|
||||
sensors.append(RainCloudSensor(raincloud.controller.faucet, sensor_type))
|
||||
else:
|
||||
# create a sensor for each zone managed by a faucet
|
||||
for zone in raincloud.controller.faucet.zones:
|
||||
@@ -48,7 +49,7 @@ class RainCloudSensor(RainCloudEntity):
|
||||
def update(self):
|
||||
"""Get the latest data and updates the states."""
|
||||
_LOGGER.debug("Updating RainCloud sensor: %s", self._name)
|
||||
if self._sensor_type == 'battery':
|
||||
if self._sensor_type == "battery":
|
||||
self._state = self.data.battery
|
||||
else:
|
||||
self._state = getattr(self.data, self._sensor_type)
|
||||
@@ -56,7 +57,8 @@ class RainCloudSensor(RainCloudEntity):
|
||||
@property
|
||||
def icon(self):
|
||||
"""Icon to use in the frontend, if any."""
|
||||
if self._sensor_type == 'battery' and self._state is not None:
|
||||
return icon_for_battery_level(battery_level=int(self._state),
|
||||
charging=False)
|
||||
if self._sensor_type == "battery" and self._state is not None:
|
||||
return icon_for_battery_level(
|
||||
battery_level=int(self._state), charging=False
|
||||
)
|
||||
return ICON_MAP.get(self._sensor_type)
|
||||
Reference in new issue
Block a user