Page 1 of 1
Notification (using PushOver)
Posted: Saturday 07 September 2019 11:26
by Kasvand
I have been Googling for a long time, and I see everyone writing about it very casually. So I suppose it's something really easy... But I just can't fgure it out...
In Domoticz settings I've set up Pushover notifactions using API-key and password. When I press the test button it works fine! It also works fine when adding a notification to a specific device. But I want to use it in a LUA script...
Now I understood all I had to do was add the follwing to a LUA script and it should work:
commandArray['SendNotification']='notificationmessage'
But it doesn't. I don't get any notifcations, neither do I see any errors in the log...
Am I missing something here? Is there something else I should set-up??
(p.s. a notification through the Domoticz app would be even better... but I understood this isn't working anymore?)
Re: Notification (using PushOver)
Posted: Saturday 07 September 2019 12:02
by waaren
Kasvand wrote: ↑Saturday 07 September 2019 11:26
In Domoticz settings I've set up Pushover notifactions using API-key and password. When I press the test button it works fine! It also works fine when adding a notification to a specific device. But I want to use it in a LUA script...
(p.s. a notification through the Domoticz app would be even better... but I understood this isn't working anymore?)
The command does look OK Can you include the complete script as there might be something else influencing the behaviour ?
GCM notification is available in recent Beta's
Re: Notification (using PushOver)
Posted: Sunday 08 September 2019 19:13
by Kasvand
Nevermind... Had a thinking error in my script. Thought it was caused by the notification script not working. My bad
Thanks for informing me the actual code was ok..
Re: Notification (using PushOver)
Posted: Sunday 08 September 2019 19:31
by Kasvand
ANother issue I now find when testing.
I have the following command
Code: Select all
commandArray['SendNotification']='Voordeur#De voordeur is geopend##2##'
I expected this to be emergency priority (and thus showing red in the app and playing sound even though the sound on the phone is dimmed (which I've set in the app... WOrks great when sending a notification through a device with emergency prioity).
But it only shows a normal priority message...? Why? (and why isn't there any documentation on this functionality! :/
Re: Notification (using PushOver)
Posted: Sunday 08 September 2019 23:19
by waaren
Kasvand wrote: ↑Sunday 08 September 2019 19:31
Why? (and why isn't there any documentation on this functionality! :/
Did you try
this ?
Domoticz is an open source project. This means that code, support and documentation are created and maintained by people for free in their spare time. That is also true for all information in the many wiki pages. So if you find something missing in this area and find out how it's done, either by support from others or finding howto by trial and error, you can help yourself and others a lot by creating or updating the documentation / wiki's.
Re: Notification (using PushOver)
Posted: Monday 09 September 2019 10:42
by Kasvand
waaren wrote: ↑Sunday 08 September 2019 23:19
Kasvand wrote: ↑Sunday 08 September 2019 19:31
Why? (and why isn't there any documentation on this functionality! :/
Did you try
this ?
Domoticz is an open source project. This means that code, support and documentation are created and maintained by people for free in their spare time. That is also true for all information in the many wiki pages. So if you find something missing in this area and find out how it's done, either by support from others or finding howto by trial and error, you can help yourself and others a lot by creating or updating the documentation / wiki's.
Of course I tried that

And I was already planning on making said Wiki page... However - right now I myself still have absolutely no clue how it should work! I really can't figure it out... Even though it's quite a basic functionality. So I assume a lot of people do know how it works (but maybe I'm mistaken here) and am a bit surprised no one yet took the trouble to write it down.
Ha! I just found somewhere else on the wiki another implementation of the notification which does work!
On the events page it's said it works like this: commandArray['SendNotification']='subject#body#extraData#priority#sound#subsystem
Somewhere else it's mentioned like this: commandArray['SendNotification']='subject#body#0'
That last one actually works! Could it be that the first one is for the latest and greatest version? (I haven't yet had the time to update my Domoticz...still on version 4.9700). Anyone with a newer version willing to try this out? If so, I can mention this on a wiki page to prevent others from running into this issue...
Re: Notification (using PushOver)
Posted: Monday 09 September 2019 15:04
by alanlsmith
I know that this doesn't actually use the included 'Sendnotification' function but as a method it works well for me
Call the function with:
Code: Select all
pushovernotify("0","Domoticz","message","1","my_phone")(
Execute function with:
Code: Select all
--Send Pushover notification to a particular device
function pushovernotify(Priority, Title, Body, Sound, Device)
-- Priority = -2,-1,0,1,2
-- Device = name of device, empty is all
-- Check for optional sound and device parameter
if Title == nil then Title = '' end
if Sound == nil then Sound = '' end
if Device == nil then Device = '' end
local UserKey = <PUSHOVER_USERKEY>'
local Token = '<PUSHOVER_USERTOKEN>'
local Msg = 'curl --data "token=' .. Token .. '&user=' .. UserKey .. '&title=' .. Title .. '&message=' .. Body .. '&priority=' .. tostring(Priority) .. '&sound=' .. Sound .. '&device=' .. Device .. '" https://api.pushover.net/1/messages.json'
os.execute(Msg)
end
Re: Notification (using PushOver)
Posted: Monday 09 September 2019 16:17
by waaren
Kasvand wrote: ↑Monday 09 September 2019 10:42
Ha! I just found somewhere else on the wiki another implementation of the notification which does work!
On the events page it's said it works like this: commandArray['SendNotification']='subject#body#extraData#priority#sound#subsystem
Somewhere else it's mentioned like this: commandArray['SendNotification']='subject#body#0'
That last one actually works!
First descriptions is not completely accurate. It must be commandArray['SendNotification']='subject#body#priority#sound#extraData#subsystem(s)
I corrected this just now on the wiki page.
Try this Lua code (saved as time triggered)
Code: Select all
--[[
SendNotification = commandArray[#commandArray + 1] = { SendNotification = 'subject#body#prio#sound#extraData#subSystem1;subSystem2;subSystem'3
subject = string ==>> required
body = string ==>> required
pri = number ==>> optional (-2,-1,0,1,2 = low, moderate, normal, high, emergency) default normal
sound = string ==>> optional (examples: bike, magic, siren )
extraData => string ==>> optional
subSystem ==> string ==>> optional (examples: pushover, pushover;pushsafer;telegram, gcm ) default All defined subsystems
]]--
commandArray = {}
commandArray[#commandArray + 1] = { SendNotification = 'test2One#test2One#0#siren##pushover'}
commandArray[#commandArray + 1] = { SendNotification = 'test2AllSubject#test2AllBody'}
commandArray[#commandArray + 1] = { SendNotification = 'test2Two#test2Two#1###pushover;pushsafer'}
return commandArray
Re: Notification (using PushOver)
Posted: Monday 09 September 2019 16:23
by waaren
alanlsmith wrote: ↑Monday 09 September 2019 15:04
I know that this doesn't actually use the included 'Sendnotification' function but as a method it works well for me
The risc of using curl directly in an event script is that you block the entire event system for the duration of the call. When calling an external site, the curl as used here will wait until the remote site have replied. It is safer to use the internal domoticz commands and when the command you need is not available then at least execute the command in the background by adding an ' &' to it or set a maxtime parameter.
Re: Notification (using PushOver)
Posted: Monday 09 September 2019 17:23
by alanlsmith
waaren wrote: ↑Monday 09 September 2019 16:23
The risk of using curl directly in an event script is that you block the entire event system for the duration of the call.
You are quite correct, I should have mentioned that. Although in my experience the Pushover API calls are handled in a negligible amount of time.
It also allows for sending a notification to a specific device.
Re: Notification (using PushOver)
Posted: Monday 09 September 2019 18:22
by Kasvand
waaren wrote: ↑Monday 09 September 2019 16:17
Kasvand wrote: ↑Monday 09 September 2019 10:42
Ha! I just found somewhere else on the wiki another implementation of the notification which does work!
On the events page it's said it works like this: commandArray['SendNotification']='subject#body#extraData#priority#sound#subsystem
Somewhere else it's mentioned like this: commandArray['SendNotification']='subject#body#0'
That last one actually works!
First descriptions is not completely accurate. It must be commandArray['SendNotification']='subject#body#priority#sound#extraData#subsystem(s)
I corrected this just now on the wiki page.
Try this Lua code (saved as time triggered)
Code: Select all
--[[
SendNotification = commandArray[#commandArray + 1] = { SendNotification = 'subject#body#prio#sound#extraData#subSystem1;subSystem2;subSystem'3
subject = string ==>> required
body = string ==>> required
pri = number ==>> optional (-2,-1,0,1,2 = low, moderate, normal, high, emergency) default normal
sound = string ==>> optional (examples: bike, magic, siren )
extraData => string ==>> optional
subSystem ==> string ==>> optional (examples: pushover, pushover;pushsafer;telegram, gcm ) default All defined subsystems
]]--
commandArray = {}
commandArray[#commandArray + 1] = { SendNotification = 'test2One#test2One#0#siren##pushover'}
commandArray[#commandArray + 1] = { SendNotification = 'test2AllSubject#test2AllBody'}
commandArray[#commandArray + 1] = { SendNotification = 'test2Two#test2Two#1###pushover;pushsafer'}
return commandArray
Thanks! I'm going to do some experimenting with this soon. When I feel I totally understand what's happening I will create a Wiki page on the SendNotification functionality (if it's still not present) and might also post something about it on my Smart Home blog! I think this is something every Domoticz user should understand and use

Re: Notification (using PushOver)
Posted: Monday 09 September 2019 19:17
by waaren
Kasvand wrote: ↑Monday 09 September 2019 18:22
I'm going to do some experimenting with this soon. When I feel I totally understand what's happening I will create a Wiki page on the SendNotification functionality (if it's still not present) and might also post something about it on my Smart Home blog! I think this is something every Domoticz user should understand and use
If you do that then please also consider to add a
link to the domoticz notify method wiki text to this new page. This dzVents notify method hide the technical nitty gritty and simplify the use of this domoticz functionality. You can find how dzVents does this in <domoticz>/dzVents/runtime/Domoticz.lua starting around line 255
Re: Notification (using PushOver)
Posted: Monday 09 September 2019 19:48
by Kasvand
Made a start with a Wiki page. Feel free to update/add info! It's far from complete nor is it perfect. But it's a start...
https://www.domoticz.com/wiki/SendNotification
Re: Notification (using PushOver)
Posted: Monday 09 September 2019 20:05
by alanlsmith
@waarren
I've just realised that in the 'Sendnotification' method the 'extradata' can be used to specify the device.
So in future I shall use that rather than curl.
Thanks for pointing me in the right direction.
@Kasvand
I've added reference to this to the Wiki page. Well done for creating it.
Re: Notification (using PushOver)
Posted: Tuesday 10 September 2019 10:11
by waaren
Kasvand wrote: ↑Monday 09 September 2019 19:48
Made a start with a Wiki page.
Good job ! Thx.