Skip to content

Commit

Permalink
Avoid exporting the value when the notification type doesn't indicate…
Browse files Browse the repository at this point in the history
… that this would be useful.

Fix for github issue # 2.

Signed-off-by: Jon Seymour <[email protected]>
  • Loading branch information
Jon Seymour committed Jan 21, 2016
1 parent b5cef62 commit 86e99ed
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions notification.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,23 @@ Notification * exportNotification(API * api, OpenZWave::Notification const* noti
{
Notification * result = newNotification(notification->GetType());
result->node = exportNode(api, notification->GetHomeId(), notification->GetNodeId());
result->notificationCode =
notification->GetType() == OpenZWave::Notification::Type_Notification
? notification->GetNotification()
: -1;
result->value = exportValue(api, notification->GetHomeId(), notification->GetValueID());
OpenZWave::Notification::NotificationType nt = notification->GetType();
result->notificationCode = -1;

switch (nt) {
case OpenZWave::Notification::Type_ValueAdded:
case OpenZWave::Notification::Type_ValueRemoved:
case OpenZWave::Notification::Type_ValueChanged:
case OpenZWave::Notification::Type_ValueRefreshed:
result->value = exportValue(api, notification->GetHomeId(), notification->GetValueID());
break;
case OpenZWave::Notification::Type_Notification:
result->notificationCode = notification->GetNotification();
break;
default:
break;
// do nothing
}
return result;
}

Expand Down

0 comments on commit 86e99ed

Please sign in to comment.