How to send notifications with a delay  [Solved]

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

gschmidt
Posts: 200
Joined: Thursday 20 December 2018 11:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

How to send notifications with a delay

Post by gschmidt »

Hi,

I am trying to create a dzVents script which sends notifications to telegram/Domoticz Log after a Switch is turned ON/OFF.
There must be 4 posibilities:

1. Switch ON -->Notification send (this works)
2. Switch ON -->Notification send 15 minutes after switch is turned ON (not working yet)
2. Switch ON -->Notification send 60 minutes after switch is turned ON (not working yet)
4. Switch OFF -->Notification send (this works)

Here is what I have sofar:

Code: Select all

-- Frietpan dzVents script

return 
{
   on = { devices = {'Test'}},

    logging = 
    {
        level = domoticz.LOG_DEBUG,
        marker = 'Test Schakelaar',
    },

    execute = function(dz, item)
        local token = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
        local chatid = XXXXXXXXXXXXXXX
        local msgAan = 'De frietpan is aangezet!'
        local msgKlaar = 'De frietpan is klaar om te frituren!'
        local msgWordt = 'De frietpan staat nog aan en wordt nu uitgezet!'
        local msgUit = 'De frietpan is uitgezet!'
        
        if (item.state == 'On') then
            os.execute('curl --data chat_id='..chatid..' --data-urlencode "text='..msgAan..'"  "https://api.telegram.org/bot'..token..'/sendMessage" ')
            dz.log(msgAan,dz.LOG_DEBUG)
        
        elseif (item.state == 'On' and "time is 15 minutes later after switch is turned ON") then
            os.execute('curl --data chat_id='..chatid..' --data-urlencode "text='..msgKlaar..'"  "https://api.telegram.org/bot'..token..'/sendMessage" ')
            dz.log(msgKlaar,dz.LOG_DEBUG)
        
        elseif (item.state == 'On' and "time is 60 minutes later  after switch is turned ON") then
            item.switchOff();
            os.execute('curl --data chat_id='..chatid..' --data-urlencode "text='..msgWordt..'"  "https://api.telegram.org/bot'..token..'/sendMessage" ')
            dz.log(msgWordt,dz.LOG_DEBUG)

        elseif (item.state == 'Off') then
            os.execute('curl --data chat_id='..chatid..' --data-urlencode "text='..msgUit..'"  "https://api.telegram.org/bot'..token..'/sendMessage" ')
            dz.log(msgUit,dz.LOG_DEBUG)
        end
    end
}
For the 1st and 2nd ELSEIF I need a value which is a certain amount of time after the Switch is turned ON.
How does this work in dzVents?
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: How to send notifications with a delay

Post by waaren »

gschmidt wrote: Tuesday 07 April 2020 11:45
I am trying to create a dzVents script which sends notifications to telegram/Domoticz Log after a Switch is turned ON/OFF.
There must be 4 possibilities:

1. Switch ON -->Notification send (this works)
2. Switch ON -->Notification send 15 minutes after switch is turned ON (not working yet)
2. Switch ON -->Notification send 60 minutes after switch is turned ON (not working yet)
4. Switch OFF -->Notification send (this works)
You could use the newly introduced customEvent for this.
Any reason why you don't use the native dz.notify ?

Code: Select all

-- Frietpan dzVents script

local myDevice =  'Test'
local myEvent = 'Friet'

