Commit Graph

3 Commits

Author SHA1 Message Date
Jagi ᯅ
1a8a7c2e2c Fix invalid device_class + unit_of_measurement combinations for HA 2026.5 (#32)
HA 2026.5 enforces strict validation of device_class/unit_of_measurement
pairs in MQTT discovery payloads. Four categories were broken:

- power_factor: unit was sent as "power_factor" (the FIMP field name); HA
  requires the field to be omitted or empty for this device class. Fixed by
  normalising the display unit separately from the FIMP data-path key.

- illuminance: unit "Lux" is rejected; normalise to "lx". When a sensor
  reports luminance as "%" (some Z-Wave devices), the illuminance device
  class is dropped so the entity becomes a generic sensor rather than
  triggering a validation error.

- reactive_power (regular/export meter): unit "VAr" is rejected; HA requires
  lowercase "var".

- reactive_power (extended meter values, e.g. p_import_react): the unit
  determination logic fell through to the generic power branch and sent "W";
  reactive power extended values now emit "var", apparent power values emit
  "VA", and reactive energy values emit "kvarh".

Fixes #31

Co-authored-by: Claude <noreply@anthropic.com>
2026-05-16 23:58:19 +02:00
Adrian Jagielak
0d993643fb Fix using the unit reported by the numerical sensor 2025-07-28 16:13:18 +02:00
Adrian Jagielak
a39f2d5928 Refactor sensors 2025-07-26 21:28:23 +02:00