Only one action in a Choose is working - why?

Thanks, solution marked! :+1: But the regex replace gives me an error and won’t save. The full trigger looks like this:

triggers:
  - trigger: state
    entity_id:
      - light.dimmer_i_ytterganga_oppe
      - light.dimmer_i_trappa_fra_yttergang_oppe
      - light.dimmer_for_taklys_pa_soverom_i_andre
      - light.dimmer_til_spotter_i_taket_pa_badet_oppe
      - light.dimmer_pa_vaskerommet_oppe
      - light.dimmer_i_soveromsganga_oppe
      - light.lys_pa_wc_et_oppe
      - light.dimmer_pa_gjesterom_i_tredje_oppe
    not_from:
      - unavailable
      - unknown
    variables:
      iden: "{{ trigger.entity_id | regex_replace('^light\.(dimmer|lys)_', '') }}"
      mode: "{{ trigger.to_state.state | bool }}"

But it won’t save. Probably because I have done something wrong. It says. Error parsing YAML: unknown escape sequence (linje: 20, kolonne: 59)

What is line 20 in the automation’s YAML code?

It’s the iden variable template. The only thing I changed.

Hmm, it doesn’t like the backslash within the regex pattern (even though it works in the Template Editor).

Remove the backslash. The template still works properly without it.

    variables:
      iden: "{{ trigger.entity_id | regex_replace('^light.(dimmer|lys)_', '') }}"

1 Like

Thanks, it saves now!