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


Python config_validation.entity_ids方法代码示例

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


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

示例1: setup_platform

# 需要导入模块: from homeassistant.helpers import config_validation [as 别名]
# 或者: from homeassistant.helpers.config_validation import entity_ids [as 别名]
def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up the Neato vacuum."""
    dev = []
    for robot in hass.data[NEATO_ROBOTS]:
        dev.append(NeatoConnectedVacuum(hass, robot))

    if not dev:
        return

    _LOGGER.debug("Adding vacuums %s", dev)
    add_entities(dev, True)

    def neato_custom_cleaning_service(call):
        """Zone cleaning service that allows user to change options."""
        for robot in service_to_entities(call):
            if call.service == SERVICE_NEATO_CUSTOM_CLEANING:
                mode = call.data.get(ATTR_MODE)
                navigation = call.data.get(ATTR_NAVIGATION)
                category = call.data.get(ATTR_CATEGORY)
                zone = call.data.get(ATTR_ZONE)
                robot.neato_custom_cleaning(
                    mode, navigation, category, zone)

    def service_to_entities(call):
        """Return the known devices that a service call mentions."""
        entity_ids = extract_entity_ids(hass, call)
        entities = [entity for entity in dev
                    if entity.entity_id in entity_ids]
        return entities

    hass.services.register(DOMAIN, SERVICE_NEATO_CUSTOM_CLEANING,
                           neato_custom_cleaning_service,
                           schema=SERVICE_NEATO_CUSTOM_CLEANING_SCHEMA) 
开发者ID:Teagan42,项目名称:HomeAssistantConfig,代码行数:35,代码来源:vacuum.py


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