celsworth / lxp-bridge

A bridge to MQTT/InfluxDB/Postgres for communications with LuxPower inverters
MIT License
13 stars 15 forks source link

Fix: add missing entities to HomeAssistant autodiscovery #190

Closed celsworth closed 1 year ago

celsworth commented 1 year ago

Missed in #189

celsworth commented 1 year ago

This is a bit unknown because HA doesn't seem to expect status/warning/fault codes like this to be sent to it?

At least, I can't see anything that looks like a matching device_class in https://developers.home-assistant.io/docs/core/entity/sensor/#available-state-classes

So hopefully "None" will work..

jacovt commented 1 year ago

This is a bit unknown because HA doesn't seem to expect status/warning/fault codes like this to be sent to it?

At least, I can't see anything that looks like a matching device_class in https://developers.home-assistant.io/docs/core/entity/sensor/#available-state-classes

So hopefully "None" will work..

@celsworth, not sure if you have seen this (see the section about diagnostic categories): https://developers.home-assistant.io/blog/2021/10/26/config-entity/

I believe it would be the most logical place to "categorize" it.

It comes out looking a little something like this in HA: Selection_027

I will dig around a little to see how to classify those on MQTT.

celsworth commented 1 year ago

Thanks @jacovt, this does look promising. The previous solution does indeed fail with this:

2023-08-25 07:26:13.733 ERROR (MainThread) [homeassistant.components.mqtt.mixins] Error 'expected SensorDeviceClass or one of 'date', 'enum', 'timestamp', 'apparent_power', 'aqi', 'atmospheric_pressure', 'battery', 'carbon_monoxide', 'carbon_dioxide', 'current', 'data_rate', 'data_size', 'distance', 'duration', 'energy', 'energy_storage', 'frequency', 'gas', 'humidity', 'illuminance', 'irradiance', 'moisture', 'monetary', 'nitrogen_dioxide', 'nitrogen_monoxide', 'nitrous_oxide', 'ozone', 'ph', 'pm1', 'pm10', 'pm25', 'power_factor', 'power', 'precipitation', 'precipitation_intensity', 'pressure', 'reactive_power', 'signal_strength', 'sound_pressure', 'speed', 'sulphur_dioxide', 'temperature', 'volatile_organic_compounds', 'volatile_organic_compounds_parts', 'voltage', 'volume', 'volume_storage', 'water', 'weight', 'wind_speed' for dictionary value @ data['device_class']'

And none of those are really appropriate. So I think I need to find the magic combination of device_class / state_class / unit_of_measurement / the mqtt topic (which currently is homeassistant/sensor/lxp_BA112121024/status/config, I think the the sensor part there is wrong). I'm finding the docs a bit sparse on how to get this right :)

celsworth commented 1 year ago

Ok, getting somewhere. Got them to appear in HA and I think simply removing all of device_class / state_class / unit_of_measurement is the way to go.

Having the integers might be a bit useless though, I do wonder if its time to convert them to strings. But I'm not sure I want to change the contents of inputs/all, so I might have HA watch new messages for these. Yeah time for a new PR to clean all this up :)