Skip to content

Handle Battery CC notifications#1365

Merged
MartinHjelmare merged 3 commits into
home-assistant-libs:mainfrom
raman325:battery
Feb 9, 2026
Merged

Handle Battery CC notifications#1365
MartinHjelmare merged 3 commits into
home-assistant-libs:mainfrom
raman325:battery

Conversation

@raman325
Copy link
Copy Markdown
Contributor

@raman325 raman325 commented Feb 5, 2026

Adds support for Battery CC notifications

I noticed we don't convert Entry Control and Notification CC notification values to enums (EntryControlEventType, EntryControlDataType, NotificationType, NotificationEvent) and just pass the raw ints. zwave-js provides the corresponding label attributes in the event automatically, so I guess this is OK, but it creates some inconsistency in what we convert to a Python friendly model and what we don't.

If we did convert those values to enums, we'd have to figure out how to handle unrecognized enums so that we don't destroy data in the event (e.g. right now our strategy is to return the UNKNOWN value for enums that support it which is -1. If we were to replace an integer value that is unrecognized, it would get serialized as -1 when the event gets emitted by HA).

Copilot AI review requested due to automatic review settings February 5, 2026 20:08
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for Battery CC notifications and updates existing notification handlers to use strongly-typed enums instead of raw integers. The changes improve type safety and code maintainability by replacing integer fields with enum types throughout the notification system.

Changes:

  • Adds new BatteryNotification class with enums for event types and urgency levels
  • Converts notification field types from integers/strings to enums (EntryControlEventType, NotificationType, NotificationEvent, MultilevelSwitchStartLevelChangeDirection)
  • Updates notification handler to include Battery CC and reorders cases alphabetically for better maintainability

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
zwave_js_server/const/command_class/battery.py Adds new enum constants for Battery CC notification events and replacement status
zwave_js_server/const/command_class/multilevel_switch.py Adds MultilevelSwitchStartLevelChangeDirection enum for direction values
zwave_js_server/model/notification.py Adds BatteryNotification class, updates existing notifications to use enum types, fixes direction field default value
zwave_js_server/model/node/init.py Adds Battery CC case to notification handler, reorders cases alphabetically
test/model/test_node.py Adds Battery CC notification test, updates existing tests to assert enum values, uses raw integers for ccId in test data

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread zwave_js_server/model/notification.py Outdated
@raman325 raman325 changed the title Handle Battery CC notification and use enums elsewhere Handle Battery CC notification Feb 5, 2026
@raman325 raman325 changed the title Handle Battery CC notification Handle Battery CC notifications Feb 5, 2026
@raman325 raman325 marked this pull request as draft February 5, 2026 20:28
@raman325 raman325 marked this pull request as ready for review February 5, 2026 20:43
Copy link
Copy Markdown
Contributor

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

If you're looking for easy fixes around notifications, these comments would be nice to address:

zwave-js/backlog#139 (comment)

@MartinHjelmare MartinHjelmare merged commit 8135d43 into home-assistant-libs:main Feb 9, 2026
6 checks passed
@raman325 raman325 deleted the battery branch February 12, 2026 01:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants