mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 04:37:06 +00:00
Handle marker attrs that may not exist (#27519)
marker-high-levels and marker-low-levels may not exist in printer attributes returned by CUPS, so we'll use .get() to avoid this and default to None: KeyError: 'marker-high-levels' Fixes #27518
This commit is contained in:
parent
5b410ff3a5
commit
57b8d1889a
@ -276,11 +276,11 @@ class MarkerSensor(Entity):
|
||||
if self._attributes is None:
|
||||
return None
|
||||
|
||||
high_level = self._attributes[self._printer]["marker-high-levels"]
|
||||
high_level = self._attributes[self._printer].get("marker-high-levels")
|
||||
if isinstance(high_level, list):
|
||||
high_level = high_level[self._index]
|
||||
|
||||
low_level = self._attributes[self._printer]["marker-low-levels"]
|
||||
low_level = self._attributes[self._printer].get("marker-low-levels")
|
||||
if isinstance(low_level, list):
|
||||
low_level = low_level[self._index]
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user