I'm wondering for some time, if it's possible to limit the amount of triggers of a script.
something like:
on = { devices = 'mySwitch' only 'every <xx> minutes' },
So the script gets triggered by mySwitch but only every xx minutes. Normally you have the combined triggering, so on the device and also on the time trigger
I have a script with a function for the trigger that checks if the temperature is above a given value. It looks like the trigger of this script comes into a loop that crashes domoticz.
selective trigger DzVents scripts [Solved]
Moderator: leecollings
-
- Posts: 15
- Joined: Thursday 24 August 2017 14:15
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.2
- Location: Holland
- Contact:
selective trigger DzVents scripts
RPI3B, Z-WAVE AEOTEC GEN5, Zigbee2Mqtt, Xiaomi gateway, GPIO, I2C, 1-wire, DS18B20, P1 meter, Growatt, Buienradar, Harmony hub, Domoticz 2020.2
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: selective trigger DzVents scripts
Can you please include the script in your post to help us understand what might cause the loop?AntoonvdOetelaar wrote: ↑Tuesday 21 January 2020 13:48 I have a script with a function for the trigger that checks if the temperature is above a given value. It looks like the trigger of this script comes into a loop that crashes domoticz.
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
-
- Posts: 15
- Joined: Thursday 24 August 2017 14:15
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.2
- Location: Holland
- Contact:
Re: selective trigger DzVents scripts
The sort of script that I think that can be the reason of the crashes is:
I did have a couple of these active at the moments of the crashes. Since I have updated to (at that time) the latest beta V4.11605, I did turn off all events with function triggers and now domoticz is running for 7 days without a reboot.
Maybe the update did fix problems, maybe the disabled script, not really sure. Will test further. For some time I was blaming OZW1.6, not sure what has changed.
Edit:
Maybe something like this but then: ['Badkamer'] = { 'every 5 minutes' },
Code: Select all
on = {
timer = {
-- 'every 10 minutes', -- test
function(domoticz)
local TimerTriggerCVKetelVloerPomp = domoticz.devices('CV ketel vloer pomp')
local TimerTriggerCVKetelPower = domoticz.devices('CV ketel power')
local TimerTriggerCvWarmWaterTemp = domoticz.devices('CV warm temp')
local TimerTriggerCvKoudWaterTemp = domoticz.devices('CV koud temp')
if (TimerTriggerCvWarmWaterTemp.temperature > 35
and TimerTriggerCVKetelVloerPomp.state == 'Off'
and TimerTriggerCVKetelVloerPomp.lastUpdate.minutesAgo > 20) or
(TimerTriggerCvWarmWaterTemp.temperature < 25
and TimerTriggerCVKetelVloerPomp.state == 'On'
and TimerTriggerCVKetelVloerPomp.lastUpdate.minutesAgo > 30) or
-- (TimerTriggerCVKetelPower.lastUpdate.minutesAgo > 28
--and TimerTriggerCVKetelPower.lastUpdate.minutesAgo < 52
--and TimerTriggerCvWarmWaterTemp.temperature < 25) or
TimerTriggerCvKoudWaterTemp.temperature < 7
then
return true
end
end
},
devices = {
'CV ketel power',
'CV ketel vloer pomp'
}
},
Maybe the update did fix problems, maybe the disabled script, not really sure. Will test further. For some time I was blaming OZW1.6, not sure what has changed.
Edit:
Code: Select all
return {
on = {
devices = {
['Badkamer'] = { 'at nighttime' },
[293] = { 'at nighttime' } -- PIR trap beneden
}
},
RPI3B, Z-WAVE AEOTEC GEN5, Zigbee2Mqtt, Xiaomi gateway, GPIO, I2C, 1-wire, DS18B20, P1 meter, Growatt, Buienradar, Harmony hub, Domoticz 2020.2
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: selective trigger DzVents scripts [Solved]
This script will not be loaded by dzVents so not execute by domoticz. For one thing because it does not have an execute section.AntoonvdOetelaar wrote: ↑Wednesday 22 January 2020 19:37 The sort of script that I think that can be the reason of the crashes is:
Please keep us informedWill test further.
This will work but probably not the way you intend. Check this test-scriptMaybe something like this but then: ['Badkamer'] = { 'every 5 minutes' },
Code: Select all
return
{
on =
{
devices =
{
'init script', -- to get the script started
['retrigger script'] = { 'every 5 minutes' },
},
},
logging =
{
level = domoticz.LOG_ERROR,
marker = "trigger combination test"
},
execute = function(dz, item)
local retrigger = dz.devices('retrigger script')
dz.log(item.name .. ' triggered this script ', dz.LOG_FORCE )
local next5minuteStart = 300 - ( os.time() % 300 ) -- os.time() % 300 is the amount of seconds of this moment after the last hh:00:00, hh:05:00 ... hh:55:00 point
retrigger.cancelQueuedCommands()
retrigger.switchOn().afterSec(5)
retrigger.switchOn().afterSec(next5minuteStart)
end
}
The above will only trigger on 'retrigger script' device when the minutes of current time are 0, 5, 10 etc
- Spoiler: show
Code: Select all
return
{
on =
{
devices =
{
'scriptTrigger',
},
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = "trigger combination test"
},
data =
{
lastTimeTriggered = { initial = 0 },
},
execute = function(dz, item)
local secondsAgo = dz.time.dDate - dz.data.lastTimeTriggered
if dz.time.dDate - dz.data.lastTimeTriggered < 100 then
dz.log('Too soon after last execution. (Only ' .. secondsAgo .. ' seconds ago).', dz.LOG_DEBUG )
return
end
dz.data.lastTimeTriggered = dz.time.dDate
-- rest of script
dz.log('I will execute the rest of the script now. Previous execution was ' .. secondsAgo .. ' seconds ago.', dz.LOG_DEBUG)
end
}
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
-
- Posts: 15
- Joined: Thursday 24 August 2017 14:15
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.2
- Location: Holland
- Contact:
Re: selective trigger DzVents scripts
Update:
Although not all scripts are functional at this moment, the crashing has completely stopped, since I updated to beta v4.11605. I also did an apt update en apt upgrade. Now it has run in total 12 days without any problems. Since yesterday also buienradar plug in and zigbee2mqtt is running.
@Waaren, thank you for trying to help me. Greatly appreciated.
Although not all scripts are functional at this moment, the crashing has completely stopped, since I updated to beta v4.11605. I also did an apt update en apt upgrade. Now it has run in total 12 days without any problems. Since yesterday also buienradar plug in and zigbee2mqtt is running.
@Waaren, thank you for trying to help me. Greatly appreciated.
RPI3B, Z-WAVE AEOTEC GEN5, Zigbee2Mqtt, Xiaomi gateway, GPIO, I2C, 1-wire, DS18B20, P1 meter, Growatt, Buienradar, Harmony hub, Domoticz 2020.2
Who is online
Users browsing this forum: No registered users and 1 guest