Skip to content

Refresh extra battery serial number and model in the device registry#378

Merged
rabits merged 1 commit into
rabits:mainfrom
GnoX:fix/extra-battery-serial-number
Jun 17, 2026
Merged

Refresh extra battery serial number and model in the device registry#378
rabits merged 1 commit into
rabits:mainfrom
GnoX:fix/extra-battery-serial-number

Conversation

@GnoX

@GnoX GnoX commented Jun 14, 2026

Copy link
Copy Markdown
Collaborator

The serial number of an extra battery rides in only about half of the device's DisplayPropertyUpload messages, so it can arrive after the extra-battery entity - and its device registry entry - were first created. EcoflowBatteryAddonEntity.device_info exposes serial_number (and the model name derived from it via battery_name_from_device), but HA reads device_info only once when the entity is added. If no SN-bearing message had landed before platform setup, the registry entry was written with serial_number=None and a fallback "Extra Battery" model and then never refreshed - so the serial number was missing "in some cases" depending on timing.

This PR makes EcoflowBatteryAddonEntity register a state-update callback on battery_{index}_sn and pushes the value into the device registry (async_update_device) once it is known, updating both the serial number and the model. It is a no-op when the SN is empty, the registry entry is missing, or the entry is already current.

Should address discussion in #362

@GnoX GnoX self-assigned this Jun 14, 2026
@GnoX GnoX added the bug Something isn't working label Jun 14, 2026
@GnoX GnoX marked this pull request as ready for review June 14, 2026 20:01
@GnoX GnoX requested a review from rabits June 14, 2026 20:01

@rabits rabits left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Looks good, thank you!

@rabits rabits merged commit 69f6bd0 into rabits:main Jun 17, 2026
4 checks passed
@GnoX GnoX deleted the fix/extra-battery-serial-number branch June 17, 2026 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants