Event_template_reloaded not updating sensor

Code review suggestions:

  • I’d suggest creating a stripped-back template with state: set to all the input variables concatenated to check is the states are as expected.
    Something like (not tested…)
    state: "{{ trigger.id }} {{ is_state('binary_sensor.douchen', 'on') }} {{ s_state('binary_sensor.auxiliary_dhw_state', 'on') }} {{ (states('sensor.humidity_badkamer_2e')|float(0) > 80) }}"

  • You have a lot of state variables driving the template logic. My hunch is either a restart/reload executes before all are set to expected values, and/or there’s not enough {% elif %} to catch all the permutations.

  • Rewrite as automations to allow tracing with the visual flow tool?

I created a test trigger to check the behaviour of id:. On core-2022.4.3, a template reload initially showed reload, then the time trigger changed it to time - as expected.

# templates.yaml
# no "template:" here as in configuration.yaml

- trigger:
    - event: start
      platform: homeassistant
      id: "start"
    - platform: event
      event_type: event_template_reloaded
      id: "reload"
    - platform: time_pattern
      # change to a few mins in the future for testing
      hours:   16
      minutes: 16
      id: "time"
  sensor:
    - name: Trigger Test
      # Test to use id: in a trigger
      state: "{{ trigger.id }}"
      icon: "mdi:test-tube"