mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +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 (
|
from homeassistant.const import (
|
||||||
PERCENTAGE,
|
PERCENTAGE,
|
||||||
STATE_UNKNOWN,
|
|
||||||
EntityCategory,
|
EntityCategory,
|
||||||
UnitOfApparentPower,
|
UnitOfApparentPower,
|
||||||
UnitOfElectricCurrent,
|
UnitOfElectricCurrent,
|
||||||
@ -1120,9 +1119,9 @@ class NUTSensor(NUTBaseEntity, SensorEntity):
|
|||||||
return status.get(self.entity_description.key)
|
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."""
|
"""Return UPS display state."""
|
||||||
try:
|
try:
|
||||||
return ", ".join(STATE_TYPES[state] for state in status[KEY_STATUS].split())
|
return ", ".join(STATE_TYPES[state] for state in status[KEY_STATUS].split())
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return STATE_UNKNOWN
|
return None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user