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


Python core.HomeAssistant方法代码示例

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


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

示例1: dummy_repository_base

# 需要导入模块: from homeassistant import core [as 别名]
# 或者: from homeassistant.core import HomeAssistant [as 别名]
def dummy_repository_base(repository=None):
    if repository is None:
        repository = HacsRepository()
    repository.hacs.hass = HomeAssistant()
    repository.hacs.hass.data = {"custom_components": []}
    repository.hacs.system.config_path = tempfile.gettempdir()
    repository.logger = Logger("hacs.test.test")
    repository.data.full_name = "test/test"
    repository.data.domain = "test"
    repository.data.last_version = "3"
    repository.data.selected_tag = "3"
    repository.ref = version_to_install(repository)
    repository.integration_manifest = {"config_flow": False, "domain": "test"}
    repository.data.published_tags = ["1", "2", "3"]
    repository.data.update_data(repository_data)
    return repository 
开发者ID:hacs,项目名称:integration,代码行数:18,代码来源:dummy_repository.py

示例2: async_options_updated

# 需要导入模块: from homeassistant import core [as 别名]
# 或者: from homeassistant.core import HomeAssistant [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 core [as 别名]
# 或者: from homeassistant.core import HomeAssistant [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

示例4: all

# 需要导入模块: from homeassistant import core [as 别名]
# 或者: from homeassistant.core import HomeAssistant [as 别名]
def all(self, hass: HomeAssistant = None, init_flag: bool = False) -> list:
        if not self._devices_cache or init_flag:
            self._devices_cache.clear()
            for device_id, device_attributes in hass.data[INTEGRATION][DATA_HAVCS_ITEMS].items():
                if ATTR_DEVICE_VISABLE not in device_attributes:
                    pass
                elif isinstance(device_attributes.get(ATTR_DEVICE_VISABLE) , str) and self._platform == device_attributes.get(ATTR_DEVICE_VISABLE):
                    pass
                elif isinstance(device_attributes.get(ATTR_DEVICE_VISABLE) , list) and self._platform in device_attributes.get(ATTR_DEVICE_VISABLE):
                    pass
                else:
                    continue
                if isinstance(device_attributes.get(ATTR_DEVICE_ENTITY_ID) , str):
                    device_attributes[ATTR_DEVICE_ENTITY_ID]= [device_attributes.get(ATTR_DEVICE_ENTITY_ID)]

                self._devices_cache.update(self.get(device_id, hass, device_attributes))

        return list(self._devices_cache.values()) 
开发者ID:cnk700i,项目名称:havcs,代码行数:20,代码来源:helper.py

示例5: _create_entities

# 需要导入模块: from homeassistant import core [as 别名]
# 或者: from homeassistant.core import HomeAssistant [as 别名]
def _create_entities(hass: HomeAssistant, entry: dict):
    entities = []

    controller = hass.data[DOMAIN][entry.entry_id]["controller"]
    coordinator = hass.data[DOMAIN][entry.entry_id]["coordinator"]
    name = entry.data[CONF_NAME]

    entities.append(ControllerOperationSwitch(entry, name, controller, coordinator))

    for _, program in controller.programs.items():
        entities.append(ProgramEnabledSwitch(entry, name, program, coordinator))

    for _, station in controller.stations.items():
        entities.append(StationEnabledSwitch(entry, name, station, coordinator))

    return entities 
开发者ID:vinteo,项目名称:hass-opensprinkler,代码行数:18,代码来源:switch.py

示例6: _create_entities

# 需要导入模块: from homeassistant import core [as 别名]
# 或者: from homeassistant.core import HomeAssistant [as 别名]
def _create_entities(hass: HomeAssistant, entry: dict):
    entities = []

    controller = hass.data[DOMAIN][entry.entry_id]["controller"]
    coordinator = hass.data[DOMAIN][entry.entry_id]["coordinator"]
    name = entry.data[CONF_NAME]

    entities.append(
        ControllerSensorActive(entry, name, "sensor_1", controller, coordinator)
    )
    entities.append(
        ControllerSensorActive(entry, name, "sensor_2", controller, coordinator)
    )
    entities.append(
        ControllerSensorActive(entry, name, "rain_delay", controller, coordinator)
    )

    for _, program in controller.programs.items():
        entities.append(ProgramIsRunningBinarySensor(entry, name, program, coordinator))

    for _, station in controller.stations.items():
        entities.append(StationIsRunningBinarySensor(entry, name, station, coordinator))

    return entities 
