GREE Controller 0.14.2

This commit is contained in:
Mateusz Gruszczyński
2026-09-15 09:14:44 +02:00
parent 0f7f1736e3
commit ce8a754b75
4 changed files with 55 additions and 8 deletions
+44 -6
View File
@@ -266,12 +266,8 @@ class GreeControllerZoneClimate(CoordinatorEntity[GreeControllerCoordinator], Cl
_attr_target_temperature_step = 0.5
_attr_hvac_modes = [HVACMode.OFF, HVACMode.AUTO, HVACMode.COOL, HVACMode.HEAT]
_attr_preset_modes = ["auto", "comfort", "sleep", "away"]
_attr_supported_features = (
ClimateEntityFeature.TARGET_TEMPERATURE
| ClimateEntityFeature.PRESET_MODE
| ClimateEntityFeature.TURN_ON
| ClimateEntityFeature.TURN_OFF
)
_attr_swing_modes = [SWING_OFF, SWING_ON]
_attr_swing_horizontal_modes = [SWING_OFF, SWING_ON]
def __init__(self, coordinator: GreeControllerCoordinator, zone_id: str) -> None:
super().__init__(coordinator)
@@ -285,10 +281,30 @@ class GreeControllerZoneClimate(CoordinatorEntity[GreeControllerCoordinator], Cl
return zone
return {}
@property
def _device(self) -> dict[str, Any]:
device_id = str(self._zone.get("device_id") or "").strip()
return self.coordinator.data.get(device_id, {}) if device_id else {}
@property
def available(self) -> bool:
return super().available and bool(self._zone)
@property
def supported_features(self) -> ClimateEntityFeature:
features = (
ClimateEntityFeature.TARGET_TEMPERATURE
| ClimateEntityFeature.PRESET_MODE
| ClimateEntityFeature.TURN_ON
| ClimateEntityFeature.TURN_OFF
)
capabilities = self._device.get("capabilities") or {}
if capabilities.get("vertical_swing", True) is not False:
features |= ClimateEntityFeature.SWING_MODE
if capabilities.get("horizontal_swing", True) is not False:
features |= ClimateEntityFeature.SWING_HORIZONTAL_MODE
return features
@property
def device_info(self) -> DeviceInfo:
zone = self._zone
@@ -325,6 +341,14 @@ class GreeControllerZoneClimate(CoordinatorEntity[GreeControllerCoordinator], Cl
def preset_mode(self) -> str:
return str(self._zone.get("preset_override") or "auto")
@property
def swing_mode(self) -> str:
return SWING_ON if self._device.get("swing_vertical", False) else SWING_OFF
@property
def swing_horizontal_mode(self) -> str:
return SWING_ON if self._device.get("swing_horizontal", False) else SWING_OFF
@property
def extra_state_attributes(self) -> dict[str, Any]:
zone = self._zone
@@ -380,6 +404,20 @@ class GreeControllerZoneClimate(CoordinatorEntity[GreeControllerCoordinator], Cl
return
await self.coordinator.async_zone_control(self._zone_id, {"preset": preset_mode})
async def async_set_swing_mode(self, swing_mode: str) -> None:
device_id = str(self._zone.get("device_id") or "").strip()
if device_id:
await self.coordinator.async_device_command(
device_id, {"swing_vertical": swing_mode == SWING_ON}
)
async def async_set_swing_horizontal_mode(self, swing_horizontal_mode: str) -> None:
device_id = str(self._zone.get("device_id") or "").strip()
if device_id:
await self.coordinator.async_device_command(
device_id, {"swing_horizontal": swing_horizontal_mode == SWING_ON}
)
async def async_turn_on(self) -> None:
await self.coordinator.async_zone_control(self._zone_id, {"power": True})
@@ -1,7 +1,7 @@
{
"domain": "gree_controller",
"name": "GREE Controller",
"version": "0.14.1",
"version": "0.14.2",
"config_flow": true,
"integration_type": "hub",
"iot_class": "local_polling",