Stop sending notifications
Moderator: leecollings
-
- Posts: 11
- Joined: Wednesday 03 November 2021 10:10
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Stop sending notifications
Hi,
If have a script that checks the level in a pound, when the level is > 30 cm a switch will open.
In the switch i have a notification that the switch is activated. But it keeps sending notifications every 10 seconds.
How can i solve this, 1 notifaction that the switch is on en 1 that it close
return
{
on =
{
devices = {'Nivo'}
},
execute = function(domoticz, switch)
if (domoticz.devices('Nivo').distance < 30) then
domoticz.devices('schakelaar').switchOn()
domoticz.notify('This rocks!',
'Turns out that it is getting filled',
domoticz.PRIORITY_HIGH)
elseif (domoticz.devices('Nivo').distance > 30) then
domoticz.devices('schakelaar').switchOff()
end
end
}
If have a script that checks the level in a pound, when the level is > 30 cm a switch will open.
In the switch i have a notification that the switch is activated. But it keeps sending notifications every 10 seconds.
How can i solve this, 1 notifaction that the switch is on en 1 that it close
return
{
on =
{
devices = {'Nivo'}
},
execute = function(domoticz, switch)
if (domoticz.devices('Nivo').distance < 30) then
domoticz.devices('schakelaar').switchOn()
domoticz.notify('This rocks!',
'Turns out that it is getting filled',
domoticz.PRIORITY_HIGH)
elseif (domoticz.devices('Nivo').distance > 30) then
domoticz.devices('schakelaar').switchOff()
end
end
}
- erem
- Posts: 230
- Joined: Tuesday 27 March 2018 12:11
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2021.1
- Location: Amsterdam/netherlands
- Contact:
Re: Stop sending notifications
use the persistent data = { ... } section to record the state of the switch, and only send he message if the switch changes
look here https://github.com/domoticz/domoticz/bl ... /README.md
look here https://github.com/domoticz/domoticz/bl ... /README.md
Regards,
Rob
Rob
- waltervl
- Posts: 5148
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Stop sending notifications
Or use the notification button/function on the switch itself.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
- kuifje
- Posts: 36
- Joined: Wednesday 25 October 2017 16:38
- Target OS: Raspberry Pi / ODroid
- Domoticz version: latest
- Location: Heemskerk
- Contact:
Re: Stop sending notifications
Piefje,
i dont know about these scripts but in blockly i was advised to use a user variable ( integer ) when i wanted to put my badkamer licht out after 60 minutes. Without it the counter kept counting.
When your pound level is <30 and the user variable is 0 turn on the valve and set the user variable to 1 and send an email.
When your pound level > 30 and the user variable is 1 turn of the valve and set the variable to 0 and send an email.
Maybe this will help
good luck
Kuifje
i dont know about these scripts but in blockly i was advised to use a user variable ( integer ) when i wanted to put my badkamer licht out after 60 minutes. Without it the counter kept counting.
When your pound level is <30 and the user variable is 0 turn on the valve and set the user variable to 1 and send an email.
When your pound level > 30 and the user variable is 1 turn of the valve and set the variable to 0 and send an email.
Maybe this will help
good luck
Kuifje
- waltervl
- Posts: 5148
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Stop sending notifications
Not if you use the checkFirst().switchOn() option in DzVents when you switch the device. Then DzVents checks the state first and if in the same state it not switch and so not trigger a notification.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
-
- Posts: 11
- Joined: Wednesday 03 November 2021 10:10
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Stop sending notifications
Is there no option like this.
return
{
on =
{
devices = {'Nivo'}
},
IF (DOMOTICZ.DEVICES('schakelaar').state = (On) and
if (domoticz.devices('Nivo').distance < 30) then
end
return
execute = function(domoticz, switch)
if (domoticz.devices('Nivo').distance < 30) then
domoticz.devices('schakelaar').switchOn()
domoticz.notify('This rocks!',
'Turns out that it is getting filled',
domoticz.PRIORITY_HIGH)
elseif (domoticz.devices('Nivo').distance > 30) then
domoticz.devices('schakelaar').switchOff()
end
end
}
return
{
on =
{
devices = {'Nivo'}
},
IF (DOMOTICZ.DEVICES('schakelaar').state = (On) and
if (domoticz.devices('Nivo').distance < 30) then
end
return
execute = function(domoticz, switch)
if (domoticz.devices('Nivo').distance < 30) then
domoticz.devices('schakelaar').switchOn()
domoticz.notify('This rocks!',
'Turns out that it is getting filled',
domoticz.PRIORITY_HIGH)
elseif (domoticz.devices('Nivo').distance > 30) then
domoticz.devices('schakelaar').switchOff()
end
end
}
- waltervl
- Posts: 5148
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Stop sending notifications
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
-
- Posts: 11
- Joined: Wednesday 03 November 2021 10:10
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Stop sending notifications
I know the options but dont know how to put then in. I only want 1 notification when the pound get filles and 1 when it stops.
- waltervl
- Posts: 5148
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Stop sending notifications
Yes
So instead of
domoticz.devices('schakelaar').switchOn()
use domoticz.devices('schakelaar').switchOn().checkfirst()
and instead of
domoticz.devices('schakelaar').switchOff()
Use
domoticz.devices('schakelaar').switchOff().checkFirst()
Delete the notification line in dzVents script.
On the widget of switch Schakelaar click on notification button and add a notification, see wiki page https://www.domoticz.com/wiki/Managing_ ... ifications
So instead of
domoticz.devices('schakelaar').switchOn()
use domoticz.devices('schakelaar').switchOn().checkfirst()
and instead of
domoticz.devices('schakelaar').switchOff()
Use
domoticz.devices('schakelaar').switchOff().checkFirst()
Delete the notification line in dzVents script.
On the widget of switch Schakelaar click on notification button and add a notification, see wiki page https://www.domoticz.com/wiki/Managing_ ... ifications
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
-
- Posts: 11
- Joined: Wednesday 03 November 2021 10:10
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Stop sending notifications
Well the problem stays, when sending notification direct, ik keep getting msg. until the switch is off
-
- Posts: 11
- Joined: Wednesday 03 November 2021 10:10
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Stop sending notifications
Hm, i have now set the interval in esp to 300 sec, now it gives me every 5 min a msg, but thats not what i want.
If the pound level is >30 then switch must on en send a msg (one time)
If the pound level is <25 then switch must off end send a msg (one time)
If the pound level is >30 then switch must on en send a msg (one time)
If the pound level is <25 then switch must off end send a msg (one time)
- waltervl
- Posts: 5148
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Stop sending notifications
I do not understand why you get this notifications if you modified the dzVents script according my suggestions. Did you change that?
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
-
- Posts: 11
- Joined: Wednesday 03 November 2021 10:10
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Stop sending notifications
Yes, the problem i think is that the sensor is sending information every 30 seconds to domoticz and that triggers the notification of the switch.
return
{
on =
{
devices = {'Nivo'}
},
execute = function(domoticz, switch)
if (domoticz.devices('Nivo').distance > 30) then
domoticz.devices('schakelaar').switchOn().checkfirst()
elseif (domoticz.devices('Nivo').distance < 25) then
domoticz.devices('schakelaar').switchOff().checkFirst()
end
end
return
{
on =
{
devices = {'Nivo'}
},
execute = function(domoticz, switch)
if (domoticz.devices('Nivo').distance > 30) then
domoticz.devices('schakelaar').switchOn().checkfirst()
elseif (domoticz.devices('Nivo').distance < 25) then
domoticz.devices('schakelaar').switchOff().checkFirst()
end
end
-
- Posts: 99
- Joined: Friday 25 January 2019 11:33
- Target OS: Linux
- Domoticz version: beta
- Location: Poland
- Contact:
Re: Stop sending notifications
Welcome
As the distance sensor reports every 30 seconds, it is better to use the timer, e.g. every 2 minutes. Then the script will not be triggered every 30 seconds. The whole thing might look like this
As the distance sensor reports every 30 seconds, it is better to use the timer, e.g. every 2 minutes. Then the script will not be triggered every 30 seconds. The whole thing might look like this
Code: Select all
return
{
on =
{
timer = {'every 2 minutes'},
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = 'Nivo',
},
data =
{
notified =
{
initial = 0,
},
},
execute = function(dz, item)
local nivo = dz.devices('Nivo')
local switch = dz.devices('schakelaar')
if item.isTimer then
if nivo.distance < 30 then
dz.data.notified = dz.data.notified + 1
switch.switchOn().checkFirst()
if dz.data.notified == 1 and nivo.distance < 30 then
local DateTimePressed = os.date("%d/%m/%Y %X")
dz.notify('This rocks!','Turns out that it is getting filled' .. DateTimePressed .. ".", dz.PRIORITY_HIGH)
end
elseif nivo.distance > 30 and dz.data.notified > 0 then
switch.switchOff().checkFirst()
dz.data.notified = 0
local DateTimePressed = os.date("%d/%m/%Y %X")
dz.notify('This rocks!','Ok' .. DateTimePressed .. ".", dz.PRIORITY_HIGH)
end
end
end
}
- erem
- Posts: 230
- Joined: Tuesday 27 March 2018 12:11
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2021.1
- Location: Amsterdam/netherlands
- Contact:
Re: Stop sending notifications
what @besix just posted is EXACTLY what i meant in my first comment.
that WILL work.
that WILL work.
Regards,
Rob
Rob
-
- Posts: 11
- Joined: Wednesday 03 November 2021 10:10
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Stop sending notifications
Thx, i only changed <30 to > 30
This works.
This works.
- waltervl
- Posts: 5148
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Stop sending notifications
It should not trigger the switch notifiy every 30 seconds or every 2 minutes as the switch is only switched on when it reaches your limit and it is not already switched on/off (due to the .checkFirst() function). Last update time should also not change unless really switched on/off.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Re: Stop sending notifications
Here is your answer. Takes some time to read and understand, but it works.
viewtopic.php?p=203641#p203641
viewtopic.php?p=203641#p203641
-
- Posts: 470
- Joined: Thursday 26 October 2017 13:37
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Delft
- Contact:
Re: Stop sending notifications
Why do we need all those fancy tricks for such a simple problem? Just a few ifs will do the work nicely. Plus, save your future self some time and put in error messages if one of the devices is not found.
Code: Select all
return
{
on =
{
devices = {'Nivo'}
},
execute = function(domoticz, switch)
local nivo = domoticz.devices('Nivo')
local schakelaar = domoticz.devices('schakelaar')
if nil == nivo then
domoticz.log( 'Device "Nivo" does not exist.', domoticz_LOG_ERROR)
elseif nil == schakelaar then
domoticz.log( 'Device "schakelaar" does not exist.', domoticz_LOG_ERROR)
elseif nivo.distance > 30 and not schakelaar.active then
local DateTimePressed = os.date("%d/%m/%Y %X")
domoticz.notify('This rocks!','Turns out that it is getting filled' .. DateTimePressed .. '.', domoticz.PRIORITY_HIGH)
schakelaar.switchOn()
elseif nivo.distance < 25 and schakelaar.active then
local DateTimePressed = os.date("%d/%m/%Y %X")
domoticz.notify('This rocks!','Ok' .. DateTimePressed .. '.', domoticz.PRIORITY_HIGH)
schakelaar.switchOff()
end
end
}
Who is online
Users browsing this forum: No registered users and 1 guest