Black
This commit is contained in:
1 parent
da05dfe708
commit
4de97abc3a
2676 files changed
+163166
-140084
No files matched your search
@@ -3,8 +3,7 @@ import logging
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.binary_sensor import (
|
||||
BinarySensorDevice, PLATFORM_SCHEMA)
|
||||
from homeassistant.components.binary_sensor import BinarySensorDevice, PLATFORM_SCHEMA
|
||||
from homeassistant.const import CONF_MONITORED_CONDITIONS
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
||||
@@ -12,15 +11,15 @@ from . import BLOOMSKY
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
SENSOR_TYPES = {
|
||||
'Rain': 'moisture',
|
||||
'Night': None,
|
||||
}
|
||||
SENSOR_TYPES = {"Rain": "moisture", "Night": None}
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
vol.Optional(CONF_MONITORED_CONDITIONS, default=list(SENSOR_TYPES)):
|
||||
vol.All(cv.ensure_list, [vol.In(SENSOR_TYPES)]),
|
||||
})
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||
{
|
||||
vol.Optional(CONF_MONITORED_CONDITIONS, default=list(SENSOR_TYPES)): vol.All(
|
||||
cv.ensure_list, [vol.In(SENSOR_TYPES)]
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
@@ -30,8 +29,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
|
||||
for device in BLOOMSKY.devices.values():
|
||||
for variable in sensors:
|
||||
add_entities(
|
||||
[BloomSkySensor(BLOOMSKY, device, variable)], True)
|
||||
add_entities([BloomSkySensor(BLOOMSKY, device, variable)], True)
|
||||
|
||||
|
||||
class BloomSkySensor(BinarySensorDevice):
|
||||
@@ -40,11 +38,11 @@ class BloomSkySensor(BinarySensorDevice):
|
||||
def __init__(self, bs, device, sensor_name):
|
||||
"""Initialize a BloomSky binary sensor."""
|
||||
self._bloomsky = bs
|
||||
self._device_id = device['DeviceID']
|
||||
self._device_id = device["DeviceID"]
|
||||
self._sensor_name = sensor_name
|
||||
self._name = '{} {}'.format(device['DeviceName'], sensor_name)
|
||||
self._name = "{} {}".format(device["DeviceName"], sensor_name)
|
||||
self._state = None
|
||||
self._unique_id = '{}-{}'.format(self._device_id, self._sensor_name)
|
||||
self._unique_id = "{}-{}".format(self._device_id, self._sensor_name)
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
@@ -70,5 +68,4 @@ class BloomSkySensor(BinarySensorDevice):
|
||||
"""Request an update from the BloomSky API."""
|
||||
self._bloomsky.refresh_devices()
|
||||
|
||||
self._state = \
|
||||
self._bloomsky.devices[self._device_id]['Data'][self._sensor_name]
|
||||
self._state = self._bloomsky.devices[self._device_id]["Data"][self._sensor_name]
|
||||
Reference in new issue
Block a user