# Solarlife MPPT BLE Client This Python application connects to an X45, 10 A, MPPT solar charge controller via Bluetooth Low Energy (BLE). It reads the data from the charge controller and publishes it to HomeAssistant using MQTT. The application establishes a connection to the MQTT broker and the BLE device, retrieves the details from the charge controller periodically, and publishes the data to MQTT topics. HomeAssistant can then subscribe to these topics to display the data in its user interface. ![HomeAssistant Screenshot](/images/hass.png) ## Requirements - Python 3.7+ - [Bleak](https://github.com/hbldh/bleak) - A BLE library for Python - [Paho MQTT](https://github.com/eclipse/paho.mqtt.python) - A MQTT library for Python ## Installation 1. Clone the repository: ```bash git clone https://github.com/subDesTagesMitExtraKaese/solarlife-mppt-ble-client.git ``` 2. Change into the project directory: ```bash cd solarlife-mppt-ble-client ``` 3. Install the required Python packages using pip: ```bash pip install -r requirements.txt ``` ## Usage 1. Run the application by providing the required command-line arguments: ```bash python main.py --host --port --username --password ``` Replace `` with the Bluetooth address of your MPPT solar charge controller. The other arguments are optional and can be used to customize the MQTT connection. 2. The application will connect to the MQTT broker and the BLE device. It will periodically retrieve the data from the charge controller and publish it to MQTT topics. 3. HomeAssistant can subscribe to the MQTT topics to display the published data in its user interface. ## MQTT Topics The application publishes the data to MQTT topics in the following format: - Sensor state topic: `homeassistant/sensor/solarlife//state` - Sensor configuration topic (MQTT Discovery): `homeassistant/sensor/solarlife//config` The `` represents the data field from the charge controller. For example, `battery_percentage`, `battery_voltage`, etc. ## HomeAssistant Integration To integrate the published data into HomeAssistant, you can use the MQTT integration and configure it to subscribe to the MQTT topics published by the BLE client. Here's an example configuration in HomeAssistant's `configuration.yaml` file: ```yaml sensor: - platform: mqtt name: "Solarlife Battery Percentage" state_topic: "homeassistant/sensor/solarlife/battery_percentage/state" unit_of_measurement: "%" ``` Replace `state_topic` with the appropriate MQTT topic for each sensor field you want to display. ## Contributing Contributions are welcome! If you encounter any issues or have suggestions for improvements, please open an issue or submit a pull request. ## License This project is licensed under the [MIT License](LICENSE).