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
|
@ -162,6 +162,9 @@ async def async_setup_entry(
|
|||
if not isy.connected:
|
||||
return False
|
||||
|
||||
# Trigger a status update for all nodes, not done automatically in PyISY v2.x
|
||||
await hass.async_add_executor_job(isy.nodes.update)
|
||||
|
||||
_categorize_nodes(hass_isy_data, isy.nodes, ignore_identifier, sensor_identifier)
|
||||
_categorize_programs(hass_isy_data, isy.programs)
|
||||
_categorize_variables(hass_isy_data, isy.variables, variable_identifier)
|
||||
|
|
|
@ -200,7 +200,7 @@ UOM_ON_OFF = "2"
|
|||
# Z-Wave Categories: https://www.universal-devices.com/developers/wsdk/5.0.4/4_fam.xml
|
||||
NODE_FILTERS = {
|
||||
BINARY_SENSOR: {
|
||||
FILTER_UOM: [],
|
||||
FILTER_UOM: [UOM_ON_OFF],
|
||||
FILTER_STATES: [],
|
||||
FILTER_NODE_DEF_ID: [
|
||||
"BinaryAlarm",
|
||||
|
@ -282,7 +282,7 @@ NODE_FILTERS = {
|
|||
FILTER_ZWAVE_CAT: ["109", "119"],
|
||||
},
|
||||
SWITCH: {
|
||||
FILTER_UOM: [UOM_ON_OFF, "78"],
|
||||
FILTER_UOM: ["78"],
|
||||
FILTER_STATES: ["on", "off"],
|
||||
FILTER_NODE_DEF_ID: [
|
||||
"AlertModuleArmed",
|
||||
|
@ -322,6 +322,7 @@ NODE_FILTERS = {
|
|||
|
||||
UOM_FRIENDLY_NAME = {
|
||||
"1": "A",
|
||||
UOM_ON_OFF: "", # Binary, no unit
|
||||
"3": f"btu/{TIME_HOURS}",
|
||||
"4": TEMP_CELSIUS,
|
||||
"5": LENGTH_CENTIMETERS,
|
||||
|
|
|
@ -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