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.util import Throttle
from .const import (
DOMAIN_DATA, DOMAIN, ISSUE_URL, PLATFORMS, REQUIRED_FILES, STARTUP, URL,
VERSION, CONF_BINARY_SENSOR, CONF_SENSOR, CONF_ENABLED, CONF_NAME,
DEAFULT_NAME)
DOMAIN_DATA,
DOMAIN,
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)
_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_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_NAME, default=DEAFULT_NAME): cv.string,
})
}
)
CONFIG_SCHEMA = vol.Schema({
DOMAIN: vol.Schema({
CONFIG_SCHEMA = vol.Schema(
{
DOMAIN: vol.Schema(
{
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]),
}),
}, extra=vol.ALLOW_EXTRA)
}
)
},
extra=vol.ALLOW_EXTRA,
)
async def async_setup(hass, config):
@ -73,10 +94,12 @@ async def async_setup(hass, config):
hass.async_create_task(
discovery.async_load_platform(
hass, platform, DOMAIN, entry_config, config)
hass, platform, DOMAIN, entry_config, config
)
)
return True
@Throttle(MIN_TIME_BETWEEN_UPDATES)
async def update_data(hass):
"""Update data."""

View File

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

View File

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

View File

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