当前位置: 首页>>代码示例>>Python>>正文


Python PLATFORM_SCHEMA.extend方法代码示例

本文整理汇总了Python中homeassistant.helpers.config_validation.PLATFORM_SCHEMA.extend方法的典型用法代码示例。如果您正苦于以下问题:Python PLATFORM_SCHEMA.extend方法的具体用法?Python PLATFORM_SCHEMA.extend怎么用?Python PLATFORM_SCHEMA.extend使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在homeassistant.helpers.config_validation.PLATFORM_SCHEMA的用法示例。


在下文中一共展示了PLATFORM_SCHEMA.extend方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_platform_specific_config_validation

# 需要导入模块: from homeassistant.helpers.config_validation import PLATFORM_SCHEMA [as 别名]
# 或者: from homeassistant.helpers.config_validation.PLATFORM_SCHEMA import extend [as 别名]
    def test_platform_specific_config_validation(self):
        """Test platform that specifies config."""

        platform_schema = PLATFORM_SCHEMA.extend({
            'valid': True,
        }, extra=vol.PREVENT_EXTRA)

        loader.set_component(
            'switch.platform_a',
            MockPlatform('comp_b', platform_schema=platform_schema))

        assert not bootstrap.setup_component(self.hass, 'switch', {
            'switch': {
                'platform': 'platform_a',
                'invalid': True
            }
        })

        assert not bootstrap.setup_component(self.hass, 'switch', {
            'switch': {
                'platform': 'platform_a',
                'valid': True,
                'invalid_extra': True,
            }
        })

        assert bootstrap.setup_component(self.hass, 'switch', {
            'switch': {
                'platform': 'platform_a',
                'valid': True
            }
        })
开发者ID:1lann,项目名称:home-assistant,代码行数:34,代码来源:test_bootstrap.py

示例2: test_validate_platform_config

# 需要导入模块: from homeassistant.helpers.config_validation import PLATFORM_SCHEMA [as 别名]
# 或者: from homeassistant.helpers.config_validation.PLATFORM_SCHEMA import extend [as 别名]
    def test_validate_platform_config(self):
        """Test validating platform configuration."""
        platform_schema = PLATFORM_SCHEMA.extend({
            'hello': str,
        })
        loader.set_component(
            'platform_conf',
            MockModule('platform_conf', platform_schema=platform_schema))

        loader.set_component(
            'platform_conf.whatever', MockPlatform('whatever'))

        assert not bootstrap._setup_component(self.hass, 'platform_conf', {
            'platform_conf': None
        })

        assert not bootstrap._setup_component(self.hass, 'platform_conf', {
            'platform_conf': {}
        })

        assert not bootstrap._setup_component(self.hass, 'platform_conf', {
            'platform_conf': {
                'hello': 'world',
                'invalid': 'extra',
            }
        })

        assert not bootstrap._setup_component(self.hass, 'platform_conf', {
            'platform_conf': {
                'platform': 'whatever',
                'hello': 'world',
            },

            'platform_conf 2': {
                'invalid': True
            }
        })

        assert not bootstrap._setup_component(self.hass, 'platform_conf', {
            'platform_conf': {
                'platform': 'not_existing',
                'hello': 'world',
            }
        })

        assert bootstrap._setup_component(self.hass, 'platform_conf', {
            'platform_conf': {
                'platform': 'whatever',
                'hello': 'world',
            }
        })

        assert bootstrap._setup_component(self.hass, 'platform_conf', {
            'platform_conf': [{
                'platform': 'whatever',
                'hello': 'world',
            }]
        })
开发者ID:1lann,项目名称:home-assistant,代码行数:60,代码来源:test_bootstrap.py

示例3: test_validate_platform_config_2

