This Python application connects to an X45 MPPT solar charge controller via Bluetooth Low Energy (BLE).

subDesTagesMitExtraKaese 0b089820f7 update readme 3 days ago
images 56a50038f2 init 1 year ago
src 006552b680 fix variable load_daily_energy 3 days ago
tests 006552b680 fix variable load_daily_energy 3 days ago
.gitignore 5444350e5d merge fix from #1 6 days ago
LICENSE 56a50038f2 init 1 year ago
README.md 0b089820f7 update readme 3 days ago
main.py c54734d9ea add parameters to homeassistant 3 days ago
renovate.json d23f27c3aa Add renovate.json 1 year ago
requirements.txt df39d9eb7c Merge remote-tracking branch 'origin/renovate/bleak-0.x' 1 month ago

README.md

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

Requirements

  • Python 3.10+
  • Bleak - A BLE library for Python
  • aiomqtt - A MQTT library for Python

Installation

  1. Clone the repository:

    git clone https://github.com/subDesTagesMitExtraKaese/solarlife-mppt-ble-client.git
    
  2. Change into the project directory:

    cd solarlife-mppt-ble-client
    
  3. Install the required Python packages using pip:

    python -m venv venv
    source venv/bin/activate
    pip install -r requirements.txt
    

Usage

  1. Run the application by providing the required command-line arguments:

    python main.py <BLE device address> --host <MQTT broker host> --port <MQTT broker port> --username <MQTT username> --password <MQTT password>
    

Replace <BLE device address> with the Bluetooth address of your MPPT solar charge controller. The other arguments are optional and can be used to customize the MQTT connection.

  1. 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.

  2. 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/<key>/state
  • Sensor configuration topic (MQTT Discovery): homeassistant/sensor/solarlife/<key>/config
  • Switch command topic: homeassistant/switch/solarlife/<key>/command

The <key> 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 have to enable the mqtt platform. The device is discovered automatically.

Here's an example configuration in HomeAssistant's configuration.yaml file:

mqtt: {}

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.