However, it doesn’t work. I’ve checked community posts and tried various approaches without success. ChatGPT failed too. I’m sure the fix is simple… Can someone help me, please?
It’s a bit hard to tell how you’ve formatted it (specific to the indenting) since you split it into multiple examples. But here’s what it should look like:
- switch:
- name: my template switch
...
- name: template switch 2
...
- sensor:
- name: my template sensor
...
- triggers:
- trigger: some trigger
...
sensor:
- name: trigger-based template sensor
...
binary_sensor:
- name: binary sensor based off same trigger
...
- triggers:
- trigger: some other trigger
...
binary_sensor:
- name: trigger-based binary template sensor
...
if I do it like that, then I’m getting the following error:
Cannot quick reload all YAML configurations because the configuration is not valid: Unexpected error calling config validator: ‘NodeListClass’ object has no attribute ‘keys’
here’s the code:
- sensor:
- name: "Defro - Bieg Zadany Max"
unique_id: "defro_bieg_zadany_max"
state: >-
{{ [
states('sensor.defro_bieg_nawiewu') | int(0),
states('sensor.defro_bieg_wywiewu') | int(0)
] | max }}
- binary_sensor:
- name: "Defro - Status"
unique_id: "binary_sensor.defro_status"
state: >-
{% set val = states('sensor.defro_bieg_zadany') | int(0) %}
{{ 'off' if val == 0 else 'on' }}
- triggers:
- trigger: state
entity_id:
- sensor.defro_bieg_nawiewu
- sensor.defro_bieg_wywiewu
not_to:
- unavailable
- unknown
sensor:
- name: "Defro - Bieg Zadany Max Test"
unique_id: "defro_bieg_zadany_max_test"
state: >-
{{ [
states('sensor.defro_bieg_nawiewu') | int(0),
states('sensor.defro_bieg_wywiewu') | int(0)
] | max }}