mirror of
https://github.com/adrianjagielak/home-assistant-futurehome.git
synced 2026-05-28 05:55:40 +00:00
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>
This commit is contained in:
@@ -72,12 +72,15 @@ export function _sensor_numeric__components(
|
||||
|
||||
if (!data) return undefined;
|
||||
|
||||
const device_class = data[0];
|
||||
let device_class = data[0];
|
||||
const name = data[1];
|
||||
let unit = svc.props?.sup_units?.[0] ?? data[2];
|
||||
if (unit === 'C') unit = '°C';
|
||||
if (unit === 'F') unit = '°F';
|
||||
if (unit === 'kph') unit = 'km/h';
|
||||
if (unit === 'Lux') unit = 'lx';
|
||||
// HA rejects illuminance + %; drop device_class for percentage-reporting sensors
|
||||
if (device_class === 'illuminance' && unit === '%') device_class = undefined;
|
||||
const state_class = data[3];
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user