Hello,
If there a way to cancel for instance dz.emitEvent.afterMin(30)? (I guess no if I refer to documentation). If no what will happen if a new dz.emitEvent.afterMin(30) is set before 30 minutes in this case. Will it be replaced by the last emitEvent?
Thank you
dzVents 3.0.14
emitEvent cancel
Moderator: leecollings
-
Number8
- Posts: 374
- Joined: Friday 23 May 2014 7:55
- Target OS: Linux
- Domoticz version: 2022.1
- Location: Saint Pierre de Jards
- Contact:
emitEvent cancel
Debian buster on NUC and three RPi with buster.
-
Number8
- Posts: 374
- Joined: Friday 23 May 2014 7:55
- Target OS: Linux
- Domoticz version: 2022.1
- Location: Saint Pierre de Jards
- Contact:
Re: emitEvent cancel
So I made some experiments. emitEventS are stacked in other words at some point in time they will all trigger a customEvent; Question then: is it conceivable to have a cancel Event?
Last edited by Number8 on Friday 11 December 2020 15:39, edited 1 time in total.
Debian buster on NUC and three RPi with buster.
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: emitEvent cancel
Not likely to be implemented in domoticz but work around doable in dzVents. Can you give me an idea of how the event flow of a delayed customEvent that needs cancellation before triggering an event would look like? (How would it be emitted, -what should it do without cancellation and what would be a reason to cancel)Number8 wrote: Friday 11 December 2020 15:14 So I made some experiments. emitEvent are stacked in other words at some point in time they will all trigger a customEvent; Question then: is it conceivable to have a cancel Event?
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
-
Number8
- Posts: 374
- Joined: Friday 23 May 2014 7:55
- Target OS: Linux
- Domoticz version: 2022.1
- Location: Saint Pierre de Jards
- Contact:
Re: emitEvent cancel
A rain detector has to trigger an alarm as soon as a drop of rain is detected. On the other hand I do not want to receive multiple detections when the rain stops and restarts again within a certain period of time. Here is the code I ended with (which is part of a bigger module)
Code: Select all
elseif item.isCustomEvent then
local rainResetDelay = 15 -- wait xx minutes before confirming that rain condition has dispeared. In order to avoid
local Time = require('Time')
if item.trigger == "rain" then
_d.rainUpdateTime = Time()
if item.data == "true" then
-- dz.log ("rain raised", dz.LOG_INFO)
if dz.devices(467).nValue ~= dz.ALERTLEVEL_RED then
dz.devices(467).updateAlertSensor(dz.ALERTLEVEL_RED, "Présence de pluie")
dz.notify ( "" , "Attention il pleut", dz.PRIORITY_NORMAL, "", "", dz.NSS_TELEGRAM)
end
else
dz.emitEvent("rainReset").afterMin(rainResetDelay)
-- dz.log ("rainReset raised", dz.LOG_INFO)
end
elseif item.trigger == "rainReset" then
-- dz.log ("rain reset trigger", dz.LOG_INFO)
local timeDifference = (Time().compare(_d.rainUpdateTime).minutes)
-- dz.log ("time difference = " .. tostring(timeDifference), dz.LOG_INFO)
if timeDifference >= rainResetDelay then
-- dz.log ("no rain for xxx minutes", dz.LOG_INFO)
if dz.devices(467).nValue ~= dz.ALERTLEVEL_GREEN then
dz.devices(467).updateAlertSensor(dz.ALERTLEVEL_GREEN, "Absence de pluie depuis " .. rainResetDelay .. " minutes")
dz.notify ( "" , "Absence de pluie a cessé depuis " .. rainResetDelay .. " minutes", dz.PRIORITY_NORMAL, "", "", dz.NSS_TELEGRAM)
end
end
end
end
Debian buster on NUC and three RPi with buster.
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: emitEvent cancel
If -d is short for dz.data then it seems you already have a work around?Number8 wrote: Friday 11 December 2020 15:54 A rain detector has to trigger an alarm as soon as a drop of rain is detected. On the other hand I do not want to receive multiple detections when the rain stops and restarts again within a certain period of time. Here is the code I ended with (which is part of a bigger module)
btw. You store a complete time object in persistent data. If you don''t need it in other parts of the script you could store only
os.time() -- Number of seconds since epoch
which is only one integer and compare that later in the script again with the new os.time().
The attribute for alert type sensors is color.
Code: Select all
if dz.devices(467).color ~= dz.ALERTLEVEL_GREEN then
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
-
Number8
- Posts: 374
- Joined: Friday 23 May 2014 7:55
- Target OS: Linux
- Domoticz version: 2022.1
- Location: Saint Pierre de Jards
- Contact:
Re: emitEvent cancel
IndeedIf -d is short for dz.data then it seems you already have a work around?
Thank you for the two tips
Debian buster on NUC and three RPi with buster.
Who is online
Users browsing this forum: No registered users and 1 guest