Refresh extra battery serial number and model in the device registry#378
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The serial number of an extra battery rides in only about half of the device's
DisplayPropertyUploadmessages, so it can arrive after the extra-battery entity - and its device registry entry - were first created.EcoflowBatteryAddonEntity.device_infoexposesserial_number(and the model name derived from it viabattery_name_from_device), but HA readsdevice_infoonly once when the entity is added. If no SN-bearing message had landed before platform setup, the registry entry was written withserial_number=Noneand a fallback"Extra Battery"model and then never refreshed - so the serial number was missing "in some cases" depending on timing.This PR makes
EcoflowBatteryAddonEntityregister a state-update callback onbattery_{index}_snand 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