开发者ID:vinteo,项目名称:hass-opensprinkler,代码行数:26,代码来源:binary_sensor.py

示例7: _create_entities

# 需要导入模块: from homeassistant import core [as 别名]
# 或者: from homeassistant.core import HomeAssistant [as 别名]
def _create_entities(hass: HomeAssistant, entry: dict):
    entities = []

    controller = hass.data[DOMAIN][entry.entry_id]["controller"]
    coordinator = hass.data[DOMAIN][entry.entry_id]["coordinator"]
    name = entry.data[CONF_NAME]

    entities.append(LastRunSensor(entry, name, controller, coordinator))
    entities.append(RainDelayStopTimeSensor(entry, name, controller, coordinator))
    entities.append(WaterLevelSensor(entry, name, controller, coordinator))
    entities.append(FlowRateSensor(entry, name, controller, coordinator))

    for _, station in controller.stations.items():
        entities.append(StationStatusSensor(entry, name, station, coordinator))

    return entities 
开发者ID:vinteo,项目名称:hass-opensprinkler,代码行数:18,代码来源:sensor.py

示例8: async_unload_entry

# 需要导入模块: from homeassistant import core [as 别名]
# 或者: from homeassistant.core import HomeAssistant [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

示例9: test_save

# 需要导入模块: from homeassistant import core [as 别名]
# 或者: from homeassistant.core import HomeAssistant [as 别名]
def test_save(tmpdir):
    hass = HomeAssistant()
    hass.config.config_dir = tmpdir.dirname
    await async_save_to_store(hass, "repositories", REPOSITORIES) 
开发者ID:hacs,项目名称:integration,代码行数:6,代码来源:test_store.py

示例10: test_load

# 需要导入模块: from homeassistant import core [as 别名]
# 或者: from homeassistant.core import HomeAssistant [as 别名]
def test_load(tmpdir):
    hass = HomeAssistant()
    hass.config.config_dir = tmpdir.dirname

    repositories = await async_load_from_store(hass, "repositories")
    assert repositories["999999"]["name"] == "test1"

    repositories = await async_load_from_store(hass, "does_not_exist")
    assert not repositories 
开发者ID:hacs,项目名称:integration,代码行数:11,代码来源:test_store.py

示例11: test_setup_platform

# 需要导入模块: from homeassistant import core [as 别名]
# 或者: from homeassistant.core import HomeAssistant [as 别名]
def test_setup_platform():
    await async_setup_platform(hass, {}, mock_setup) 
开发者ID:hacs,项目名称:integration,代码行数:4,代码来源:test_sensor.py

示例12: test_setup_entry

# 需要导入模块: from homeassistant import core [as 别名]
# 或者: from homeassistant.core import HomeAssistant [as 别名]
def test_setup_entry():
    await async_setup_entry(hass, {}, mock_setup) 
开发者ID:hacs,项目名称:integration,代码行数:4,代码来源:test_sensor.py

示例13: async_setup_entry

# 需要导入模块: from homeassistant import core [as 别名]
# 或者: from homeassistant.core import HomeAssistant [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

示例14: __init__

# 需要导入模块: from homeassistant import core [as 别名]
# 或者: from homeassistant.core import HomeAssistant [as 别名]
def __init__(self, hass: HomeAssistant, client, visonic_device):
        """Initialise a Visonic X10 Device."""
        #_LOGGER.info("Creating X10 Switch {0}".format(visonic_device.name))
        self.client = client
        self.visonic_device = visonic_device
        self.x10id = self.visonic_device.id
        self._name = "Visonic " + self.visonic_device.name
        # Append device id to prevent name clashes in HA.
        self.visonic_id = slugify(self._name) # VISONIC_ID_FORMAT.format( slugify(self._name), visonic_device.getDeviceID())
        self.entity_id = ENTITY_ID_FORMAT.format(self.visonic_id)
        self.current_value = self.visonic_device.state
        self.visonic_device.install_change_handler(self.onChange) 
开发者ID:davesmeghead,项目名称:visonic,代码行数:14,代码来源:switch.py

示例15: async_setup_entry

# 需要导入模块: from homeassistant import core [as 别名]
# 或者: from homeassistant.core import HomeAssistant [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


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