# 需要导入模块: from homeassistant.helpers.config_validation import PLATFORM_SCHEMA [as 别名]
# 或者: from homeassistant.helpers.config_validation.PLATFORM_SCHEMA import extend [as 别名]
    def test_validate_platform_config_2(self, caplog):
        """Test component PLATFORM_SCHEMA_BASE prio over PLATFORM_SCHEMA."""
        platform_schema = PLATFORM_SCHEMA.extend({
            'hello': str,
        })
        platform_schema_base = PLATFORM_SCHEMA_BASE.extend({
            'hello': 'world',
        })
        loader.set_component(
            self.hass,
            'platform_conf',
            MockModule('platform_conf',
                       platform_schema=platform_schema,
                       platform_schema_base=platform_schema_base))

        loader.set_component(
            self.hass,
            'platform_conf.whatever',
            MockPlatform('whatever',
                         platform_schema=platform_schema))

        with assert_setup_component(1):
            assert setup.setup_component(self.hass, 'platform_conf', {
                # fail: no extra keys allowed in platform schema
                'platform_conf': {
                    'platform': 'whatever',
                    'hello': 'world',
                    'invalid': 'extra',
                }
            })
            assert caplog.text.count('Your configuration contains '
                                     'extra keys') == 1

        self.hass.data.pop(setup.DATA_SETUP)
        self.hass.config.components.remove('platform_conf')

        with assert_setup_component(1):
            assert setup.setup_component(self.hass, 'platform_conf', {
                # pass
                'platform_conf': {
                    'platform': 'whatever',
                    'hello': 'world',
                },
                # fail: key hello violates component platform_schema_base
                'platform_conf 2': {
                    'platform': 'whatever',
                    'hello': 'there'
                }
            })

        self.hass.data.pop(setup.DATA_SETUP)
        self.hass.config.components.remove('platform_conf')
开发者ID:arsaboo,项目名称:home-assistant,代码行数:54,代码来源:test_setup.py

示例4: test_platform_specific_config_validation

# 需要导入模块: from homeassistant.helpers.config_validation import PLATFORM_SCHEMA [as 别名]
# 或者: from homeassistant.helpers.config_validation.PLATFORM_SCHEMA import extend [as 别名]
    def test_platform_specific_config_validation(self):
        """Test platform that specifies config."""
        platform_schema = PLATFORM_SCHEMA.extend({
            'valid': True,
        }, extra=vol.PREVENT_EXTRA)

        mock_setup = mock.MagicMock(spec_set=True)

        loader.set_component(
            self.hass,
            'switch.platform_a',
            MockPlatform(platform_schema=platform_schema,
                         setup_platform=mock_setup))

        with assert_setup_component(0, 'switch'):
            assert setup.setup_component(self.hass, 'switch', {
                'switch': {
                    'platform': 'platform_a',
                    'invalid': True
                }
            })
            assert mock_setup.call_count == 0

        self.hass.data.pop(setup.DATA_SETUP)
        self.hass.config.components.remove('switch')

        with assert_setup_component(0):
            assert setup.setup_component(self.hass, 'switch', {
                'switch': {
                    'platform': 'platform_a',
                    'valid': True,
                    'invalid_extra': True,
                }
            })
            assert mock_setup.call_count == 0

        self.hass.data.pop(setup.DATA_SETUP)
        self.hass.config.components.remove('switch')

        with assert_setup_component(1):
            assert setup.setup_component(self.hass, 'switch', {
                'switch': {
                    'platform': 'platform_a',
                    'valid': True
                }
            })
            assert mock_setup.call_count == 1
开发者ID:EarthlingRich,项目名称:home-assistant,代码行数:49,代码来源:test_setup.py

示例5: async_setup_platform

# 需要导入模块: from homeassistant.helpers.config_validation import PLATFORM_SCHEMA [as 别名]
# 或者: from homeassistant.helpers.config_validation.PLATFORM_SCHEMA import extend [as 别名]
CONF_LEVEL_TEMPLATE = 'level_template'

LIGHT_SCHEMA = vol.Schema({
    vol.Required(CONF_ON_ACTION): cv.SCRIPT_SCHEMA,
    vol.Required(CONF_OFF_ACTION): cv.SCRIPT_SCHEMA,
    vol.Optional(CONF_VALUE_TEMPLATE): cv.template,
    vol.Optional(CONF_ICON_TEMPLATE): cv.template,
    vol.Optional(CONF_ENTITY_PICTURE_TEMPLATE): cv.template,
    vol.Optional(CONF_LEVEL_ACTION): cv.SCRIPT_SCHEMA,
    vol.Optional(CONF_LEVEL_TEMPLATE): cv.template,
    vol.Optional(CONF_FRIENDLY_NAME): cv.string,
    vol.Optional(CONF_ENTITY_ID): cv.entity_ids
})

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_LIGHTS): vol.Schema({cv.slug: LIGHT_SCHEMA}),
})


async def async_setup_platform(hass, config, async_add_entities,
                               discovery_info=None):
    """Set up the Template Lights."""
    lights = []

    for device, device_config in config[CONF_LIGHTS].items():
        friendly_name = device_config.get(CONF_FRIENDLY_NAME, device)
        state_template = device_config.get(CONF_VALUE_TEMPLATE)
        icon_template = device_config.get(CONF_ICON_TEMPLATE)
        entity_picture_template = device_config.get(
            CONF_ENTITY_PICTURE_TEMPLATE)
        on_action = device_config[CONF_ON_ACTION]
开发者ID:ManHammer,项目名称:home-assistant,代码行数:33,代码来源:template.py

示例6: timedelta

# 需要导入模块: from homeassistant.helpers.config_validation import PLATFORM_SCHEMA [as 别名]
# 或者: from homeassistant.helpers.config_validation.PLATFORM_SCHEMA import extend [as 别名]
ATTR_PRESSURE = 'pressure'
ATTR_SULFUR_DIOXIDE = 'sulfur_dioxide'
ATTR_TIME = 'time'
ATTRIBUTION = 'Data provided by the World Air Quality Index project'

CONF_LOCATIONS = 'locations'
CONF_STATIONS = 'stations'

MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=10)

SENSOR_TYPES = {
    'aqi': ['AQI', '0-300+', 'mdi:cloud']
}

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Optional(CONF_STATIONS): cv.ensure_list,
    vol.Required(CONF_LOCATIONS): cv.ensure_list,
})


def setup_platform(hass, config, add_devices, discovery_info=None):
    """Set up the requested World Air Quality Index locations."""
    import pwaqi

    dev = []
    station_filter = config.get(CONF_STATIONS)
    for location_name in config.get(CONF_LOCATIONS):
        station_ids = pwaqi.findStationCodesByCity(location_name)
        _LOGGER.info("The following stations were returned: %s", station_ids)
        for station in station_ids:
            waqi_sensor = WaqiSensor(WaqiData(station), station)
            if (not station_filter) or \
开发者ID:Teagan42,项目名称:home-assistant,代码行数:34,代码来源:waqi.py

示例7: test_validate_platform_config

