This container allows you to connect your Voltronic inverter (or any other inverter that works with PI30
protocol) to MQTT (and, becase of MQTT, Home Assistant :)).
- Clone this repository:
git clone https://github.com/rrroyal/voltronic-mqtt.git
- Navigate to the cloned repository:
cd voltronic-mqtt
To use this container, you must have Docker and, optionally, docker-compose installed on your system.
- Edit the
docker-compose.yml
file to specify the correct device path, MQTT host, and MQTT password for your system. - Run
docker-compose up
to start the container.
Alternatively, use these commands (with parameters configured to your use case) to run the container without docker-compose
:
# Build the image
docker build -t voltronic-mqtt .
# Run the container
docker run -it -d --name voltronic-mqtt \
-e VERBOSE=2 \
-e DEVICE_PATH="/dev/ttyUSB0" \
-e POLLING_INTERVAL=60 \
-e MQTT_HOST="127.0.0.1:1883" \
-e MQTT_PASS="user:pass" \
-e MQTT_CLIENT_ID="voltronic-mqtt" \
-e MQTT_TOPIC="homeassistant/sensor/voltronic" \
-e MQTT_TOPIC_SUB="send_cmd" \
--device "/dev/ttyUSB0:/dev/ttyUSB0" \
--restart unless-stopped \
--network host \
--privileged \
voltronic-mqtt
You can also run the app by itself:
- Configure
.env.example
for your use case and save it as.env
. - Initialize a new
venv
environment:python3 -m venv venv && source venv/bin/activate
- Install dependencies:
pip install -r requirements.txt
- Run the program:
./standalone.sh
(if you're having errors with connecting to serial device, execute this command as root).
This file contains the following configuration options:
-
Level of logging (never:
-2
, always:-1
, silent:0
, error:1
, notice:2
, info:3
, debug:4
). -
The path to the device that the inverter is connected to. This is typically
/dev/ttyUSB0
on UNIX systems. - The interval (in seconds) at which to poll the inverter for data.
-
The hostname and port of the MQTT broker. Format:
host:port
(i.e.127.0.0.1:1883
). -
The username and password to use when connecting to the MQTT broker. Format:
user:pass
(i.e.AzureDiamond:hunter2
). -
The ID of the MQTT client (i.e.
voltronic-mqtt
). -
The topic of MQTT messages (i.e.
homeassistant/sensor/voltronic
) Note: lowercased command will be added as a suffix (i.e./qpigs
). -
The MQTT topic suffix to subscribe to (i.e.
send_cmd
)
The container uses the following device:
-
This is the device that the inverter is connected to. This must be specified in the
docker-compose.yml
/.env
file.
To use this program with Home Assistant you will need to connect your Home Assistant instance to the same MQTT broker as this program - you can read more about it here. You can also deploy your own broker - i.e. eclipse-mosquitto.
After that, you will need to configure MQTT entities. Example config is located inside the homeassistant-mqtt.yml
file.