Notification via nextcloud
Posted: Friday 22 January 2021 14:16
Hello,
Based on this topic viewtopic.php?f=31&t=35252 I have made simple script to use Nextcloud as notification server.
Thx again @waaren
You can activate notification for example by MQTT:
Or another dzVents script where will be executed:
I believe there are many users who uses Domoticz and also Nextcloud, so there will be no need to use 3rd party notification services like Pushbullet for them, since you can install Nextcloud app on any device.
Based on this topic viewtopic.php?f=31&t=35252 I have made simple script to use Nextcloud as notification server.
Thx again @waaren

Code: Select all
return
{
on =
{
customEvents = { "notification" },
},
logging = {
level = domoticz.LOG_DEBUG,
marker = notification,
},
execute = function(dz, item)
local function notify()
local ADMIN = "adminuser"
local TOKEN = "secret-token"
local USER = "targetuser"
local MESSAGE = item.data
dz.executeShellCommand(
{
command = 'curl -H "OCS-APIREQUEST: true" -X POST https://'..ADMIN..':'..TOKEN..'@redandblack.cz/ocs/v2.php/apps/admin_notifications/api/v1/notifications/'..USER..' -d "shortMessage='..MESSAGE..'"' ,
timeout = 300,
})
end
if item.isTimer or item.isDevice or item.customEvent then
notify()
else
dz.log(item,dz.LOG_DEBUG)
end
end
}
Code: Select all
mosquitto_pub -h domoticz -t domoticz/in -m '{"command":"customevent", "event":"notification","data":"message"}'
Code: Select all
domoticz.emitEvent('notification','message"')