Пример #1
0
    vol.Required(CONF_ZONENAME):
    cv.string,
    vol.Optional(CONF_ZONETYPE, default=DEFAULT_ZONETYPE):
    cv.string
})

PARTITION_SCHEMA = vol.Schema({vol.Required(CONF_PARTITIONNAME): cv.string})

CONFIG_SCHEMA = vol.Schema(
    {
        DOMAIN:
        vol.Schema({
            vol.Required(CONF_EVL_HOST):
            cv.string,
            vol.Required(CONF_PANEL_TYPE):
            vol.All(cv.string, vol.In(['HONEYWELL', 'DSC'])),
            vol.Required(CONF_USERNAME):
            cv.string,
            vol.Required(CONF_PASS):
            cv.string,
            vol.Optional(CONF_CODE):
            cv.string,
            vol.Optional(CONF_PANIC, default=DEFAULT_PANIC):
            cv.string,
            vol.Optional(CONF_ZONES): {
                vol.Coerce(int): ZONE_SCHEMA
            },
            vol.Optional(CONF_PARTITIONS): {
                vol.Coerce(int): PARTITION_SCHEMA
            },
            vol.Optional(CONF_EVL_PORT, default=DEFAULT_PORT):
SENSOR_TYPES = ['fajr', 'sunrise', 'dhuhr', 'asr', 'maghrib', 'isha',
                'midnight']

CONF_CALC_METHOD = 'calculation_method'
CONF_SENSORS = 'sensors'

CALC_METHODS = ['karachi', 'isna', 'mwl', 'makkah']
DEFAULT_CALC_METHOD = 'isna'
DEFAULT_SENSORS = ['fajr', 'dhuhr', 'asr', 'maghrib', 'isha']

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Optional(CONF_CALC_METHOD, default=DEFAULT_CALC_METHOD): vol.In(
        CALC_METHODS),
    vol.Optional(CONF_SENSORS, default=DEFAULT_SENSORS):
        vol.All(cv.ensure_list, vol.Length(min=1), [vol.In(SENSOR_TYPES)]),
})


async def async_setup_platform(
        hass, config, async_add_entities, discovery_info=None):
    """Set up the Islamic prayer times sensor platform."""
    latitude = hass.config.latitude
    longitude = hass.config.longitude
    calc_method = config.get(CONF_CALC_METHOD)

    if None in (latitude, longitude):
        _LOGGER.error("Latitude or longitude not set in Home Assistant config")
        return

    prayer_times_data = IslamicPrayerTimesData(latitude,
Пример #3
0
    SERVICE_SUSPEND_INTEGRATION,
    UPDATE_OPTIONS_SIGNAL,
    UPDATE_SIGNAL,
)

_LOGGER = logging.getLogger(__name__)

SCAN_INTERVAL = timedelta(seconds=10)

NOTIFY_SCHEMA = vol.Any(
    None,
    vol.Schema(
        {
            vol.Optional(CONF_NAME): cv.string,
            vol.Optional(CONF_RECIPIENT): vol.Any(
                None, vol.All(cv.ensure_list, [cv.string])
            ),
        }
    ),
)

CONFIG_SCHEMA = vol.Schema(
    {
        DOMAIN: vol.All(
            cv.ensure_list,
            [
                vol.Schema(
                    {
                        vol.Required(CONF_URL): cv.url,
                        vol.Optional(CONF_USERNAME): cv.string,
                        vol.Optional(CONF_PASSWORD): cv.string,
Пример #4
0
    vol.Required(CONF_COMMAND_OFF_TEMPLATE):
    cv.template,
    vol.Optional(CONF_STATE_TEMPLATE):
    cv.template,
    vol.Optional(CONF_BRIGHTNESS_TEMPLATE):
    cv.template,
    vol.Optional(CONF_RED_TEMPLATE):
    cv.template,
    vol.Optional(CONF_GREEN_TEMPLATE):
    cv.template,
    vol.Optional(CONF_BLUE_TEMPLATE):
    cv.template,
    vol.Optional(CONF_OPTIMISTIC, default=DEFAULT_OPTIMISTIC):
    cv.boolean,
    vol.Optional(CONF_QOS, default=mqtt.DEFAULT_QOS):
    vol.All(vol.Coerce(int), vol.In([0, 1, 2])),
    vol.Optional(CONF_RETAIN, default=mqtt.DEFAULT_RETAIN):
    cv.boolean
})


def setup_platform(hass, config, add_devices, discovery_info=None):
    """Setup a MQTT Template light."""
    add_devices([
        MqttTemplate(hass, config.get(CONF_NAME), {
            key: config.get(key)
            for key in (CONF_STATE_TOPIC, CONF_COMMAND_TOPIC)
        }, {
            key: config.get(key)
            for key in (CONF_COMMAND_ON_TEMPLATE, CONF_COMMAND_OFF_TEMPLATE,
                        CONF_STATE_TEMPLATE, CONF_BRIGHTNESS_TEMPLATE,
Пример #5
0
SENSOR_TYPES = {
    'weather': ['Condition', None],
    'temperature': ['Temperature', None],
    'wind_speed': ['Wind speed', 'm/s'],
    'humidity': ['Humidity', '%'],
    'pressure': ['Pressure', 'mbar'],
    'clouds': ['Cloud coverage', '%'],
    'rain': ['Rain', 'mm'],
    'snow': ['Snow', 'mm']
}

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_API_KEY): cv.string,
    vol.Optional(CONF_MONITORED_CONDITIONS, default=[]):
        vol.All(cv.ensure_list, [vol.In(SENSOR_TYPES)]),
    vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
    vol.Optional(CONF_FORECAST, default=False): cv.boolean
})


def setup_platform(hass, config, add_devices, discovery_info=None):
    """Setup the OpenWeatherMap sensor."""
    if None in (hass.config.latitude, hass.config.longitude):
        _LOGGER.error("Latitude or longitude not set in Home Assistant config")
        return False

    from pyowm import OWM

    SENSOR_TYPES['temperature'][1] = hass.config.units.temperature_unit
Пример #6
0
    HOLD_MODE_TEMPERATURE,
    VALID_FAN_STATES,
    VALID_THERMOSTAT_MODES,
)

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_HOST):
    cv.string,
    vol.Optional(CONF_PASSWORD):
    cv.string,
    vol.Optional(CONF_HUMIDIFIER, default=True):
    cv.boolean,
    vol.Optional(CONF_SSL, default=DEFAULT_SSL):
    cv.boolean,
    vol.Optional(CONF_TIMEOUT, default=5):
    vol.All(vol.Coerce(int), vol.Range(min=1)),
    vol.Optional(CONF_USERNAME):
    cv.string,
    vol.Optional(CONF_PIN):
    cv.string,
})


async def async_setup_entry(
    hass: HomeAssistant,
    config_entry: ConfigEntry,
    async_add_entities: AddEntitiesCallback,
) -> None:
    """Set up the Venstar thermostat."""
    venstar_data_coordinator = hass.data[DOMAIN][config_entry.entry_id]
    async_add_entities(
Пример #7
0
    vol.Required(CONF_HOST):
    cv.string,
    vol.Optional(CONF_SSL, default=False):
    cv.boolean,
    vol.Optional(CONF_VERIFY_SSL, default=True):
    cv.boolean,
    vol.Optional(CONF_PORT, default=DEFAULT_PORT):
    cv.port,
    vol.Optional(CONF_TIMEOUT, default=DEFAULT_TIMEOUT):
    cv.positive_int,
    vol.Required(CONF_USERNAME):
    cv.string,
    vol.Required(CONF_PASSWORD):
    cv.string,
    vol.Optional(CONF_MONITORED_CONDITIONS):
    vol.All(cv.ensure_list, [vol.In(_MONITORED_CONDITIONS)]),
    vol.Optional(CONF_NICS, default=None):
    cv.ensure_list,
    vol.Optional(CONF_DRIVES, default=None):
    cv.ensure_list,
    vol.Optional(CONF_VOLUMES, default=None):
    cv.ensure_list,
})


# pylint: disable=unused-argument
def setup_platform(hass, config, add_devices, discovery_info=None):
    """Setup the QNAP NAS sensor."""
    api = QNAPStatsAPI(config)
    api.update()
Пример #8
0
from homeassistant.const import CONF_HOST, CONF_PORT, EVENT_HOMEASSISTANT_STOP
from homeassistant.core import HomeAssistant
from homeassistant.helpers import config_validation as cv

from .const import DOMAIN, PLATFORMS, SERVICE_REBOOT
from .router import FreeboxRouter

_LOGGER = logging.getLogger(__name__)

FREEBOX_SCHEMA = vol.Schema({
    vol.Required(CONF_HOST): cv.string,
    vol.Required(CONF_PORT): cv.port
})

CONFIG_SCHEMA = vol.Schema(
    {DOMAIN: vol.Schema(vol.All(cv.ensure_list, [FREEBOX_SCHEMA]))},
    extra=vol.ALLOW_EXTRA,
)


async def async_setup(hass, config):
    """Set up the Freebox integration."""
    if DOMAIN in config:
        for entry_config in config[DOMAIN]:
            hass.async_create_task(
                hass.config_entries.flow.async_init(
                    DOMAIN,
                    context={"source": SOURCE_IMPORT},
                    data=entry_config))

    return True
Пример #9
0
        DOMAIN:
        vol.Schema({
            vol.Required(CONF_PASSWORD):
            cv.string,
            vol.Required(CONF_USERNAME):
            cv.string,
            vol.Optional(CONF_COUNTRY, default="ES"):
            cv.string,
            vol.Optional(CONF_ALARM, default=True):
            cv.boolean,
            vol.Optional(CONF_CODE_DIGITS, default=4):
            cv.positive_int,
            vol.Optional(CONF_CODE, default=""):
            cv.string,
            vol.Optional(CONF_SCAN_INTERVAL, default=DEFAULT_SCAN_INTERVAL):
            (vol.All(cv.time_period, vol.Clamp(min=MIN_SCAN_INTERVAL))),
        })
    },
    extra=vol.ALLOW_EXTRA,
)


def setup(hass, config):
    """Set up the Securitas component."""
    global HUB
    HUB = SecuritasHub(config[DOMAIN])
    HUB.update_overview = Throttle(config[DOMAIN][CONF_SCAN_INTERVAL])(
        HUB.update_overview)
    if not HUB.login():
        return False
    hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, lambda event: HUB.logout())
