Return empty dictionary at first for attributes (#41348)

This commit is contained in:
springstan authored and GitHub committed 2020-10-06 18:08:53 +02:00
1 parent 4d12fcc218
commit 61d9067a49
16 files changed
+75 -77

No files matched your search

@@ -112,6 +112,6 @@ class HomeKitAlarmControlPanelEntity(HomeKitEntity, AlarmControlPanelEntity):
"""Return the optional state attributes."""
battery_level = self.service.value(CharacteristicsTypes.BATTERY_LEVEL)
if battery_level:
return {ATTR_BATTERY_LEVEL: battery_level}
return {}
if not battery_level:
return {}
return {ATTR_BATTERY_LEVEL: battery_level}
@@ -120,10 +120,9 @@ class HomeKitGarageDoorCover(HomeKitEntity, CoverEntity):
obstruction_detected = self.service.value(
CharacteristicsTypes.OBSTRUCTION_DETECTED
)
if obstruction_detected:
return {"obstruction-detected": obstruction_detected}
return {}
if not obstruction_detected:
return {}
return {"obstruction-detected": obstruction_detected}
class HomeKitWindowCover(HomeKitEntity, CoverEntity):
@@ -250,6 +249,6 @@ class HomeKitWindowCover(HomeKitEntity, CoverEntity):
obstruction_detected = self.service.value(
CharacteristicsTypes.OBSTRUCTION_DETECTED
)
if obstruction_detected:
return {"obstruction-detected": obstruction_detected}
return {}
if not obstruction_detected:
return {}
return {"obstruction-detected": obstruction_detected}