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


Python config_entries.ConfigEntry方法代码示例

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


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

示例1: async_setup_entry

# 需要导入模块: from homeassistant import config_entries [as 别名]
# 或者: from homeassistant.config_entries import ConfigEntry [as 别名]
def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
    """Set up Home Connect from a config entry."""
    implementation = await config_entry_oauth2_flow.async_get_config_entry_implementation(
        hass, entry
    )

    hc_api = api.ConfigEntryAuth(hass, entry, implementation)

    hass.data[DOMAIN][entry.entry_id] = hc_api

    await update_all_devices(hass, entry)

    for component in PLATFORMS:
        hass.async_create_task(
            hass.config_entries.async_forward_entry_setup(entry, component)
        )

    return True 
开发者ID:DavidMStraub,项目名称:homeassistant-homeconnect,代码行数:20,代码来源:__init__.py

示例2: async_options_updated

# 需要导入模块: from homeassistant import config_entries [as 别名]
# 或者: from homeassistant.config_entries import ConfigEntry [as 别名]
def async_options_updated(hass: HomeAssistant, entry: ConfigEntry):
    """Edit visonic entry."""
    log.info("************* update connection here ************** {0}".format(entry.entry_id))
    #log.info("     options {0}".format(entry.options))
    #log.info("     data    {0}".format(entry.data))

    client = hass.data[DOMAIN][DOMAINCLIENT][entry.unique_id]

    # convert python map to dictionary
    conf = {}
    # the entry.data dictionary contains all the old data used on creation and is a complete set
    for k in entry.data:
        conf[k] = entry.data[k]
    # the entry.config dictionary contains the latest/updated values but may not be a complete set
    for k in entry.options:
        conf[k] = entry.options[k]
       
    # save the parameters for control flow editing
    set_defaults(conf)
    
    # update the client parameter set
    client.updateConfig(conf)
    
    return True 
开发者ID:davesmeghead,项目名称:visonic,代码行数:26,代码来源:__init__.py

示例3: async_setup_entry

# 需要导入模块: from homeassistant import config_entries [as 别名]
# 或者: from homeassistant.config_entries import ConfigEntry [as 别名]
def async_setup_entry(
    hass: HomeAssistantType, entry: ConfigEntry, async_add_entities
) -> None:
    """A Ubiquiti Unifi Protect Sensor."""
    upv_object = hass.data[DOMAIN][entry.entry_id]["upv"]
    coordinator = hass.data[DOMAIN][entry.entry_id]["coordinator"]
    if not coordinator.data:
        return

    sensors = []
    for sensor in SENSOR_TYPES:
        for camera in coordinator.data:
            sensors.append(UnifiProtectSensor(upv_object, coordinator, camera, sensor))
            _LOGGER.debug("UNIFIPROTECT SENSOR CREATED: %s", sensor)

    async_add_entities(sensors, True)

    return True 
开发者ID:briis,项目名称:unifiprotect,代码行数:20,代码来源:sensor.py

示例4: async_unload_entry

# 需要导入模块: from homeassistant import config_entries [as 别名]
# 或者: from homeassistant.config_entries import ConfigEntry [as 别名]
def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
    """Handle removal of an entry."""
    coordinator = hass.data[DOMAIN][entry.entry_id]
    unloaded = all(
        await asyncio.gather(
            *[
                hass.config_entries.async_forward_entry_unload(entry, platform)
                for platform in PLATFORMS
                if platform in coordinator.platforms
            ]
        )
    )
    if unloaded:
        hass.data[DOMAIN].pop(entry.entry_id)

    return unloaded 
开发者ID:custom-components,项目名称:blueprint,代码行数:18,代码来源:__init__.py

示例5: async_setup_entry

# 需要导入模块: from homeassistant import config_entries [as 别名]
# 或者: from homeassistant.config_entries import ConfigEntry [as 别名]
def async_setup_entry( hass: HomeAssistant, entry: ConfigEntry, async_add_entities ) -> None:
    """Set up the Visonic Alarm Binary Sensors"""
    if DOMAIN in hass.data:
        client = hass.data[DOMAIN][DOMAINCLIENT][entry.unique_id]
        devices = [
            VisonicSwitch(hass, client, device)
            for device in hass.data[DOMAIN]['switch']   
        ]
        hass.data[DOMAIN]["switch"] = list()
        async_add_entities(devices) 
开发者ID:davesmeghead,项目名称:visonic,代码行数:12,代码来源:switch.py

示例6: async_setup_entry

# 需要导入模块: from homeassistant import config_entries [as 别名]
# 或者: from homeassistant.config_entries import ConfigEntry [as 别名]
def async_setup_entry( hass: HomeAssistant, entry: ConfigEntry, async_add_entities ) -> None:
    """Set up the Visonic Alarm Binary Sensors"""
    
    _LOGGER.info("************* binary sensor async_setup_entry **************")
    #_LOGGER.info("     options {0}".format(entry.options))
    #_LOGGER.info("     data    {0}".format(entry.data))
    
#    @callback
#    def async_add_binary_sensor(binary_sensor):
#        """Add Visonic binary sensor."""
#        _LOGGER.info(f"   got device {binary_sensor.getDeviceID()}")
#        async_add_entities([binary_sensor], True)

#    async_dispatcher_connect(hass, "visonic_new_binary_sensor", async_add_binary_sensor)

    if DOMAIN in hass.data:
        _LOGGER.info("   In binary sensor async_setup_entry")
        sensors = [
            VisonicSensor(device)
            for device in hass.data[DOMAIN]['binary_sensor']   
        ]
        # empty the list as we have copied the entries so far in to sensors
        hass.data[DOMAIN]["binary_sensor"] = list()       
        async_add_entities(sensors, True)

#   Each Sensor in Visonic Alarms can be Armed/Bypassed individually 
开发者ID:davesmeghead,项目名称:visonic,代码行数:28,代码来源:binary_sensor.py

示例7: async_unload_entry

# 需要导入模块: from homeassistant import config_entries [as 别名]
# 或者: from homeassistant.config_entries import ConfigEntry [as 别名]
def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
    """Unload visonic entry."""
    log.info("************* terminate connection here ************** {0}".format(entry.entry_id))
    #log.info("     options {0}".format(entry.options))
    #log.info("     data    {0}".format(entry.data))

    client = hass.data[DOMAIN][DOMAINCLIENT][entry.unique_id]

    # stop the comms to/from the panel
    await client.service_comms_stop(None)
    # stop all activity in the client
    await client.service_panel_stop(None)
    
    unload_ok = all(
        await asyncio.gather(
            *[
                hass.config_entries.async_forward_entry_unload(entry, component)
                for component in PLATFORMS
            ]
        )
    )

    if not unload_ok:
        return False
    return True


# This function is called when there have been changes made to the parameters in the control flow 
开发者ID:davesmeghead,项目名称:visonic,代码行数:30,代码来源:__init__.py

示例8: async_setup_entry

# 需要导入模块: from homeassistant import config_entries [as 别名]
# 或者: from homeassistant.config_entries import ConfigEntry [as 别名]
def async_setup_entry( hass: HomeAssistant, entry: ConfigEntry, async_add_entities ) -> None:
    #_LOGGER.info("alarm control panel async_setup_entry called")
    client = hass.data[DOMAIN][DOMAINCLIENT][entry.unique_id]
    va = VisonicAlarm(hass, client, 1)
    devices = [va]
    async_add_entities(devices) 
开发者ID:davesmeghead,项目名称:visonic,代码行数:8,代码来源:alarm_control_panel.py

示例9: async_unload_entry

# 需要导入模块: from homeassistant import config_entries [as 别名]
# 或者: from homeassistant.config_entries import ConfigEntry [as 别名]
def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
    """Unload a config entry."""
    unload_ok = all(
        await asyncio.gather(
            *[
                hass.config_entries.async_forward_entry_unload(entry, component)
                for component in PLATFORMS
            ]
        )
    )
    if unload_ok:
        hass.data[DOMAIN].pop(entry.entry_id)

    return unload_ok 
开发者ID:DavidMStraub,项目名称:homeassistant-homeconnect,代码行数:16,代码来源:__init__.py

示例10: __init__

# 需要导入模块: from homeassistant import config_entries [as 别名]
# 或者: from homeassistant.config_entries import ConfigEntry [as 别名]
def __init__(
        self,
        hass: core.HomeAssistant,
        config_entry: config_entries.ConfigEntry,
        implementation: config_entry_oauth2_flow.AbstractOAuth2Implementation,
    ):
        """Initialize Home Connect Auth."""
        self.hass = hass
        self.config_entry = config_entry
        self.session = config_entry_oauth2_flow.OAuth2Session(
            hass, config_entry, implementation
        )
        super().__init__(self.session.token)
        self.devices = [] 
开发者ID:DavidMStraub,项目名称:homeassistant-homeconnect,代码行数:16,代码来源:api.py

示例11: async_setup_entry

