1 """Select entities for the Motionblinds Bluetooth integration."""
3 from __future__
import annotations
7 from motionblindsble.const
import MotionBlindType, MotionSpeedLevel
8 from motionblindsble.device
import MotionDevice
16 from .const
import ATTR_SPEED, CONF_MAC_CODE, DOMAIN
17 from .entity
import MotionblindsBLEEntity
19 _LOGGER = logging.getLogger(__name__)
24 SELECT_TYPES: dict[str, SelectEntityDescription] = {
27 translation_key=ATTR_SPEED,
28 entity_category=EntityCategory.CONFIG,
29 options=[
"1",
"2",
"3"],
35 hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
37 """Set up select entities based on a config entry."""
39 device: MotionDevice = hass.data[DOMAIN][entry.entry_id]
41 if device.blind_type
not in {MotionBlindType.CURTAIN, MotionBlindType.VERTICAL}:
46 """Representation of a speed select entity."""
52 entity_description: SelectEntityDescription,
54 """Initialize the speed select entity."""
56 device, entry, entity_description, unique_id_suffix=entity_description.key
61 """Register device callbacks."""
63 "(%s) Setting up speed select entity",
64 self.
entryentry.data[CONF_MAC_CODE],
70 """Update the speed sensor value."""
75 """Change the selected speed sensor value."""
76 speed_level = MotionSpeedLevel(
int(option))
77 await self.
devicedevice.speed(speed_level)
None __init__(self, MotionDevice device, ConfigEntry entry, SelectEntityDescription entity_description)
None async_added_to_hass(self)
None async_select_option(self, str option)
None async_update_speed(self, MotionSpeedLevel|None speed_level)
None async_write_ha_state(self)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)