# 需要导入模块: from homeassistant.helpers.config_validation import PLATFORM_SCHEMA [as 别名]
# 或者: from homeassistant.helpers.config_validation.PLATFORM_SCHEMA import extend [as 别名]
    def test_validate_platform_config(self):
        """Test validating platform configuration."""
        platform_schema = PLATFORM_SCHEMA.extend({
            'hello': str,
        })
        loader.set_component(
            'platform_conf',
            MockModule('platform_conf', platform_schema=platform_schema))

        loader.set_component(
            'platform_conf.whatever', MockPlatform('whatever'))

        with assert_setup_component(0):
            assert bootstrap._setup_component(self.hass, 'platform_conf', {
                'platform_conf': {
                    'hello': 'world',
                    'invalid': 'extra',
                }
            })

        self.hass.config.components.remove('platform_conf')

        with assert_setup_component(1):
            assert bootstrap._setup_component(self.hass, 'platform_conf', {
                'platform_conf': {
                    'platform': 'whatever',
                    'hello': 'world',
                },
                'platform_conf 2': {
                    'invalid': True
                }
            })

        self.hass.config.components.remove('platform_conf')

        with assert_setup_component(0):
            assert bootstrap._setup_component(self.hass, 'platform_conf', {
                'platform_conf': {
                    'platform': 'not_existing',
                    'hello': 'world',
                }
            })

        self.hass.config.components.remove('platform_conf')

        with assert_setup_component(1):
            assert bootstrap._setup_component(self.hass, 'platform_conf', {
                'platform_conf': {
                    'platform': 'whatever',
                    'hello': 'world',
                }
            })

        self.hass.config.components.remove('platform_conf')

        with assert_setup_component(1):
            assert bootstrap._setup_component(self.hass, 'platform_conf', {
                'platform_conf': [{
                    'platform': 'whatever',
                    'hello': 'world',
                }]
            })

        self.hass.config.components.remove('platform_conf')

        # Any falsey platform config will be ignored (None, {}, etc)
        with assert_setup_component(0) as config:
            assert bootstrap._setup_component(self.hass, 'platform_conf', {
                'platform_conf': None
            })
            assert 'platform_conf' in self.hass.config.components
            assert not config['platform_conf']  # empty

            assert bootstrap._setup_component(self.hass, 'platform_conf', {
                'platform_conf': {}
            })
            assert 'platform_conf' in self.hass.config.components
            assert not config['platform_conf']  # empty
开发者ID:krzynio,项目名称:home-assistant,代码行数:80,代码来源:test_bootstrap.py

示例8: timedelta

# 需要导入模块: from homeassistant.helpers.config_validation import PLATFORM_SCHEMA [as 别名]
# 或者: from homeassistant.helpers.config_validation.PLATFORM_SCHEMA import extend [as 别名]
                'pm': [ATTR_PM2_5, 'µg/m3', 'mdi:cloud'],
                'tmp': [ATTR_TEMPERATURE, TEMP_CELSIUS, 'mdi:thermometer'],
                'hum': [ATTR_HUMIDITY, '%', 'mdi:water-percent'],
                'co2': [ATTR_CARBON_DIOXIDE, 'ppm',
                        'mdi:periodic-table-co2'],
                'voc': [ATTR_VOLATILE_ORGANIC_COMPOUNDS, 'ppb',
                        'mdi:cloud'],
                'allpollu': [ATTR_FOOBOT_INDEX, '%', 'mdi:percent']}

SCAN_INTERVAL = timedelta(minutes=10)
PARALLEL_UPDATES = 1

TIMEOUT = 10

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_TOKEN): cv.string,
    vol.Required(CONF_USERNAME): cv.string,
})


async def async_setup_platform(hass, config, async_add_entities,
                               discovery_info=None):
    """Set up the devices associated with the account."""
    from foobot_async import FoobotClient

    token = config.get(CONF_TOKEN)
    username = config.get(CONF_USERNAME)

    client = FoobotClient(token, username,
                          async_get_clientsession(hass),
                          timeout=TIMEOUT)
    dev = []
开发者ID:EarthlingRich,项目名称:home-assistant,代码行数:34,代码来源:foobot.py

示例9: async_setup_platform

# 需要导入模块: from homeassistant.helpers.config_validation import PLATFORM_SCHEMA [as 别名]
# 或者: from homeassistant.helpers.config_validation.PLATFORM_SCHEMA import extend [as 别名]
CONF_LEVEL_TEMPLATE = 'level_template'