# 需要导入模块: from homeassistant import config_entries [as 别名]
# 或者: from homeassistant.config_entries import ConfigEntry [as 别名]
def async_setup_entry(
    hass: HomeAssistantType, entry: ConfigEntry, async_add_entities
) -> None:
    """A Ubiquiti Unifi Protect Sensor."""
    upv_object = hass.data[DOMAIN][entry.entry_id]["upv"]
    coordinator = hass.data[DOMAIN][entry.entry_id]["coordinator"]
    if not coordinator.data:
        return

    ir_on = entry.data[CONF_IR_ON]
    if ir_on == "always_on":
        ir_on = "on"

    ir_off = entry.data[CONF_IR_OFF]
    if ir_off == "led_off":
        ir_off = "autoFilterOnly"
    elif ir_off == "always_off":
        ir_off = "off"

    switches = []
    for switch in SWITCH_TYPES:
        for camera in coordinator.data:
            switches.append(
                UnifiProtectSwitch(
                    upv_object, coordinator, camera, switch, ir_on, ir_off,
                )
            )
            _LOGGER.debug("UNIFIPROTECT SWITCH CREATED: %s", switch)

    async_add_entities(switches, True)

    return True 
开发者ID:briis,项目名称:unifiprotect,代码行数:34,代码来源:switch.py

示例12: async_setup_entry

# 需要导入模块: from homeassistant import config_entries [as 别名]
# 或者: from homeassistant.config_entries import ConfigEntry [as 别名]
def async_setup_entry(
    hass: HomeAssistantType, entry: ConfigEntry, async_add_entities
) -> None:
    """A Ubiquiti Unifi Protect Binary Sensor."""
    upv_object = hass.data[DOMAIN][entry.entry_id]["upv"]
    coordinator = hass.data[DOMAIN][entry.entry_id]["coordinator"]
    if not coordinator.data:
        return

    sensors = []
    for camera in coordinator.data:
        if coordinator.data[camera]["type"] == DEVICE_CLASS_DOORBELL:
            sensors.append(
                UnifiProtectBinarySensor(
                    upv_object, coordinator, camera, DEVICE_CLASS_DOORBELL
                )
            )
            _LOGGER.debug(
                "UNIFIPROTECT DOORBELL SENSOR CREATED: %s",
                coordinator.data[camera]["name"],
            )

        sensors.append(
            UnifiProtectBinarySensor(
                upv_object, coordinator, camera, DEVICE_CLASS_MOTION
            )
        )
        _LOGGER.debug(
            "UNIFIPROTECT MOTION SENSOR CREATED: %s", coordinator.data[camera]["name"]
        )

    async_add_entities(sensors, True)

    return True 
开发者ID:briis,项目名称:unifiprotect,代码行数:36,代码来源:binary_sensor.py

示例13: _async_get_or_create_nvr_device_in_registry

# 需要导入模块: from homeassistant import config_entries [as 别名]
# 或者: from homeassistant.config_entries import ConfigEntry [as 别名]
def _async_get_or_create_nvr_device_in_registry(
    hass: HomeAssistantType, entry: ConfigEntry, nvr
) -> None:
    device_registry = await dr.async_get_registry(hass)
    device_registry.async_get_or_create(
        config_entry_id=entry.entry_id,
        connections={(dr.CONNECTION_NETWORK_MAC, nvr["server_id"])},
        identifiers={(DOMAIN, nvr["server_id"])},
        manufacturer=DEFAULT_BRAND,
        name=entry.data[CONF_ID],
        model=nvr["server_model"],
        sw_version=nvr["server_version"],
    ) 
开发者ID:briis,项目名称:unifiprotect,代码行数:15,代码来源:__init__.py

示例14: async_update_options

# 需要导入模块: from homeassistant import config_entries [as 别名]
# 或者: from homeassistant.config_entries import ConfigEntry [as 别名]
def async_update_options(hass: HomeAssistantType, entry: ConfigEntry):
    """Update options."""
    await hass.config_entries.async_reload(entry.entry_id) 
开发者ID:briis,项目名称:unifiprotect,代码行数:5,代码来源:__init__.py

示例15: async_unload_entry

# 需要导入模块: from homeassistant import config_entries [as 别名]
# 或者: from homeassistant.config_entries import ConfigEntry [as 别名]
def async_unload_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool:
    """Unload Unifi Protect config entry."""
    unload_ok = all(
        await asyncio.gather(
            *[
                hass.config_entries.async_forward_entry_unload(entry, component)
                for component in UNIFI_PROTECT_PLATFORMS
            ]
        )
    )

    if unload_ok:
        hass.data[DOMAIN].pop(entry.entry_id)

    return unload_ok 
开发者ID:briis,项目名称:unifiprotect,代码行数:17,代码来源:__init__.py


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