litinoveweedle / hass-template-climate

❄️Templatable Climate Device for Home Assistant, Supports Running Actions On Service Calls.
MIT License
24 stars 1 forks source link

target_humidity not specify but appear in thermostat in HA #22

Closed devildant closed 2 months ago

devildant commented 2 months ago

The problem

Hi, I hadn't paid attention but I have the option to define the target humidity, however I don't have this option on my air conditioner, how can I remove this option from the thermostat ha?

image

- platform: climate_template
  name: Climatisation Chambre Climate Template
  unique_id: climatisation_chambre_climate_template
  # unique id not working but mendatory for working
  icon_template: mdi:air-conditioner
  hvac_modes:
    - "dry"
    - "off"
    - "cool"
    - "fan_only"
  fan_modes:
    - "Auto"
    - "20%"
    - "40%"
    - "60%"
    - "80%"
    - "100%"
    - "Silencieux"
    - "Turbo"
  swing_modes:
    - "Position 1"
    - "Position 2"
    - "Position 3"
    - "Position 4"
    - "Position 5"
    - "Activé"
    - "Désactivé"
  min_temp: 16
  max_temp: 31
  availability_template: "{{ states('switch.localtuya_integration_climatisation_chambre_power') in ['on', 'off'] }}"
  current_temperature_template: "{{ states('sensor.localtuya_integration_climatisation_chambre_temperature_courante') }}"
  set_hvac_mode:
    - service: automation.trigger
      data:
        skip_condition: false
      target:
        entity_id: automation.0011_climate_template_climatisation_chambre_set_hvac_mode
  set_fan_mode:
    - service: automation.trigger
      data:
        skip_condition: false
      target:
        entity_id: automation.0011_climate_template_climatisation_chambre_set_fan_mode
  set_swing_mode:
    - service: automation.trigger
      data:
        skip_condition: false
      target:
        entity_id: automation.0011_climate_template_climatisation_chambre_set_swing_mode
  set_temperature:
    - service: automation.trigger
      data:
        skip_condition: false
      target:
        entity_id: automation.0011_climate_template_climatisation_chambre_set_temperature

What version of Template Climate has the issue?

0.7.1

What version of Home Assistant are you running?

2024.6.3

What type of installation are you running?

Home Assistant OS

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

devildant commented 2 months ago

I think it's a small oversight on line 530 in climate.py, you activate the feature even if _template_target_humidity is not defined.

maybe fix like that :

if HVACMode.DRY in self._attr_hvac_modes:
    if self._template_target_humidity:
        self._attr_supported_features |= ClimateEntityFeature.TARGET_HUMIDITY
devildant commented 2 months ago

image

I tested successfully but I'm not sure, with your presets_features option (I don't use it)

litinoveweedle commented 2 months ago

Hello, it is actually not that simple. There are two ways ho to set target humidity:

So the fact, that humidity template is not defined doesn't mean, that someone is not using HA to set humidity. So far the logic was: if there is DRY mode in hvac mode then we suppose, that target humidity could be set, While I understand, that some devices might have DRY mode, but not allow to set target humidity (for example some AC units), then what you propose would be more limiting to users, who need this functionality and will not be able to use it, if they do not use template to set target humidity (which is not always the case).

So proposed way would be to implement whole condition:

            if  (
                self._action_humidity
                or self._template_target_humidity
                or self._presets_features & ClimateEntityPresetFeature.TARGET_HUMIDITY
            ):
                self._attr_supported_features |= ClimateEntityFeature.TARGET_HUMIDITY
            else:
                _LOGGER.info(

The same logic should be implemented for TARGET_TEMPERATURE as well. I will evaluate this and if it would be OK I will implement this in the next release.

devildant commented 2 months ago

Hello, it is actually not that simple. There are two ways ho to set target humidity:

  • via template
  • via HA GUI

So the fact, that humidity template is not defined doesn't mean, that someone is not using HA to set humidity. So far the logic was: if there is DRY mode in hvac mode then we suppose, that target humidity could be set, While I understand, that some devices might have DRY mode, but not allow to set target humidity (for example some AC units), then what you propose would be more limiting to users, who need this functionality and will not be able to use it, if they do not use template to set target humidity (which is not always the case).

So proposed way would be to implement whole condition:

            if  (
                self._action_humidity
                or self._template_target_humidity
                or self._presets_features & ClimateEntityPresetFeature.TARGET_HUMIDITY
            ):
                self._attr_supported_features |= ClimateEntityFeature.TARGET_HUMIDITY
            else:
                _LOGGER.info(

The same logic should be implemented for TARGET_TEMPERATURE as well. I will evaluate this and if it would be OK I will implement this in the next release.

your condition seems to me more complete. it was at least to give a quick forward, and help a little with the resolution.

I suspected my solution was a bit lightweight. that's why I didn't do a "PR" +1 for apply same logcal for the temperature

litinoveweedle commented 2 months ago

hello, fixed in this branch, please copy climate.py, restart HA test and report back please. Thank you.

devildant commented 2 months ago

hello, fixed in this branch, please copy climate.py, restart HA test and report back please. Thank you.

image

👍

litinoveweedle commented 2 months ago

Released in 0.7.2