LIGHT_SCHEMA = vol.Schema({
    vol.Required(CONF_ON_ACTION): cv.SCRIPT_SCHEMA,
    vol.Required(CONF_OFF_ACTION): cv.SCRIPT_SCHEMA,
    vol.Optional(CONF_VALUE_TEMPLATE): cv.template,
    vol.Optional(CONF_ICON_TEMPLATE): cv.template,
    vol.Optional(CONF_ENTITY_PICTURE_TEMPLATE): cv.template,
    vol.Optional(CONF_LEVEL_ACTION): cv.SCRIPT_SCHEMA,
    vol.Optional(CONF_LEVEL_TEMPLATE): cv.template,
    vol.Optional(CONF_FRIENDLY_NAME): cv.string,
    vol.Optional(CONF_ENTITY_ID): cv.entity_ids
})

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_LIGHTS): cv.schema_with_slug_keys(LIGHT_SCHEMA),
})


async def async_setup_platform(hass, config, async_add_entities,
                               discovery_info=None):
    """Set up the Template Lights."""
    lights = []

    for device, device_config in config[CONF_LIGHTS].items():
        friendly_name = device_config.get(CONF_FRIENDLY_NAME, device)
        state_template = device_config.get(CONF_VALUE_TEMPLATE)
        icon_template = device_config.get(CONF_ICON_TEMPLATE)
        entity_picture_template = device_config.get(
            CONF_ENTITY_PICTURE_TEMPLATE)
        on_action = device_config[CONF_ON_ACTION]
开发者ID:Martwall,项目名称:home-assistant,代码行数:33,代码来源:template.py

示例10: setup_platform

# 需要导入模块: from homeassistant.helpers.config_validation import PLATFORM_SCHEMA [as 别名]
# 或者: from homeassistant.helpers.config_validation.PLATFORM_SCHEMA import extend [as 别名]
DEFAULT_DEEP_STANDBY = False
DEFAULT_MAC_ADDRESS = ''
DEFAULT_SOURCE_BOUQUET = ''

SUPPORTED_ENIGMA2 = SUPPORT_VOLUME_SET | SUPPORT_VOLUME_MUTE | \
                    SUPPORT_TURN_OFF | SUPPORT_NEXT_TRACK | SUPPORT_STOP | \
                    SUPPORT_PREVIOUS_TRACK | SUPPORT_VOLUME_STEP | \
                    SUPPORT_TURN_ON | SUPPORT_PAUSE | SUPPORT_SELECT_SOURCE

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_HOST): cv.string,
    vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
    vol.Optional(CONF_PORT, default=DEFAULT_PORT): cv.port,
    vol.Optional(CONF_USERNAME, default=DEFAULT_USERNAME): cv.string,
    vol.Optional(CONF_PASSWORD, default=DEFAULT_PASSWORD): cv.string,
    vol.Optional(CONF_SSL, default=DEFAULT_SSL): cv.boolean,
    vol.Optional(CONF_USE_CHANNEL_ICON,
                 default=DEFAULT_USE_CHANNEL_ICON): cv.boolean,
    vol.Optional(CONF_DEEP_STANDBY, default=DEFAULT_DEEP_STANDBY): cv.boolean,
    vol.Optional(CONF_MAC_ADDRESS, default=DEFAULT_MAC_ADDRESS): cv.string,
    vol.Optional(CONF_SOURCE_BOUQUET,
                 default=DEFAULT_SOURCE_BOUQUET): cv.string,
})


def setup_platform(hass, config, add_devices, discovery_info=None):
    """Set up of an enigma2 media player."""
    if discovery_info:
        # Discovery gives us the streaming service port (8001)
        # which is not useful as OpenWebif never runs on that port.
        # So use the default port instead.
        config[CONF_PORT] = DEFAULT_PORT
开发者ID:fbradyirl,项目名称:home-assistant,代码行数:34,代码来源:media_player.py

示例11: async_setup_platform

# 需要导入模块: from homeassistant.helpers.config_validation import PLATFORM_SCHEMA [as 别名]
# 或者: from homeassistant.helpers.config_validation.PLATFORM_SCHEMA import extend [as 别名]
    'SS': 'Snow Showers',
    'SU': 'Sunny',
    'SW': 'Strong Winds',
    'TL': 'Thundery Showers',
    'WC': 'Windy, Cloudy',
    'WD': 'Windy',
    'WF': 'Windy, Fair',
    'WR': 'Windy, Rain',
    'WS': 'Windy, Showers',
}

