mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 01:08:12 +00:00
Fix display state to return None instead of STATE_UNKNOWN in NUT (#143297)
Fix return value to avoid STATE_UNKNOWN
This commit is contained in:
parent
b4344a8de2
commit
f5c0c207ec
@ -13,7 +13,6 @@ from homeassistant.components.sensor import (
|
||||
)
|
||||
from homeassistant.const import (
|
||||
PERCENTAGE,
|
||||
STATE_UNKNOWN,
|
||||
EntityCategory,
|
||||
UnitOfApparentPower,
|
||||
UnitOfElectricCurrent,
|
||||
@ -1120,9 +1119,9 @@ class NUTSensor(NUTBaseEntity, SensorEntity):
|
||||
return status.get(self.entity_description.key)
|
||||
|
||||
|
||||
def _format_display_state(status: dict[str, str]) -> str:
|
||||
def _format_display_state(status: dict[str, str]) -> str | None:
|
||||
"""Return UPS display state."""
|
||||
try:
|
||||
return ", ".join(STATE_TYPES[state] for state in status[KEY_STATUS].split())
|
||||
except KeyError:
|
||||
return STATE_UNKNOWN
|
||||
return None
|
||||
|
Loading…
x
Reference in New Issue
Block a user