Пример #10
0
_LOGGER = logging.getLogger(__name__)

CONF_I2C_ADDRESS = "i2c_address"

DEFAULT_NAME = "SHT31"
DEFAULT_I2C_ADDRESS = 0x44

SENSOR_TEMPERATURE = "temperature"
SENSOR_HUMIDITY = "humidity"
SENSOR_TYPES = (SENSOR_TEMPERATURE, SENSOR_HUMIDITY)

MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=10)

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Optional(CONF_I2C_ADDRESS, default=DEFAULT_I2C_ADDRESS):
    vol.All(vol.Coerce(int), vol.Range(min=0x44, max=0x45)),
    vol.Optional(CONF_MONITORED_CONDITIONS, default=list(SENSOR_TYPES)):
    vol.All(cv.ensure_list, [vol.In(SENSOR_TYPES)]),
    vol.Optional(CONF_NAME, default=DEFAULT_NAME):
    cv.string,
})


def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up the sensor platform."""

    i2c_address = config.get(CONF_I2C_ADDRESS)
    sensor = SHT31(address=i2c_address)

    try:
        if sensor.read_status() is None:
    'conditionexact_3d': ['Full condition 3d', None, None],
    'conditionexact_4d': ['Full condition 4d', None, None],
    'conditionexact_5d': ['Full condition 5d', None, None],
    'symbol_1d': ['Symbol 1d', None, None],
    'symbol_2d': ['Symbol 2d', None, None],
    'symbol_3d': ['Symbol 3d', None, None],
    'symbol_4d': ['Symbol 4d', None, None],
    'symbol_5d': ['Symbol 5d', None, None],
}

CONF_TIMEFRAME = 'timeframe'

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Optional(CONF_MONITORED_CONDITIONS,
                 default=['symbol', 'temperature']): vol.All(
                     cv.ensure_list, vol.Length(min=1),
                     [vol.In(SENSOR_TYPES.keys())]),
    vol.Inclusive(CONF_LATITUDE, 'coordinates',
                  'Latitude and longitude must exist together'): cv.latitude,
    vol.Inclusive(CONF_LONGITUDE, 'coordinates',
                  'Latitude and longitude must exist together'): cv.longitude,
    vol.Optional(CONF_TIMEFRAME, default=60):
        vol.All(vol.Coerce(int), vol.Range(min=5, max=120)),
})


@asyncio.coroutine
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
    """Create the buienradar sensor."""
    from homeassistant.components.weather.buienradar import DEFAULT_TIMEFRAME
Пример #12
0
ATTR_EXTRA = 'extra'
ATTR_TIMESTAMP = 'timestamp'
ATTR_EMPTY_SLOTS = 'empty_slots'
ATTR_FREE_BIKES = 'free_bikes'
ATTR_TIMESTAMP = 'timestamp'
CITYBIKES_ATTRIBUTION = "Information provided by the CityBikes Project "\
                        "(https://citybik.es/#about)"


PLATFORM_SCHEMA = vol.All(
    cv.has_at_least_one_key(CONF_RADIUS, CONF_STATIONS_LIST),
    PLATFORM_SCHEMA.extend({
        vol.Optional(CONF_NAME, default=''): cv.string,
        vol.Optional(CONF_NETWORK): cv.string,
        vol.Inclusive(CONF_LATITUDE, 'coordinates'): cv.latitude,
        vol.Inclusive(CONF_LONGITUDE, 'coordinates'): cv.longitude,
        vol.Optional(CONF_RADIUS, 'station_filter'): cv.positive_int,
        vol.Optional(CONF_STATIONS_LIST, 'station_filter'):
            vol.All(
                cv.ensure_list,
                vol.Length(min=1),
                [cv.string])
    }))

NETWORK_SCHEMA = vol.Schema({
    vol.Required(ATTR_ID): cv.string,
    vol.Required(ATTR_NAME): cv.string,
    vol.Required(ATTR_LOCATION): vol.Schema({
        vol.Required(ATTR_LATITUDE): cv.latitude,
        vol.Required(ATTR_LONGITUDE): cv.longitude,
        }, extra=vol.REMOVE_EXTRA),
    }, extra=vol.REMOVE_EXTRA)
Пример #13
0
    ATTR_FAN_STATE,
    ATTR_HVAC_STATE,
    CONF_HUMIDIFIER,
    DEFAULT_SSL,
    DOMAIN,
    HOLD_MODE_TEMPERATURE,
)

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
    {
        vol.Required(CONF_HOST): cv.string,
        vol.Optional(CONF_PASSWORD): cv.string,
        vol.Optional(CONF_HUMIDIFIER, default=True): cv.boolean,
        vol.Optional(CONF_SSL, default=DEFAULT_SSL): cv.boolean,
        vol.Optional(CONF_TIMEOUT, default=5): vol.All(
            vol.Coerce(int), vol.Range(min=1)
        ),
        vol.Optional(CONF_USERNAME): cv.string,
        vol.Optional(CONF_PIN): cv.string,
    }
)


async def async_setup_entry(
    hass: HomeAssistant,
    config_entry: ConfigEntry,
    async_add_entities: AddEntitiesCallback,
) -> None:
    """Set up the Venstar thermostat."""
    venstar_data_coordinator = hass.data[DOMAIN][config_entry.entry_id]
    async_add_entities(
Пример #14
0
_LOGGER = logging.getLogger(__name__)

ON_OFF_SERVICE_SCHEMA = vol.Schema({vol.Optional(ATTR_ENTITY_ID): cv.comp_entity_ids})

SET_AWAY_MODE_SCHEMA = vol.Schema(
    {
        vol.Optional(ATTR_ENTITY_ID): cv.comp_entity_ids,
        vol.Required(ATTR_AWAY_MODE): cv.boolean,
    }
)
SET_TEMPERATURE_SCHEMA = vol.Schema(
    vol.All(
        {
            vol.Required(ATTR_TEMPERATURE, "temperature"): vol.Coerce(float),
            vol.Optional(ATTR_ENTITY_ID): cv.comp_entity_ids,
            vol.Optional(ATTR_OPERATION_MODE): cv.string,
        }
    )
)
SET_OPERATION_MODE_SCHEMA = vol.Schema(
    {
        vol.Optional(ATTR_ENTITY_ID): cv.comp_entity_ids,
        vol.Required(ATTR_OPERATION_MODE): cv.string,
    }
)


async def async_setup(hass, config):
    """Set up water_heater devices."""
    component = hass.data[DOMAIN] = EntityComponent(
Пример #15
0
SWITCH_SCHEMA = vol.Schema({
    vol.Required(CONF_NAME): cv.string,
    vol.Optional(CONF_COMMAND_OFF): data_packet,
    vol.Optional(CONF_COMMAND_ON): data_packet,
})

PLATFORM_SCHEMA = vol.All(
    cv.deprecated(CONF_HOST),
    cv.deprecated(CONF_SLOTS),
    cv.deprecated(CONF_TIMEOUT),
    cv.deprecated(CONF_TYPE),
    PLATFORM_SCHEMA.extend({
        vol.Required(CONF_MAC):
        mac_address,
        vol.Optional(CONF_HOST):
        cv.string,
        vol.Optional(CONF_SWITCHES, default=[]):
        vol.All(
            cv.ensure_list,
            [SWITCH_SCHEMA],
        ),
    }),
)


async def async_setup_platform(
    hass: HomeAssistant,
    config: ConfigType,
    async_add_entities: AddEntitiesCallback,
    discovery_info: DiscoveryInfoType | None = None,
Пример #16
0
    vol.Optional(CONF_TILT_STATE_OPTIMISTIC, default=DEFAULT_TILT_OPTIMISTIC):
    cv.boolean,
    vol.Optional(CONF_TILT_STATUS_TOPIC):
    valid_subscribe_topic,
    vol.Optional(CONF_TILT_STATUS_TEMPLATE):
    cv.template,
    vol.Optional(CONF_VALUE_TEMPLATE):
    cv.template,
    vol.Optional(CONF_GET_POSITION_TEMPLATE):
    cv.template,
    vol.Optional(CONF_TILT_COMMAND_TEMPLATE):
    cv.template,
}).extend(MQTT_ENTITY_COMMON_SCHEMA.schema)

PLATFORM_SCHEMA_MODERN = vol.All(
    _PLATFORM_SCHEMA_BASE,
    validate_options,
)

# Configuring MQTT Covers under the cover platform key is deprecated in HA Core 2022.6
PLATFORM_SCHEMA = vol.All(
    cv.PLATFORM_SCHEMA.extend(_PLATFORM_SCHEMA_BASE.schema),
    validate_options,
    warn_for_legacy_schema(cover.DOMAIN),
)

DISCOVERY_SCHEMA = vol.All(
    cv.removed("tilt_invert_state"),
    _PLATFORM_SCHEMA_BASE.extend({}, extra=vol.REMOVE_EXTRA),
    validate_options,
)
Пример #17
0
    "video3": "Video 3",
    "video4": "Video 4",
    "video5": "Video 5",
    "video6": "Video 6",
    "video7": "Video 7",
    "fm": "Radio",
}

DEFAULT_PLAYABLE_SOURCES = ("fm", "am", "tuner")

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
    {
        vol.Optional(CONF_HOST): cv.string,
        vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
        vol.Optional(CONF_MAX_VOLUME, default=SUPPORTED_MAX_VOLUME): vol.All(
            vol.Coerce(int), vol.Range(min=1, max=SUPPORTED_MAX_VOLUME)
        ),
        vol.Optional(CONF_SOURCES, default=DEFAULT_SOURCES): {cv.string: cv.string},
    }
)

TIMEOUT_MESSAGE = "Timeout waiting for response."

ATTR_HDMI_OUTPUT = "hdmi_output"
ACCEPTED_VALUES = [
    "no",
    "analog",
    "yes",
    "out",
    "out-sub",
    "sub",
Пример #18
0
    "gb",
    "kr",
    "kr2",
    "mx",
    "sg",
    "us",
    "vn2",
]

CONF_ALPR_BIN = "alpr_bin"

DEFAULT_BINARY = "alpr"

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_REGION):
    vol.All(vol.Lower, vol.In(OPENALPR_REGIONS)),
    vol.Optional(CONF_ALPR_BIN, default=DEFAULT_BINARY):
    cv.string,
})


async def async_setup_platform(hass,
                               config,
                               async_add_entities,
                               discovery_info=None):
    """Set up the OpenALPR local platform."""
    command = [config[CONF_ALPR_BIN], "-c", config[CONF_REGION], "-"]
    confidence = config[CONF_CONFIDENCE]

    entities = []
    for camera in config[CONF_SOURCE]:
Пример #19
0
"""Support for binary sensor using GC100."""
import voluptuous as vol

from homeassistant.components.binary_sensor import PLATFORM_SCHEMA, BinarySensorEntity
from homeassistant.const import DEVICE_DEFAULT_NAME
import homeassistant.helpers.config_validation as cv

from . import CONF_PORTS, DATA_GC100

_SENSORS_SCHEMA = vol.Schema({cv.string: cv.string})

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
    {vol.Required(CONF_PORTS): vol.All(cv.ensure_list, [_SENSORS_SCHEMA])})


def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up the GC100 devices."""
    binary_sensors = []
    ports = config.get(CONF_PORTS)
    for port in ports:
        for port_addr, port_name in port.items():
            binary_sensors.append(
                GC100BinarySensor(port_name, port_addr, hass.data[DATA_GC100]))
    add_entities(binary_sensors, True)


class GC100BinarySensor(BinarySensorEntity):
    """Representation of a binary sensor from GC100."""
    def __init__(self, name, port_addr, gc100):
        """Initialize the GC100 binary sensor."""
        self._name = name or DEVICE_DEFAULT_NAME
Пример #20
0
from openpeerpower import exceptions
from openpeerpower.const import CONF_FOR, CONF_PLATFORM, CONF_VALUE_TEMPLATE
from openpeerpower.core import callback
from openpeerpower.helpers import condition, config_validation as cv, template
from openpeerpower.helpers.event import async_track_same_state, async_track_template

# mypy: allow-untyped-defs, no-check-untyped-defs

_LOGGER = logging.getLogger(__name__)

TRIGGER_SCHEMA = IF_ACTION_SCHEMA = vol.Schema(
    {
        vol.Required(CONF_PLATFORM): "template",
        vol.Required(CONF_VALUE_TEMPLATE): cv.template,
        vol.Optional(CONF_FOR): vol.Any(
            vol.All(cv.time_period, cv.positive_timedelta),
            cv.template,
            cv.template_complex,
        ),
    }
)


async def async_attach_trigger(
    opp, config, action, automation_info, *, platform_type="numeric_state"
):
    """Listen for state changes based on configuration."""
    value_template = config.get(CONF_VALUE_TEMPLATE)
    value_template.opp = opp
    time_delta = config.get(CONF_FOR)
    template.attach(opp, time_delta)
