Page 1 of 1
Is it possible to send message when domoticz started?
Posted: Tuesday 09 October 2018 17:23
by Mixanoid
Sometimes we have problems on power line. I cannot see when the line is down (domoticz does not work without electricity) but can I receive the message when domoticz turns on?
Re: Is it possible to send message when domoticz started?
Posted: Tuesday 09 October 2018 17:47
by Egregius
You could use a cron job for that, or alter the init.d script.
Re: Is it possible to send message when domoticz started?
Posted: Tuesday 09 October 2018 18:47
by waaren
Mixanoid wrote: ↑Tuesday 09 October 2018 17:23
Sometimes we have problems on power line. I cannot see when the line is down (domoticz does not work without electricity) but can I receive the message when domoticz turns on?
I use this dzVents script to notify when domoticz has been started.
Code: Select all
--[[
active when function returns true ( domoticz started less then 180 seconds ago )
The defined tasks will only execute once after domoticz started.
Please note that in theory this is not a failsafe way of handling this.
If domoticz crashes / is stopped after the first excution of this script and before 120 seconds after
it started, the Executed value is not set back to 0 and the script needs to be reloaded to reset the persistent data.
If domoticz starts extremely slow, in theory it could be that this script will not be evaluated before the 180 seconds
after startup has passed. On my test system (PI-3), first execution is well within that window. (somewhere between 13 and 60 seconds)
]]--
return {
active = function(domoticz)
return domoticz.startTime.secondsAgo < 180
end,
on = { timer = { 'every minute' } },
data = { Executed = { initial = 0 } },
execute = function(dz)
if dz.data.Executed == 0 then
dz.notify("Domoticz has just been started")
else
print ("Älready executed; " .. tostring(dz.data.Executed) .. " seconds after domoticz started.")
if dz.startTime.secondsAgo > 119 then
dz.data.Executed = 0
end
end
end
}
Re: Is it possible to send message when domoticz started?
Posted: Tuesday 09 October 2018 19:51
by EdddieN
I use Monit for it with pushover, but I also like very much @waaren solution.
Re: Is it possible to send message when domoticz started?
Posted: Wednesday 27 January 2021 0:33
by waltervl
waaren wrote: ↑Tuesday 09 October 2018 18:47
I use this dzVents script to notify when domoticz has been started.
Code: Select all
--[[
active when function returns true ( domoticz started less then 180 seconds ago )
The defined tasks will only execute once after domoticz started.
Please note that in theory this is not a failsafe way of handling this.
If domoticz crashes / is stopped after the first excution of this script and before 120 seconds after
it started, the Executed value is not set back to 0 and the script needs to be reloaded to reset the persistent data.
If domoticz starts extremely slow, in theory it could be that this script will not be evaluated before the 180 seconds
after startup has passed. On my test system (PI-3), first execution is well within that window. (somewhere between 13 and 60 seconds)
]]--
return {
active = function(domoticz)
return domoticz.startTime.secondsAgo < 180
end,
on = { timer = { 'every minute' } },
data = { Executed = { initial = 0 } },
execute = function(dz)
if dz.data.Executed == 0 then
dz.notify("Domoticz has just been started")
dz.data.Executed = dz.startTime.secondsAgo
else
print ("Allready executed; " .. tostring(dz.data.Executed) .. " seconds after domoticz started.")
if dz.startTime.secondsAgo > 119 then
dz.data.Executed = 0
end
end
end
}
I use this script but got up to 3 notifications after a restart of Domoticz. 1 is enough

So I added the line
Code: Select all
dz.data.Executed = dz.startTime.secondsAgo
after dz.notify("Domoticz has just been started") and now I get only 1 notification.
Re: Is it possible to send message when domoticz started?
Posted: Wednesday 27 January 2021 0:58
by waaren
waltervl wrote: ↑Wednesday 27 January 2021 0:33
I use this dzVents script to notify when domoticz has been started....
This script was posted a long time ago. dzVents evolved since then ...
You can now do
Code: Select all
-- system triggers available in dzVents >= 3.0.0 (domoticz V4 build 11687)
return
{
on =
{
system =
{
'start',
},
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = 'startup tasks'
},
execute = function(dz)
dz.notify("Domoticz has just been started")
end
}