Page 1 of 1

[help]how to use "onNotification" function in python plugin file

Posted: Saturday 16 June 2018 8:38
by jia175891641
Version: V3.8135 (stable)
Platform: windows
Plugin/Hardware: no hardware,the code down from "https://github.com/domoticz/domoticz/bl ... emplate.py"
Description:
i do not know how to use (or how to active) "onNotification" callbacks function, who can tell me ? i find in Developing_a_Python_plugin.pdf .but is too simple

I Created a virtual hardware which download from "https://github.com/domoticz/domoticz/bl ... emplate.py"
this is my code :


and i've active all Notification system , as matter of fact,my phone is aleady receiving Notification(prowl)
1.PNG
1.PNG (138.53 KiB) Viewed 891 times
2.PNG
2.PNG (27.13 KiB) Viewed 890 times
and this is runing debug logs

23.PNG
23.PNG (70.4 KiB) Viewed 883 times
I mean when i press "switch" button . the onCommand function executioned and loged at history file but。。。 the onNotification no run yet
========================================================================================
i don't know how to post imgs, i used google photo album . pls copy the url at brower sorry
i am chinese. i've studied Domoticz about six months,this is my first time i've asked a question , i hope you can help me thank you !!!

Re: [help]how to use "onNotification" function in python plugin file

Posted: Sunday 17 June 2018 13:42
by Dnpwwo
@jia175891641,

Have a look at the Kodi plugin here: https://github.com/dnpwwo/Domoticz-Kodi ... /plugin.py

There are 2 important bit:
  • Line 122: Domoticz.Notifier(Parameters["Mode4"]), this registers the plugin as being able to recieve notifications. Mode4 is a parameter to the plugin that holds the name such as "Kodi-Lounge" or "Kodi-Family" in my case
  • Line 488: def onNotification(self, Name, Subject, Text, Status, Priority, Sound, ImageFile): Called when notifications are sent
Once the plugin is enabled and running you should be able to send notifications to it by selecting it under Notifications for devices:
Untitled.jpg
Untitled.jpg (141.02 KiB) Viewed 868 times

Re: [help]how to use "onNotification" function in python plugin file

Posted: Tuesday 19 June 2018 15:55
by jia175891641
i am done !! thank you very much