Пример #21
0
CONF_ON_CHANGE_OF_RELATIVE = "on_change_of_relative"

CONF_NOTIFICATIONS = "notifications"
CONF_ON_MALFUNCTION = "on_malfunction"
CONF_REPEAT_AFTER = "repeat_after"

DEFAULT_UPDATE_INTERVAL = 60
DEFAULT_CYCLIC_SENDING_INTERVAL = 600
DEFAULT_BAUDRATE = 115200
DEFAULT_GATEWAY_PORT = 3671
DEFAULT_AUTO_RECONNECT_WAIT = 3
DEFAULT_RATE_LIMIT = 10  # XKNX.DEFAULT_RATE_LIMIT

SYNCHRONIZE_CLOCK_WEEKLY_SCHEMA = vol.Schema({
    CONF_SYNCHRONIZE_CLOCK_WEEKDAY:
    vol.All(cv.string, vol.In(cv.WEEKDAYS)),
    CONF_SYNCHRONIZE_CLOCK_TIME:
    cv.time,
})

GENERAL_SCHEMA = vol.Schema({
    vol.Optional(CONF_UPDATE_INTERVAL, default=DEFAULT_UPDATE_INTERVAL):
    cv.time_interval,
    vol.Optional(CONF_CYCLIC_SENDING_INTERVAL,
                 default=DEFAULT_CYCLIC_SENDING_INTERVAL):
    cv.time_interval,
    vol.Optional(CONF_SYNCHRONIZE_CLOCK_WEEKLY):
    SYNCHRONIZE_CLOCK_WEEKLY_SCHEMA,
})

