Page 1 of 1

Notify function problem when using subsytem [CLOSED]

Posted: Thursday 30 July 2020 11:34
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.

Re: Notify function problem when using subsytem

Posted: Thursday 30 July 2020 12:07
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
}


Re: Notify function problem when using subsytem

Posted: Thursday 30 July 2020 12:42
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.

Re: Notify function problem when using subsytem

Posted: Thursday 30 July 2020 14:02
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

Re: Notify function problem when using subsytem [CLOSED]

Posted: Thursday 30 July 2020 15:24
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.

Re: Notify function problem when using subsytem [CLOSED]

Posted: Thursday 30 July 2020 16:07
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

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

Posted: Thursday 30 July 2020 18:50
by Deufo
ok, many thanks, I will take into account your return.