ZHA patch for more precision display of data for all Zigbee devices.
Opened this issue · 0 comments
pvvx commented
ZHA patch for more precision display of data for all Zigbee devices.
Find the file components/zha/sensor.py
(base path ~/.lib64/python3.xx/site-packages/homeassistant
) and fix it:
class Sensor(ZhaEntity, SensorEntity):
"""Base ZHA sensor."""
_attribute_name: int | str | None = None
_decimals: int = 2
_divisor: int = 1
_multiplier: int | float = 1
"""Return the state of the entity."""
# per zcl specs battery percent is reported at 200% ¯\_(ツ)_/¯
if not isinstance(value, numbers.Number) or value == -1:
return None
value = round(value / 2, 1)
return value
site-packages/homeassistant/components/zha/core/cluster_handlers/general.py :
class DeviceTemperature(ClusterHandler):
"""Device Temperature cluster handler."""
REPORT_CONFIG = (
{
"attr": "current_temperature",
"config": (REPORT_CONFIG_MIN_INT, REPORT_CONFIG_MAX_INT, 10),
},
)
site-packages/homeassistant/components/zha/core/cluster_handlers/measurement.py :
class RelativeHumidity(ClusterHandler):
"""Relative Humidity measurement cluster handler."""
REPORT_CONFIG = (
AttrReportConfig(
attr="measured_value",
config=(REPORT_CONFIG_MIN_INT, REPORT_CONFIG_MAX_INT, 50),
),
)
...
class TemperatureMeasurement(ClusterHandler):
"""Temperature measurement cluster handler."""
REPORT_CONFIG = (
AttrReportConfig(
attr="measured_value",
config=(REPORT_CONFIG_MIN_INT, REPORT_CONFIG_MAX_INT, 10),
),
)
site-packages/homeassistant/components/zha/core/const.py :
REPORT_CONFIG_ATTR_PER_REQ = 3
REPORT_CONFIG_MAX_INT = 180
REPORT_CONFIG_MAX_INT_BATTERY_SAVE = 10800
REPORT_CONFIG_MIN_INT = 30
REPORT_CONFIG_MIN_INT_ASAP = 1