diff --git a/custom_components/gree_custom/climate.py b/custom_components/gree_custom/climate.py index 968d2ad..99c21e4 100755 --- a/custom_components/gree_custom/climate.py +++ b/custom_components/gree_custom/climate.py @@ -34,7 +34,7 @@ from homeassistant.helpers.restore_state import RestoreEntity from homeassistant.util.unit_conversion import TemperatureConverter -from .aiogree.api import FanSpeed, HorizontalSwingMode, VerticalSwingMode +from .aiogree.api import FanSpeed, GreeProp, HorizontalSwingMode, VerticalSwingMode from .aiogree.const import MAX_TEMP_C, MAX_TEMP_F, MIN_TEMP_C, MIN_TEMP_F from .aiogree.errors import GreeTurboUnavailable from .const import ( @@ -125,7 +125,7 @@ async def async_setup_entry( _LOGGER.info( "Climate Entity will not be created because no Climate options and features are available for the device" ) - return + continue _LOGGER.debug( "Adding Climate Entity for device '%s'", @@ -196,9 +196,10 @@ def __init__( if any(mode != HVACMode.OFF for mode in hvac_modes): self._attr_supported_features |= ClimateEntityFeature.TURN_ON + # Only offer a target temperature when the unit has one. if any( mode in hvac_modes for mode in (HVACMode.HEAT, HVACMode.COOL, HVACMode.AUTO) - ): + ) and self.device.supports_property(GreeProp.TARGET_TEMPERATURE): self._attr_supported_features |= ClimateEntityFeature.TARGET_TEMPERATURE if fan_modes: @@ -207,13 +208,17 @@ def __init__( else: self._attr_fan_modes = None - if swing_modes: + # The options form leaves the swing lists out for a unit without swing, + # and the defaults would then add swing anyway. + if swing_modes and self.device.supports_property(GreeProp.SWING_VERTICAL): self._attr_supported_features |= ClimateEntityFeature.SWING_MODE self._attr_swing_modes = swing_modes else: self._attr_swing_modes = None - if swing_horizontal_modes: + if swing_horizontal_modes and self.device.supports_property( + GreeProp.SWING_HORIZONTAL + ): self._attr_supported_features |= ClimateEntityFeature.SWING_HORIZONTAL_MODE self._attr_swing_horizontal_modes = swing_horizontal_modes else: diff --git a/docs/entities.md b/docs/entities.md index e26db85..bdbf2c4 100644 --- a/docs/entities.md +++ b/docs/entities.md @@ -17,11 +17,11 @@ The main entity. Its name is the device name. | Part | What it does | |---|---| | HVAC mode | Auto, Cool, Dry, Fan only, Heat, Off. You choose the list at setup. Off turns the unit off, every other mode turns it on. | -| Target temperature | 16 to 30 degrees C, or 61 to 86 degrees F. Available when Heat, Cool or Auto is in the mode list. The step is the **Temperature Step** option. In Auto mode the unit uses its own factory setting, so a temperature sent with Auto is ignored and logged as a warning. | +| Target temperature | 16 to 30 degrees C, or 61 to 86 degrees F. Available when Heat, Cool or Auto is in the mode list and the unit has a target temperature. The step is the **Temperature Step** option. In Auto mode the unit uses its own factory setting, so a temperature sent with Auto is ignored and logged as a warning. | | Current temperature | The unit's room sensor, converted to the unit's temperature scale. Replaced by the **External Temperature Sensor** when one is set. That changes only what Home Assistant shows; the unit keeps regulating on its own sensor. | | Current humidity | The unit's humidity sensor, when it has one. Replaced by the **External Humidity Sensor** when one is set. Display only, like the temperature. | | Fan mode | Auto, Low, Medium-Low, Medium, Medium-High, High, plus Turbo and Quiet when the unit has them. See below. | -| Swing mode | Vertical positions and swing ranges. | +| Swing mode | Vertical positions and swing ranges, when the unit has vertical swing. | | Horizontal swing mode | Horizontal positions and swing ranges, when the unit has them. | Extra attribute: `current_outside_temperature`, the outdoor sensor value in the unit's temperature scale, when the unit has an outdoor sensor. Read it with `{{ state_attr('climate.your_ac', 'current_outside_temperature') }}`.