Switch not turned on even though it seems to be in automation history

Hi,

I’m going nuts trying to figure out what I’m doing wrong here.
I have an automation which triggers on camera motion detection and it should activate a switch which triggers a few other automations.
The thing is that when I look in the trace file of the automation it looks as though the switch is triggered correctly, but when I look at the switch history it hasn’t changed.

The switch is configured as such:

switch:
  - platform: command_line
    switches:        
      activate_recording_entre:
        */ Some Commands /*
        value_template: "{{ value | regex_search('emulate_motion = on', ignorecase=True) }}"
        friendly_name: Camera Entre Recording Activated`

Here is the trace of the automation:
Executed: 14 november 2021 17:15:55
Result:
params:

  • domain: switch*
  • service: turn_on*
  • service_data:*
  • entity_id: switch.activate_recording_entre*
  • target: {}*
    running_script: false
    limit: 10

As it looks, the switch.activate_recording_entre seems to be “turned_on”.
I cannot understand however why activate_recording_entre is never shown as “on” in the history.

I have also noted that if I try to force the switch.activate_recording_entre to “on” using lovelace it deafults back to “off” after just a few seconds, which I think means it actually never get sets (i.e. it resets when it reads the state and sees that it is “off”)

Also, this has worked before, but I recently reinstalld HomeAssistant to get 64 bit. I did not use any backup restore, instead I just copy-pasted the old .yaml files.

Any help would be much appreciated!

Any privacy reasons to not show those?

Correct.

The commands are:

command_on
command_off
command_state

Each use different curl commands to communicate with an add on.

I haven’t set them up with secrets yet, so that’s why I left it out.

Could it be that when using command switches, the switch state is actually not changed, i.e. that it just fires the commands once? Any idea on a good way to debug a command_line switch?

Thanks!

Just removed the commands and then the switch is activated so I guess there is something wrong with my commands. I guess I need to dig into that a bit more…

My point, exacly…