How to reference a local expression inside a Shell Command
-
Referencing an expression inside a reaction is in the form of ${{ expression }}. When referenced inside my shell command to set the watering delay duration for my Rachio sprinkler system, it just does not work.
If I enter "86400" instead of referencing the expression lWateringDelayDuration, it works. Either I am doing something wrong or referencing an expression inside a shell command is not supported.
Reactor version: 24212
Local Expression
lWateringDelayDuration =WDD = getEntity( "hass>input_number_h_watering_delay_duration" ).attributes.value_sensor.value, if WDD == 0 then 0 elif WDD == 1 then 86400 elif WDD == 2 then 172800 elif WDD == 3 then 259200 elif WDD == 4 then 345600 endif
Setting Reaction using Shell command
curl -X PUT -H "Content-Type: application/json" -H "Authorization: Bearer xxxxxxxxxx -d '{ "id" : "xxxxxxxxxx", "duration" : ${{ lWateringDelayDuration}} }' https://api.rach.io/1/public/device/rain_delay
Thanks in advance
-
Because of the security concerns around shell commands (which is why they are disabled by default), I never allowed substitutions. But that was also in the days when Reactor didn't have authentication and access control. Now that it does, the chance of the action being abused is reduced, so I can add substitution in shell commands to a future (soon) build. It will likely be an additional option you need to enable.
-
By the way, this is probably better done using an HTTP Request action. Is there a reason you're not doing it that way?
-
By the way, this is probably better done using an HTTP Request action. Is there a reason you're not doing it that way?
@toggledbits It never crossed my mind to use HTTP. I'll give it a try.
-
T toggledbits locked this topic on