HEAT_PUMP_SCHEMA = vol.Schema({
Пример #22
0
                    cv.string,
                    vol.Optional(CONF_USERNAME, default=DEFAULT_USERNAME):
                    cv.string,
                    vol.Optional(CONF_PASSWORD, default=DEFAULT_PASSWORD):
                    cv.string,
                }
            },
            vol.Optional(CONF_LOCAL_IP, default=DEFAULT_LOCAL_IP): cv.string,
            vol.Optional(CONF_LOCAL_PORT): cv.port,
        }),
    },
    extra=vol.ALLOW_EXTRA)

SCHEMA_SERVICE_VIRTUALKEY = vol.Schema({
    vol.Required(ATTR_ADDRESS):
    vol.All(cv.string, vol.Upper),
    vol.Required(ATTR_CHANNEL):
    vol.Coerce(int),
    vol.Required(ATTR_PARAM):
    cv.string,
    vol.Optional(ATTR_INTERFACE):
    cv.string,
})

SCHEMA_SERVICE_SET_VARIABLE_VALUE = vol.Schema({
    vol.Required(ATTR_NAME):
    cv.string,
    vol.Required(ATTR_VALUE):
    cv.match_all,
    vol.Optional(ATTR_ENTITY_ID):
    cv.entity_ids,
Пример #23
0
# Stores all ChromecastInfo we encountered through discovery or config as a set
# If we find a chromecast with a new host, the old one will be removed again.
KNOWN_CHROMECAST_INFO_KEY = 'cast_known_chromecasts'
# Stores UUIDs of cast devices that were added as entities. Doesn't store
# None UUIDs.
ADDED_CAST_DEVICES_KEY = 'cast_added_cast_devices'

# Dispatcher signal fired with a ChromecastInfo every time we discover a new
# Chromecast or receive it through configuration
SIGNAL_CAST_DISCOVERED = 'cast_discovered'

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Optional(CONF_HOST):
    cv.string,
    vol.Optional(CONF_IGNORE_CEC, default=[]):
    vol.All(cv.ensure_list, [cv.string])
})


