Automation fires possibly in a recurrent way

Hi all,

I did some automation to change the operation_mode of the climate vs input_select and vice-versa and I have the feeling that the automations are executed recurrently. Here are the automation:

- alias: Set Thermostat Mode
  trigger:
    - platform: event
      event_type: state_changed
      event_data:
        entity_id: sensor.modo_termostato
  action:
    - service: input_select.select_option
      data_template: 
        entity_id: input_select.thermostat_mode
        option: '{{ states.sensor.modo_termostato.state }}'

- alias: Set Thermostat to Input Select Mode Heat
  trigger:
    - platform: event
      event_type: state_changed
      event_data:
        entity_id: input_select.thermostat_mode
  action:
    - service: climate.set_operation_mode
      entity_id: climate.termostato
      data_template:
        operation_mode: '{{ states.input_select.thermostat_mode.state }}'

As you can see, when the input select changes, the operation mode does, and when the operation mode changes then the input select as well…

Do you know if this recurrently is happening? How can I check it? Do you have a better way to automate this?

Thanks for your help,
Oscar

My first question is, why are you trying to keep an input_select in sync with a climate setting? Why not just use the climate entity directly?

Having said (or asked) that, I don’t think you have to worry about an infinite loop here. If you change an entity to the state it already is, that (generally) does not cause a new state_changed event. (I say “generally” because some components can force a state_changed event even if the state doesn’t change.)

Lastly, why are you using an event trigger instead of a state trigger? E.g., why not:

  trigger:
    platform: state
    entity_id: sensor.modo_termostato

and

  trigger:
    platform: state
    entity_id: input_select.thermostat_mode

Thanks for you answer @pnbruckner :grinning:

My first question is, why are you trying to keep an input_select in sync with a climate setting? Why not just use the climate entity directly?

The reason is that I use hadashboard when I am at home and you can not change the operation_mode with the climete widget :wink: In fact, when I am using hass with my mobile or laptop I change it via climate entity directly and don’t use the input_select.

For your second question… yes, you are right. I could use the state platform directly but why not to complicate what it is easy?? :rofl::rofl::rofl: (I’m joking) I didn’t it because I started using the platform event… nothing else

thanks a lot for your time!

1 Like