feat: Einstellungen, Neustart, Diagnose-Sensoren und Diagnose-Download

This commit is contained in:
Michael Sauer
2026-09-16 16:08:47 +02:00
parent be0a8e21b6
commit cc318c9d25
13 changed files with 608 additions and 1 deletions
+43
View File
@@ -0,0 +1,43 @@
"""Wake-on-change switch of a ninlight lamp."""
from __future__ import annotations
from typing import Any
from homeassistant.components.switch import SwitchEntity
from homeassistant.const import EntityCategory
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
from .coordinator import NinlightConfigEntry, NinlightCoordinator
from .entity import NinlightEntity
PARALLEL_UPDATES = 0
async def async_setup_entry(
hass: HomeAssistant,
entry: NinlightConfigEntry,
async_add_entities: AddConfigEntryEntitiesCallback,
) -> None:
async_add_entities([NinlightWakeSwitch(entry.runtime_data)])
class NinlightWakeSwitch(NinlightEntity, SwitchEntity):
"""Turn the lamp on when its colour, temperature or brightness is changed."""
_attr_entity_category = EntityCategory.CONFIG
_attr_translation_key = "wake_on_change"
def __init__(self, coordinator: NinlightCoordinator) -> None:
super().__init__(coordinator, "wake_on_change")
@property
def is_on(self) -> bool:
return bool(self.coordinator.data.state.get("wake_on_change"))
async def async_turn_on(self, **kwargs: Any) -> None:
await self.coordinator.async_set_state(wake_on_change=True)
async def async_turn_off(self, **kwargs: Any) -> None:
await self.coordinator.async_set_state(wake_on_change=False)