Exemplo n.º 1
0
async def async_setup_entry(
    hass: HomeAssistant,
    config_entry: ConfigEntry,
    async_add_entities: AddEntitiesCallback,
) -> None:
    """Set up climate device."""

    if get_device_entry_gen(config_entry) == 2:
        return

    wrapper: BlockDeviceWrapper = hass.data[DOMAIN][DATA_CONFIG_ENTRY][
        config_entry.entry_id][BLOCK]

    if wrapper.device.initialized:
        await async_setup_climate_entities(async_add_entities, wrapper)
    else:
        await async_restore_climate_entities(hass, config_entry,
                                             async_add_entities, wrapper)
Exemplo n.º 2
0
async def async_setup_entry(
    hass: HomeAssistant,
    config_entry: ConfigEntry,
    async_add_entities: AddEntitiesCallback,
) -> None:
    """Set up climate device."""

    if get_device_entry_gen(config_entry) == 2:
        return

    device_block: Block | None = None
    sensor_block: Block | None = None

    wrapper = hass.data[DOMAIN][DATA_CONFIG_ENTRY][
        config_entry.entry_id][BLOCK]
    for block in wrapper.device.blocks:
        if block.type == "device":
            device_block = block
        if hasattr(block, "targetTemp"):
            sensor_block = block

    if sensor_block and device_block:
        async_add_entities(
            [ShellyClimate(wrapper, sensor_block, device_block)])