Does not work with this command. Can I use the command with a variable?
dateutils.ddiff '$last-water-change-date-var' 'now' -f '%dd %Hh'
-
Shell sensor command with variable
Pimatic = Smart Home
-
@wutu please explain what you want to do… I dont think you can execute a terminal command without using the api through curl. There might be another solution so please explain what you want.
-
Detects the time that has elapsed since a certain date.
wutu@vpimatic9:~$ dateutils.ddiff '2016-09-08 02:37:00' 'now' -f '%dd %Hh' 3d 15h wutu@vpimatic9:~$
Pimatic = Smart Home
-
@wutu I think this is not possible at the moment. You can perhaps work around the matter using a script similar to what @envagyok suggested at https://forum.pimatic.org/topic/933/time-variable/11
"It always takes longer than you expect, even when you take into account Hofstadter's Law.", Hofstadter's Law
-
@mwittig thanks for explaining. If this were possible, it would reduce the number of external scripts. I do not like external scripts. I have not yet.
I will try to yo look, but do not give it much of a chance.Pimatic = Smart Home
-
The way i would donit is to curl the variable with the api and from there filter out the value. For examples
curl -s http://username:password@192.168.X.X/api/variables/open | jq '.variable.value'
Will result in output “40”. The example is for a magnetic switch variable.
From there on you can build your data
To explain JQ, this is a json parser.
It grabs the .value from the .variable section.If you test with jq ‘.’ it should display the whole variable in json format, work from there.
If you need help, post output of:
curl -s http://username:password@192.168.X.X/api/variables/last-water-change-date-var | jq '.'
I am not sure if this would work commandline-wise but that is up to you.
-
@wutu said in Shell sensor command with variable:
Does not work with this command. Can I use the command with a variable?
dateutils.ddiff ‘$last-water-change-date-var’ ‘now’ -f ‘%dd %Hh’Shell commands can now be handled optionally as pimatic expressions. It can be actived on a per-device basis. The code is on master for testing.
https://github.com/pimatic/pimatic-shell-execute/commit/ec7eb26fb6b82cfa106606853450cda68b9a1d60
"It always takes longer than you expect, even when you take into account Hofstadter's Law.", Hofstadter's Law