Skip to content

Select

One SelectEntity per active PWM channel, exposing pwm#X#manager — the scheduling mode for that channel.

Options

Option Device value Description
none 0 No automatic program; channel is manual
dayplanner 1 Uses the day-planner schedule
weekplanner 2 Uses the week-planner schedule
fixed 3 Holds the value set in pwm#X#fixed

Reference

select

Classes

SunRiserPWMManagerSelect

Bases: CoordinatorEntity[SunRiserCoordinator], SelectEntity

Select which planner controls a PWM channel (pwm#X#manager).

Source code in custom_components/sunriser/select.py
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
class SunRiserPWMManagerSelect(CoordinatorEntity[SunRiserCoordinator], SelectEntity):
    """Select which planner controls a PWM channel (pwm#X#manager)."""

    _attr_has_entity_name = True
    _attr_translation_key = "pwm_manager"
    _attr_entity_category = EntityCategory.CONFIG
    _attr_options = list(MANAGER_OPTIONS.values())
    # Advanced config — most users set once and never revisit; disabled by default.
    _attr_entity_registry_enabled_default = False

    def __init__(
        self,
        coordinator: SunRiserCoordinator,
        entry: ConfigEntry,
        pwm_num: int,
    ) -> None:
        super().__init__(coordinator)
        self._pwm_num = pwm_num
        self._attr_unique_id = f"{entry.entry_id}_pwm_{pwm_num}_manager"
        self._attr_translation_placeholders = {"channel": coordinator.pwm_name(pwm_num)}
        self._attr_device_info = coordinator.device_info

    @property
    def current_option(self) -> str:
        return MANAGER_OPTIONS.get(self.coordinator.pwm_manager(self._pwm_num), "none")

    async def async_select_option(self, option: str) -> None:
        value = _MANAGER_TO_INT.get(option, 0)
        await self.coordinator.async_set_config({f"pwm#{self._pwm_num}#manager": value})
        self.coordinator.config[f"pwm#{self._pwm_num}#manager"] = value