Events system thread (questions and feedback)

Must be cleaned all topics go to the right subforum
User avatar
gizmocuz
Posts: 8117
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi
Domoticz version: beta
Location: Top of the world
Contact:

Re: Events system thread (questions and feedback)

Postby gizmocuz » Sunday 04 December 2016 10:24

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
Quality outlives Quantity!

korniza
Posts: 180
Joined: Thursday 27 August 2015 18:12
Target OS: Raspberry Pi
Domoticz version: V3.6028
Location: Greece
Contact:

Re: Events system thread (questions and feedback)

Postby korniza » Sunday 04 December 2016 16:16

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
Attachments
blocky_var_trigger.png
blocky_var_trigger.png (77.79 KiB) Viewed 392 times
>>>> Google Home <<<<<
SBC: Odroid XU4 * Raspberry Pi2 * banana Pi v1
Peripherals: rfxtrx433E, aeon z-stick gen5, bluetooth dongles
Extended Software packages: Xeoma (video NVR), FHEM (extra home automation software)

Lorccan
Posts: 21
Joined: Wednesday 21 December 2016 11:18
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Events system thread (questions and feedback)

Postby Lorccan » Wednesday 21 December 2016 11:26

(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.)

darrepac
Posts: 149
Joined: Tuesday 04 February 2014 22:31
Target OS: Raspberry Pi
Domoticz version:
Location: Isère, France
Contact:

Re: Events system thread (questions and feedback)

Postby darrepac » Wednesday 21 December 2016 11:30

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

Lorccan
Posts: 21
Joined: Wednesday 21 December 2016 11:18
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Events system thread (questions and feedback)

Postby Lorccan » Wednesday 21 December 2016 11:52

Thanks for the quick response, but I still don't understand the purpose of the action scripts.

Nautilus
Posts: 546
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi
Domoticz version: beta
Location: Finland
Contact:

Re: Events system thread (questions and feedback)

Postby Nautilus » Wednesday 21 December 2016 15:06

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.
Last edited by Nautilus on Wednesday 21 December 2016 15:32, edited 2 times in total.

Lorccan
Posts: 21
Joined: Wednesday 21 December 2016 11:18
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Events system thread (questions and feedback)

Postby Lorccan » Wednesday 21 December 2016 15:18

Thank you! That now makes perfect sense to me.

drego
Posts: 3
Joined: Friday 28 April 2017 8:10
Target OS: OS X
Domoticz version:
Contact:

Re: Events system thread (questions and feedback)

Postby drego » Friday 28 April 2017 8:15

Hi, it works fine by me also. Thanks!


Return to “Scripts [cleaning in progress]”

Who is online

Users browsing this forum: No registered users and 7 guests