- Posted on
Mon Apr 18, 2016 12:00 pm
-
ydcl
offline
-
- Posts: 4
- Joined: Apr 15, 2016
That's I've done, of course.
May be I'm not clear enough (sorry for my English).
Trigger On Zwave command
2 actions (in that order) :
- copy the sensor value to indigo variable
- AppleScript uses that indigo variable
When the AppleScript is called with no delay, the new value is not in the indigo variable.
When the AppleScript is called with delay, the new value is in the indigo variable.
Since this question/remark, I've tested with Python (I am not used to) (indeed of the AppleScript).
I've got the same behavior, the variable is not set.
But I can access to the device value directly, the value is correct.
(For personal purpose, I have to send it with an AppleEvent, and it is so easy from Python).
The Python Script :
myDev = indigo.devices[1159781392] # "Cuis - Temperature"
myDevVal = myDev.sensorValue
indigo.server.log(str(myDevVal)) # dev value
myVar = indigo.variables[751674025] # "CuisTemperature"
myVarVal = myVar.value
indigo.server.log(str(myVarVal)) # var value
So, in log, so the dev value first, the var value second :
18 avr. 2016 19:12:06
Z-Wave received "Cuis - Temperature" sensor update to 19.3 °C
Trigger Cuis Temperature changes (d+v)
Script 19.3 -> dev correct
Script 19.2 -> var not correct, not updated
The variable is not set.
If I delay the PythonScript by 1s, the variable is set.
(in the log, all the value are same, but new)
8 avr. 2016 19:24:11
Z-Wave received "Cuis - Temperature" sensor update to 19.4 °C
Trigger Cuis Temperature (d+v)
Schedule Cuis Temperature (d+v) (delayed action)
Script 19.4
Script 19.4
I duplicated the Python Script (2 same scripts in trigger) : both script with no delay.
Z-Wave received "Cuis - Temperature" sensor update to 19.3 °C
Trigger Cuis Temperature (d+v)
Script 19.3 -> dev correct
Script 19.4 -> var not updated
Script 19.3 -> dev still correct (of course)
Script 19.3 -> var updated !!!
The second one works as expected !
That seems to confirm that we have to wait (delay) to have the variable set.
Are you sure the process to update the variable is fully completed when the script begins ?
Or are you starting the script while the variable update process is just lunched (and not completed) ?