Page 1 of 1
Send only email notification
Posted: Thursday 29 November 2018 17:40
by elgringo
I want to send a notify only via email since it is long and contains multiple lines. When using the notify there is an option to send a system:
Code: Select all
NSS_GOOGLE_CLOUD_MESSAGING, NSS_HTTP, NSS_KODI, NSS_LOGITECH_MEDIASERVER, NSS_NMA,NSS_PROWL, NSS_PUSHALOT, NSS_PUSHBULLET, NSS_PUSHOVER, NSS_PUSHSAFER, NSS_TELEGRAM
However there is no 'NSS_EMAIL'. Is it possible to send a notify only via email? I know there is a email command but rather want to use the notify function to prevent storing the email addresses at multiple places.
Re: Send only email notification
Posted: Friday 30 November 2018 1:16
by waaren
elgringo wrote: Thursday 29 November 2018 17:40
I want to send a notify only via email since it is long and contains multiple lines. When using the notify there is an option to send a system
However there is no 'NSS_EMAIL'. Is it possible to send a notify only via email? I know there is a email command but rather want to use the notify function to prevent storing the email addresses at multiple places.
the Domoticz notification system differs from the email system. In the notification settings the addressee is set and in the Email system the sender.
However there are at least two ways to overcome this for your requirement.
The first method is to ask domoticz for the senders address and store that in persistent data and use that as mailTo information. This can be done at either script persistent data level or on global persistent data level.
The other "dirty" method is to use "root@localhost" as mailTo address. This generates an error in the maildelivery susbsystem but (at least in gmail) the endresult is that the Email lands in the inbox of the in domoticz defined sender.
See below for an example dzVents script.
Code: Select all
local httpResponse = "settingsFromDomoticz"
return {
on = { timer = { "every minute" },
httpResponses = { httpResponse }},
data = { mailTo = { initial = false }},
execute = function(dz, item, info)
local function extractMailTo()
rt = item.json
dz.data.mailTo = rt.EmailTo
end
local function getDomoticzSettings()
local url = dz.settings['Domoticz url'] .. "/json.htm?type=settings"
dz.openURL ({ url = url, method = "GET", callback = httpResponse })
end
if item.isHTTPResponse then
extractMailTo()
elseif not dz.data.mailTo then
getDomoticzSettings()
return
end
-- Rest of script
-- This one use the elegant method by taking the mailTo address from dz.data.mailTo
dz.email(info.scriptName .. ". Triggered by event: " .. info.trigger ,"I got this Email adres from data", dz.data.mailTo )
-- This one use the dirty method (using a dummy mailTo address, and produce an event eror but still ends up in your inbox
dz.email(info.scriptName .. ". Triggered by ëvent: " .. info.trigger ,"I use a dummy mailTo address","root@localhost")
end
}