Page 1 of 1
Send notifications to android app
Posted: Friday 18 October 2019 21:27
by snellejellep
Hi all,
i want to send notifications to the domoticz android app, would like to certain phones only but all of them will also be ok.
i currently have this, i found it on the forum over here.
Code: Select all
dz.notify("ALARM!", "sensor" .. device.name .. "heeft beweging gedetecteerd!", dz.PRIORITY_EMERGENCY,dz.SOUND_DEFAULT, "" , dz.NSS_GOOGLE_CLOUD_MESSAGING)
which does not seem to work.
anyone a suggestion what will work?
Re: Send notifications to android app
Posted: Saturday 19 October 2019 1:38
by waaren
snellejellep wrote: Friday 18 October 2019 21:27
i want to send notifications to the domoticz android app, would like to certain phones only but all of them will also be ok.
Syntaxis is OK. Did you set GCM active in the [setup][settings][notification] tab and pressed the test button ?
Re: Send notifications to android app
Posted: Saturday 19 October 2019 16:57
by snellejellep
waaren wrote: Saturday 19 October 2019 1:38
Syntaxis is OK. Did you set GCM active in the [setup][settings][notification] tab and pressed the test button ?
yes, that is turned on and sending a test message that way works too.
Re: Send notifications to android app
Posted: Saturday 19 October 2019 17:36
by waaren
snellejellep wrote: Saturday 19 October 2019 16:57
waaren wrote: Saturday 19 October 2019 1:38
Syntaxis is OK. Did you set GCM active in the [setup][settings][notification] tab and pressed the test button ?
yes, that is turned on and sending a test message that way works too.
Can you share the complete script and log ? That might help in identifying why the notify does not work as expected.
Re: Send notifications to android app
Posted: Saturday 19 October 2019 17:46
by snellejellep
sure, this is the script:
Code: Select all
return {
on = {
devices = {
'PIR*',
'beweging brug',
'Deur*',
'roldeur'
}
},
execute = function(dz, device)
local brug = dz.devices("beweging brug")
local security = dz.devices("Domoticz Security Panel").state
local announce = dz.variables("Announce")
if security == "Arm Away" then
dz.notify("ALARM!", "sensor" .. device.name .. "heeft beweging gedetecteerd!", dz.PRIORITY_EMERGENCY,dz.SOUND_DEFAULT, "" , dz.NSS_GOOGLE_CLOUD_MESSAGING)
announce.set("Er is beweging gedetecteerd door ".. device.name .."")
elseif security == "Arm Home" then
if brug.lastUpdate.secondsAgo < 5 then
dz.notify("ALARM!", "sensor" .. device.name .. "heeft beweging gedetecteerd!", dz.PRIORITY_EMERGENCY,dz.SOUND_DEFAULT, "" , dz.NSS_GOOGLE_CLOUD_MESSAGING)
end
end
end
}
and this is my log output:
Code: Select all
2019-10-19 17:43:53.874 Status: dzVents: Info: Handling events for: "PIR schuurzolder", value: "On"
2019-10-19 17:43:53.874 Status: dzVents: Info: ------ Start internal script: Alarm away dzvents: Device: "PIR schuurzolder (Dummy/virtual)", Index: 799
2019-10-19 17:43:53.881 Status: dzVents: Info: ------ Finished Alarm away dzvents
Re: Send notifications to android app
Posted: Saturday 19 October 2019 19:00
by waaren
Can you try this ?
Code: Select all
return
{
on =
{
devices =
{
'PIR*',
'beweging brug',
'Deur*',
'roldeur',
-- 'myTrigger',
}
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = 'secure notify',
},
execute = function(dz, device)
local brug = dz.devices("beweging brug")
local announce = dz.variables("Announce")
dz.log('Security state: ' .. dz.security,dz.LOG_DEBUG)
dz.log('Device ' .. device.name .. ' lastUpdate was ' .. device.lastUpdate.secondsAgo .. ' seconds ago',dz.LOG_DEBUG)
if dz.security == dz.SECURITY_ARMEDAWAY then
dz.notify("ALARM!", "sensor" .. device.name .. "heeft beweging gedetecteerd!", dz.PRIORITY_EMERGENCY,dz.SOUND_DEFAULT, "" , dz.NSS_GOOGLE_CLOUD_MESSAGING)
announce.set("Er is beweging gedetecteerd door ".. device.name )
elseif dz.security == dz.SECURITY_ARMEDHOME then
if brug.lastUpdate.secondsAgo < 5 then
dz.notify("ALARM!", "sensor" .. device.name .. "heeft beweging gedetecteerd!", dz.PRIORITY_EMERGENCY,dz.SOUND_DEFAULT, "" , dz.NSS_GOOGLE_CLOUD_MESSAGING)
end
end
end
}
Re: Send notifications to android app [Solved]
Posted: Saturday 19 October 2019 19:06
by snellejellep
that works, thank you verry much!