Events system thread (questions and feedback)

Moderator: leecollings

User avatar
gizmocuz
Posts: 2350
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: Events system thread (questions and feedback)

Post 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
Quality outlives Quantity!
korniza
Posts: 157
Joined: Thursday 27 August 2015 18:12
Target OS: Raspberry Pi / ODroid
Domoticz version: V3.6028
Location: Greece
Contact:

Re: Events system thread (questions and feedback)

Post 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
Attachments
blocky_var_trigger.png
blocky_var_trigger.png (77.79 KiB) Viewed 10696 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: 32
Joined: Wednesday 21 December 2016 10:18
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Events system thread (questions and feedback)

Post 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.)
darrepac
Posts: 133
Joined: Tuesday 04 February 2014 21:31
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Isère, France
Contact:

Re: Events system thread (questions and feedback)

Post 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
Lorccan
Posts: 32
Joined: Wednesday 21 December 2016 10:18
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Events system thread (questions and feedback)

Post by Lorccan »

Thanks for the quick response, but I still don't understand the purpose of the action scripts.
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: Events system thread (questions and feedback)

Post 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.
Last edited by Nautilus on Wednesday 21 December 2016 14:32, edited 2 times in total.
Lorccan
Posts: 32
Joined: Wednesday 21 December 2016 10:18
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Events system thread (questions and feedback)

Post by Lorccan »

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)

Post by drego »

Hi, it works fine by me also. Thanks!
MrAP
Posts: 2
Joined: Monday 15 December 2014 0:50
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Events system thread (questions and feedback)

Post by MrAP »

Hi,
I have problems with temperature values in this event?
E1.png
E1.png (28.02 KiB) Viewed 10177 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".
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests