Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle UserAlerts and ManufacturerSpecificDBReady notifications #208

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions src-api/openzwave/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ class ZWaveNetwork(ZWaveObject):
* SIGNAL_NOTIFICATION = 'Notification'
* SIGNAL_CONTROLLER_COMMAND = 'ControllerCommand'
* SIGNAL_CONTROLLER_WAITING = 'ControllerWaiting'
* SIGNAL_USER_ALERTS = 'UserAlerts'
* SIGNAL_MANUFACTURER_SPECIFIC_DB_READY = 'ManufacturerSpecificDBReady'

The table presented below sets notifications in the order they might typically be received,
and grouped into a few logically related categories. Of course, given the variety
Expand Down Expand Up @@ -282,6 +284,8 @@ class ZWaveNetwork(ZWaveObject):
SIGNAL_NOTIFICATION = 'Notification'
SIGNAL_CONTROLLER_COMMAND = 'ControllerCommand'
SIGNAL_CONTROLLER_WAITING = 'ControllerWaiting'
SIGNAL_USER_ALERTS = 'UserAlerts'
SIGNAL_MANUFACTURER_SPECIFIC_DB_READY = 'ManufacturerSpecificDBReady'

STATE_STOPPED = 0
STATE_FAILED = 1
Expand Down Expand Up @@ -984,6 +988,10 @@ def zwcallback(self, args):
self._handle_driver_removed(args)
elif notify_type == self.SIGNAL_CONTROLLER_COMMAND:
self._handle_controller_command(args)
elif notify_type == self.SIGNAL_USER_ALERTS:
self._handle_user_alerts(args)
elif notify_type == self.SIGNAL_MANUFACTURER_SPECIFIC_DB_READY:
self._handle_manufacturer_specific_db_ready(args)
else:
logger.warning(u'Skipping unhandled notification [%s]', args)
except:
Expand Down Expand Up @@ -1600,6 +1608,32 @@ def _handle_controller_command(self, args):
"""
self._controller._handle_controller_command(args)

def _handle_user_alerts(self, args):
"""
Called when the library generates a warning or notification for the user
(e.g. out-of-date config files). The actual warning text is missing from the args dict,
but it shows up in the C++ logging output.

:param args: data sent by the notification
:type args: dict()

"""
logger.info(u'Z-Wave Notification UserAlert, see OZW_Log for details : %s', args)
dispatcher.send(self.SIGNAL_USER_ALERTS, \
**{'network': self})

def _handle_manufacturer_specific_db_ready(self, args):
"""
Called when the ManufacturerSpecific database is ready.

:param args: data sent by the notification
:type args: dict()

"""
logger.debug(u'Z-Wave Notification ManufacturerSpecificDBReady : %s', args)
dispatcher.send(self.SIGNAL_MANUFACTURER_SPECIFIC_DB_READY, \
**{'network': self})

def _handle_msg_complete(self, args):
"""
The last message that was sent is now complete.
Expand Down
2 changes: 2 additions & 0 deletions src-lib/libopenzwave/libopenzwave.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ PyNotifications = [
EnumWithDoc('DriverRemoved').setDoc("The Driver is being removed."),
EnumWithDoc('ControllerCommand').setDoc("When Controller Commands are executed, Notifications of Success/Failure etc are communicated via this Notification."),
EnumWithDoc('NodeReset').setDoc("A node has been reset from OpenZWave's set. The Device has been reset and thus removed from the NodeList in OZW."),
EnumWithDoc('UserAlerts').setDoc("Warnings and Notifications Generated by the library that should be displayed to the user (eg, out of date config files)."),
EnumWithDoc('ManufacturerSpecificDBReady').setDoc("The ManufacturerSpecific Database Is Ready."),
]

PyNotificationCodes = [
Expand Down