1 """Support for SleepIQ foundation preset selection."""
3 from __future__
import annotations
5 from asyncsleepiq
import (
18 from .const
import DOMAIN, FOOT_WARMER
19 from .coordinator
import SleepIQData, SleepIQDataUpdateCoordinator
20 from .entity
import SleepIQBedEntity, SleepIQSleeperEntity, sleeper_for_side
26 async_add_entities: AddEntitiesCallback,
28 """Set up the SleepIQ foundation preset select entities."""
29 data: SleepIQData = hass.data[DOMAIN][entry.entry_id]
30 entities: list[SleepIQBedEntity] = []
31 for bed
in data.client.beds.values():
34 for preset
in bed.foundation.presets
38 for foot_warmer
in bed.foundation.foot_warmers
44 """Representation of a SleepIQ select entity."""
48 coordinator: SleepIQDataUpdateCoordinator,
50 preset: SleepIQPreset,
52 """Initialize the select entity."""
55 self.
_attr_name_attr_name = f
"SleepNumber {bed.name} Foundation Preset"
57 if preset.side != Side.NONE:
58 self.
_attr_name_attr_name += f
" {preset.side_full}"
67 """Update entity attributes."""
71 """Change the current preset."""
72 await self.
presetpreset.set_preset(option)
78 SleepIQSleeperEntity[SleepIQDataUpdateCoordinator], SelectEntity
80 """Representation of a SleepIQ foot warming temperature select entity."""
82 _attr_icon =
"mdi:heat-wave"
83 _attr_options = [e.name.lower()
for e
in FootWarmingTemps]
84 _attr_translation_key =
"foot_warmer_temp"
88 coordinator: SleepIQDataUpdateCoordinator,
90 foot_warmer: SleepIQFootWarmer,
92 """Initialize the select entity."""
95 super().
__init__(coordinator, bed, sleeper, FOOT_WARMER)
100 """Update entity attributes."""
106 """Change the current preset."""
107 temperature = FootWarmingTemps[option.upper()]
113 await self.
foot_warmerfoot_warmer.turn_on(temperature, timer)
None _async_update_attrs(self)
None __init__(self, SleepIQDataUpdateCoordinator coordinator, SleepIQBed bed, SleepIQPreset preset)
None async_select_option(self, str option)
None async_write_ha_state(self)
None async_request_refresh(self)
SleepIQSleeper sleeper_for_side(SleepIQBed bed, str side)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)