Is it possible to send message when domoticz started?

Moderator: leecollings

Post Reply
Mixanoid
Posts: 1
Joined: Sunday 17 June 2018 13:53
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Is it possible to send message when domoticz started?

Post 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?
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Is it possible to send message when domoticz started?

Post by Egregius »

You could use a cron job for that, or alter the init.d script.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Is it possible to send message when domoticz started?

Post 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
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
EdddieN
Posts: 510
Joined: Wednesday 16 November 2016 11:31
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9700
Location: Scotland
Contact:

Re: Is it possible to send message when domoticz started?

Post by EdddieN »

I use Monit for it with pushover, but I also like very much @waaren solution.
11101101 - www.machinon.com
User avatar
waltervl
Posts: 5890
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Is it possible to send message when domoticz started?

Post 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.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Is it possible to send message when domoticz started?

Post 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
}

Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest