Get unit from sensor using zwavejs2mqtt

I need to check the unit of a sensor. This information is visible in zwavejs2mqtt. How can I access this information in Home Assistant (template)?

Try unit_of_measurement.

{{ state_attr("entity_name", "unit_of_measurement") }}

Thanks, is this value updated, if zwavejs reports something else?

I don’t think so. That one is based on your unit preferences, and is what is used in conjunction with the sensor state.

There’s also a native_unit_of_measurement, I think that should reflect the unit reported by the driver.

1 Like

Unfortunately the device reports null.

It’s possible that property isn’t available to templates.

So this is not accessible for me then?

Not from templates at least. State object attributes are documented here. Native unit is not exposed.

1 Like

Just curious, why do you need it?

My motion sensor from Fibaro has a known (but not solvable) issue that it reports the wrong values. My guess is, that it reports lux instead of °C. I can cover most cases with a upper and lower limit (e.g. 100°C), but if the brightness is at 30 lx it still might be triggering 30 °C (or lux but for temperature). These are rare cases, but they will happen, I guess.

My previous software could do that and I never had any false values for years.