Page 1 of 1
Turn on two devices one after the other
Posted: Saturday 15 August 2020 12:14
by Quax1507
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
Re: Turn on two devices one after the other
Posted: Saturday 15 August 2020 13:43
by waaren
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
Re: Turn on two devices one after the other
Posted: Saturday 15 August 2020 18:13
by Quax1507
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?
Re: Turn on two devices one after the other
Posted: Saturday 15 August 2020 18:44
by waaren
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?
Re: Turn on two devices one after the other [Solved]
Posted: Sunday 16 August 2020 11:25
by Quax1507
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!!