Is there a way to add a pimatic variable to a shell_execute command?
E.g.
echo "Variable Test is ($myvar_test)"
Shell-Execute Command with Pimatic Variables
Is there a way to add a pimatic variable to a shell_execute command?
E.g.
echo "Variable Test is ($myvar_test)"
@Un.kn0wn said in Shell-Execute Command with Pimatic Variables:
Is there a way to add a pimatic variable to a shell_execute command?
No, if you want to use the variable as part of a command attribute of a device, e.g. “getStateCommand” of a “ShellSwitch”. However, it is possible to use variables as part of a rule shell execute action, e.g. execute "echo $now > /home/pi/echo.log"
"It always takes longer than you expect, even when you take into account Hofstadter's Law.", Hofstadter's Law
@Un.kn0wn I proposed a feature request for this a while ago. If you like, please upvote this at https://forum.pimatic.org/topic/193/variables-in-shellswitch-command-attributes
I realised this by a workaroud by exceuting a rule with the variable from a dummyswitch:
Rule:
execute "curl http://192.168.0.58/?mytimer=$Tuin-sproeier-tijd-var-minute >/dev/null 2>&1"
@lschip but that isnt a shell-execute command. What he kinda wants is a shell device that outputs
My ip address: 192.168.x.x
Where the ip address originates from a pimatic variable.
However, @Un-kn0wn what is possible is enclosing it in a bash script.
I can post an example later.
Edit;; kinda out of my head and untested.
Create a bash script and put these lines in:
VAR=`curl -s http://user:pass@yourpimaticip/api/variables/yourvariablewithout$ | jq '.variable.value'`
echo "My variable value is: $VAR"
Chmod +x your bash and run it and see if it is the desired output. Then simply execute that script from the shell device.
Also you need to install jq!!