warhammerkid / bluetti_mqtt

MQTT interface for Bluetti power stations
MIT License
133 stars 47 forks source link

mqtt sensors not belonging to bluetti device in HA #58

Open renarena opened 1 year ago

renarena commented 1 year ago

in HA with mqtt auto discovery i have a bluetti device with nearly no sensors and i have a lot of sensors without device. It would be nice to have all sensors belonging to bluetti device after discovery rather then need to add them manually.

I dont know the exact circumstances, but for my thermostats with another topic structure the sensors belong to the respective devices.

Bluetti topics: bluetti/state/ac200_device_id/detail homeassistant /sensor/device_id_detail_name

Thermostat topics: thermostat/room/detail homeassistant/sensor/device_id/detail_name https://github.com/zewelor/bt-mqtt-gateway

areyoufserious commented 1 year ago

i confirm this issue at least once mqtt device (and entitiies) had proper values (maybe at first lauunch?) but since that all device entities are unavailable and i can just see separate topics in mqtt

warhammerkid commented 1 year ago

Sorry for the slow response on this - just getting back around to work on this. I installed the latest version and booted up my Home Assistant server to test, and here's how it should be working:

For each sensor there should be a retained message on the MQTT server like:

homeassistant/sensor/2000000000000_ac_input_power/config {"state_topic":"bluetti/state/AC300-2000000000000/ac_input_power","device":{"identifiers":["2000000000000"],"manufacturer":"Bluetti","name":"AC300 2000000000000","model":"AC300"},"unique_id":"2000000000000_ac_input_power","object_id":"AC300_ac_input_power","name":"AC Input Power","unit_of_measurement":"W","device_class":"power","state_class":"measurement","force_update":true}

The new value should be published to a topic like:

bluetti/state/AC300-2000000000000/ac_input_power 0

I'm curious if something got corrupted somehow here and it no longer looks like this?

renarena commented 1 year ago

other devices have topics like this:

homeassistant/climate/mac_address/device_id/config
homeassistant/sensor/mac_address/device_id/config

https://www.home-assistant.io/integrations/mqtt/ tell:

The discovery topic needs to follow a specific format:

//[/]/config

but bluetti has no device id before the sensor name:

homeassistant/sensor/2000000000000_ac_input_power/config

try homeassistant/sensor/2000000000000/ac_input_power/config instead?