INV_CONDITION_DETAILS = {v: k for k, v in CONDITION_DETAILS.items()}

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_AREA): cv.string,
    vol.Optional(CONF_RESOURCE, default=DEFAULT_RESOURCE): cv.string,
    vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
})

@asyncio.coroutine
async def async_setup_platform(hass, config, async_add_entities,
                               discovery_info=None):

    """Set up the Web scrape sensor."""
    _LOGGER.info('SGNEAWEB loaded')
    name = config.get(CONF_NAME)
    resource = config.get(CONF_RESOURCE)
    area = config.get(CONF_AREA)

    method = 'GET'
    payload = None
开发者ID:tyjtyj,项目名称:sgneaweb,代码行数:33,代码来源:sgneaweb.py

示例12: test_validate_platform_config

# 需要导入模块: from homeassistant.helpers.config_validation import PLATFORM_SCHEMA [as 别名]
# 或者: from homeassistant.helpers.config_validation.PLATFORM_SCHEMA import extend [as 别名]
    def test_validate_platform_config(self, caplog):
        """Test validating platform configuration."""
        platform_schema = PLATFORM_SCHEMA.extend({
            'hello': str,
        })
        platform_schema_base = PLATFORM_SCHEMA_BASE.extend({
        })
        loader.set_component(
            self.hass,
            'platform_conf',
            MockModule('platform_conf',
                       platform_schema_base=platform_schema_base))

        loader.set_component(
            self.hass,
            'platform_conf.whatever',
            MockPlatform('whatever',
                         platform_schema=platform_schema))

        with assert_setup_component(1):
            assert setup.setup_component(self.hass, 'platform_conf', {
                'platform_conf': {
                    'platform': 'whatever',
                    'hello': 'world',
                    'invalid': 'extra',
                }
            })
            assert caplog.text.count('Your configuration contains '
                                     'extra keys') == 1

        self.hass.data.pop(setup.DATA_SETUP)
        self.hass.config.components.remove('platform_conf')

        with assert_setup_component(2):
            assert setup.setup_component(self.hass, 'platform_conf', {
                'platform_conf': {
                    'platform': 'whatever',
                    'hello': 'world',
                },
                'platform_conf 2': {
                    'platform': 'whatever',
                    'invalid': True
                }
            })
            assert caplog.text.count('Your configuration contains '
                                     'extra keys') == 2

        self.hass.data.pop(setup.DATA_SETUP)
        self.hass.config.components.remove('platform_conf')

        with assert_setup_component(0):
            assert setup.setup_component(self.hass, 'platform_conf', {
                'platform_conf': {
                    'platform': 'not_existing',
                    'hello': 'world',
                }
            })

        self.hass.data.pop(setup.DATA_SETUP)
        self.hass.config.components.remove('platform_conf')

        with assert_setup_component(1):
            assert setup.setup_component(self.hass, 'platform_conf', {
                'platform_conf': {
                    'platform': 'whatever',
                    'hello': 'world',
                }
            })

        self.hass.data.pop(setup.DATA_SETUP)
        self.hass.config.components.remove('platform_conf')

        with assert_setup_component(1):
            assert setup.setup_component(self.hass, 'platform_conf', {
                'platform_conf': [{
                    'platform': 'whatever',
                    'hello': 'world',
                }]
            })

        self.hass.data.pop(setup.DATA_SETUP)
        self.hass.config.components.remove('platform_conf')

        # Any falsey platform config will be ignored (None, {}, etc)
        with assert_setup_component(0) as config:
            assert setup.setup_component(self.hass, 'platform_conf', {
                'platform_conf': None
            })
            assert 'platform_conf' in self.hass.config.components
            assert not config['platform_conf']  # empty

            assert setup.setup_component(self.hass, 'platform_conf', {
                'platform_conf': {}
            })
            assert 'platform_conf' in self.hass.config.components
            assert not config['platform_conf']  # empty
