cyrils / renogy-bt

Python library to read Renogy compatible BT-1 or BT-2 bluetooth modules using Raspberry Pi.
GNU General Public License v3.0
76 stars 27 forks source link

MQTT Discovery support #62

Closed FrancineMatos closed 4 months ago

FrancineMatos commented 4 months ago

I've added the MQTT Discovery function that auto create the components in Home Assistant.

1 - We need to add this to DataLogger.py (for some reason i cant paste the code here it's broke the editor) image

2 - some changes need to be done on log_mqtt function still in DataLogger.py image

3 - We need to create the call for the new function on example.py or whathever you are using to start the renogy image

4 - We neet to indicate in the config.ini the instance name of our home assistant image

A video fo the thing working: https://github.com/cyrils/renogy-bt/assets/148077119/13f61b24-5d9e-4b15-a75d-4f838eb8766e

Files.zip

FrancineMatos commented 4 months ago

Another improvment, now it's return the device class and the unit of measurement of the components by Home Assistant MQTT Discovery so the sensor is correctly registred.

Was necessary to change a bit the data structure but i dont think that it can do something bad

Some changes in DataLogger.py and RoverClient.py

Files.zip

cyrils commented 4 months ago

Instead of the zip file can you create a PR against branch mqtt-discovery?

FrancineMatos commented 4 months ago

I'm not famillyar with githut plataform but i cant try. I ll find some tutorial teaching how to do it.

FrancineMatos commented 4 months ago

Instead of the zip file can you create a PR against branch mqtt-discovery?

Ok, i think i did it, my first time using github to update a repository but i guess i did it rigth.

cyrils commented 4 months ago

Ah ok. Thanks for the PR, I bet you learned a thing or two today. 😊