當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。