#!/bin/bash
status=$(curl -X GET http://192.168.1.10:8080/user/var/120/10101/0/0/12080 | xmlstarlet sel -N x=http://www.eta.co.at/rest/v1 -t -v //x:value -n)
if [ "$status" = "1803" ]; then
echo "1"
else
echo "0"
fi
Problem is, that command_state is not rendering correct switch state - it runs every 5 seconds but even if script returns 1, switch will not change its state.
I tried to remove all content except echo “1” from script to test if switch can react to script and it worked(also with echo “0”) and switch changed its state. Also I tried to run that curl via Terminal and it also worked.
Please help what I’m missing?
Thank you
My understanding is that the problem here is that the state of the switch is wrong. I had the same problem when I used value_template because then {{ value == '1' }} is always false because the result of the command_state script is ignored and value seems to be never 1 in this case. When I deleted value_template the state was correct. Let’s see what Max87 says.
Is there a way to console log value of value variable?
We tried to delete value_template, no luck. Also to retur 0/1 as integer, not string and evaluate it as string/int - no luck.
Strange is that if I remove that curl from string and just print “1”, it worked…
Hmm. Seems like the curl command used in the script is not executing properly. Is xmlstarlet a command that HA can find? Maybe you need to specifiy the full path?