@attr.s(slots=True, frozen=True)
class ChromecastInfo(object):
    """Class to hold all data about a chromecast for creating connections.

    This also has the same attributes as the mDNS fields by zeroconf.
    """

    host = attr.ib(type=str)
    port = attr.ib(type=int)
    uuid = attr.ib(type=Optional[str],
                   converter=attr.converters.optional(str),
                   default=None)  # always convert UUID to string if not None
Пример #24
0
_LOGGER = logging.getLogger(__name__)

CONF_CODE_OFF = 'code_off'
CONF_CODE_ON = 'code_on'
CONF_GPIO = 'gpio'
CONF_PROTOCOL = 'protocol'
CONF_PULSELENGTH = 'pulselength'
CONF_SIGNAL_REPETITIONS = 'signal_repetitions'

DEFAULT_PROTOCOL = 1
DEFAULT_SIGNAL_REPETITIONS = 10

SWITCH_SCHEMA = vol.Schema({
    vol.Required(CONF_CODE_OFF):
    vol.All(cv.ensure_list_csv, [cv.positive_int]),
    vol.Required(CONF_CODE_ON):
    vol.All(cv.ensure_list_csv, [cv.positive_int]),
    vol.Optional(CONF_PULSELENGTH):
    cv.positive_int,
    vol.Optional(CONF_SIGNAL_REPETITIONS, default=DEFAULT_SIGNAL_REPETITIONS):
    cv.positive_int,
    vol.Optional(CONF_PROTOCOL, default=DEFAULT_PROTOCOL):
    cv.positive_int,
})

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_GPIO):
    cv.positive_int,
    vol.Required(CONF_SWITCHES):
    vol.Schema({cv.string: SWITCH_SCHEMA}),
