Page 1 of 3
Question about notifications in dzVents
Posted: Monday 03 July 2017 18:24
by schulpr
Hi,
I'm rebuilding some of my LUA scripts to dzVents scripts. I have a question about the notifications.
In LUA I can send a notification to a specific device like this:
notificatie = "Mieke aanwezig#Mieke is het huis binnengekomen. Om "..(tijd).." is de telefoon geactiveerd.#0#Magic#iPhoneRob"
commandArray['SendNotification'] = (notificatie)
In dzVents I'm doing this for now:
domoticz.notify('Mieke aanwezig!','Mieke is het huis binnengekomen. Om '..(tijdstip)..' is de telefoon geactiveerd.',SOUND_MAGIC,domoticz.PRIORITY_LOW,domoticz.NSS_PUSHOVER)
How can I send a notification to a specific device in dzVents?
What is the purpose of the parameter "extra" in the string "notify(subject, message, priority, sound, extra, subsystem)"?
I use Pushover as notification system.
Thanks for the help.
Kind regards, Rob
Re: Question about notifications in dzVents
Posted: Tuesday 04 July 2017 8:25
by dannybloe
Hi Rob,
That's a very good question. The api for sending notifications is very badly documented. I believe, from reading the C++ code that extraData is indeed the device. That's the 5th part in your traditional notifcation string. In dzVents that's the extra argument.
The thing is that what this extra does is dependent on the notification subsystem you use. It's up to them to deal with this extra data.
Let me know if that works for you. I'll update the dzVents docs for this information.
Re: Question about notifications in dzVents
Posted: Wednesday 05 July 2017 6:45
by schulpr
Hi,
I tried putting the name of my iPhone in the "extra" field without success so far. With and without quotes, as variable, etc. messages are send to all devices still. If you have a suggestion, please let me know.
Thanks for all the good work you are doing with dzVents!
Rob
Re: Question about notifications in dzVents
Posted: Wednesday 05 July 2017 9:33
by dannybloe
Can you activate the debug logging mode in the settings and see in the logs what kind of commandArray it builds up that is sent back to Domoticz? (don't forget to disable debugging afterwards).
It should build the same command as when you did this before without dzVents.
Re: Question about notifications in dzVents
Posted: Thursday 06 July 2017 17:36
by schulpr
Do you mean the setting for logging in dzVents or the general logging of Domoticz? I see a lot of log files in /var/log. Is this the correct place were I have to look?
Rob
Re: Question about notifications in dzVents
Posted: Thursday 06 July 2017 17:58
by dannybloe
No, the dzvents debug logging mode (see settings > other), dropdown. That will log the commandArray as it is being sent back to domoticz.
Re: Question about notifications in dzVents
Posted: Friday 07 July 2017 22:41
by dannybloe
Have you figured it out?
Re: Question about notifications in dzVents
Posted: Friday 29 December 2017 19:54
by Quax1507
Did this ever get resolved?
I am moving to to dzvents at the moment and cannot send selective notifications.
I thied this in dzvents:
Code: Select all
domoticz.notify('ALARM STATUS','Alarmanlage aktiviert!',SOUND_MAGIC,domoticz.PRIORITY_LOW,domoticz.NSS_PROWL)
Debug in dzvents says:
Code: Select all
SendNotification: ALARM STATUS#Alarmanlage aktiviert!#0#-2#prowl#
Notifications are also sent by email...
Re: Question about notifications in dzVents
Posted: Monday 01 January 2018 18:05
by acaonweb
extra is the device
i'm using pushover, and i've registred many devices, one of them is called iPhone6S
Code: Select all
domoticz.notify('Notifica Aerazione','Chiudere le finestre',PRIORITY_NORMAL,'siren','iPhone6S',domoticz.NSS_PUSHOVER)
the notification is sent only to that device called 'iPhone6S
Re: Question about notifications in dzVents
Posted: Wednesday 30 May 2018 18:41
by DAVIZINHO
Hello,
Im looking for information about the domoticz.notify() and i find it for some cases
Now I have 3 notification subsystem:
- GCM
- KODI
- TELEGRAM
And im trying to send notifications from dzvents selecting the subsystem, but for telegram the notification send to all subsystem
I can send only to kodi with this syntaxis:
Code: Select all
domoticz.notify('CUSTOM_TITLE', 'CUSTOM_TEXT', domoticz.PRIORITY_NORMAL, domoticz.SOUND_NONE,'', domoticz.NSS_KODI)
AND if i want to send a notification only to GCM I use this syntaxis:
Code: Select all
domoticz.notify('CUSTOM_TITLE', 'CUSTOM_TEXT', domoticz.PRIORITY_NORMAL, domoticz.SOUND_NONE,'', domoticz.NSS_GOOGLE_CLOUD_MESSAGING)
anyone knows how can i send notification only throw TELEGRAM?
thanks a lot
-David-
Re: Question about notifications in dzVents
Posted: Wednesday 30 May 2018 19:46
by waaren
I don't think it is implemented as a standard in dzVents but @papoo did put a small helper function on GIT earlier this year.
Code: Select all
local function telegram(msg)
domoticz.openURL('https://api.telegram.org/bot"your BOT API key"/sendMessage?chat_id="Your chat-ID"&text=' .. msg)
end
Re: Question about notifications in dzVents
Posted: Wednesday 30 May 2018 20:04
by DAVIZINHO
yes, now i use the https command to send telegram and works like a charm.
But I the subsystem is configure, why dont use it?

Re: Question about notifications in dzVents
Posted: Tuesday 03 January 2023 16:42
by Xavier82
Picking up an old thread...sorry for that...
I would like to achive the next thing.
I want Domoticz to send a message to Telegram to a specific both Called "Notification".
The message which I would like to send is data based on a lua script which can be found here
https://www.huizebruin.nl/domoticz/hand ... n-per-dag/, its in dutch.
This LUA script is written to sent power consumption in kWh and Euro and power production/delivery (solarpanels) in a clear format.
This has to be done 1 time a day.
The issue I encounter is that I don't know how to send this to a specific bot.
I found this code but don't know how to implement...
Code: Select all
local function telegram(msg)
domoticz.openURL('https://api.telegram.org/bot"your BOT API key"/sendMessage?chat_id="Your chat-ID"&text=' .. msg)
end
So after text= the textmessage should the message/output in the lua script.
I hope somebody can help me with this
Re: Question about notifications in dzVents
Posted: Tuesday 03 January 2023 18:16
by waltervl
For Lua see the command array here
viewtopic.php?t=14884#p116009
For that you have to have the telegram subsystem active in Domoticz:
https://www.domoticz.com/wiki/Telegram_notification
Re: Question about notifications in dzVents
Posted: Tuesday 03 January 2023 18:28
by waltervl
And the Lua alternative of DzVents openURL is (it is the other way around....

)
Code: Select all
commandArray['OpenURL']='https://api.telegram.org/bot"your BOT API key"/sendMessage?chat_id="Your chat-ID"&text=' .. msg'
Re: Question about notifications in dzVents
Posted: Wednesday 04 January 2023 11:18
by Xavier82
Thanks for the replies Walter, I have the notification subsystems active for Telegram, thats not the issue.
The issue is that I don't know how/don't understand how I can integrate the commandArray in the LUA OpenURL so the messege is being sent.
This is the code I have now:
Code: Select all
local ScriptVersion = '03/01/2023-/-v1.13' -- domoticz > V2022.2 / dzVents >= 3.1.7
return {
on = {
timer = { 'at 23:59' },
},
logging = {
level = domoticz.LOG_DEBUG, -- set to error when all OK
marker = "Dag verbruik in euros " .. ScriptVersion },
execute = function(dz)
print('Dag verbruik in euros')
local subject = (dz.moduleLabel or 'Mijn Energie Overzicht'):gsub('#','')
--Devices
local vandaagKwh = dz.devices('Power').counterToday -- Stroommeter P1 device verbruik
local vandaagKwhzon = dz.devices('Teruglevering').counterToday -- Stroommeter p1 -Teruglevering
local vandaagKwhth = dz.devices('Teruglevering Hoog').counterToday -- Stroommeter p1 -Teruglevering Hoog
local vandaagKwhtl = dz.devices('Teruglevering Laag').counterToday -- Stroommeter p1 -Teruglevering Laag
local vandaagKwhvh = dz.devices('Verbruik Hoog').counterToday -- Stroommeter p1 -Verbruik Hoog
local vandaagKwhvl = dz.devices('Verbruik Laag').counterToday -- Stroommeter p1 -Verbruik Laag
local vandaagM3Gas = dz.devices('Gas').counterToday -- Gasmeter P1 device
-- local vandaagM3Water = dz.devices('Water').counterToday -- Watermeter pulsmeter device
-- Vaste kosten in Euro's per dag (zoals vastrecht)
local gasM3PrijsVast = 0.72433
local gasM3Prijs = 1.45
-- local waterM3PrijsVast = 0.1266
-- local waterM3Prijs = 0.00057
local kwhPrijsVast = 0.94661
--Hierboven is geen Daltarief en normaal tarief geld niet vooor gas en water
if (dz.time == 'Between 21:00 and 07:00') or (dz.day == 'Saturday') or (dz.day == 'Sunday') then
kwhPrijs = 0.40 -- Daltarief
else kwhPrijs = 0.40 -- Normaal tarief
end
--Verzend informatie. Dit is 1 bericht, met alle informatie. regels uit -- ervoor anders ze ervoor weg halen om te krijgen
local subject = 'Mijn Energie overzicht : '
local message = 'Mijn Energie Overzicht : ' .. os.date("%d-%m-%Y")..'\n' ..
'--------------P1 Elektriciteitmeter-----------' .. '\n' ..
'Stroomkosten Totaal : € ' .. tonumber(dz.utils.round( (kwhPrijs * vandaagKwh) + kwhPrijsVast,2)).. '\n' ..
'Stroomkosten Hoog : € ' .. tonumber(dz.utils.round( (kwhPrijs * vandaagKwhvh) ,2)).. '\n' ..
'Stroomkosten Laag : € ' .. tonumber(dz.utils.round( (kwhPrijs * vandaagKwhvl) ,2)).. '\n' ..
'Teruglevering Hoog : € ' .. tonumber(dz.utils.round( (kwhPrijs * vandaagKwhth) ,2)).. '\n' ..
'Teruglevering Laag : € ' .. tonumber(dz.utils.round( (kwhPrijs * vandaagKwhtl) ,2)).. '\n' ..
'---------------------------------------------------' .. '\n' ..
'Verbruik Hoog : ' ..vandaagKwhvh.. ' kWh'.. '\n' ..
'Verbruik Laag : ' ..vandaagKwhvl.. ' kWh'.. '\n' ..
'Teruglevering Hoog : ' ..vandaagKwhth.. ' kWh' .. '\n' ..
'Teruglevering Laag : ' ..vandaagKwhtl.. ' kWh' .. '\n' ..
'Totaal Verbruik Elektra vandaag : ' ..vandaagKwh.. ' kWh'.. '\n' ..
'--------------P1 Gasmeter---------------------' .. '\n' ..
'Gas M3 : € ' .. tonumber(dz.utils.round( (gasM3Prijs * vandaagM3Gas) + gasM3PrijsVast,2))..'\n' ..
'Totaal Verbruik Gas vandaag : ' ..vandaagM3Gas.. ' M3'.. '\n' ..
-- '--------------Watermeter----------------------' .. '\n' ..
-- 'Water : € ' .. tonumber(dz.utils.round( (waterM3Prijs * vandaagM3Water)/1000 + waterM3PrijsVast,2))..'\n' ..
-- 'Totaal Verbruik Water vandaag : ' ..vandaagM3Water.. ' M3'.. '\n' ..
'--------------Zonnepanelen--------------------' .. '\n' ..
'Totaal Opbrengst Zonnepanelen : ' ..vandaagKwhzon.. ' kWh'.. '\n' ..
'Zonopbrengst Totaal € ' .. tonumber(dz.utils.round( (kwhPrijs * vandaagKwhzon) + kwhPrijsVast,2))..'\n' ..
'-------------- Einde Dag Overzicht -------------'
-- Notificatie voor verschillende aanbieders
-- dz.notify(subject, message, dz.PRIORITY_MEDIUM, dz.SOUND_PERSISTENT, nil, dz.NSS_TELEGRAM)
--local function telegram(msg)
-- commandArray['OpenURL'] 'https://api.telegram.org/botnewnumber:newAPI/sendMessage?chat_id=chatID "same as subsystem"&text=' .. msg
--end
end
}
As seen I have blocked the last part of the code.
The thing I'm missing is the last part to sent the message:
Code: Select all
-Verzend informatie. Dit is 1 bericht, met alle informatie. regels uit -- ervoor anders ze ervoor weg halen om te krijgen
local subject = 'Mijn Energie overzicht : '
local message = 'Mijn Energie Overzicht : ' .. os.date("%d-%m-%Y")..'\n' ..
'--------------P1 Elektriciteitmeter-----------' .. '\n' ..
'Stroomkosten Totaal : € ' .. tonumber(dz.utils.round( (kwhPrijs * vandaagKwh) + kwhPrijsVast,2)).. '\n' ..
'Stroomkosten Hoog : € ' .. tonumber(dz.utils.round( (kwhPrijs * vandaagKwhvh) ,2)).. '\n' ..
'Stroomkosten Laag : € ' .. tonumber(dz.utils.round( (kwhPrijs * vandaagKwhvl) ,2)).. '\n' ..
'Teruglevering Hoog : € ' .. tonumber(dz.utils.round( (kwhPrijs * vandaagKwhth) ,2)).. '\n' ..
'Teruglevering Laag : € ' .. tonumber(dz.utils.round( (kwhPrijs * vandaagKwhtl) ,2)).. '\n' ..
'---------------------------------------------------' .. '\n' ..
'Verbruik Hoog : ' ..vandaagKwhvh.. ' kWh'.. '\n' ..
'Verbruik Laag : ' ..vandaagKwhvl.. ' kWh'.. '\n' ..
'Teruglevering Hoog : ' ..vandaagKwhth.. ' kWh' .. '\n' ..
'Teruglevering Laag : ' ..vandaagKwhtl.. ' kWh' .. '\n' ..
'Totaal Verbruik Elektra vandaag : ' ..vandaagKwh.. ' kWh'.. '\n' ..
'--------------P1 Gasmeter---------------------' .. '\n' ..
'Gas M3 : € ' .. tonumber(dz.utils.round( (gasM3Prijs * vandaagM3Gas) + gasM3PrijsVast,2))..'\n' ..
'Totaal Verbruik Gas vandaag : ' ..vandaagM3Gas.. ' M3'.. '\n' ..
-- '--------------Watermeter----------------------' .. '\n' ..
-- 'Water : € ' .. tonumber(dz.utils.round( (waterM3Prijs * vandaagM3Water)/1000 + waterM3PrijsVast,2))..'\n' ..
-- 'Totaal Verbruik Water vandaag : ' ..vandaagM3Water.. ' M3'.. '\n' ..
'--------------Zonnepanelen--------------------' .. '\n' ..
'Totaal Opbrengst Zonnepanelen : ' ..vandaagKwhzon.. ' kWh'.. '\n' ..
'Zonopbrengst Totaal € ' .. tonumber(dz.utils.round( (kwhPrijs * vandaagKwhzon) + kwhPrijsVast,2))..'\n' ..
'-------------- Einde Dag Overzicht -------------'
to the newbot named "Notification"
Re: Question about notifications in dzVents
Posted: Wednesday 04 January 2023 11:41
by waltervl
OK, you got me completely confused here....
So you have the Lua script converted to DzVents and now you want to send a message to telegram from that script.
If you want to send it to the telegram Bot as defined in your Domoticz Setup - Settings - Notification you use the dzVents function:
Code: Select all
dz.notify(subject, message, dz.PRIORITY_MEDIUM, dz.SOUND_PERSISTENT, nil, dz.NSS_TELEGRAM)
Variables subject and message are available in the script so this should work.
If you want to send it to another telegram Bot, different from the one set in DomoticzSetup - Settings - Notification, you use the the open url one
Code: Select all
dz.openURL('https://api.telegram.org/bot"your BOT API key"/sendMessage?chat_id="Your chat-ID"&text=' .. message)
change "your BOT API key" and "Your chat-ID" to real values.
Re: Question about notifications in dzVents
Posted: Wednesday 04 January 2023 11:53
by Xavier82
Sorry for the confusion....
So I used the manual from
https://www.huizebruin.nl/domoticz/hand ... n-per-dag/ to get this job done.
I created an event of type DzVents Timer, so forget the LUA (there is no LUA) my mistake.
I indeed want to use a another telegram Bot, different from the one set in DomoticzSetup.
This is the code I now have:
Code: Select all
local ScriptVersion = '03/01/2023-/-v1.13' -- domoticz > V2022.2 / dzVents >= 3.1.7
return {
on = {
timer = { 'at 11:50' },
},
logging = {
level = domoticz.LOG_DEBUG, -- set to error when all OK
marker = "Dag verbruik in euros " .. ScriptVersion },
execute = function(dz)
print('Dag verbruik in euros')
local subject = (dz.moduleLabel or 'Mijn Energie Overzicht'):gsub('#','')
--Devices
local vandaagKwh = dz.devices('Power').counterToday -- Stroommeter P1 device verbruik
local vandaagKwhzon = dz.devices('Teruglevering').counterToday -- Stroommeter p1 -Teruglevering
local vandaagKwhth = dz.devices('Teruglevering Hoog').counterToday -- Stroommeter p1 -Teruglevering Hoog
local vandaagKwhtl = dz.devices('Teruglevering Laag').counterToday -- Stroommeter p1 -Teruglevering Laag
local vandaagKwhvh = dz.devices('Verbruik Hoog').counterToday -- Stroommeter p1 -Verbruik Hoog
local vandaagKwhvl = dz.devices('Verbruik Laag').counterToday -- Stroommeter p1 -Verbruik Laag
local vandaagM3Gas = dz.devices('Gas').counterToday -- Gasmeter P1 device
-- local vandaagM3Water = dz.devices('Water').counterToday -- Watermeter pulsmeter device
-- Vaste kosten in Euro's per dag (zoals vastrecht)
local gasM3PrijsVast = 0.72433
local gasM3Prijs = 1.45
-- local waterM3PrijsVast = 0.1266
-- local waterM3Prijs = 0.00057
local kwhPrijsVast = 0.94661
--Hierboven is geen Daltarief en normaal tarief geld niet vooor gas en water
if (dz.time == 'Between 21:00 and 07:00') or (dz.day == 'Saturday') or (dz.day == 'Sunday') then
kwhPrijs = 0.40 -- Daltarief
else kwhPrijs = 0.40 -- Normaal tarief
end
--Verzend informatie. Dit is 1 bericht, met alle informatie. regels uit -- ervoor anders ze ervoor weg halen om te krijgen
local subject = 'Mijn Energie overzicht : '
local message = 'Mijn Energie Overzicht : ' .. os.date("%d-%m-%Y")..'\n' ..
'--------------P1 Elektriciteitmeter-----------' .. '\n' ..
'Stroomkosten Totaal : € ' .. tonumber(dz.utils.round( (kwhPrijs * vandaagKwh) + kwhPrijsVast,2)).. '\n' ..
'Stroomkosten Hoog : € ' .. tonumber(dz.utils.round( (kwhPrijs * vandaagKwhvh) ,2)).. '\n' ..
'Stroomkosten Laag : € ' .. tonumber(dz.utils.round( (kwhPrijs * vandaagKwhvl) ,2)).. '\n' ..
'Teruglevering Hoog : € ' .. tonumber(dz.utils.round( (kwhPrijs * vandaagKwhth) ,2)).. '\n' ..
'Teruglevering Laag : € ' .. tonumber(dz.utils.round( (kwhPrijs * vandaagKwhtl) ,2)).. '\n' ..
'---------------------------------------------------' .. '\n' ..
'Verbruik Hoog : ' ..vandaagKwhvh.. ' kWh'.. '\n' ..
'Verbruik Laag : ' ..vandaagKwhvl.. ' kWh'.. '\n' ..
'Teruglevering Hoog : ' ..vandaagKwhth.. ' kWh' .. '\n' ..
'Teruglevering Laag : ' ..vandaagKwhtl.. ' kWh' .. '\n' ..
'Totaal Verbruik Elektra vandaag : ' ..vandaagKwh.. ' kWh'.. '\n' ..
'--------------P1 Gasmeter---------------------' .. '\n' ..
'Gas M3 : € ' .. tonumber(dz.utils.round( (gasM3Prijs * vandaagM3Gas) + gasM3PrijsVast,2))..'\n' ..
'Totaal Verbruik Gas vandaag : ' ..vandaagM3Gas.. ' M3'.. '\n' ..
-- '--------------Watermeter----------------------' .. '\n' ..
-- 'Water : € ' .. tonumber(dz.utils.round( (waterM3Prijs * vandaagM3Water)/1000 + waterM3PrijsVast,2))..'\n' ..
-- 'Totaal Verbruik Water vandaag : ' ..vandaagM3Water.. ' M3'.. '\n' ..
'--------------Zonnepanelen--------------------' .. '\n' ..
'Totaal Opbrengst Zonnepanelen : ' ..vandaagKwhzon.. ' kWh'.. '\n' ..
'Zonopbrengst Totaal € ' .. tonumber(dz.utils.round( (kwhPrijs * vandaagKwhzon) + kwhPrijsVast,2))..'\n' ..
'-------------- Einde Dag Overzicht -------------'
-- Notificatie voor verschillende aanbieders
-- dz.notify(subject, message, dz.PRIORITY_MEDIUM, dz.SOUND_PERSISTENT, nil, dz.NSS_TELEGRAM)
local function telegram(msg)
dz.openURL('https://api.telegram.org/botXXX:XXXX/sendMessage?chat_id=XXXXX&text=' .. msg)
end
end
}
Nothing happens, nothing is being sent to Telegram, no errors in the error log of Domoticz.
I'm missing out on the part where ".. msg)" is.
Re: Question about notifications in dzVents
Posted: Wednesday 04 January 2023 19:26
by waltervl
As I showed in my example replace msg in message and it should work.
Also you can check in a browser the url to see if it works
Code: Select all
https://api.telegram.org/botXXX:XXXX/sendMessage?chat_id=XXXXX&text=' Test message'
Re: Question about notifications in dzVents
Posted: Thursday 05 January 2023 9:48
by Xavier82
When using
Code: Select all
dz.openURL('https://api.telegram.org/botXXX:XXXX/sendMessage?chat_id=XXXXX&text=test')
I do get the message "test" in Telegram, but in that case it only contains the word "Test" instead of:
Mijn Energie Overzicht : 05-01-2023
--------------P1 Elektriciteitsmeter-----------
Stroomkosten Totaal : € 1.00
Stroomkosten Hoog : €0.80
Stroomkosten Laag : € 0.20
Teruglevering Hoog : €0.80
Teruglevering Laag : € 0
---------------------------------------------------
Verbruik Hoog : 16 kWh
Verbruik Laag : 3 kWh
Teruglevering Hoog : 1 kWh
Teruglevering Laag : 0 kWh
Totaal Verbruik Elektra vandaag : 19 kWh
--------------P1 Gasmeter---------------------
Gas M3 : € 1.33
Totaal Verbruik Gas vandaag : 0.9
--------------Zonnepanelen--------------------
Totaal Opbrengst Zonnepanelen : 1 kWh
Zonopbrengst Totaal € 0.80
-------------- Einde Dag Overzicht -------------