v0.7.2
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
"""Writable zone enabled switches for GREE Controller."""
|
||||
"""Writable house, group, zone and device switches for GREE Controller."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
@@ -37,9 +37,13 @@ async def async_setup_entry(
|
||||
entities: list[SwitchEntity] = [
|
||||
GreeControllerHousePowerSwitch(runtime.coordinator),
|
||||
*[
|
||||
GreeControllerZoneEnabledSwitch(runtime.coordinator, str(zone["zone_id"]))
|
||||
for zone in runtime.coordinator.plan.get("zones", [])
|
||||
if zone.get("zone_id")
|
||||
GreeControllerZoneEnabledSwitch(runtime.coordinator, str(zone["zone_id"]))
|
||||
for zone in runtime.coordinator.plan.get("zones", [])
|
||||
if zone.get("zone_id")
|
||||
],
|
||||
*[
|
||||
GreeControllerGroupPowerSwitch(runtime.coordinator, group_id)
|
||||
for group_id in runtime.coordinator.groups
|
||||
],
|
||||
]
|
||||
for device_id, device in runtime.coordinator.data.items():
|
||||
@@ -78,6 +82,56 @@ class GreeControllerHousePowerSwitch(CoordinatorEntity[GreeControllerCoordinator
|
||||
await self.coordinator.async_request_refresh()
|
||||
|
||||
|
||||
class GreeControllerGroupPowerSwitch(CoordinatorEntity[GreeControllerCoordinator], SwitchEntity):
|
||||
"""Enable or disable one controller climate group."""
|
||||
|
||||
_attr_has_entity_name = True
|
||||
_attr_name = "Power"
|
||||
|
||||
def __init__(self, coordinator: GreeControllerCoordinator, group_id: str) -> None:
|
||||
super().__init__(coordinator)
|
||||
self._group_id = group_id
|
||||
self._attr_unique_id = f"{group_id}-group-power"
|
||||
|
||||
@property
|
||||
def _group(self) -> dict[str, Any]:
|
||||
return self.coordinator.groups.get(self._group_id, {})
|
||||
|
||||
@property
|
||||
def available(self) -> bool:
|
||||
return super().available and bool(self._group)
|
||||
|
||||
@property
|
||||
def is_on(self) -> bool:
|
||||
return bool(self._group.get("power_enabled", False))
|
||||
|
||||
@property
|
||||
def device_info(self) -> DeviceInfo:
|
||||
group = self._group
|
||||
return DeviceInfo(
|
||||
identifiers={(DOMAIN, f"group:{self._group_id}")},
|
||||
name=str(group.get("name") or self._group_id),
|
||||
manufacturer="GREE Controller",
|
||||
model="Climate group",
|
||||
via_device=(DOMAIN, "controller"),
|
||||
)
|
||||
|
||||
@property
|
||||
def extra_state_attributes(self) -> dict[str, Any]:
|
||||
return {
|
||||
"effective_power": bool(self._group.get("effective_power", False)),
|
||||
"zone_count": self._group.get("zone_count"),
|
||||
}
|
||||
|
||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||
await self.coordinator.client.group_control(self._group_id, {"power": True})
|
||||
await self.coordinator.async_request_refresh()
|
||||
|
||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||
await self.coordinator.client.group_control(self._group_id, {"power": False})
|
||||
await self.coordinator.async_request_refresh()
|
||||
|
||||
|
||||
class GreeControllerZoneEnabledSwitch(CoordinatorEntity[GreeControllerCoordinator], SwitchEntity):
|
||||
"""Enable or disable a controller thermostat zone."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user