Пример #25
0
VACUUM_SCHEMA = vol.All(
    cv.deprecated(CONF_ENTITY_ID),
    vol.Schema({
        vol.Optional(CONF_FRIENDLY_NAME):
        cv.string,
        vol.Optional(CONF_VALUE_TEMPLATE):
        cv.template,
        vol.Optional(CONF_BATTERY_LEVEL_TEMPLATE):
        cv.template,
        vol.Optional(CONF_FAN_SPEED_TEMPLATE):
        cv.template,
        vol.Optional(CONF_AVAILABILITY_TEMPLATE):
        cv.template,
        vol.Optional(CONF_ATTRIBUTE_TEMPLATES, default={}):
        vol.Schema({cv.string: cv.template}),
        vol.Required(SERVICE_START):
        cv.SCRIPT_SCHEMA,
        vol.Optional(SERVICE_PAUSE):
        cv.SCRIPT_SCHEMA,
        vol.Optional(SERVICE_STOP):
        cv.SCRIPT_SCHEMA,
        vol.Optional(SERVICE_RETURN_TO_BASE):
        cv.SCRIPT_SCHEMA,
        vol.Optional(SERVICE_CLEAN_SPOT):
        cv.SCRIPT_SCHEMA,
        vol.Optional(SERVICE_LOCATE):
        cv.SCRIPT_SCHEMA,
        vol.Optional(SERVICE_SET_FAN_SPEED):
        cv.SCRIPT_SCHEMA,
        vol.Optional(CONF_FAN_SPEED_LIST, default=[]):
        cv.ensure_list,
        vol.Optional(CONF_ENTITY_ID):
        cv.entity_ids,
        vol.Optional(CONF_UNIQUE_ID):
        cv.string,
    }),
)
Пример #26
0
})

CONFIG_SCHEMA = vol.Schema(
    {
        DOMAIN:
        vol.Schema({
            vol.Optional(CONF_KNX_CONFIG):
            cv.string,
            vol.Exclusive(CONF_KNX_ROUTING, "connection_type"):
            ROUTING_SCHEMA,
            vol.Exclusive(CONF_KNX_TUNNELING, "connection_type"):
            TUNNELING_SCHEMA,
            vol.Inclusive(CONF_KNX_FIRE_EVENT, "fire_ev"):
            cv.boolean,
            vol.Inclusive(CONF_KNX_FIRE_EVENT_FILTER, "fire_ev"):
            vol.All(cv.ensure_list, [cv.string]),
            vol.Optional(CONF_KNX_STATE_UPDATER, default=True):
            cv.boolean,
            vol.Optional(CONF_KNX_RATE_LIMIT, default=20):
            vol.All(vol.Coerce(int), vol.Range(min=1, max=100)),
            vol.Optional(CONF_KNX_EXPOSE):
            vol.All(cv.ensure_list, [EXPOSE_SCHEMA]),
        })
    },
    extra=vol.ALLOW_EXTRA,
)

SERVICE_KNX_SEND_SCHEMA = vol.Schema({
    vol.Required(SERVICE_KNX_ATTR_ADDRESS):
    cv.string,
    vol.Required(SERVICE_KNX_ATTR_PAYLOAD):
Пример #27
0
# https://github.com/quandyfactory/dicttoxml/issues/60
logging.getLogger("dicttoxml").setLevel(logging.WARNING)

MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=10)

DOMAIN = "huawei_lte"
DATA_KEY = "huawei_lte"

CONFIG_SCHEMA = vol.Schema(
    {
        DOMAIN:
        vol.All(
            cv.ensure_list,
            [
                vol.Schema({
                    vol.Required(CONF_URL): cv.url,
                    vol.Required(CONF_USERNAME): cv.string,
                    vol.Required(CONF_PASSWORD): cv.string,
                })
            ],
        )
    },
    extra=vol.ALLOW_EXTRA,
)


@attr.s
class RouterData:
    """Class for router state."""

    client = attr.ib()
    mac = attr.ib()
Пример #28
0
NODE_SCHEMA = vol.Schema(
    {cv.positive_int: {
        vol.Required(CONF_NODE_NAME): cv.string
    }})

GATEWAY_SCHEMA = vol.Schema(
    vol.All(
        deprecated(CONF_NODES),
        {
            vol.Required(CONF_DEVICE):
            cv.string,
            vol.Optional(CONF_PERSISTENCE_FILE):
            vol.All(cv.string, is_persistence_file),
            vol.Optional(CONF_BAUD_RATE, default=DEFAULT_BAUD_RATE):
            cv.positive_int,
            vol.Optional(CONF_TCP_PORT, default=DEFAULT_TCP_PORT):
            cv.port,
            vol.Optional(CONF_TOPIC_IN_PREFIX):
            valid_subscribe_topic,
            vol.Optional(CONF_TOPIC_OUT_PREFIX):
            valid_publish_topic,
            vol.Optional(CONF_NODES, default={}):
            NODE_SCHEMA,
        },
    ))

CONFIG_SCHEMA = vol.Schema(
    {
        DOMAIN:
        vol.Schema(
            vol.All(
Пример #29
0
def filters_for_all_tracked_objects(object_config):
    for tracked_object in object_config.get('track', DEFAULT_TRACKED_OBJECTS):
        if not 'filters' in object_config:
            object_config['filters'] = {}
        if not tracked_object in object_config['filters']:
            object_config['filters'][tracked_object] = {}
    return object_config

OBJECTS_SCHEMA = vol.Schema(vol.All(filters_for_all_tracked_objects,
    {
        'track': [str],
        'mask': vol.Any(str, [str]),
        vol.Optional('filters', default = {}): FILTER_SCHEMA.extend(
            { 
                str: {
                        'min_score': float,
                        'mask': vol.Any(str, [str]),
                    }
            })
    }
))

def each_role_used_once(inputs):
    roles = [role for i in inputs for role in i['roles']]
    roles_set = set(roles)
    if len(roles) > len(roles_set):
        raise ValueError
    return inputs

def detect_is_required(inputs):
Пример #30
0
EVENT_TIMER_FINISHED = "timer.finished"
EVENT_TIMER_CANCELLED = "timer.cancelled"
EVENT_TIMER_STARTED = "timer.started"
EVENT_TIMER_RESTARTED = "timer.restarted"
EVENT_TIMER_PAUSED = "timer.paused"

SERVICE_START = "start"
SERVICE_PAUSE = "pause"
SERVICE_CANCEL = "cancel"
SERVICE_FINISH = "finish"

STORAGE_KEY = DOMAIN
STORAGE_VERSION = 1

CREATE_FIELDS = {
    vol.Required(CONF_NAME): vol.All(str, vol.Length(min=1)),
    vol.Optional(CONF_NAME): cv.string,
    vol.Optional(CONF_ICON): cv.icon,
    vol.Optional(CONF_DURATION, default=DEFAULT_DURATION): cv.time_period,
}
UPDATE_FIELDS = {
    vol.Optional(CONF_NAME): cv.string,
    vol.Optional(CONF_ICON): cv.icon,
    vol.Optional(CONF_DURATION): cv.time_period,
}


def _format_timedelta(delta: timedelta):
    total_seconds = delta.total_seconds()
    hours, remainder = divmod(total_seconds, 3600)
    minutes, seconds = divmod(remainder, 60)