Fix TypeError of vacuum battery level None (#62722)

Co-authored-by: Franck Nijhof <frenck@frenck.nl>
This commit is contained in:
htmltiger 2021-12-27 19:55:43 +00:00 committed by GitHub
parent 45ab9a3e33
commit de2adce1ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -650,6 +650,8 @@ class EnergyStorageTrait(_Trait):
def query_attributes(self):
"""Return EnergyStorage query attributes."""
battery_level = self.state.attributes.get(ATTR_BATTERY_LEVEL)
if battery_level is None:
return {}
if battery_level == 100:
descriptive_capacity_remaining = "FULL"
elif 75 <= battery_level < 100: