Easy to use, 100% Lua-based event scripting framework.
Moderator: leecollings
Quax1507
Posts: 101 Joined: Tuesday 07 April 2015 21:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:
Post
by Quax1507 » Saturday 15 August 2020 12:14
Hello community,
I am trying to turn on two devices (garden irrigators) one after the other unsing one trigger.
The two relevant code lines are:
Code: Select all
if [...]
irrigator1.switchOn().forMin(10)
irrigator2.switchOn().afterMin(10).forMin(10)
elseif [...]
Both irrigators should be activated for 10 minutes - one after the other.
Using the commands above, they are turned on at the same time, but I don't really undertsand why...
Any idea?
Quaxx
waaren
Posts: 6028 Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:
Post
by waaren » Saturday 15 August 2020 13:43
Quax1507 wrote: Saturday 15 August 2020 12:14
Using the commands above, they are turned on at the same time, but I don't really undertsand why...
I cannot replicate this on my test system (V2020.2 build 12242, dzVents 3.0.11) My test script does trigger the test lights as- and when expected (see below for script and log)
What is your domoticz / dzVents version?
What is the the hardware, devicetype and subtype of these devices?
Code: Select all
return {
on =
{
devices =
{
'testFor',
'testLamp1',
'testLamp2',
},
},
logging =
{
level = domoticz.LOG_DEBUG,
marker= 'testFor',
},
execute = function(dz, item)
local tester = dz.devices('testFor')
local l1 = dz.devices('testLamp1')
local l2 = dz.devices('testLamp2')
dz.log('State of ' .. l1.name .. ' is ' .. l1.state,dz.LOG_DEBUG )
dz.log('State of ' .. l2.name .. ' is ' .. l2.state,dz.LOG_DEBUG )
if item == tester then
l1.switchOn().forMin(2)
l2.switchOn().afterMin(2).forMin(2)
end
end
}
log from script
Spoiler: show Code: Select all
2020-08-15 13:18:16.777 Status: User: Admin initiated a switch command (480/testFor/On)
2020-08-15 13:18:16.781 (Virtual) Light/Switch (testFor)
2020-08-15 13:18:16.821 Status: dzVents: Info: Handling events for: "testFor", value: "On"
2020-08-15 13:18:16.821 Status: dzVents: Info: testFor: ------ Start internal script: 20200815 dz testFor: Device: "testFor (Virtual)", Index: 480
2020-08-15 13:18:16.822 Status: dzVents: Debug: testFor: Processing device-adapter for testLamp1: Switch device adapter
2020-08-15 13:18:16.822 Status: dzVents: Debug: testFor: Processing device-adapter for testLamp2: Switch device adapter
2020-08-15 13:18:16.822 Status: dzVents: Debug: testFor: State of testLamp1 is Off
2020-08-15 13:18:16.822 Status: dzVents: Debug: testFor: State of testLamp2 is Off
2020-08-15 13:18:16.822 Status: dzVents: Debug: testFor: Constructed timed-command: On
2020-08-15 13:18:16.822 Status: dzVents: Debug: testFor: Constructed timed-command: On FOR 120 SECONDS
2020-08-15 13:18:16.822 Status: dzVents: Debug: testFor: Constructed timed-command: On
2020-08-15 13:18:16.822 Status: dzVents: Debug: testFor: Constructed timed-command: On AFTER 120 SECONDS
2020-08-15 13:18:16.822 Status: dzVents: Debug: testFor: Constructed timed-command: On AFTER 120 SECONDS FOR 120 SECONDS
2020-08-15 13:18:16.823 Status: dzVents: Info: testFor: ------ Finished 20200815 dz testFor
2020-08-15 13:18:16.830 (Virtual) Light/Switch (testLamp1)
2020-08-15 13:18:16.865 Status: dzVents: Info: Handling events for: "testLamp1", value: "On"
2020-08-15 13:18:16.865 Status: dzVents: Info: testFor: ------ Start internal script: 20200815 dz testFor: Device: "testLamp1 (Virtual)", Index: 478
2020-08-15 13:18:16.866 Status: dzVents: Debug: testFor: Processing device-adapter for testFor: Switch device adapter
2020-08-15 13:18:16.866 Status: dzVents: Debug: testFor: Processing device-adapter for testLamp2: Switch device adapter
2020-08-15 13:18:16.866 Status: dzVents: Debug: testFor: State of testLamp1 is On
2020-08-15 13:18:16.866 Status: dzVents: Debug: testFor: State of testLamp2 is Off
2020-08-15 13:18:16.866 Status: dzVents: Info: testFor: ------ Finished 20200815 dz testFor
2020-08-15 13:20:16.862 (Virtual) Light/Switch (testLamp1)
2020-08-15 13:20:16.874 (Virtual) Light/Switch (testLamp2)
2020-08-15 13:20:16.901 Status: dzVents: Info: Handling events for: "testLamp1", value: "Off"
2020-08-15 13:20:16.901 Status: dzVents: Info: testFor: ------ Start internal script: 20200815 dz testFor: Device: "testLamp1 (Virtual)", Index: 478
2020-08-15 13:20:16.901 Status: dzVents: Debug: testFor: Processing device-adapter for testFor: Switch device adapter
2020-08-15 13:20:16.902 Status: dzVents: Debug: testFor: Processing device-adapter for testLamp2: Switch device adapter
2020-08-15 13:20:16.902 Status: dzVents: Debug: testFor: State of testLamp1 is Off
2020-08-15 13:20:16.902 Status: dzVents: Debug: testFor: State of testLamp2 is Off
2020-08-15 13:20:16.902 Status: dzVents: Info: testFor: ------ Finished 20200815 dz testFor
2020-08-15 13:20:16.940 Status: dzVents: Info: Handling events for: "testLamp2", value: "On"
2020-08-15 13:20:16.940 Status: dzVents: Info: testFor: ------ Start internal script: 20200815 dz testFor: Device: "testLamp2 (Virtual)", Index: 479
2020-08-15 13:20:16.940 Status: dzVents: Debug: testFor: Processing device-adapter for testFor: Switch device adapter
2020-08-15 13:20:16.941 Status: dzVents: Debug: testFor: Processing device-adapter for testLamp1: Switch device adapter
2020-08-15 13:20:16.941 Status: dzVents: Debug: testFor: State of testLamp1 is Off
2020-08-15 13:20:16.941 Status: dzVents: Debug: testFor: State of testLamp2 is On
2020-08-15 13:20:16.941 Status: dzVents: Info: testFor: ------ Finished 20200815 dz testFor
2020-08-15 13:22:16.834 (Virtual) Light/Switch (testLamp2)
2020-08-15 13:22:16.874 Status: dzVents: Info: Handling events for: "testLamp2", value: "Off"
2020-08-15 13:22:16.875 Status: dzVents: Info: testFor: ------ Start internal script: 20200815 dz testFor: Device: "testLamp2 (Virtual)", Index: 479
2020-08-15 13:22:16.875 Status: dzVents: Debug: testFor: Processing device-adapter for testFor: Switch device adapter
2020-08-15 13:22:16.876 Status: dzVents: Debug: testFor: Processing device-adapter for testLamp1: Switch device adapter
2020-08-15 13:22:16.876 Status: dzVents: Debug: testFor: State of testLamp1 is Off
2020-08-15 13:22:16.876 Status: dzVents: Debug: testFor: State of testLamp2 is Off
2020-08-15 13:22:16.876 Status: dzVents: Info: testFor: ------ Finished 20200815 dz testFor
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>>
dzVents wiki
Quax1507
Posts: 101 Joined: Tuesday 07 April 2015 21:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:
Post
by Quax1507 » Saturday 15 August 2020 18:13
I am on Build 12240 and ended up doing this:
Code: Select all
if [...]
irrigator1.switchOn().afterSec(1).forMin(10)
irrigator2.switchOn().afterMin(10).forMin(10)
elseif [...]
This works without any problems so far...
Little difference: my trigger is a time. Perhaps the reason?
waaren
Posts: 6028 Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:
Post
by waaren » Saturday 15 August 2020 18:44
Quax1507 wrote: Saturday 15 August 2020 18:13
Little difference: my trigger is a time. Perhaps the reason?
Not likely. I also tested with a timer as trigger: same result. Also strange that it now works with the extra afterSec() while the initial afterMin() seem to have been ignored.
Can you share the log for both situations? Also what is the hardware, devicetype and subtype?
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>>
dzVents wiki
Quax1507
Posts: 101 Joined: Tuesday 07 April 2015 21:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:
Post
by Quax1507 » Sunday 16 August 2020 11:25
I did some more testing and I found the reason
I used "irrigator2.switchOn().aftermin(10).forMin(10)"
instead of "irrigator2.switchOn().afterMin(10).forMin(10)"
Stupid typo!
Thank You for Your support!!
Users browsing this forum: No registered users and 1 guest