Hello,
I’ve got a plugin which has to be monitored. If its actions fail, I want to be notified.
What the best way to handle that ?
- expose a special variable which is triggered in case of failure ?
- some devices have a panel for notifications : how does it work ?
The Notification’s tab on a device provides the user to issue a notification for any of the events defined in it’s JSON file.
The best way to notify failure could be “luup.set_failure”.
It sets the variable “CommFailure” to 1 and there’s an entry in the notifications’ tab.
The problem is that in that state, the plugin responds no more (in UI7).
A call to a plugin service returns directly “ERROR: Device communication failure”.
The service is not really called (ie that it’s not possible to externally execute lua code in the plugin that could fix the communication failure).
In UI5, it seems to be handled slightly differently. Lua code of the service is still called.
EDIT : UI5 behaves in the same way as UI7.
It seems that Vera handles failures just during the initialisation of plugins.
Extract from the wiki : http://support.getvera.com/customer/portal/articles/1710500-plugin-development
lu_SetCommFailure sets a "communication failure" flag for the device, which logs a critical error, and allows the user to see that the device is having problems. Whenever the Luup engine reloads, such as clicking 'save', the flag is cleared again.
I understand, that it is expected that the luup engine reloads to try to solve the communication problems with a new startup of the plugin.
Perhaps it could be possible with UI5, but now UI7 seems to be designed differently and reloads less often.
My problem is that I want to report a failure during regular jobs, and that the plugin, staying reachable, is able to retry its process on user demand.
After having talked to the support, it appears that there’s no standard solution.
The easier is to set a variable and then it’s possible to watch it and to react to communication problems.
I would have prefered a way that allows to store the communication fault (in the alerts on UI).
EDIT :
Besides, you can process events in an alternate event server :
http://wiki.micasaverde.com/index.php/AlternateEventServer
If you want to able to add a notification by the standard process : here are some notes.
In the file ‘D_Plugin.json’, add :
...
"Tabs":[
...
{
"Label": {
"lang_tag": "ui7_notifications",
"text": "Notifications"
},
"Position": 4,
"TabType": "javascript",
"ScriptName": "shared.js",
"Function": "device_notifications"
},
...
],
...
"eventList2":[
{
"id": 1,
"label": {
"lang_tag": "ui7_SurveillanceStationRemote_has_com_failure",
"text": "Whenever _DEVICE_NAME_ has a communication failure"
},
"serviceId": "urn:upnp-org:serviceId:SurveillanceStationRemote1",
"serviceStateTable": {
"CommFailure": {
"value": "1",
"comparisson": "="
}
}
}
],
...
AND BE CAREFUL !!!
The variable your are watching must be defined in the file ‘D_Plugin.xml’.
If not, you run the risk of having the LUUP engine reloading infinitely.