Page 1 of 1

Send Notification from device subtype text

Posted: Wednesday 08 May 2024 16:20
by McMelloW
Hi to all

For my SolarEdge Inverter I have a device subtype Text. Is show the status of my inverter as a text.
When the status is Fault or Off I would like to receive a notification. However these devices do not have the notification option.

Who knows the trick to send a notification on these status values from this device

Thanks in advace

Re: Send Notification from device subtype text

Posted: Thursday 09 May 2024 0:00
by waltervl
I would setup a dzvents script:
trigger on the text device change
read the text contents
if text contains Fault or Off send a notification.

Something like below (not tested so you probably have to tweak some things)

Code: Select all

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

    execute = function(domoticz, item)
       if item.text == 'Off' or item.text == 'Fault' then
          domoticz.notify('Solar edge issue!',
                        'Solar edge is Off or in Fault',
                        domoticz.PRIORITY_LOW)
        end
}
Below the notify function from the wiki https://www.domoticz.com/wiki/DzVents:_ ... _scripting
notify(subject, message [,priority][,sound][,extra][,subsystem][,delay]3.0.10 ): Function. Send a notification (like Prowl). Priority can be like domoticz.PRIORITY_LOW, PRIORITY_MODERATE, PRIORITY_NORMAL, PRIORITY_HIGH, PRIORITY_EMERGENCY. extra is notification subsystem specific. For NSS_FIREBASE you can use this field to specify the target mobile (‘midx_1’, midx_2, etc..). For sound see list of dzVents Constants for the SOUND constants below. subsystem defaults to all subsystems but can be one subsystem or a table containing one or more notification subsystems. See list of dzVents Constants for domoticz.NSS_subsystem types. Delay is delay in seconds

Re: Send Notification from device subtype text

Posted: Thursday 09 May 2024 22:25
by McMelloW
@waltervl

Thanks for your example. I will try this out.

Got it working in test situation. It is now in production an have wait for live status changes.

Re: Send Notification from device subtype text

Posted: Saturday 11 May 2024 17:05
by McMelloW
waltervl wrote: Thursday 09 May 2024 0:00 I would setup a dzvents script:
trigger on the text device change
read the text contents
if text contains Fault or Off send a notification.

Something like below (not tested so you probably have to tweak some things)

Code: Select all

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

    execute = function(domoticz, item)
       if item.text == 'Off' or item.text == 'Fault' then
          domoticz.notify('Solar edge issue!',
                        'Solar edge is Off or in Fault',
                        domoticz.PRIORITY_LOW)
        end
}
Hi Waltervl.
I have turned things around, only whenthe status is Producing or Sleeping I will not send a notification. These are the normal day and night status. All other status may send a notification. Somehow my equation does not work correct, because notifications are send with Producing or Sleeping Can you tell me what is wrong.

Code: Select all

return
{
    
    on =
    {
        devices = { 'SE - Status'}
    },

    execute = function(domoticz, item)
       if (item.text ~= 'Sleeping') or (item.text ~= 'Producing') then
          domoticz.notify('SolarEdge Status notification!',
                        'SolarEdge Status is now: ' .. item.text,
                        domoticz.PRIORITY_HIGH)
        end
    end    
}

Re: Send Notification from device subtype text

Posted: Sunday 12 May 2024 15:14
by waltervl
Is the status exactly Sleeping or Producing?
Perhaps put an extra log statement in it to get the real text value.

Re: Send Notification from device subtype text

Posted: Sunday 12 May 2024 17:06
by habahabahaba
try

Code: Select all

if (item.text ~= 'Sleeping' and item.text ~= 'Producing') then
          domoticz.notify('SolarEdge Status notification!',
                        'SolarEdge Status is now: ' .. item.text,
                        domoticz.PRIORITY_HIGH)
        end

Re: Send Notification from device subtype text

Posted: Monday 13 May 2024 14:18
by McMelloW
habahabahaba wrote: Sunday 12 May 2024 17:06 try

Code: Select all

if (item.text ~= 'Sleeping' and item.text ~= 'Producing') then
          domoticz.notify('SolarEdge Status notification!',
                        'SolarEdge Status is now: ' .. item.text,
                        domoticz.PRIORITY_HIGH)
        end
Thanks @habahabahaba, an AND operator did the trick. it works perfect now.

@waltervl The real value of item.text was already included in the notification text. So I am able to see it already.