Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
SENSOR_TEMP = 'temperature'
SENSOR_HUMID = 'humidity'
SENSOR_PRESS = 'pressure'
SENSOR_TYPES = {
SENSOR_TEMP: ['Temperature', None],
SENSOR_HUMID: ['Humidity', '%'],
SENSOR_PRESS: ['Pressure', 'mb']
}
DEFAULT_MONITORED = [SENSOR_TEMP, SENSOR_HUMID, SENSOR_PRESS]
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
vol.Optional(CONF_I2C_ADDRESS, default=DEFAULT_I2C_ADDRESS): cv.string,
vol.Optional(CONF_MONITORED_CONDITIONS, default=DEFAULT_MONITORED):
vol.All(cv.ensure_list, [vol.In(SENSOR_TYPES)]),
vol.Optional(CONF_I2C_BUS, default=DEFAULT_I2C_BUS): vol.Coerce(int),
vol.Optional(CONF_OVERSAMPLING_TEMP,
default=DEFAULT_OVERSAMPLING_TEMP): vol.Coerce(int),
vol.Optional(CONF_OVERSAMPLING_PRES,
default=DEFAULT_OVERSAMPLING_PRES): vol.Coerce(int),
vol.Optional(CONF_OVERSAMPLING_HUM,
default=DEFAULT_OVERSAMPLING_HUM): vol.Coerce(int),
vol.Optional(CONF_OPERATION_MODE,
default=DEFAULT_OPERATION_MODE): vol.Coerce(int),
vol.Optional(CONF_T_STANDBY,
default=DEFAULT_T_STANDBY): vol.Coerce(int),
vol.Optional(CONF_FILTER_MODE,
default=DEFAULT_FILTER_MODE): vol.Coerce(int),
vol.Optional(CONF_DELTA_TEMP,
default=DEFAULT_DELTA_TEMP): vol.Coerce(float),
})
['Download before offpeak', GIGABITS, 'mdi:download'],
'before_offpeak_upload':
['Upload before offpeak', GIGABITS, 'mdi:upload'],
'before_offpeak_total':
['Total before offpeak', GIGABITS, 'mdi:download'],
'offpeak_download': ['Offpeak download', GIGABITS, 'mdi:download'],
'offpeak_upload': ['Offpeak Upload', GIGABITS, 'mdi:upload'],
'offpeak_total': ['Offpeak Total', GIGABITS, 'mdi:download'],
'download': ['Download', GIGABITS, 'mdi:download'],
'upload': ['Upload', GIGABITS, 'mdi:upload'],
'total': ['Total', GIGABITS, 'mdi:download'],
}
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_MONITORED_VARIABLES):
vol.All(cv.ensure_list, [vol.In(SENSOR_TYPES)]),
vol.Required(CONF_USERNAME): cv.string,
vol.Required(CONF_PASSWORD): cv.string,
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
})
async def async_setup_platform(hass, config, async_add_entities,
discovery_info=None):
"""Set up the EBox sensor."""
username = config.get(CONF_USERNAME)
password = config.get(CONF_PASSWORD)
httpsession = hass.helpers.aiohttp_client.async_get_clientsession()
ebox_data = EBoxData(username, password, httpsession)
name = config.get(CONF_NAME)
CONF_EXCLUDE = 'exclude'
CONF_INCLUDE = 'include'
CONF_ENTITIES = 'entities'
CONF_DOMAINS = 'domains'
CONFIG_SCHEMA = vol.Schema({
DOMAIN: vol.Schema({
CONF_EXCLUDE: vol.Schema({
vol.Optional(CONF_ENTITIES, default=[]): cv.entity_ids,
vol.Optional(CONF_DOMAINS, default=[]): vol.All(cv.ensure_list,
[cv.string])
}),
CONF_INCLUDE: vol.Schema({
vol.Optional(CONF_ENTITIES, default=[]): cv.entity_ids,
vol.Optional(CONF_DOMAINS, default=[]): vol.All(cv.ensure_list,
[cv.string])
})
}),
}, extra=vol.ALLOW_EXTRA)
EVENT_LOGBOOK_ENTRY = 'logbook_entry'
GROUP_BY_MINUTES = 15
ATTR_NAME = 'name'
ATTR_MESSAGE = 'message'
ATTR_DOMAIN = 'domain'
ATTR_ENTITY_ID = 'entity_id'
LOG_MESSAGE_SCHEMA = vol.Schema({
vol.Required(ATTR_NAME): cv.string,
CONF_EXCLUSIONS = 'exclusions'
CONF_SHOW_TOPN = 'show_topn'
DEFAULT_SCAN_INTERVAL = timedelta(hours=1)
COMPONENT_REPO = 'https://github.com/custom-components/sensor.feedparser/'
SCAN_INTERVAL = timedelta(hours=1)
ICON = 'mdi:rss'
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_NAME): cv.string,
vol.Required(CONF_FEED_URL): cv.string,
vol.Required(CONF_DATE_FORMAT, default='%a, %b %d %I:%M %p'): cv.string,
vol.Optional(CONF_SHOW_TOPN, default=9999): cv.positive_int,
vol.Optional(CONF_INCLUSIONS, default=[]): vol.All(cv.ensure_list, [cv.string]),
vol.Optional(CONF_EXCLUSIONS, default=[]): vol.All(cv.ensure_list, [cv.string]),
})
@asyncio.coroutine
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
async_add_devices([FeedParserSensor(
feed=config[CONF_FEED_URL],
name=config[CONF_NAME],
date_format=config[CONF_DATE_FORMAT],
show_topn=config[CONF_SHOW_TOPN],
inclusions=config[CONF_INCLUSIONS],
exclusions=config[CONF_EXCLUSIONS]
)], True)
class FeedParserSensor(Entity):
CONF_SLOT = "slot"
CONF_COMMANDS = "commands"
DEFAULT_TIMEOUT = 10
DEFAULT_SLOT = 1
LEARN_COMMAND_SCHEMA = vol.Schema(
{
vol.Required(ATTR_ENTITY_ID): vol.All(str),
vol.Optional(CONF_TIMEOUT, default=10): vol.All(int, vol.Range(min=0)),
vol.Optional(CONF_SLOT, default=1): vol.All(int, vol.Range(min=1, max=1000000)),
}
)
COMMAND_SCHEMA = vol.Schema(
{vol.Required(CONF_COMMAND): vol.All(cv.ensure_list, [cv.string])}
)
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
{
vol.Optional(CONF_NAME): cv.string,
vol.Required(CONF_HOST): cv.string,
vol.Optional(CONF_TIMEOUT, default=DEFAULT_TIMEOUT): vol.All(
int, vol.Range(min=0)
),
vol.Optional(CONF_SLOT, default=DEFAULT_SLOT): vol.All(
int, vol.Range(min=1, max=1000000)
),
vol.Optional(ATTR_HIDDEN, default=True): cv.boolean,
vol.Required(CONF_TOKEN): vol.All(str, vol.Length(min=32, max=32)),
vol.Optional(CONF_COMMANDS, default={}): cv.schema_with_slug_keys(
COMMAND_SCHEMA
FUEL_TYPES = [
"Benzina",
"Benzina speciale",
"Diesel",
"Diesel speciale",
"GPL",
"Metano",
]
SCAN_INTERVAL = timedelta(minutes=120)
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
{
vol.Required(CONF_STATION): cv.string,
vol.Optional(CONF_NAME, None): cv.string,
vol.Optional(CONF_TYPES, None): vol.All(cv.ensure_list, [vol.In(FUEL_TYPES)]),
}
)
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the PrezziBenzina sensor platform."""
station = config[CONF_STATION]
name = config.get(CONF_NAME)
types = config.get(CONF_TYPES)
client = PrezziBenzinaPy()
dev = []
info = client.get_by_id(station)
if name is None:
CONF_AREAS = 'areas'
CONF_LAT_NE = 'lat_ne'
CONF_LON_NE = 'lon_ne'
CONF_LAT_SW = 'lat_sw'
CONF_LON_SW = 'lon_sw'
DEFAULT_NAME = 'Netatmo Public Data'
DEFAULT_TYPE = 'max'
SENSOR_TYPES = {'max', 'avg'}
# NetAtmo Data is uploaded to server every 10 minutes
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=600)
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_AREAS): vol.All(cv.ensure_list, [
{
vol.Required(CONF_LAT_NE): cv.latitude,
vol.Required(CONF_LAT_SW): cv.latitude,
vol.Required(CONF_LON_NE): cv.longitude,
vol.Required(CONF_LON_SW): cv.longitude,
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
vol.Optional(CONF_TYPE, default=DEFAULT_TYPE):
vol.In(SENSOR_TYPES)
}
]),
})
def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the access to Netatmo binary sensor."""
netatmo = hass.components.netatmo
COLOR_MAP[CONF_LIGHT_TYPE_RGBW_AUTO] = [255, 255, 255]
COLOR_MAP[CONF_LIGHT_TYPE_DRGB] = [255, 255, 255]
COLOR_MAP[CONF_LIGHT_TYPE_DRGBW] = [255, 255, 255]
COLOR_MAP[CONF_LIGHT_TYPE_RGBWD] = [255, 255, 255]
COLOR_MAP[CONF_LIGHT_TYPE_SWITCH] = None
COLOR_MAP[CONF_LIGHT_TYPE_CUSTOM_WHITE] = None
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_HOST): cv.string,
vol.Optional(CONF_UNIVERSE, default=0): cv.byte,
vol.Optional(CONF_DMX_CHANNELS, default=512): vol.All(vol.Coerce(int),
vol.Range(min=1,
max=512)),
vol.Optional(CONF_DEFAULT_LEVEL, default=255): cv.byte,
vol.Optional(CONF_DEFAULT_TYPE, default=CONF_LIGHT_TYPE_DIMMER): cv.string,
vol.Required(CONF_DEVICES): vol.All(cv.ensure_list, [
{
vol.Required(CONF_CHANNEL): vol.All(vol.Coerce(int),
vol.Range(min=1, max=512)),
vol.Optional(CONF_NAME): cv.string,
vol.Optional(CONF_TYPE): vol.In(CONF_LIGHT_TYPES),
vol.Optional(CONF_DEFAULT_LEVEL): cv.byte,
vol.Optional(ATTR_WHITE_VALUE): cv.byte,
vol.Optional(CONF_DEFAULT_COLOR): vol.All(
vol.ExactSequence((cv.byte, cv.byte, cv.byte)),
vol.Coerce(tuple)),
vol.Optional(CONF_TRANSITION, default=0): vol.All(vol.Coerce(int),
vol.Range(min=0,
max=60)),
vol.Optional(CONF_CHANNEL_SETUP): cv.string,
}
]),
AREA_SCHEMA = vol.Schema(
{
vol.Optional(CONF_BOTTOM, default=1): cv.small_float,
vol.Optional(CONF_LEFT, default=0): cv.small_float,
vol.Optional(CONF_RIGHT, default=1): cv.small_float,
vol.Optional(CONF_TOP, default=0): cv.small_float,
}
)
CATEGORY_SCHEMA = vol.Schema(
{vol.Required(CONF_CATEGORY): cv.string, vol.Optional(CONF_AREA): AREA_SCHEMA}
)
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
{
vol.Optional(CONF_FILE_OUT, default=[]): vol.All(cv.ensure_list, [cv.template]),
vol.Required(CONF_MODEL): vol.Schema(
{
vol.Required(CONF_GRAPH): cv.isfile,
vol.Optional(CONF_AREA): AREA_SCHEMA,
vol.Optional(CONF_CATEGORIES, default=[]): vol.All(
cv.ensure_list, [vol.Any(cv.string, CATEGORY_SCHEMA)]
),
vol.Optional(CONF_LABELS): cv.isfile,
vol.Optional(CONF_MODEL_DIR): cv.isdir,
}
),
}
)
def setup_platform(hass, config, add_entities, discovery_info=None):
from homeassistant.components.switch import (SwitchDevice, PLATFORM_SCHEMA)
from homeassistant.const import (
CONF_HOST, CONF_NAME, CONF_SWITCHES, CONF_MAC, CONF_DISCOVERY)
import homeassistant.helpers.config_validation as cv
REQUIREMENTS = ['orvibo==1.1.1']
_LOGGER = logging.getLogger(__name__)
DEFAULT_NAME = 'Orvibo S20 Switch'
DEFAULT_DISCOVERY = True
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_SWITCHES, default=[]):
vol.All(cv.ensure_list, [{
vol.Required(CONF_HOST): cv.string,
vol.Optional(CONF_MAC): cv.string,
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string
}]),
vol.Optional(CONF_DISCOVERY, default=DEFAULT_DISCOVERY): cv.boolean,
})
def setup_platform(hass, config, add_entities_callback, discovery_info=None):
"""Set up S20 switches."""
from orvibo.s20 import discover, S20, S20Exception
switch_data = {}
switches = []
switch_conf = config.get(CONF_SWITCHES, [config])