Black format

This commit is contained in:
ludeeus 2019-03-09 13:01:44 +01:00
parent 44df9faee0
commit 775d56196c
4 changed files with 57 additions and 35 deletions

View File

@ -13,31 +13,52 @@ import homeassistant.helpers.config_validation as cv
from homeassistant.helpers import discovery from homeassistant.helpers import discovery
from homeassistant.util import Throttle from homeassistant.util import Throttle
from .const import ( from .const import (
DOMAIN_DATA, DOMAIN, ISSUE_URL, PLATFORMS, REQUIRED_FILES, STARTUP, URL, DOMAIN_DATA,
VERSION, CONF_BINARY_SENSOR, CONF_SENSOR, CONF_ENABLED, CONF_NAME, DOMAIN,
DEAFULT_NAME) ISSUE_URL,
PLATFORMS,
REQUIRED_FILES,
STARTUP,
URL,
VERSION,
CONF_BINARY_SENSOR,
CONF_SENSOR,
CONF_ENABLED,
CONF_NAME,
DEAFULT_NAME,
)
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=30) MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=30)
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
BINARY_SENSOR_SCHEMA = vol.Schema({ BINARY_SENSOR_SCHEMA = vol.Schema(
{
vol.Optional(CONF_ENABLED, default=False): cv.boolean, vol.Optional(CONF_ENABLED, default=False): cv.boolean,
vol.Optional(CONF_NAME, default=DEAFULT_NAME): cv.string, vol.Optional(CONF_NAME, default=DEAFULT_NAME): cv.string,
}) }
)
SENSOR_SCHEMA = vol.Schema({ SENSOR_SCHEMA = vol.Schema(
{
vol.Optional(CONF_ENABLED, default=False): cv.boolean, vol.Optional(CONF_ENABLED, default=False): cv.boolean,
vol.Optional(CONF_NAME, default=DEAFULT_NAME): cv.string, vol.Optional(CONF_NAME, default=DEAFULT_NAME): cv.string,
}) }
)
CONFIG_SCHEMA = vol.Schema({ CONFIG_SCHEMA = vol.Schema(
DOMAIN: vol.Schema({ {
DOMAIN: vol.Schema(
{
vol.Optional(CONF_BINARY_SENSOR): vol.All( vol.Optional(CONF_BINARY_SENSOR): vol.All(
cv.ensure_list, [BINARY_SENSOR_SCHEMA]), cv.ensure_list, [BINARY_SENSOR_SCHEMA]
),
vol.Optional(CONF_SENSOR): vol.All(cv.ensure_list, [SENSOR_SCHEMA]), vol.Optional(CONF_SENSOR): vol.All(cv.ensure_list, [SENSOR_SCHEMA]),
}), }
}, extra=vol.ALLOW_EXTRA) )
},
extra=vol.ALLOW_EXTRA,
)
async def async_setup(hass, config): async def async_setup(hass, config):
@ -73,10 +94,12 @@ async def async_setup(hass, config):
hass.async_create_task( hass.async_create_task(
discovery.async_load_platform( discovery.async_load_platform(
hass, platform, DOMAIN, entry_config, config) hass, platform, DOMAIN, entry_config, config
)
) )
return True return True
@Throttle(MIN_TIME_BETWEEN_UPDATES) @Throttle(MIN_TIME_BETWEEN_UPDATES)
async def update_data(hass): async def update_data(hass):
"""Update data.""" """Update data."""

View File

@ -1,8 +1,7 @@
"""Binary ensor platform for blueprint.""" """Binary ensor platform for blueprint."""
from homeassistant.components.binary_sensor import BinarySensorDevice from homeassistant.components.binary_sensor import BinarySensorDevice
from . import update_data from . import update_data
from .const import ( from .const import BINARY_SENSOR_DEVICE_CLASS, DOMAIN_DATA, SENSOR_ICON
BINARY_SENSOR_DEVICE_CLASS, DOMAIN_DATA, SENSOR_ICON)
async def async_setup_platform( async def async_setup_platform(
@ -19,7 +18,7 @@ class BlueprintBinarySensor(BinarySensorDevice):
self.hass = hass self.hass = hass
self.attr = {} self.attr = {}
self._status = False self._status = False
self._name = config['name'] self._name = config["name"]
async def async_update(self): async def async_update(self):
"""Update the sensor.""" """Update the sensor."""
@ -36,8 +35,8 @@ class BlueprintBinarySensor(BinarySensorDevice):
self._status = updated.get("completed") self._status = updated.get("completed")
# Set/update attributes # Set/update attributes
self.attr['user_id'] = updated.get('userId') self.attr["user_id"] = updated.get("userId")
self.attr['title'] = updated.get('title') self.attr["title"] = updated.get("title")
@property @property
def name(self): def name(self):

View File

@ -18,19 +18,19 @@ If you have any issues with this you need to open an issue here:
""" """
# Operational # Operational
URL = 'https://jsonplaceholder.typicode.com/todos/1' URL = "https://jsonplaceholder.typicode.com/todos/1"
# Icons # Icons
SENSOR_ICON = "mdi:format-quote-close" SENSOR_ICON = "mdi:format-quote-close"
# Device classes # Device classes
BINARY_SENSOR_DEVICE_CLASS = 'connectivity' BINARY_SENSOR_DEVICE_CLASS = "connectivity"
# Configuration # Configuration
CONF_BINARY_SENSOR = 'binary_sensor' CONF_BINARY_SENSOR = "binary_sensor"
CONF_SENSOR = 'sensor' CONF_SENSOR = "sensor"
CONF_ENABLED = 'enabled' CONF_ENABLED = "enabled"
CONF_NAME = 'name' CONF_NAME = "name"
# Defaults # Defaults
DEAFULT_NAME = DOMAIN DEAFULT_NAME = DOMAIN

View File

@ -18,7 +18,7 @@ class BlueprintSensor(Entity):
self.hass = hass self.hass = hass
self.attr = {} self.attr = {}
self._state = None self._state = None
self._name = config['name'] self._name = config["name"]
async def async_update(self): async def async_update(self):
"""Update the sensor.""" """Update the sensor."""
@ -35,8 +35,8 @@ class BlueprintSensor(Entity):
self._state = updated.get("title") self._state = updated.get("title")
# Set/update attributes # Set/update attributes
self.attr['user_id'] = updated.get('userId') self.attr["user_id"] = updated.get("userId")
self.attr['completed'] = updated.get('completed') self.attr["completed"] = updated.get("completed")
@property @property
def name(self): def name(self):