Notify function problem when using subsytem [CLOSED]  [SOLVED]

Moderator: leecollings

Post Reply
Deufo
Posts: 6
Joined: Thursday 30 July 2020 10:51
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Notify function problem when using subsytem [CLOSED]

Post by Deufo »

Hello,
By trying to choose only one way to send a notification on my phone, I discovered a little problem in the function.
The wiki list the following constant :
NSS_FIREBASE, NSS_FIREBASE_CLOUD_MESSAGING, NSS_GOOGLE_DEVICES 3.0.10 Only with installed casting plugin, NSS_HTTP, NSS_KODI, NSS_LOGITECH_MEDIASERVER, NSS_NMA,NSS_PROWL, NSS_PUSHALOT, NSS_PUSHBULLET, NSS_PUSHOVER, NSS_PUSHSAFER, NSS_TELEGRAM** 2.4.8, NSS_GOOGLE_CLOUD_MESSAGING deprecated by Google and replaced by firebase: for notification subsystem
but those didn't work for me.

A look in Domoticz.lua & constants.lua, we can find those definitions:

Code: Select all

	['NSS_GOOGLE_CLOUD_MESSAGING'] = 'gcm',
		['NSS_HTTP'] = 'http',
		['NSS_KODI'] = 'kodi',
		['NSS_LOGITECH_MEDIASERVER'] = 'lms',
		['NSS_NMA'] = 'nma',
		['NSS_PROWL'] = 'prowl',
		['NSS_PUSHALOT'] = 'pushalot',
		['NSS_PUSHBULLET'] = 'pushbullet',
		['NSS_PUSHOVER'] = 'pushover',
		['NSS_PUSHSAFER'] = 'pushsafer',
		['NSS_TELEGRAM'] = 'telegram',
But there is nothing in the code using it:

Code: Select all

-- combine
			if (type(subSystems) == 'table') then
				_subSystem = table.concat(subSystems, ";")
			elseif (type(subSystems) == 'string') then
				_subSystem = subSystems
			else
				_subSystem = ''
			end

The wiki also indicates:
subsystem can be a table containing one or more notification subsystems. See domoticz.NSS_subsystem
but here, it's just a string that must be used.

I'm using directly "telegram" and it works but it took me some time to understand the problem.

Thanks for your work.
Last edited by Deufo on Thursday 30 July 2020 12: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: Notify function problem when using subsytem

Post by waaren »

Deufo wrote: Thursday 30 July 2020 11:34 By trying to choose only one way to send a notification on my phone, I discovered a little problem in the function.
The function does work as designed. Did you see this in the wiki?
IMPORTANT: you have to prefix these constants with the name of your domoticz object. Example: domoticz.ALERTLEVEL_RED:
You can use a string for one notification subsystem, nil for all active notification subsystems or a table for some active notification subsystems.

Code: Select all

return
{
    on =
    {
        timer =
        {
            'every minute',
        },
    },

    logging =
    {
        level = domoticz.LOG_DEBUG,
        marker = 'notify options',
    },

    execute = function(dz)
        dz.notify('All systems', 'All')
        dz.notify('One system', 'One',nil,nil,nil,dz.NSS_TELEGRAM)
        dz.notify('Some systems', 'Some',nil,nil,nil,{ dz.NSS_TELEGRAM, dz.NSS_PUSHOVER } )
    end
}

Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Deufo
Posts: 6
Joined: Thursday 30 July 2020 10:51
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Notify function problem when using subsytem

Post by Deufo »

Ok, my bad, found my problem.

I created a local variable outside the function with domotciz.NSS_TELEGRAM, don't know why but no error and the created variable was nil.

If I wan't to keep the creation of the variable at the beginning of the script (easier to find what to modify), I should use the string name directly ?

Thanks for your quick answer.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Notify function problem when using subsytem

Post by waaren »

Deufo wrote: Thursday 30 July 2020 12:42 I created a local variable outside the function with domotciz.NSS_TELEGRAM, don't know why but no error and the created variable was nil.
When the subsystem var is nil, the function assumes all subsystems are intended.
If I wan't to keep the creation of the variable at the beginning of the script (easier to find what to modify), I should use the string name directly ?
Sorry but I don't understand the question
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Deufo
Posts: 6
Joined: Thursday 30 July 2020 10:51
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Notify function problem when using subsytem [CLOSED]

Post by Deufo »

Sorry, I give you an example:

Code: Select all


local Subsystem = domoticz.NSS_TELEGRAM


return
{
    on =
    {
        timer =
        {
            'every minute',
        },
    },

    logging =
    {
        level = domoticz.LOG_DEBUG,
        marker = 'notify options',
    },

    execute = function(dz)
        dz.notify('Some systems', 'Some',nil,nil,nil,Subsystem )
    end
}
I always try to create the variable that must be updated to configure the script before the return but in this case, Subsystem stays nil.
I had the feeling that my configuration is done, no error but as it stays nil, I had all the notifications.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Notify function problem when using subsytem [CLOSED]

Post by waaren »

Deufo wrote: Thursday 30 July 2020 15:24 I always try to create the variable that must be updated to configure the script before the return but in this case, Subsystem stays nil.
I had the feeling that my configuration is done, no error but as it stays nil, I had all the notifications.
the domoticz object is not completely filled before the execute function section. The only values available in the domoticz object at the location where you try to use it are:

domoticz.SECURITY_ARMEDAWAY: Armed Away
domoticz.SECURITY_ARMEDHOME: Armed Home
domoticz.SECURITY_DISARMED: Disarmed
domoticz.LOG_ERROR: 1
domoticz.LOG_MODULE_EXEC_INFO: 2
domoticz.LOG_INFO: 3
domoticz.LOG_DEBUG: 4
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Deufo
Posts: 6
Joined: Thursday 30 July 2020 10:51
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Notify function problem when using subsytem [CLOSED]  [SOLVED]

Post by Deufo »

ok, many thanks, I will take into account your return.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest