Automation does not trigger in normal operation

I have a template sensor “Heating level” with a value set to “Normal”, “Eco” or “Off” based on the electricity price. Further on I have three automations triggered by changes of the “Heating level”. The automations executes differents actions depending on the sensor value. By this I can control three different groups of heating devices at home.

I manually change the value of the “Heating level” on the States tab in Developer tools, everything works fine. All three automations trigger and action is executed as expected. See the following screen dump of the Log book:

The actions are labelled “Gamla huset autoadjust”, “Nybygget autoadjust” and “Daikin autoadjust”. Each action executes a specific scripts, and everrything works as expected.

However, during normal operation when the template sensor is changed by a change in elecrity price, something strange is happening. Only two of the automations are triggered. Instead of the third automation (“Daikin autoadjust”), the entity (Daikin HVAC) is affected directly - not by the script in the “Daikin autoadjust” automation. See the following dump:

I can’t figure out why “Daikin autoadjust” fires when I set the state of the triggering template sensor manually, but not when this state change is triggered by the electricity price. The Daikin control fails due to this. I’m puzzled…

I enclose the YAML of the automations and they are very similar.

- alias: Daikin autoadjust
  description: Will adjust settings based on energy price-
  trigger:
  - platform: state
    entity_id: sensor.heating_level
  condition: "{{ not is_state_attr('climate.gamla_huset', 'hvac_action', 'off') or is_state('input_boolean.offbyprice_daikin','on')  }}"
  action:
    service: >-
      {% if is_state('sensor.heating_level','Normal') %} script.set_daikin_normal
      {% elif is_state('sensor.heating_level','Eco') %} script.set_daikin_eco
      {% elif is_state('sensor.heating_level','Off') %} script.set_daikin_off
      {% else %} script.set_heating_unknown
      {% endif %}
  id: 619102838d2f47f8b2f6c37fa21aa264
  mode: single

- alias: Nybygget autoadjust
  description: Will adjust settings based on energy price-
  trigger:
  - platform: state
    entity_id:
    - sensor.heating_level
  condition: "{{ not is_state_attr('climate.storstugan', 'hvac_action', 'off') or is_state('input_boolean.offbyprice_nybygget','on') }}"
  action:
    service: >-
      {% if is_state('sensor.heating_level','Normal') %} script.set_nybygget_normal
      {% elif is_state('sensor.heating_level','Eco') %} script.set_nybygget_eco
      {% elif is_state('sensor.heating_level','Off') %} script.set_nybygget_off
      {% else %} script.set_heating_unknown
      {% endif %}
  id: 669b2f3946694ce1b57a48c6dd0bcd18
  mode: single

- alias: Gamla huset autoadjust
  description: Will adjust settings based on energy price-
  trigger:
  - platform: state
    entity_id:
    - sensor.heating_level
  condition: "{{ not is_state_attr('climate.badrum_gamla_huset', 'hvac_action', 'off') or is_state('input_boolean.offbyprice_gamla_huset','on') }}"
  action:
    service: >-
      {% if is_state('sensor.heating_level','Normal') %} script.set_gamla_huset_normal 
      {% elif is_state('sensor.heating_level','Eco') %} script.set_gamla_huset_eco
      {% elif is_state('sensor.heating_level','Off') %} script.set_gamla_huset_off
      {% else %} script.set_heating_unknown
      {% endif %}
  mode: single

Any input on this is appreciated!!

Hm, I have made some wrong conclusions here I’m afraid. What is seen in the log book are scripts triggered by automations. The specific automation triggered by a change of Heating level, holds a condition that prevents the set_daikin_x script to be executed when the Daikin HVAC has been turned off manually. When I run this test, I have manually turned off the Daikin HVAC, so the set_daikin_x script should not be visible in the logg. And it is not. This is how it should work.

However, there is a log entry showing the Daikin HVAC is set to “heat” in this case. This is what causes my problem since this command turns on the HVAC. There are no references to the Daikin climate entity in my YAML files except for in the set_daikin_x scripts. And if I look in the list of automations I can’t find any not showing up in the YAML file. But if I search the list of entities, I find 3 (!) old automation entities referring to Daikin. They all have a status “Restored”. Looking in the history tab, I can find those as well, but they are all marked as “unavailable” and they are greyed out. Those automations are my first attempt to automate the Daikin control, but those have been replaced by the Daikin_adjust automation.

Is it possible those automations are still active in the system but no longer visible in the automations.yaml file? This could explain why the climate entity is manipulated even if none of my Daikin scripts are not executed.

I will file a separate question about “lost” automations in a restored state.

Edit: When I clicked on the mysterious old daikin automations on the entities tab, I got the information those automations are not longer available and should be removed. I did so. Maybe this will solve my problem.