HI I am trying to setup a command line switch to turn on the motion detect in motioned.
The switch works fine without using command_state, but I want to check the state
This is the switch
lounge_detect:
command_on: 'wget -O- "http://192.168.0.87:7999/2/detection/start" >/dev/null'
command_off: 'wget -O- "http://192.168.0.87:7999/2/detection/pause" >/dev/null'
command_state: 'wget -O- "http://192.168.0.87:7999/2/detection/status"'
value_template: '{{ value == "Camera 1 Detection status ACTIVE" }}'
Running the command in ssh returns the the below capture in out.txt
wget -O- "http://192.168.0.87:7999/2/detection/status" >out.txt
returns
Camera 1 Detection status ACTIVE
Any help would be appreciated
Thanks
You’re missing a space in your value_template.
"Camera1 Detection status ACTIVE"
Camera 1 Detection status ACTIVE
Yeah already noticed that thanks
changed but made no difference the switch still bounces back
finity
August 16, 2019, 8:00pm
4
try removing the quotes from around the command_state command:
command_state: wget -O- "http://192.168.0.87:7999/2/detection/status"
Same issue, is there anyway to run to test the template to see what is happening as there are no errors
Maybe try a command_line sensor to see what HA produces from your command.
finity
August 17, 2019, 9:39pm
7
Kelvin_Sudlow:
Same issue,
Since you quoted yourself I’m not sure who you are replying to.
Did you try my suggestion above?
If you did and it’s still not working then try building a different template to specifically make the value true:
value_template: >
{% if value == "Camera 1 Detection status ACTIVE" %}
true
{% else %}
false
{% endif %}
1 Like
Thanks
used sensor to check my code from finity, then moved to switch all good
thanks heaps
finity
August 17, 2019, 11:23pm
10
which one worked?
Removing the quotes or using the multi-line template?
Quotes made no difference but the multi-line template worked great
Thanks you for your help
Final code
lounge_detect:
command_on: 'wget -O- "http://192.168.#.#:7999/2/detection/start" >/dev/null'
command_off: 'wget -O- "http://192.168.#.#:7999/2/detection/pause" >/dev/null'
command_state: 'wget -O- "http://192.168.#.#:7999/2/detection/status"'
value_template: >
{% if value == "Camera 2 Detection status ACTIVE" %}
true
{% else %}
false
{% endif %}
2 Likes
finity
August 17, 2019, 11:34pm
12
Cool!
Glad to help.
If you can could you mark my post as the solution. It helps others possibly find answers later.