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

Python and python framework

Moderator: leecollings

Post Reply
jia175891641
Posts: 5
Joined: Tuesday 12 June 2018 17:07
Target OS: Raspberry Pi / ODroid
Domoticz version: V3.9000
Location: China-Zhejiang
Contact:

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

Post 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 847 times
2.PNG
2.PNG (27.13 KiB) Viewed 846 times
and this is runing debug logs

23.PNG
23.PNG (70.4 KiB) Viewed 839 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 !!!
只要够努力 时间总会给你想要的
User avatar
Dnpwwo
Posts: 819
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

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

Post 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 824 times
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
jia175891641
Posts: 5
Joined: Tuesday 12 June 2018 17:07
Target OS: Raspberry Pi / ODroid
Domoticz version: V3.9000
Location: China-Zhejiang
Contact:

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

Post by jia175891641 »

i am done !! thank you very much
只要够努力 时间总会给你想要的
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest