#Authomation trigered by template does not perform the action

1 messages · Page 1 of 1 (latest)

wicked hollow
#

Hello all,

I have this authomation, that is trigered corectly (on the events) but no acction,. can someone help me understand where the problem is?

alias: AUTH - CLIMATE - Spegni Caldaia
description: ""
triggers:

  • trigger: template
    value_template: >-
    {% set c =
    ['climate.thermostat_camera_di_alex','climate.thermostat_camera_di_elena','climate.thermostat_piano_terra','climate.thermostat_camera_matrimoniale']
    %}

    {{ 'false' if (
    states.climate|selectattr('entity_id','in',c)|selectattr('attributes.hvac_action','==','heating')|list|count

  1. else 'true' }}
    for:
    hours: 0
    minutes: 0
    seconds: 30
    conditions: []
    actions:
  • action: switch.turn_off
    metadata: {}
    target:
    entity_id: switch.rele_caldaia
    data: {}
    mode: single
karmic karmaBOT
#

To format your text as code, enter three backticks on the first line, press Enter for a new line, paste your code, press Enter again for another new line, and lastly three more backticks.
```yaml
example: here
```
Don't forget you can edit your post rather than repeatedly posting the same thing.

vestal thicket
#

review the trace and it should tell you

wicked hollow
#

The trace is Ok, but not turn off the switch

vestal thicket
#

Then you should focus on the switch action

wicked hollow
#

if I run manualy the switch go off

vestal thicket
#

And please format the code

#

There isn't much more you can do debug from the automation perspective. Look for logs

wicked hollow
#

No error log for the authomation or switch 🙁

#

alias: AUTH - CLIMATE - Spegni Caldaia
description: ""
triggers:

  • value_template: |-
    {% set c = [
    'climate.thermostat_camera_di_alex',
    'climate.thermostat_camera_di_elena',
    'climate.thermostat_piano_terra',
    'climate.thermostat_camera_matrimoniale'
    ] %}
    {{ states.climate
    | selectattr('entity_id','in',c)
    | selectattr('attributes.hvac_action','==','heating')
    | list
    | count == 0 }}
    for:
    seconds: 30
    trigger: template
    conditions: []
    actions:
  • target:
    entity_id: switch.rele_caldaia
    action: switch.turn_off
    mode: single
vestal thicket
#

please please please format your code

wicked hollow
#

Sorry but I'm not understand what you intend wit format code

vestal thicket
wicked hollow
#
id: '1773101940029'
alias: AUTH - CLIMATE - Spegni Caldaia
description: ''
triggers:
  - trigger: template
    value_template: >-
      {% set c =
      ['climate.thermostat_camera_di_alex','climate.thermostat_camera_di_elena','climate.thermostat_piano_terra','climate.thermostat_camera_matrimoniale']
      %}

      {{ 'false' if (
      states.climate|selectattr('entity_id','in',c)|selectattr('attributes.hvac_action','==','heating')|list|count
      > 0) else 'true' }}
    for:
      hours: 0
      minutes: 0
      seconds: 30
conditions: []
actions:
  - action: switch.turn_off
    metadata: {}
    target:
      entity_id: switch.rele_caldaia
    data: {}
mode: single
vestal thicket
#

Still, I don't see any reason why the automation action would behave any differently from calling the service directly. It's pretty straightforward

#

that template is unnecessarily complicated, but that won't affect the action. the last line can just be this:

      {{ states.climate|selectattr('entity_id','in',c)|selectattr('attributes.hvac_action','==','heating')|list|count
      > 0 }}
wicked hollow
#

I'm agree with you, I will change and let you know. Thank you

wicked hollow
vestal thicket
#

oh, you flipped it. So flip the logic

#

the point is that the logic returns a boolean, you don't need to actually return true or false

wicked hollow
#

mmmmm, im not shure that I understand, the template says " when cahnge from false to true" .

vestal thicket
#

it's just a boolean statement

#

you're testing for > 0 and you want == 0

#

did you write that, or get it from somewhere?

wicked hollow
#

I saw it in the forum example and I adapt it to my authomation

#

I'm more and more sure that the problem is with the switch and not with the automation

#

I will let you know.... thank you for support

wicked hollow
#

Hello @vestal thicket , thanks for your help yesterday. I can confirm that the problem was the switch; it was online but unresponsive. I turned it off, deleted it, and re-associated it with the home assistant, and now it's working properly. Thanks to you, I've figured out how the automation works when using the true/false template.

#

I've further simplified the code; here are my automations:

#
alias: AUTH - CLIMATE - Accendi Caldaia
description: ""
triggers:
  - trigger: template
    value_template: |-
      {{ expand(label_entities('Thermostat'))
         | selectattr('attributes.hvac_action','defined')
         | selectattr('attributes.hvac_action','eq','heating')
         | list
         | count > 0 }}
    for:
      hours: 0
      minutes: 0
      seconds: 30
conditions: []
actions:
  - action: switch.turn_on
    metadata: {}
    target:
      entity_id: switch.rele_caldaia
    data: {}
mode: single
#
alias: AUTH - CLIMATE - Spegni Caldaia
description: Spegne la caldaia quando nessun termostato richiede riscaldamento
triggers:
  - value_template: |
      {{ expand(label_entities('Thermostat'))
         | selectattr('attributes.hvac_action','defined')
         | selectattr('attributes.hvac_action','eq','heating')
         | list
         | count == 0 }}
    for:
      hours: 0
      minutes: 0
      seconds: 30
      milliseconds: 0
    trigger: template
conditions: []
actions:
  - target:
      entity_id: switch.rele_caldaia
    action: switch.turn_off
mode: single
#

Best regards

strong mural