开发者ID:arsaboo,项目名称:home-assistant,代码行数:98,代码来源:test_setup.py

示例13: timedelta

# 需要导入模块: from homeassistant.helpers.config_validation import PLATFORM_SCHEMA [as 别名]
# 或者: from homeassistant.helpers.config_validation.PLATFORM_SCHEMA import extend [as 别名]
ATTR_OZONE = 'ozone'
ATTR_PARTICLE = 'particle'
ATTR_PRESSURE = 'pressure'
ATTR_TIME = 'time'
ATTRIBUTION = 'Data provided by the World Air Quality Index project'

CONF_LOCATIONS = 'locations'

MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=10)

SENSOR_TYPES = {
    'aqi': ['AQI', '0-300+', 'mdi:cloud']
}

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_LOCATIONS): cv.ensure_list
})


def setup_platform(hass, config, add_devices, discovery_info=None):
    """Set up the requested World Air Quality Index locations."""
    import pwaqi

    dev = []
    for location_name in config.get(CONF_LOCATIONS):
        station_ids = pwaqi.findStationCodesByCity(location_name)
        _LOGGER.error('The following stations were returned: %s', station_ids)
        for station in station_ids:
            dev.append(WaqiSensor(WaqiData(station), station))

    add_devices(dev)
开发者ID:DavidLP,项目名称:home-assistant,代码行数:33,代码来源:waqi.py

示例14: async_setup_platform

# 需要导入模块: from homeassistant.helpers.config_validation import PLATFORM_SCHEMA [as 别名]
# 或者: from homeassistant.helpers.config_validation.PLATFORM_SCHEMA import extend [as 别名]
    vol.Required(CONF_OFF_ACTION): cv.SCRIPT_SCHEMA,

    vol.Optional(CONF_SET_SPEED_ACTION): cv.SCRIPT_SCHEMA,
    vol.Optional(CONF_SET_OSCILLATING_ACTION): cv.SCRIPT_SCHEMA,
    vol.Optional(CONF_SET_DIRECTION_ACTION): cv.SCRIPT_SCHEMA,

    vol.Optional(
        CONF_SPEED_LIST,
        default=[SPEED_LOW, SPEED_MEDIUM, SPEED_HIGH]
    ): cv.ensure_list,

    vol.Optional(CONF_ENTITY_ID): cv.entity_ids
})

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_FANS): vol.Schema({cv.slug: FAN_SCHEMA}),
})


async def async_setup_platform(
        hass, config, async_add_devices, discovery_info=None
):
    """Set up the Template Fans."""
    fans = []

    for device, device_config in config[CONF_FANS].items():
        friendly_name = device_config.get(CONF_FRIENDLY_NAME, device)

        state_template = device_config[CONF_VALUE_TEMPLATE]
        speed_template = device_config.get(CONF_SPEED_TEMPLATE)
        oscillating_template = device_config.get(
开发者ID:DavidMStraub,项目名称:home-assistant,代码行数:33,代码来源:template.py

示例15: timedelta

# 需要导入模块: from homeassistant.helpers.config_validation import PLATFORM_SCHEMA [as 别名]
# 或者: from homeassistant.helpers.config_validation.PLATFORM_SCHEMA import extend [as 别名]
ICON = 'mdi:fuel'

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."""
    from prezzibenzina import PrezziBenzinaPy

    station = config[CONF_STATION]
    name = config.get(CONF_NAME)
    types = config.get(CONF_TYPES)

    client = PrezziBenzinaPy()
    dev = []
开发者ID:Martwall,项目名称:home-assistant,代码行数:34,代码来源:prezzibenzina.py


注:本文中的homeassistant.helpers.config_validation.PLATFORM_SCHEMA.extend方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。