Skip to content

Button

A single reboot button that triggers GET /reboot on the device.

Reference

button

Classes

SunRiserRebootButton

Bases: CoordinatorEntity[SunRiserCoordinator], ButtonEntity

Button that reboots the SunRiser device.

Source code in custom_components/sunriser/button.py
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
class SunRiserRebootButton(CoordinatorEntity[SunRiserCoordinator], ButtonEntity):
    """Button that reboots the SunRiser device."""

    _attr_has_entity_name = True
    _attr_translation_key = "reboot"
    _attr_device_class = ButtonDeviceClass.RESTART
    _attr_entity_category = EntityCategory.CONFIG

    def __init__(self, coordinator: SunRiserCoordinator, entry: ConfigEntry) -> None:
        super().__init__(coordinator)
        self._attr_unique_id = f"{entry.entry_id}_reboot"
        self._attr_device_info = coordinator.device_info

    async def async_press(self) -> None:
        await self.coordinator.async_reboot()