return 
{
    on = 
    { 
        devices = 
        {
            myDevice,            
        },
        customEvent =
        {
            myEvent,
        },

    logging = 
    {
        level = domoticz.LOG_DEBUG,
        marker = 'Test Schakelaar',
    },

    execute = function(dz, item)
        
        myDevice = dz.devices(myDevice)
        
        local msgAan = 'De frietpan is aangezet!'
        local msgKlaar = 'De frietpan is klaar om te frituren!'
        local msgWordt = 'De frietpan staat nog aan en wordt nu uitgezet!'
        local msgUit = 'De frietpan is uitgezet!'
        
        local klaarDelay = 15
        local OffDelay = 60 - klaarDelay
        
        local function sendMessage(message, emitMinutes)
            -- Native dzVents / domoticz method
            dz.notify(dz.moduleLabel, message, dz.PRIORITY_MODERATE, nil, nil, dz.NSS_TELEGRAM)

            -- OS approach
            local token = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
            local chatid = XXXXXXXXXXXXXXX
            -- os.execute('curl --data chat_id='..chatid..' --data-urlencode "text='..msgAan..'"  "https://api.telegram.org/bot'..token..'/sendMessage"  &')

            dz.log(messsage,dz.LOG_DEBUG)
            if emitMinutes ~= nil then dz.emitEvent(myEvent, emitMinutes).afterMin(emitMinutes) end
            --  if emitMinutes ~= nil then dz.emitEvent(myEvent, emitMinutes).afterSec(emitMinutes) end -- for test use seconds
        end

        if item.isDevice and item.state == 'On' then
            sendMessage(msgAan, klaarDelay)
        elseif item.isCustomEvent and myDevice.state == 'On' and tonumber(item.data) == klaarDelay then
            sendMessage(msgKlaar, OffDelay)
        elseif item.isCustomEvent and myDevice.state == 'On' and tonumber(item.data) == OffDelay then 
            myDevice.switchOff().silent()
            sendMessage(msgWordt)
        elseif (item.state == 'Off') then
            sendMessage(msgUit)
        end

    end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
gschmidt
Posts: 200
Joined: Thursday 20 December 2018 11:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: How to send notifications with a delay

Post by gschmidt »

waaren wrote: Tuesday 07 April 2020 13:06 You could use the newly introduced customEvent for this.
Thanx man, I will study and test the script.
Where can I find the documentation for dzVents customEvent?
waaren wrote: Tuesday 07 April 2020 13:06 Any reason why you don't use the native dz.notify ?
I didn't know that dz.notify existed...just looked for an example and the first one I got was the os.execute example
I guess dz.notify is using the credentials I set for Telegram at the domoticz settings page?
gschmidt
Posts: 200
Joined: Thursday 20 December 2018 11:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: How to send notifications with a delay

Post by gschmidt »

waaren wrote: Tuesday 07 April 2020 13:06
gschmidt wrote: Tuesday 07 April 2020 11:45
I am trying to create a dzVents script which sends notifications to telegram/Domoticz Log after a Switch is turned ON/OFF.
There must be 4 possibilities:

1. Switch ON -->Notification send (this works)
2. Switch ON -->Notification send 15 minutes after switch is turned ON (not working yet)
2. Switch ON -->Notification send 60 minutes after switch is turned ON (not working yet)
4. Switch OFF -->Notification send (this works)
You could use the newly introduced customEvent for this.
Any reason why you don't use the native dz.notify ?

Code: Select all

-- Frietpan dzVents script

local myDevice =  'Test'
local myEvent = 'Friet'

return 
{
    on = 
    { 
        devices = 
        {
            myDevice,            
        },
        customEvent =
        {
            myEvent,
        },

    logging = 
    {
        level = domoticz.LOG_DEBUG,
        marker = 'Test Schakelaar',
    },

    execute = function(dz, item)
        
        myDevice = dz.devices(myDevice)
        
        local msgAan = 'De frietpan is aangezet!'
        local msgKlaar = 'De frietpan is klaar om te frituren!'
        local msgWordt = 'De frietpan staat nog aan en wordt nu uitgezet!'
        local msgUit = 'De frietpan is uitgezet!'
        
        local klaarDelay = 15
        local OffDelay = 60 - klaarDelay
        
        local function sendMessage(message, emitMinutes)
            -- Native dzVents / domoticz method
            dz.notify(dz.moduleLabel, message, dz.PRIORITY_MODERATE, nil, nil, dz.NSS_TELEGRAM)

            -- OS approach
            local token = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
            local chatid = XXXXXXXXXXXXXXX
            -- os.execute('curl --data chat_id='..chatid..' --data-urlencode "text='..msgAan..'"  "https://api.telegram.org/bot'..token..'/sendMessage"  &')

            dz.log(messsage,dz.LOG_DEBUG)
            if emitMinutes ~= nil then dz.emitEvent(myEvent, emitMinutes).afterMin(emitMinutes) end
            --  if emitMinutes ~= nil then dz.emitEvent(myEvent, emitMinutes).afterSec(emitMinutes) end -- for test use seconds
        end

        if item.isDevice and item.state == 'On' then
            sendMessage(msgAan, klaarDelay)
        elseif item.isCustomEvent and myDevice.state == 'On' and tonumber(item.data) == klaarDelay then
            sendMessage(msgKlaar, OffDelay)
        elseif item.isCustomEvent and myDevice.state == 'On' and tonumber(item.data) == OffDelay then 
            myDevice.switchOff().silent()
            sendMessage(msgWordt)
        elseif (item.state == 'Off') then
            sendMessage(msgUit)
        end

    end
}
I get the following error:

Code: Select all

2020-04-07 15:24:27.463 Error: dzVents: Error: (3.0.1) error loading module 'Script #2' from file '/home/pi/domoticz/scripts/dzVents/generated_scripts/Script #2.lua':
2020-04-07 15:24:27.463 ...domoticz/scripts/dzVents/generated_scripts/Script #2.lua:20: '}' expected (to close '{' at line 7) near 'logging'
gschmidt
Posts: 200
Joined: Thursday 20 December 2018 11:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: How to send notifications with a delay

Post by gschmidt »

I think it was the "on =" closing brace },

After fixing this I got the next error:

Code: Select all

2020-04-07 15:29:22.866 Error: dzVents: Error: (3.0.1) Test Schakelaar: An error occurred when calling event handler Script #2
2020-04-07 15:29:22.866 Error: dzVents: Error: (3.0.1) Test Schakelaar: /home/pi/domoticz/dzVents/runtime/Domoticz.lua:115: attempt to concatenate a nil value (local 'subject')
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: How to send notifications with a delay

Post by waaren »

gschmidt wrote: Tuesday 07 April 2020 15:33 I think it was the "on =" closing brace },

After fixing this I got the next error:

Code: Select all

2020-04-07 15:29:22.866 Error: dzVents: Error: (3.0.1) Test Schakelaar: An error occurred when calling event handler Script #2
2020-04-07 15:29:22.866 Error: dzVents: Error: (3.0.1) Test Schakelaar: /home/pi/domoticz/dzVents/runtime/Domoticz.lua:115: attempt to concatenate a nil value (local 'subject')
I missed an 's' in customEvents :oops:

Code: Select all

-- Frietpan dzVents script

local myDevice =  'Test'
local myEvent = 'Friet'

return 
{
    on = 
    { 
        devices = 
        {
            myDevice,            
        },
        customEvents =
        {
            myEvent,
        },
    },
    
    logging = 
    {
        level = domoticz.LOG_DEBUG,  -- change to LOG_ERROR when ok
        marker = 'Test Schakelaar',
    },

    execute = function(dz, item)
        
        myDevice = dz.devices(myDevice)
        
        local msgAan = 'De frietpan is aangezet!'
        local msgKlaar = 'De frietpan is klaar om te frituren!'
        local msgWordt = 'De frietpan staat nog aan en wordt nu uitgezet!'
        local msgUit = 'De frietpan is uitgezet!'
        
        local klaarDelay = 15
        local OffDelay = 60 - klaarDelay
        
        local function sendMessage(message, emitMinutes)
            
            -- Native dzVents / domoticz method
            dz.notify(dz.moduleLabel, message, dz.PRIORITY_MODERATE, nil, nil, dz.NSS_TELEGRAM)
            
            -- OS approach
            local token = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
            local chatid = XXXXXXXXXXXXXXX
            -- os.execute('curl --data chat_id='..chatid..' --data-urlencode "text='..msgAan..'"  "https://api.telegram.org/bot'..token..'/sendMessage"  &')
            
            dz.log(message,dz.LOG_DEBUG)
            if emitMinutes ~= nil then dz.emitEvent(myEvent, emitMinutes).afterMin(emitMinutes) end
            -- if emitMinutes ~= nil then dz.emitEvent(myEvent, emitMinutes).afterSec(emitMinutes) end -- for test only
        end
        
        if item.isDevice and item.state == 'On' then
            sendMessage(msgAan, klaarDelay)
                        
        elseif item.isCustomEvent and myDevice.state == 'On' and tonumber(item.data) == klaarDelay then
            sendMessage(msgKlaar, OffDelay)
            
        elseif item.isCustomEvent and myDevice.state == 'On' and tonumber(item.data) == OffDelay then 
            myDevice.switchOff().silent()
            sendMessage(msgWordt)
            
        elseif (item.state == 'Off') then
            sendMessage(msgUit)
            
        end
    end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
gschmidt
Posts: 200
Joined: Thursday 20 December 2018 11:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: How to send notifications with a delay

Post by gschmidt »

But also dzNotify has an error...

Code: Select all

dz.notify(dz.moduleLabel, message, dz.PRIORITY_MODERATE, nil, nil, dz.NSS_TELEGRAM)
when I used the os.execute instead, I got a telegram notification

Code: Select all

local token = "xxxxxxxxxxxxxxxxxxxxxxxxxxx"
local chatid = xxxxxxxxxxxxxxx
os.execute('curl --data chat_id='..chatid..' --data-urlencode "text='..message..'"  "https://api.telegram.org/bot'..token..'/sendMessage"  &')
gschmidt
Posts: 200
Joined: Thursday 20 December 2018 11:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: How to send notifications with a delay

Post by gschmidt »

Your last script has the following error:

Code: Select all

2020-04-07 16:03:38.701 Error: dzVents: Error: (3.0.1) Test Schakelaar: An error occurred when calling event handler Script #2
2020-04-07 16:03:38.701 Error: dzVents: Error: (3.0.1) Test Schakelaar: /home/pi/domoticz/dzVents/runtime/Domoticz.lua:115: attempt to concatenate a nil value (local 'subject')
I think it has to do with dz.notify, because when I switched back to the os.execute method, the error was gone and I received a telegram notification
gschmidt
Posts: 200
Joined: Thursday 20 December 2018 11:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: How to send notifications with a delay

Post by gschmidt »

Script is working, I tested it with 1 and 3 minutes, and this works!
Only dz.notify gives an error and no notifications but with the os.execute it all works fine

What happens if I have turned on the Switch by accident and then turn it OFF, is the "sendMessage(msgAan, klaarDelay)" still send to telegram?
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: How to send notifications with a delay

Post by waaren »

gschmidt wrote: Tuesday 07 April 2020 16:25 Script is working, I tested it with 1 and 3 minutes, and this works!
Only dz.notify gives an error and no notifications but with the os.execute it all works fine

What happens if I have turned on the Switch by accident and then turn it OFF, is the "sendMessage(msgAan, klaarDelay)" still send to telegram?
the dz.notify error is probably related to the use of dz.moduleLabel
This is available in latest Beta's (>= build 11899) If you are on lower build or Stable , you should change that to 'frietpan' (with the quotes)

If you switch it on and within the 15 minutes to off the message klaarDelay will not be send.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
gschmidt
Posts: 200
Joined: Thursday 20 December 2018 11:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: How to send notifications with a delay

Post by gschmidt »

waaren wrote: Tuesday 07 April 2020 18:24
gschmidt wrote: Tuesday 07 April 2020 16:25 Script is working, I tested it with 1 and 3 minutes, and this works!
Only dz.notify gives an error and no notifications but with the os.execute it all works fine

What happens if I have turned on the Switch by accident and then turn it OFF, is the "sendMessage(msgAan, klaarDelay)" still send to telegram?
the dz.notify error is probably related to the use of dz.moduleLabel
This is available in latest Beta's (>= build 11899) If you are on lower build or Stable , you should change that to 'frietpan' (with the quotes)

If you switch it on and within the 15 minutes to off the message klaarDelay will not be send.
Updated to the latest beta version.
dz.notify is working.....however the message in my telegrambot is “2”, also when switch is turned off
gschmidt
Posts: 200
Joined: Thursday 20 December 2018 11:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: How to send notifications with a delay

Post by gschmidt »

Changing dz.moduleLabel with ‘frietpan’ is working...
But this way there is no notification sound in telegram...with os.execute there is! Strange :shock:
Last edited by gschmidt on Tuesday 07 April 2020 22:43, edited 1 time in total.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: How to send notifications with a delay

Post by waaren »

gschmidt wrote: Tuesday 07 April 2020 22:02 Updated to the latest beta version.
dz.notify is working.....however the message in my telegrambot is “2”, also when switch is turned off
:D Funny bug this is !

What happens is that your script was probably named something like 'script #2'
The domoticz notify function use the # character as separator for the various fields (subject, message, priority, etc.)
internally it is converted to "subject#message#prio#etc"

so you messages was translated into
"script #2#frietpan klaar#2#" with 2 being the message..

I will modify the dzVents function to prevent this behavior.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
gschmidt
Posts: 200
Joined: Thursday 20 December 2018 11:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: How to send notifications with a delay

Post by gschmidt »

waaren wrote: Tuesday 07 April 2020 22:30
gschmidt wrote: Tuesday 07 April 2020 22:02 Updated to the latest beta version.
dz.notify is working.....however the message in my telegrambot is “2”, also when switch is turned off
:D Funny bug this is !

What happens is that your script was probably named something like 'script #2'
The domoticz notify function use the # character as separator for the various fields (subject, message, priority, etc.)
internally it is converted to "subject#message#prio#etc"

so you messages was translated into
"script #2#frietpan klaar#2#" with 2 being the message..

I will modify the dzVents function to prevent this behavior.
Yes, it is called script #2....because it is in testing phase :D :D :D
And are you familiar with the “no sound” notification in telegram, when using dz.notify?
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: How to send notifications with a delay

Post by waaren »

gschmidt wrote: Tuesday 07 April 2020 22:46 And are you familiar with the “no sound” notification in telegram, when using dz.notify?
Some small changes..

I don't know how to force telegram to produce sound. I use other notification subsystems and always without sound.
Do you use the same chatid and token in domoticz settings for telegram as in the os execute ?

Code: Select all

-- Frietpan dzVents script

local myDevicename = 'Test'
local myEvent = 'Friet'

return 
{
    on = 
    { 
        devices = 
        {
            myDevicename,            
        },
        customEvents =
        {
            myEvent,
        },
    },
    
    logging = 
    {
        level = domoticz.LOG_DEBUG,  -- change to LOG_ERROR when ok
        marker = 'Test Schakelaar',
    },

    execute = function(dz, item)
        
        local myDevice = dz.devices(myDevicename)
        
        local msgAan = 'De frietpan is aangezet!'
        local msgKlaar = 'De frietpan is klaar om te frituren!'
        local msgWordt = 'De frietpan staat nog aan en wordt nu uitgezet!'
        local msgUit = 'De frietpan is uitgezet!'
        
        local klaarDelay = 15
        local OffDelay = 60 - klaarDelay
        
        local function sendMessage(message, emitMinutes)
            
            -- Native dzVents / domoticz method
            local subject = (dz.moduleLabel or 'frietpan'):gsub('#','')
            dz.notify(subject, message, dz.PRIORITY_MODERATE, dz.SOUND_PERSISTENT, nil, dz.NSS_TELEGRAM)
            
            -- OS approach
            local token = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
            local chatid = XXXXXXXXXXXXXXX
            -- os.execute('curl --data chat_id='..chatid..' --data-urlencode "text='..msgAan..'"  "https://api.telegram.org/bot'..token..'/sendMessage"  &')
            
            dz.log(message,dz.LOG_DEBUG)
            if emitMinutes ~= nil then dz.emitEvent(myEvent, emitMinutes).afterMin(emitMinutes) end
            -- if emitMinutes ~= nil then dz.emitEvent(myEvent, emitMinutes).afterSec(emitMinutes) end -- for test only
        end
        
        if item.isDevice and item.state == 'On' then
            sendMessage(msgAan, klaarDelay)
                        
        elseif item.isCustomEvent and myDevice.state == 'On' and tonumber(item.data) == klaarDelay then
            sendMessage(msgKlaar, OffDelay)
            
        elseif item.isCustomEvent and myDevice.state == 'On' and tonumber(item.data) == OffDelay then 
            myDevice.switchOff().silent()
            sendMessage(msgWordt)
            
        elseif item.isDevice and item.state == 'Off' then
            sendMessage(msgUit)
            
        end
    end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
gschmidt
Posts: 200
Joined: Thursday 20 December 2018 11:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: How to send notifications with a delay

Post by gschmidt »

I don't know how to force telegram to produce sound. I use other notification subsystems and always without sound.
Do you use the same chatid and token in domoticz settings for telegram as in the os execute ?
I think it is the other way around, by default most communication apps (also Telegram) produce notification sounds. You can modify them to their own needs. But in this case it looks like dz.notify forces Telegram not to produce a notification sound.

Yes I use the same credentials.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: How to send notifications with a delay

Post by waaren »

gschmidt wrote: Wednesday 08 April 2020 7:54 I think it is the other way around, by default most communication apps (also Telegram) produce notification sounds.
The absence of sound is because of the notification priority. In the script it is set to moderate.

If you change in the script to a higher level you will get sound.

possible levels are
dz.PRIORITY_EMERGENCY
dz.PRIORITY_HIGH
dz.PRIORITY_NORMAL
dz.PRIORITY_MODERATE -- no sound
dz.PRIORITY_LOW -- no sound
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
gschmidt
Posts: 200
Joined: Thursday 20 December 2018 11:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: How to send notifications with a delay

Post by gschmidt »

waaren wrote: Wednesday 08 April 2020 9:18
gschmidt wrote: Wednesday 08 April 2020 7:54 I think it is the other way around, by default most communication apps (also Telegram) produce notification sounds.
The absence of sound is because of the notification priority. In the script it is set to moderate.

If you change in the script to a higher level you will get sound.

possible levels are
dz.PRIORITY_EMERGENCY
dz.PRIORITY_HIGH
dz.PRIORITY_NORMAL
dz.PRIORITY_MODERATE -- no sound
dz.PRIORITY_LOW -- no sound
Your last script is working properly now.
I have played with the levels, and this is working.
So now I can set the level of a notification, based on priority.
Thanx!
gschmidt
Posts: 200
Joined: Thursday 20 December 2018 11:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: How to send notifications with a delay

Post by gschmidt »

I have another question, maybe you have an answer.
I also use node-red-contrib-cast nodes to send audio notifications for the "Frietpan" Switch to my google home speakers.
Now this is working when I turn the "Frietpan" switch ON or OFF, but the 2 delay notifications I have a problem with:

the Switch ON/OFF message is published through the MQTT node: domoticz/out into the node-red flow, but is it also possible to publish a "domoticz" log message to the MQTT node? Then I could use the domoticz "frietpan" delay messages to send the audio messages parallel
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: How to send notifications with a delay

Post by waaren »

gschmidt wrote: Wednesday 08 April 2020 21:19 I have another question, maybe you have an answer.
I also use node-red-contrib-cast nodes to send audio notifications for the "Frietpan" Switch to my google home speakers.
Now this is working when I turn the "Frietpan" switch ON or OFF, but the 2 delay notifications I have a problem with:

the Switch ON/OFF message is published through the MQTT node: domoticz/out into the node-red flow, but is it also possible to publish a "domoticz" log message to the MQTT node? Then I could use the domoticz "frietpan" delay messages to send the audio messages parallel
using os.execute dzVents can send any MQTT message to any topic. Only thing needed is installed mosquitto on the domoticz system.

Just let me know what you want to send to which topic and when and I will have a look.
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