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.const import (
|
||||
CONF_NAME, CONF_UNIT_OF_MEASUREMENT, CONF_PAYLOAD)
|
||||
from homeassistant.const import CONF_NAME, CONF_UNIT_OF_MEASUREMENT, CONF_PAYLOAD
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.components import pilight
|
||||
@@ -12,26 +11,32 @@ import homeassistant.helpers.config_validation as cv
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
CONF_VARIABLE = 'variable'
|
||||
CONF_VARIABLE = "variable"
|
||||
|
||||
DEFAULT_NAME = 'Pilight Sensor'
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
vol.Required(CONF_VARIABLE): cv.string,
|
||||
vol.Required(CONF_PAYLOAD): vol.Schema(dict),
|
||||
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
|
||||
vol.Optional(CONF_UNIT_OF_MEASUREMENT): cv.string,
|
||||
})
|
||||
DEFAULT_NAME = "Pilight Sensor"
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||
{
|
||||
vol.Required(CONF_VARIABLE): cv.string,
|
||||
vol.Required(CONF_PAYLOAD): vol.Schema(dict),
|
||||
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
|
||||
vol.Optional(CONF_UNIT_OF_MEASUREMENT): cv.string,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up Pilight Sensor."""
|
||||
add_entities([PilightSensor(
|
||||
hass=hass,
|
||||
name=config.get(CONF_NAME),
|
||||
variable=config.get(CONF_VARIABLE),
|
||||
payload=config.get(CONF_PAYLOAD),
|
||||
unit_of_measurement=config.get(CONF_UNIT_OF_MEASUREMENT)
|
||||
)])
|
||||
add_entities(
|
||||
[
|
||||
PilightSensor(
|
||||
hass=hass,
|
||||
name=config.get(CONF_NAME),
|
||||
variable=config.get(CONF_VARIABLE),
|
||||
payload=config.get(CONF_PAYLOAD),
|
||||
unit_of_measurement=config.get(CONF_UNIT_OF_MEASUREMENT),
|
||||
)
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
class PilightSensor(Entity):
|
||||
@@ -84,5 +89,7 @@ class PilightSensor(Entity):
|
||||
self.schedule_update_ha_state()
|
||||
except KeyError:
|
||||
_LOGGER.error(
|
||||
'No variable %s in received code data %s',
|
||||
str(self._variable), str(call.data))
|
||||
"No variable %s in received code data %s",
|
||||
str(self._variable),
|
||||
str(call.data),
|
||||
)
|
||||
Reference in new issue
Block a user