From e12b7d46dd81ec3a584c4daddb384d3c3e2df2d0 Mon Sep 17 00:00:00 2001 From: aes-alienrip <73251414+aes-alienrip@users.noreply.github.com> Date: Wed, 5 Aug 2026 18:54:02 +0800 Subject: [PATCH 1/4] Add support for external humidity sensor --- custom_components/gree/climate.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/custom_components/gree/climate.py b/custom_components/gree/climate.py index 539373ef..dd8ec9e2 100644 --- a/custom_components/gree/climate.py +++ b/custom_components/gree/climate.py @@ -177,8 +177,9 @@ def __init__( self._temp_sensor_offset = temp_sensor_offset - # Store for external temp sensor entity (set by sensor entity) + # Store for external temp and humid sensor entity (set by sensor entity) self._external_temperature_sensor = None + self._external_humidity_sensor = None # Keep unsub callbacks for deregistering listeners self._listeners: list = [] @@ -450,11 +451,26 @@ def UpdateHAOutsideTemperature(self): _LOGGER.debug(f"{self._name}: UpdateHAOutsideTemperature: HA outside temperature set with device built-in outside temperature sensor state: {self._current_outside_temperature}{self._unit_of_measurement}") def UpdateHARoomHumidity(self): + # Use external humidity sensor if available + if self._external_humidity_sensor: + external_sensor_state = self.hass.states.get(self._external_humidity_sensor) + + if external_sensor_state and external_sensor_state.state not in ("unknown", "unavailable"): + try: + _LOGGER.debug(f"{self._name}: Using external humidity sensor {self._external_humidity_sensor}: {external_sensor_state.state}%") + self._current_room_humidity = float(external_sensor_state.state) + _LOGGER.debug(f"{self._name}: Current room humidity from external sensor: {self._current_room_humidity}%") + return + except (ValueError, TypeError) as ex: + _LOGGER.error(f"{self._name}: Unable to update from external humidity sensor {self._external_humidity_sensor}: {ex}") + # Update room humidity from built-in AC room humidity sensor if available if self._has_room_humidity_sensor: _LOGGER.debug(f"{self._name}: UpdateHARoomHumidity: DwatSen: {self._acOptions['DwatSen']}") self._current_room_humidity = self._acOptions["DwatSen"] _LOGGER.debug(f"{self._name}: UpdateHARoomHumidity: HA room humidity set with device built-in room humidity sensor state: {self._current_room_humidity}%") + else: + self._current_room_humidity = None def UpdateHAStateToCurrentACState(self): self.UpdateHATargetTemperature() @@ -652,6 +668,11 @@ def current_temperature(self): # Return the current temperature. return self._current_temperature + @property + def current_humidity(self) -> float | None: + # Return the current humidity. + return self._current_room_humidity + @property def min_temp(self): if self._unit_of_measurement == "°C": From bf993abf434e5afe7f1a7f8405ab9f2d0fd4cc1f Mon Sep 17 00:00:00 2001 From: aes-alienrip <73251414+aes-alienrip@users.noreply.github.com> Date: Wed, 5 Aug 2026 18:54:04 +0800 Subject: [PATCH 2/4] Add humidity sensor options to select component --- custom_components/gree/select.py | 36 +++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/custom_components/gree/select.py b/custom_components/gree/select.py index 4971ac93..d9510fe3 100644 --- a/custom_components/gree/select.py +++ b/custom_components/gree/select.py @@ -50,6 +50,20 @@ def get_temperature_sensor_options(hass: HomeAssistant) -> list[str]: return options +def get_humidity_sensor_options(hass: HomeAssistant) -> list[str]: + """Get list of available humidity sensor entities.""" + options = ["None"] # Always include "None" as first option + + # Get all entities from the registry + for state in hass.states.async_all(): + # Look for humidity sensors + if state.entity_id.startswith("sensor."): + # Check for explicit device_class + if state.attributes.get("device_class") == "humidity": + options.append(state.entity_id) + + return options + SELECTS: tuple[GreeSelectEntityDescription, ...] = ( GreeSelectEntityDescription( @@ -62,6 +76,16 @@ def get_temperature_sensor_options(hass: HomeAssistant) -> list[str]: restore_state=True, options_fn=lambda hass: get_temperature_sensor_options(hass), ), + GreeSelectEntityDescription( + property_key="external_humidity_sensor", + icon="mdi:water-percent", + options=[], # Will be populated dynamically + value_fn=lambda device: getattr(device, "_external_humidity_sensor", "None"), + set_fn=lambda device, value: setattr(device, "_external_humidity_sensor", None if value == "None" else value), + entity_category=EntityCategory.CONFIG, + restore_state=True, + options_fn=lambda hass: get_humidity_sensor_options(hass), + ), ) @@ -83,7 +107,9 @@ def __init__(self, hass: HomeAssistant, entry, description: GreeSelectEntityDesc super().__init__(hass, entry, description) self._hass = hass # Initialize with no external sensor configured - self._device._external_temperature_sensor = None + attr_name = f"_{description.property_key}" + if not hasattr(self._device, attr_name): + setattr(self._device, attr_name, None) # Set up options dynamically if description.options_fn: self._attr_options = description.options_fn(hass) @@ -121,8 +147,12 @@ async def async_select_option(self, option: str) -> None: if self.entity_description.set_fn: self.entity_description.set_fn(self._device, option) - self.async_write_ha_state() - _LOGGER.info("Selected %s: %s", self.entity_description.property_key, option) + self._device.UpdateHACurrentTemperature() + self._device.UpdateHARoomHumidity() + self._device.async_write_ha_state() + + self.async_write_ha_state() + _LOGGER.info("Selected %s: %s", self.entity_description.property_key, option) async def async_update(self) -> None: """Update the entity.""" From 368b3e73882c378f35298d5089de04fafc44fe2b Mon Sep 17 00:00:00 2001 From: aes-alienrip <73251414+aes-alienrip@users.noreply.github.com> Date: Wed, 5 Aug 2026 18:54:07 +0800 Subject: [PATCH 3/4] Add external humidity sensor translation --- custom_components/gree/translations/en.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/custom_components/gree/translations/en.json b/custom_components/gree/translations/en.json index 0d80a217..d6c77437 100644 --- a/custom_components/gree/translations/en.json +++ b/custom_components/gree/translations/en.json @@ -200,6 +200,10 @@ "external_temperature_sensor": { "name": "External Temperature Sensor", "description": "Select a temperature sensor entity to use instead of the built-in AC sensor. Choose 'None' to use the built-in sensor." + }, + "external_humidity_sensor": { + "name": "External Humidity Sensor", + "description": "Select a humidity sensor entity to use instead of the built-in AC sensor. Choose 'None' to use the built-in sensor." } }, "sensor": { From 3ea1fc2e87487e1f5a5c37dcd8e98757fa2eb43e Mon Sep 17 00:00:00 2001 From: aes-alienrip <73251414+aes-alienrip@users.noreply.github.com> Date: Wed, 5 Aug 2026 19:00:39 +0800 Subject: [PATCH 4/4] Add External Humidity Sensor feature to README Added information about the External Humidity Sensor feature to the README. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index c786fd92..711b7a8c 100644 --- a/README.md +++ b/README.md @@ -140,6 +140,7 @@ The integration exposes various entities to configure additional features of you - **Auto Light**: Automatically controls the display lights based on HVAC operations. When enabled, lights will turn on/off with the AC unit. *Note: This is an integration feature, not an actual AC unit state* - **Temperature Step**: Sets the increment step for adjusting the target temperature. This allows you to configure how much the temperature changes when using the up/down controls in Home Assistant - **External Temperature Sensor**: Select a temperature sensor entity to use instead of the built-in AC sensor. Choose 'None' to use the built-in sensor. This is useful if you have a more accurate room temperature sensor that you want the AC to use for temperature readings +- **External Humidity Sensor**: Select a humidity sensor entity to use instead of the built-in AC sensor. Choose 'None' to use the built-in sensor. This is useful if you have a more accurate room humidity sensor that you want the AC to use for humidity readings ## Credits