1 """Support for SleepIQ buttons."""
3 from __future__
import annotations
5 from collections.abc
import Callable
6 from dataclasses
import dataclass
9 from asyncsleepiq
import SleepIQBed
16 from .const
import DOMAIN
17 from .coordinator
import SleepIQData
18 from .entity
import SleepIQEntity
21 @dataclass(frozen=True, kw_only=True)
23 """Class to describe a Button entity."""
25 press_action: Callable[[SleepIQBed], Any]
28 ENTITY_DESCRIPTIONS = [
32 press_action=
lambda client: client.calibrate(),
38 press_action=
lambda client: client.stop_pump(),
47 async_add_entities: AddEntitiesCallback,
49 """Set up the sleep number buttons."""
50 data: SleepIQData = hass.data[DOMAIN][entry.entry_id]
54 for bed
in data.client.beds.values()
55 for ed
in ENTITY_DESCRIPTIONS
60 """Representation of an SleepIQ button."""
62 entity_description: SleepIQButtonEntityDescription
65 self, bed: SleepIQBed, entity_description: SleepIQButtonEntityDescription
67 """Initialize the Button."""
69 self.
_attr_name_attr_name = f
"SleepNumber {bed.name} {entity_description.name}"
74 """Press the button."""