Improve ISY994 NodeServer sorting and format sensor display values (#42050)
This commit is contained in:
parent
a17da16dd2
commit
c4821bfa74
3 changed files with 15 additions and 3 deletions
|
@ -15,6 +15,8 @@ from .const import (
|
|||
ISY994_VARIABLES,
|
||||
UOM_DOUBLE_TEMP,
|
||||
UOM_FRIENDLY_NAME,
|
||||
UOM_INDEX,
|
||||
UOM_ON_OFF,
|
||||
UOM_TO_STATES,
|
||||
)
|
||||
from .entity import ISYEntity, ISYNodeEntity
|
||||
|
@ -58,6 +60,9 @@ class ISYSensorEntity(ISYNodeEntity):
|
|||
if isy_states:
|
||||
return isy_states
|
||||
|
||||
if uom in [UOM_ON_OFF, UOM_INDEX]:
|
||||
return uom
|
||||
|
||||
return UOM_FRIENDLY_NAME.get(uom)
|
||||
|
||||
@property
|
||||
|
@ -74,6 +79,9 @@ class ISYSensorEntity(ISYNodeEntity):
|
|||
if isinstance(uom, dict):
|
||||
return uom.get(value, value)
|
||||
|
||||
if uom in [UOM_INDEX, UOM_ON_OFF]:
|
||||
return self._node.formatted
|
||||
|
||||
# Handle ISY precision and rounding
|
||||
value = convert_isy_value_to_hass(value, uom, self._node.prec)
|
||||
|
||||
|
@ -88,7 +96,7 @@ class ISYSensorEntity(ISYNodeEntity):
|
|||
"""Get the Home Assistant unit of measurement for the device."""
|
||||
raw_units = self.raw_unit_of_measurement
|
||||
# Check if this is a known index pair UOM
|
||||
if isinstance(raw_units, dict):
|
||||
if isinstance(raw_units, dict) or raw_units in [UOM_ON_OFF, UOM_INDEX]:
|
||||
return None
|
||||
if raw_units in (TEMP_FAHRENHEIT, TEMP_CELSIUS, UOM_DOUBLE_TEMP):
|
||||
return self.hass.config.units.temperature_unit
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue