Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FR] Conditional service for set_hvac_mode #95

Open
gbaste84 opened this issue Jan 22, 2025 · 1 comment
Open

[FR] Conditional service for set_hvac_mode #95

gbaste84 opened this issue Jan 22, 2025 · 1 comment

Comments

@gbaste84
Copy link

The problem

I use some switchbot hub mini to replicate IR command for 3 air conditionner.

The switchbot integration create 2 entities for each air conditionner :

  • a switch entity that can be used to switch on/off the air conditonner.
  • a climate entity that can be used to manage hvac mode, temperature or fan mode, but the hvac_mode "off" is not supported by this entity.

I want to use climate_template to create a new "template entity" and to be able to do a conditional action for hvac_mode :

  • if the template-climate hvac_mode is set to off, the called service must be switch.turn_off
  • Else the called service must be climate.set_hvac_mode with the state of the "template_entity"

I have done some research (and the last is #65) but I did not succed to implement a solution that works.

Can you help me ?

Best regards,

What version of Template Climate has the issue?

1.0.1

What version of Home Assistant are you running?

2025.1.2

What type of installation are you running?

None

Example YAML snippet

- platform: climate_template
    name: clim_chambre
    unique_id: '6b33f07d-3e6b-471f-a648-aa53a8f88ed4'
    modes:
          - "auto"
          - "dry"
          - "off"
          - "cool"
          - "fan_only"
          - "heat"
    fan_modes:
          - "auto"
          - "low"
          - "medium"
          - "high"
    min_temp: 16
    max_temp: 30

    # get current temp.
    current_temperature_template: "{{ states('sensor.capteur_temperature_chambre_temperature') }}"

    # get current humidity.
    current_humidity_template: "{{ states('sensor.capteur_temperature_chambre_humidity') }}"

    # example action

    hvac_action_template: "{{ states('climate.clim_chambre' ) }}"


    set_hvac_mode:
      - service: climate.set_hvac_mode
        data:
         entity_id: climate.clim_parents
         hvac_mode: "{{ states('climate.clim_chambre') }}"
 
    set_fan_mode:
      - service: climate.set_fan_mode
        data:
         entity_id: climate.clim_parents
         fan_mode: "{{ state_attr('climate.clim_chambre', 'fan_mode') }}"

    set_temperature:
      - service: climate.set_temperature
        data:
         entity_id: climate.clim_parents
         temperature: "{{ state_attr('climate.clim_chambre', 'temperature') | int }}"

Anything in the logs that might be useful for us?

Additional information

No response

@jcwillox
Copy link
Owner

That should be super easy to implement if I understand it right, just use an if statement and a state condition (if template entity is off) then execute the desired action.

The state update is done before the action so if you are setting HVAC mode to off then the state of the template entity will be off before the action runs, so you can use the the normal state condition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants