Page 16 of 16

Re: Events system thread (questions and feedback)

Posted: Sunday 04 December 2016 9:24
by gizmocuz
korniza wrote:But when it is performed by domoticz, nothing happen. :cry:
You mean when it is performed by a script or blockly, it does not trigger another lua/blockly ?
This is by design and mentioned everywhere, because you could create an endless loop case

Re: Events system thread (questions and feedback)

Posted: Sunday 04 December 2016 15:16
by korniza
gizmocuz wrote:
korniza wrote:But when it is performed by domoticz, nothing happen. :cry:
You mean when it is performed by a script or blockly, it does not trigger another lua/blockly ?
This is by design and mentioned everywhere, because you could create an endless loop case
Yes, when the value on user variable is changing using a lua, blocky did not trigger.
About loop: even without user variables, loop can be created.
I have an attached blocky that it reads variables that changed by lua and after reset it (gefense_Zac from 2 -> 1) so to run once the script.
unfortunately , it does not work as domoticz does not check script if variable has changed by following lua.

Edit To be more clear:
virtual switch (TAG Zac) change status triggers script_Tag_Flags.lua. user variable [geofence_Zac] change from 1 -> 2. I suppose that domoticz check changes on variables so it sould trigger the blocky. Blocky script runs the script and reset back [geofence_Zac] to 1. I think no loop can be found here.

Code: Select all

-- Title: script_Tag_Flags.lua
-- Date: 19-11-2015
--
commandArray = {}
 
--tc=next(devicechanged)
for chgdev, chgsts in pairs(otherdevices) do
--Panel=tostring(tc)
Beacon=chgdev
if (Beacon:sub(1,3)=='TAG') then
        if (devicechanged['TAG Zac']=='On') then
                print('Zac back Home.')
                commandArray['Variable:geofence_Zac'] = '2'          
        elseif (devicechanged['TAG Maria']=='On') then
             print('Maria Back Home.')
                commandArray['Variable:geofence_Maria'] = '2'     
    end

end
end
return commandArray

Re: Events system thread (questions and feedback)

Posted: Wednesday 21 December 2016 10:26
by Lorccan
(I have read through all the wikis etc, but can't find an answer to this question.)

Given that a device script is triggered each time any device changes state (at least that's my understanding) what is the purpose of the 'On action|Off action' in the device definition itself?

I have experimented, and it does not seem that a script can be limited to a single device by this method, but this might be to do with the script naming conventions. (By the way I am using scripts that I am placing in the domoticz/scripts/lua directory.)

Re: Events system thread (questions and feedback)

Posted: Wednesday 21 December 2016 10:30
by darrepac
Sometimes you can do same things with Lua/Blockly/Action scripts, sometimes you don't because they are not designed for it.
Personnaly, I am using some few actions scripts and lots of lua scripting

Re: Events system thread (questions and feedback)

Posted: Wednesday 21 December 2016 10:52
by Lorccan
Thanks for the quick response, but I still don't understand the purpose of the action scripts.

Re: Events system thread (questions and feedback)

Posted: Wednesday 21 December 2016 14:06
by Nautilus
Lorccan wrote:Thanks for the quick response, but I still don't understand the purpose of the action scripts.
With the device (On / Off action) script you can trigger whatever scripts you have. LUA device scripts (like script_device_XXX.lua) are triggered automatically on each device change. So, it is of course possible to trigger the "external" script also with LUA (if devicechanged['xyz'] == 'On' then os.execute(/my/script/scripts.sh') end) but I think this is meant as an easier way to trigger a specific script for On or Off action of a switch.

So yes, if you have a LUA device script (script_device_XXX.lua) you cannot limit it to be triggered by a single switch even if you define it as On or Off action script. This is because the way the LUA (device, time and variable) scripts are designed to work. But if you specify there any other random script (even LUA but with different naming or in different directory), then of course this script is only triggered with the switch whose On or Off action it is.

Re: Events system thread (questions and feedback)

Posted: Wednesday 21 December 2016 14:18
by Lorccan
Thank you! That now makes perfect sense to me.

Re: Events system thread (questions and feedback)

Posted: Friday 28 April 2017 8:15
by drego
Hi, it works fine by me also. Thanks!

Re: Events system thread (questions and feedback)

Posted: Saturday 17 June 2017 14:42
by MrAP
Hi,
I have problems with temperature values in this event?
E1.png
E1.png (28.02 KiB) Viewed 11022 times
If I use one of the others temperature sensors it work but not with this one?
It updates OK from a lua script but it seems not to trigger the event, I have tried with "ALL, TIME, and DEVICE".