I have experienced the inconvenience that the distance of my Zigbee presence sensors from Tuya https://www.zigbee2mqtt.io/devices/ZY-M100-24G.html do neither have a device_class nor a unit in Home assistant.
As far as I understand Zigbee2MQTT just sends the json payload and the interpretation happens somewhere in HA.
The payload looks like this
{
"distance": 0,
"illuminance_lux": 62,
"linkquality": 65,
"move_sensitivity": 2,
"presence": false,
"presence_sensitivity": 2.5,
"presence_timeout": 5,
"radar_range": 5.5,
"state": "none"
}
When checking the debug information of the device in HA, illuminance_lux is set correctly with device_class, unit_of_measurement and state_class:
availability:
- topic: zigbee2mqtt/bridge/state
value_template: '{{ value_json.state }}'
device:
identifiers:
- zigbee2mqtt_0xa4c138b62a647ced
manufacturer: Tuya
model: 24G MmWave radar human presence motion sensor (ZY-M100-24G)
via_device: zigbee2mqtt_bridge_0x00124b00258d4e6f
name: Presence/Küche
device_class: illuminance
enabled_by_default: true
object_id: presence/küche_illuminance_lux
origin:
name: Zigbee2MQTT
support_url: https://www.zigbee2mqtt.io
sw_version: 1.40.1
state_class: measurement
state_topic: zigbee2mqtt/Presence/Küche
unique_id: 0xa4c138b62a647ced_illuminance_lux_zigbee2mqtt
unit_of_measurement: lx
value_template: '{{ value_json.illuminance_lux }}'
platform: mqtt
However, distance is missing these settings:
availability:
- topic: zigbee2mqtt/bridge/state
value_template: '{{ value_json.state }}'
device:
identifiers:
- zigbee2mqtt_0xa4c138b62a647ced
manufacturer: Tuya
model: 24G MmWave radar human presence motion sensor (ZY-M100-24G)
via_device: zigbee2mqtt_bridge_0x00124b00258d4e6f
name: Presence/Küche
enabled_by_default: true
object_id: presence/küche_distance
origin:
name: Zigbee2MQTT
support_url: https://www.zigbee2mqtt.io
sw_version: 1.40.1
state_topic: zigbee2mqtt/Presence/Küche
unique_id: 0xa4c138b62a647ced_distance_zigbee2mqtt
value_template: '{{ value_json.distance }}'
name: Distance
platform: mqtt
That makes for example the history more or less useless:
The question is: Does anyone have an idea how to add/edit this information? There is probably a workaround with an additional template sensor, but the cleaner solution would be to fix the configuration.