AfterMin problem [Solved]
Moderator: leecollings
-
ronaldbro
- Posts: 327
- Joined: Thursday 15 November 2018 21:38
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.2
- Location: Netherlands
- Contact:
AfterMin problem
Hi,
I have a few scripts using afterMin to dim some lights after a period of inactivity. I noticed that one of the scripts stopped working. I did some tests and found that it depends on the number of minutes. 1, 2, 3 and 4 minutes work as expected but 5 and 10 minutes does nothing.
There’s nothing wrong with the scripts. I tried multiple scripts using “device.dimTo(level).afterMin(delay)” using a ‘constant’ variable for level and delay and I only changed the value of delay in the scripts.
I also see in the log that a timed command is created with the correct number of seconds.
I’m using the latest beta and I think the problem started about 1 or 2 weeks ago.
Anyone else have a problem with this?
I have a few scripts using afterMin to dim some lights after a period of inactivity. I noticed that one of the scripts stopped working. I did some tests and found that it depends on the number of minutes. 1, 2, 3 and 4 minutes work as expected but 5 and 10 minutes does nothing.
There’s nothing wrong with the scripts. I tried multiple scripts using “device.dimTo(level).afterMin(delay)” using a ‘constant’ variable for level and delay and I only changed the value of delay in the scripts.
I also see in the log that a timed command is created with the correct number of seconds.
I’m using the latest beta and I think the problem started about 1 or 2 weeks ago.
Anyone else have a problem with this?
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: AfterMin problem
Can you please share ( an example of) the script to test if this behavior can be replicated ?ronaldbro wrote: Wednesday 06 November 2019 22:31 I have a few scripts using afterMin to dim some lights after a period of inactivity. I noticed that one of the scripts stopped working. I did some tests and found that it depends on the number of minutes. 1, 2, 3 and 4 minutes work as expected but 5 and 10 minutes does nothing.
And please include the hardware, type and subtype of the light.
In my tests with Hue and Yeelight connected dimmable lights I don't see this (domoticz 4.11462)
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
ronaldbro
- Posts: 327
- Joined: Thursday 15 November 2018 21:38
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.2
- Location: Netherlands
- Contact:
Re: AfterMin problem
Sure, no problem.
Here's the script:
The bulbs are Tradfri (only dimmable) connected to zigate.
Thanks for your help.
Here's the script:
Code: Select all
local DIMLEVEL_IDLE = 1
local DIMLEVEL_ACTIVITY = 50
local MINUTES_ACTIVITY_LEVEL = 4
return {
on = {
devices = {
idx_bijkeuken_achterdeur,
idx_garage_deur,
idx_garage_garagedeur,
idx_achtertuin_beweging
},
timer = {
'at sunset',
'at sunrise'
}
},
logging = {
level = domoticz.LOG_DEBUG,
-- level = domoticz.LOG_INFO,
-- level = domoticz.LOG_Error,
marker = "Achtertuin - Zithoek"
},
execute = function(dz, triggeredItem, info)
local lamp = dz.devices(idx_achtertuin_zithoek)
if triggeredItem.isTimer then
if triggeredItem.trigger == 'at sunset' and lamp.active == false then
dz.log('Sunset: Set lvl to ' .. DIMLEVEL_IDLE)
lamp.dimTo(DIMLEVEL_IDLE)
elseif triggeredItem.trigger == 'at sunrise' and lamp.active then
dz.log('Sunrise: switch lamp off.')
lamp.cancelQueuedCommands()
lamp.switchOff()
end
elseif triggeredItem.isDevice and dz.security == dz.SECURITY_DISARMED and lamp.active then
dz.log('Set lvl to ' .. DIMLEVEL_ACTIVITY .. ' for ' .. MINUTES_ACTIVITY_LEVEL .. ' minutes.')
lamp.cancelQueuedCommands()
lamp.dimTo(DIMLEVEL_ACTIVITY)
lamp.dimTo(DIMLEVEL_IDLE).afterMin(MINUTES_ACTIVITY_LEVEL)
end
end
}
Thanks for your help.
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: AfterMin problem
Thx but I don't see any declarations for these vars. Where are they set ?ronaldbro wrote: Wednesday 06 November 2019 23:41 idx_bijkeuken_achterdeur,
idx_garage_deur,
idx_garage_garagedeur,
idx_achtertuin_beweging
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
ronaldbro
- Posts: 327
- Joined: Thursday 15 November 2018 21:38
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.2
- Location: Netherlands
- Contact:
Re: AfterMin problem
They are in global_data so I use them in every script.
Top 3 are xiaomi doorsensors on Zigate and the last one is a Z-wave Fibaro PIR
Top 3 are xiaomi doorsensors on Zigate and the last one is a Z-wave Fibaro PIR
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: AfterMin problem
Can you please share your global_data.lua as well to get a complete picture ? If you don't want to share it here you can send it via PM.ronaldbro wrote: Wednesday 06 November 2019 23:50 They are in global_data so I use them in every script.
Top 3 are xiaomi doorsensors on Zigate and the last one is a Z-wave Fibaro PIR
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
ronaldbro
- Posts: 327
- Joined: Thursday 15 November 2018 21:38
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.2
- Location: Netherlands
- Contact:
Re: AfterMin problem
No problem, here it is
Code: Select all
idx_test_deursensor = 191
idx_test_switch = 428
idx_achtertuin_beweging = 364
idx_achtertuin_zithoek = 427
idx_achtertuin_lux = 366
idx_aanwezig_iemand = 172
idx_aanwezig_eline = 154
idx_aanwezig_ronald = 153
idx_alarm_knop = 301
idx_alarm_securityPanel = 70
idx_alarm_toggleAlarmAway = 122
idx_alarm_sirene = 135
idx_alarm_sireneSound = 75
idx_alarm_sireneVolume = 79
idx_badkamer_relVocht = 239
idx_badkamer_ventilator = 4
idx_badkamer_ventilator_PowerUsage = 9
idx_bijkeuken_achterdeur = 202
idx_floris_dimmer = 281
idx_floris_plafond = 280
idx_floris_relVocht = 234
idx_garage_deur = 200
idx_garage_garagedeur = 201
idx_kantoor_raam = 208
idx_kantoor_relVocht = 250
idx_kantoor_rolluik = 273
idx_kantoor_rolluik_switch = 272
idx_keuken_aanrechtverlichting = 403
idx_keuken_beweging = 356
idx_keuken_lux = 357
idx_slaapkamer_bewegingLinks = 217
idx_slaapkamer_bewegingLinks_lux = 218
idx_slaapkamer_bewegingRechts = 213
idx_slaapkamer_bewegingRechts_lux = 216
idx_slaapkamer_bedlamp = 118
idx_slaapkamer_raam = 207
idx_slaapkamer_relVocht = 245
idx_slaapkamer_rolluik = 276
idx_slaapkamer_rolluikManualMode = 279
idx_olivier_lamp = 267
idx_woonkamer_rolluikManualMode = 43
idx_woonkamer_rolluik = 38
idx_woonkamer_spotsUitbouw = 422
idx_woonkamer_dressoir = 254
idx_woonkamer_eettafel = 174
idx_woonkamer_zithoek = 175
idx_woonkamer_leeslampKnop = 269
idx_woonkamer_leeslamp = 402
idx_sceneswitch_avond = 149
idx_sceneswitch_avondAlleenAan = 300
idx_sceneswitch_welterusten = 150
idx_sceneswitch_goedemorgen = 151
idx_sceneswitch_checkScenes = 430
var_idx_dagNacht = 5
CONST_DAGNACHT_DAG = 'DAG'
CONST_DAGNACHT_NACHT = 'NACHT'
return {
-- global persistent data
-- data = {
-- myGlobalVar = { initial = 12 }
-- },
-- global helper functions
helpers = {
------------------------------------------------------------------------
-- isHoliday
-- Is het vandaag een feestdag?
-- return true/false
------------------------------------------------------------------------
isHoliday = function(domoticz)
local year = domoticz.time.year
local month = domoticz.time.month
local day = domoticz.time.day
local result = false
if (month==1 and day==1) --Nieuwjaar
or (month==4 and day==27) --Koningsdag
or (month==12 and day==25) --Eerste kerstdag
or (month==12 and day==26) --Tweede kerstdag
then
result = true
elseif year==2019 then
if (month==4 and day==21) --Eerste paasdag
or (month==4 and day==22) --Tweede paasdag
or (month==5 and day==30) --Hemelvaart
or (month==6 and day==9) --1e pinksterdag
or (month==6 and day==10) --2e pinksterdag
then
result = true
end
elseif year==2020 then
if (month==4 and day==12) --Eerste paasdag
or (month==4 and day==13) --Tweede paasdag
or (month==5 and day==5) --bevrijdingsdag
or (month==5 and day==21) --Hemelvaart
or (month==5 and day==31) --1e pinksterdag
or (month==6 and day==1) --2e pinksterdag
then
result = true
end
elseif year==2021 then
if (month==4 and day==4) --Eerste paasdag
or (month==4 and day==5) --Tweede paasdag
or (month==5 and day==13) --Hemelvaart
or (month==5 and day==23) --1e pinksterdag
or (month==5 and day==24) --2e pinksterdag
then
result = true
end
elseif year==2022 then
if (month==4 and day==17) --Eerste paasdag
or (month==4 and day==18) --Tweede paasdag
or (month==5 and day==26) --Hemelvaart
or (month==6 and day==5) --1e pinksterdag
or (month==6 and day==6) --2e pinksterdag
then
result = true
end
elseif year==2023 then
if (month==4 and day==9) --Eerste paasdag
or (month==4 and day==10) --Tweede paasdag
or (month==5 and day==18) --Hemelvaart
or (month==5 and day==28) --1e pinksterdag
or (month==5 and day==29) --2e pinksterdag
then
result = true
end
elseif year==2024 then
if (month==3 and day==31) --Eerste paasdag
or (month==4 and day==1) --Tweede paasdag
or (month==5 and day==9) --Hemelvaart
or (month==5 and day==19) --1e pinksterdag
or (month==5 and day==20) --2e pinksterdag
then
result = true
end
end
return result
end,
------------------------------------------------------------------------
-- isSunOrHoliday
-- Is het vandaag een zondag of een feestdag?
-- return true/false
------------------------------------------------------------------------
isSunOrHoliday = function(domoticz)
local result = false
result = domoticz.time.matchesRule('on sun')
if result == false then
result = domoticz.helpers.isHoliday(domoticz)
end
return result
end
}
}
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: AfterMin problem
[
What do you see in the logs at the ecpected time ?
Tried to replicate but no luck yet.ronaldbro wrote: Wednesday 06 November 2019 22:31 I have a few scripts using afterMin to dim some lights after a period of inactivity. I noticed that one of the scripts stopped working. I did some tests and found that it depends on the number of minutes. 1, 2, 3 and 4 minutes work as expected but 5 and 10 minutes does nothing.
What do you see in the logs at the ecpected time ?
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
ronaldbro
- Posts: 327
- Joined: Thursday 15 November 2018 21:38
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.2
- Location: Netherlands
- Contact:
Re: AfterMin problem
Got some logs:
1 minute delay:
2019-11-07 21:17:04.137 Status: dzVents: Info: Handling events for: "Achtertuin: Zithoek", value: "On"
2019-11-07 21:17:05.639 (Zigate) UpdateDevice - (Achtertuin: Zithoek Links) 1:1
With 10 minute delay I see nothing
1 minute delay:
- Spoiler: show
- Spoiler: show
2019-11-07 21:17:04.137 Status: dzVents: Info: Handling events for: "Achtertuin: Zithoek", value: "On"
2019-11-07 21:17:05.639 (Zigate) UpdateDevice - (Achtertuin: Zithoek Links) 1:1
With 10 minute delay I see nothing
-
ronaldbro
- Posts: 327
- Joined: Thursday 15 November 2018 21:38
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.2
- Location: Netherlands
- Contact:
Re: AfterMin problem
Just thought of a possible cause. I disabled all the script containing cancelQueuedCommands and the the 10 minute delay worked fine.
Going to test a bit further with that
Going to test a bit further with that
-
ronaldbro
- Posts: 327
- Joined: Thursday 15 November 2018 21:38
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.2
- Location: Netherlands
- Contact:
Re: AfterMin problem [Solved]
Found it waaren, it was indeed a misplaced cancelQueuedCommands 
I made my own 'Scene control' script which includes a function to change the color of some lights. For neutral white to warm white during the evening. This function iterates through all my defined scenes and changes the color temp and dim level when the desired setpoint is 'auto'. The misplaced cancelQueuedCommands was called for every device which is in a scene and not only for the devices which need to be updated.
The troubled lights were part of a scene and got a cancelQueuedCommand every 5 minutes.
That's why short delays worked and 5 minutes or greater didn't. (Although short commands should also have failed some times, but I was lucky in my tests I guess)
Sorry for wasting your time on this issue. But many thanks anyway
I made my own 'Scene control' script which includes a function to change the color of some lights. For neutral white to warm white during the evening. This function iterates through all my defined scenes and changes the color temp and dim level when the desired setpoint is 'auto'. The misplaced cancelQueuedCommands was called for every device which is in a scene and not only for the devices which need to be updated.
The troubled lights were part of a scene and got a cancelQueuedCommand every 5 minutes.
That's why short delays worked and 5 minutes or greater didn't. (Although short commands should also have failed some times, but I was lucky in my tests I guess)
Sorry for wasting your time on this issue. But many thanks anyway
Who is online
Users browsing this forum: No registered users and 1 guest