Page 1 of 1

WIKI: domoticz.notify ?

Posted: Friday 18 January 2019 16:46
by Varazir
Hello

I have looked at the wiki for DzVents and can't find how domoticz.notify works.

I like to send a custom http action notification.


TIA
Daniel

Re: WIKI: domoticz.notify ?

Posted: Friday 18 January 2019 21:22
by waaren
Varazir wrote: Friday 18 January 2019 16:46 Hello

I have looked at the wiki for DzVents and can't find how domoticz.notify works.

I like to send a custom http action notification.


TIA
Daniel
notify in dzVents:

notify(subject, message, priority, sound, extra, subsystem): Function. Send a notification (like Prowl). Priority can be like domoticz.PRIORITY_LOW, PRIORITY_MODERATE, PRIORITY_NORMAL, PRIORITY_HIGH, PRIORITY_EMERGENCY. For sound see the SOUND constants below. subsystem can be a table containing one or more notification subsystems. See domoticz.NSS_xxx types.

so for http use domoticz.NSS_HTTP as notification subsystem. What the HTTP notification does is defined in the domoticz settings -> notifications page and not controlled by dzVents.

Re: WIKI: domoticz.notify ?

Posted: Friday 18 January 2019 23:54
by Varazir
waaren wrote: Friday 18 January 2019 21:22
Varazir wrote: Friday 18 January 2019 16:46 Hello

I have looked at the wiki for DzVents and can't find how domoticz.notify works.

I like to send a custom http action notification.


TIA
Daniel
notify in dzVents:

notify(subject, message, priority, sound, extra, subsystem): Function. Send a notification (like Prowl). Priority can be like domoticz.PRIORITY_LOW, PRIORITY_MODERATE, PRIORITY_NORMAL, PRIORITY_HIGH, PRIORITY_EMERGENCY. For sound see the SOUND constants below. subsystem can be a table containing one or more notification subsystems. See domoticz.NSS_xxx types.

so for http use domoticz.NSS_HTTP as notification subsystem. What the HTTP notification does is defined in the domoticz settings -> notifications page and not controlled by dzVents.
So domoticz.NSS_HTTP('subject', 'message') should work?

Re: WIKI: domoticz.notify ?

Posted: Saturday 19 January 2019 0:01
by waaren
Varazir wrote: Friday 18 January 2019 23:54 So domoticz.NSS_HTTP('subject', 'message') should work?
No.
syntax is notify(subject, message, priority, sound, extra, subsystem)
so you should use something like

Code: Select all

domoticz.notify("subject","message", domoticz.PRIORITY_NORMAL,nil,nil,domoticz.NSS_HTTP)

Re: WIKI: domoticz.notify ?

Posted: Saturday 19 January 2019 0:02
by Varazir
waaren wrote: Saturday 19 January 2019 0:01
Varazir wrote: Friday 18 January 2019 23:54 So domoticz.NSS_HTTP('subject', 'message') should work?
No.
syntax is notify(subject, message, priority, sound, extra, subsystem)
so you should use something like

Code: Select all

domoticz.notify("subject","message", domoticz.PRIORITY_NORMAL,nil,nil,domoticz.NSS_HTTP)
When you say it you are ofc right :)

Thanks will try

Re: WIKI: domoticz.notify ?

Posted: Thursday 24 January 2019 10:23
by Varazir
waaren wrote: Saturday 19 January 2019 0:01
Varazir wrote: Friday 18 January 2019 23:54 So domoticz.NSS_HTTP('subject', 'message') should work?
No.
syntax is notify(subject, message, priority, sound, extra, subsystem)
so you should use something like

Code: Select all

domoticz.notify("subject","message", domoticz.PRIORITY_NORMAL,nil,nil,domoticz.NSS_HTTP)
I get this

Code: Select all

2019-01-24 07:26:41.700 Status: dzVents: Error (2.4.10): LightControl: An error occured when calling event handler Detection
2019-01-24 07:26:41.700 Status: dzVents: Error (2.4.10): LightControl: ...domoticz/scripts/dzVents/generated_scripts/Detection.lua:84: attempt to index global 'domoticz' (a nil value)

Code: Select all

domoticz.notify("IKEA Hallen","Stänger av Lamporna i hallen", domoticz.PRIORITY_NORMAL,nil,nil,domoticz.NSS_HTTP)

Re: WIKI: domoticz.notify ?  [Solved]

Posted: Thursday 24 January 2019 11:03
by waaren
Varazir wrote: Thursday 24 January 2019 10:23
waaren wrote: Saturday 19 January 2019 0:01
Varazir wrote: Friday 18 January 2019 23:54 So domoticz.NSS_HTTP('subject', 'message') should work?
No.
syntax is notify(subject, message, priority, sound, extra, subsystem)
so you should use something like

Code: Select all

domoticz.notify("subject","message", domoticz.PRIORITY_NORMAL,nil,nil,domoticz.NSS_HTTP)
I get this

Code: Select all

2019-01-24 07:26:41.700 Status: dzVents: Error (2.4.10): LightControl: An error occured when calling event handler Detection
2019-01-24 07:26:41.700 Status: dzVents: Error (2.4.10): LightControl: ...domoticz/scripts/dzVents/generated_scripts/Detection.lua:84: attempt to index global 'domoticz' (a nil value)

Code: Select all

domoticz.notify("IKEA Hallen","Stänger av Lamporna i hallen", domoticz.PRIORITY_NORMAL,nil,nil,domoticz.NSS_HTTP)
If you look at your script you will see a line starting with execute = function(
The first parameter in this line is the reference to the domoticz object with all devices, variables, constants, etc..
You can give it any valid name (also called identifier) In Lua and dzVents a name can be any string of letters, digits, and underscores, not beginning with a digit and not one of the reserved words (and, break, do, else, elseif, end, false, for, function, if, in,local, nil, not, or, repeat, return, then, true, until, while)
So if you use domoticz as name you can reference any sub object in the domoticz object using that name followed by a dot "domoticz."
for example domoticz.devices() , domoticz.log, etc

If you choose dz as name you must use that so it would become dz.devices() dz.log, etc.

in your example is would become

Code: Select all

dz.notify("IKEA Hallen","Stänger av Lamporna i hallen", dz.PRIORITY_NORMAL,nil,nil,dz.NSS_HTTP)
Hope this clarifies