fixes battery setting when device is not available (#2890)

* device: fix battery setting when device is not available
This commit is contained in:
Peter F. Patel-Schneider 2025-06-09 05:31:52 -04:00 committed by GitHub
parent 694513832d
commit bebadc219c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 2 deletions

View File

@ -397,8 +397,8 @@ class Device:
self.persister["_battery"] = feature.value
return battery
except Exception:
if self.persister and battery_feature is None:
self.persister["_battery"] = result
if self.persister and battery_feature is None and result is not None:
self.persister["_battery"] = result.value
def set_battery_info(self, info):
"""Update battery information for device, calling changed callback if necessary"""