Hi there
I’am trying for hours to configure a toggle switch that turns motion on/off (and therefor the webcam) and returns the actual state of motion.
My motion sensor looks like this (it only return on/off):
sensor:
- platform: command_line
name: motion
friendly_name: Kamera Software
command: service motion status | sed '3q;d' | grep -o -P '(?<=\().*(?=\))' | sed 's/running/on/;s/start/on/;s/dead/off/;s/stop/off/'
scan_interval: 1
My normal camera on/off switch (the one with the lightning symbol):
switch:
- platform: command_line
switches:
camera:
friendly_name: Kamera
command_on: 'sudo service motion start'
command_off: 'sudo service motion stop'
My template toggle switch:
- platform: template
switches:
camera2:
friendly_name: "Kamera 2"
value_template: "{{ is_state('switch.camera_toggle', 'sensor.motion.state', 'on') }}"
turn_on:
service: switch.toggle
entity_id: switch.camera
turn_off:
service: switch.toggle
entity_id: switch.camera
The problem is: The template toggle switch toggles always back to off when I click it, the state of the sensor and the normal switch are behaving normally.
Any help would be highly appreciated