Skip to content

Commit 11ee7d6

Browse files
authored
Remove vesync unused extra attributes, refine enums (home-assistant#153171)
1 parent 080a7dc commit 11ee7d6

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

homeassistant/components/vesync/fan.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,17 +156,27 @@ def extra_state_attributes(self) -> dict[str, Any]:
156156
if hasattr(self.device.state, "active_time"):
157157
attr["active_time"] = self.device.state.active_time
158158

159-
if hasattr(self.device.state, "display_status"):
159+
if (
160+
hasattr(self.device.state, "display_status")
161+
and self.device.state.display_status is not None
162+
):
160163
attr["display_status"] = getattr(
161164
self.device.state.display_status, "value", None
162165
)
163166

164-
if hasattr(self.device.state, "child_lock"):
167+
if (
168+
hasattr(self.device.state, "child_lock")
169+
and self.device.state.child_lock is not None
170+
):
165171
attr["child_lock"] = self.device.state.child_lock
166172

167-
if hasattr(self.device.state, "nightlight_status"):
168-
attr["night_light"] = self.device.state.nightlight_status
169-
173+
if (
174+
hasattr(self.device.state, "nightlight_status")
175+
and self.device.state.nightlight_status is not None
176+
):
177+
attr["night_light"] = getattr(
178+
self.device.state.nightlight_status, "value", None
179+
)
170180
if hasattr(self.device.state, "mode"):
171181
attr["mode"] = self.device.state.mode
172182

tests/components/vesync/snapshots/test_fan.ambr

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@
8282
'display_status': 'on',
8383
'friendly_name': 'Air Purifier 131s',
8484
'mode': 'sleep',
85-
'night_light': None,
8685
'percentage': None,
8786
'percentage_step': 33.333333333333336,
8887
'preset_mode': 'sleep',
@@ -182,7 +181,7 @@
182181
'display_status': 'on',
183182
'friendly_name': 'Air Purifier 200s',
184183
'mode': 'manual',
185-
'night_light': <DeviceStatus.OFF: 'off'>,
184+
'night_light': 'off',
186185
'percentage': 33,
187186
'percentage_step': 33.333333333333336,
188187
'preset_mode': None,
@@ -282,7 +281,7 @@
282281
'display_status': 'on',
283282
'friendly_name': 'Air Purifier 400s',
284283
'mode': 'manual',
285-
'night_light': <DeviceStatus.OFF: 'off'>,
284+
'night_light': 'off',
286285
'percentage': 25,
287286
'percentage_step': 25.0,
288287
'preset_mode': None,
@@ -383,7 +382,7 @@
383382
'display_status': 'on',
384383
'friendly_name': 'Air Purifier 600s',
385384
'mode': 'manual',
386-
'night_light': <DeviceStatus.OFF: 'off'>,
385+
'night_light': 'off',
387386
'percentage': 25,
388387
'percentage_step': 25.0,
389388
'preset_mode': None,

0 commit comments

Comments
 (0)