This commit is contained in:
Mateusz Gruszczyński
2026-08-24 23:58:44 +02:00
parent 9191fba212
commit 25e1a854e3
9 changed files with 71 additions and 17 deletions
+2
View File
@@ -122,5 +122,7 @@ The recommended `combined` strategy keeps the GREE sensor as the primary input a
Each controller zone is exposed as a full Home Assistant `climate` entity with current/target temperature and HVAC modes: Off, Auto (follow the controller house mode), Cool and Heat. The existing zone target `number` and enabled `switch` remain available for compatibility.
From version 0.6.4, zone climate entities use `climate.<zone_name>_thermostat`, for example `climate.igor_thermostat`. On integration reload, existing zone climate registry entries are migrated to this scheme using the zone's current name. If the target entity ID is already occupied, the old ID is retained and Home Assistant logs a warning.
When the controller detects optional GREE properties, the integration also creates switches for supported features such as panel light, Quiet, Turbo, X-FAN, Air, Health and native Sleep. Reload the integration (or restart Home Assistant) after upgrading so newly added entity types are created.
@@ -20,6 +20,7 @@ from homeassistant.helpers import entity_registry as er
from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
from homeassistant.helpers.update_coordinator import CoordinatorEntity
from homeassistant.util import slugify
from . import GreeControllerRuntimeData
from .const import DOMAIN
@@ -73,11 +74,54 @@ async def async_setup_entry(
for zone in runtime.coordinator.plan.get("zones", []):
zone_id = str(zone.get("zone_id") or "").strip()
if zone_id:
_ensure_zone_thermostat_entity_id(registry, zone)
entities.append(GreeControllerZoneClimate(runtime.coordinator, zone_id))
async_add_entities(entities)
def _ensure_zone_thermostat_entity_id(
registry: er.EntityRegistry, zone: dict[str, Any]
) -> None:
"""Keep zone climate entity IDs stable and descriptive.
Zone climate entities use ``climate.<zone_name>_thermostat``. Existing
registry entries are migrated to the same scheme, which also fixes stale
IDs left behind after a zone was renamed (for example ``climate.jan_2``
for a zone currently named Igor).
"""
zone_id = str(zone.get("zone_id") or "").strip()
if not zone_id:
return
unique_id = f"{zone_id}-zone-climate"
current_entity_id = registry.async_get_entity_id("climate", DOMAIN, unique_id)
if current_entity_id is None:
return
zone_name = str(zone.get("zone_name") or zone_id).strip() or zone_id
object_id = slugify(zone_name) or slugify(zone_id) or "zone"
desired_entity_id = f"climate.{object_id}_thermostat"
if current_entity_id == desired_entity_id:
return
occupied = registry.async_get(desired_entity_id)
if occupied is not None and occupied.entity_id != current_entity_id:
_LOGGER.warning(
"Cannot rename zone thermostat %s to %s because that entity ID is already in use",
current_entity_id,
desired_entity_id,
)
return
registry.async_update_entity(current_entity_id, new_entity_id=desired_entity_id)
_LOGGER.info(
"Renamed zone thermostat entity %s to %s",
current_entity_id,
desired_entity_id,
)
class GreeControllerClimate(CoordinatorEntity[GreeControllerCoordinator], ClimateEntity):
"""Home Assistant climate entity controlled through the Rust service."""
@@ -216,7 +260,7 @@ class GreeControllerZoneClimate(CoordinatorEntity[GreeControllerCoordinator], Cl
"""Full climate entity for a controller thermostat zone."""
_attr_has_entity_name = True
_attr_name = None
_attr_name = "Thermostat"
_attr_temperature_unit = UnitOfTemperature.CELSIUS
_attr_min_temp = 8.0
_attr_max_temp = 30.0
@@ -1,7 +1,7 @@
{
"domain": "gree_controller",
"name": "GREE Controller",
"version": "0.6.3",
"version": "0.6.4",
"config_flow": true,
"integration_type": "hub",
"iot_class": "local_polling",