1 """Support for TPLink button entities."""
3 from __future__
import annotations
5 from dataclasses
import dataclass
6 from typing
import Final
8 from kasa
import Feature
11 DOMAIN
as BUTTON_DOMAIN,
14 ButtonEntityDescription,
20 from .
import TPLinkConfigEntry
21 from .deprecate
import DeprecatedInfo, async_cleanup_deprecated
22 from .entity
import CoordinatedTPLinkFeatureEntity, TPLinkFeatureEntityDescription
25 @dataclass(frozen=True, kw_only=True)
27 ButtonEntityDescription, TPLinkFeatureEntityDescription
29 """Base class for a TPLink feature based button entity description."""
32 BUTTON_DESCRIPTIONS: Final = [
36 platform=BUTTON_DOMAIN,
37 new_platform=SIREN_DOMAIN,
38 breaks_in_ha_version=
"2025.4.0",
44 platform=BUTTON_DOMAIN,
45 new_platform=SIREN_DOMAIN,
46 breaks_in_ha_version=
"2025.4.0",
51 device_class=ButtonDeviceClass.RESTART,
55 BUTTON_DESCRIPTIONS_MAP = {desc.key: desc
for desc
in BUTTON_DESCRIPTIONS}
60 config_entry: TPLinkConfigEntry,
61 async_add_entities: AddEntitiesCallback,
64 data = config_entry.runtime_data
65 parent_coordinator = data.parent_coordinator
66 children_coordinators = data.children_coordinators
67 device = parent_coordinator.device
69 entities = CoordinatedTPLinkFeatureEntity.entities_for_device_and_its_children(
72 coordinator=parent_coordinator,
73 feature_type=Feature.Type.Action,
74 entity_class=TPLinkButtonEntity,
75 descriptions=BUTTON_DESCRIPTIONS_MAP,
76 child_coordinators=children_coordinators,
83 """Representation of a TPLink button entity."""
85 entity_description: TPLinkButtonEntityDescription
89 await self.
_feature_feature.set_value(
True)
92 """No need to update anything."""
None async_cleanup_deprecated(HomeAssistant hass, str platform, str entry_id, Sequence[CoordinatedTPLinkFeatureEntity] entities)