-
Notifications
You must be signed in to change notification settings - Fork 0
2. Installation
Richard Pearce edited this page Apr 28, 2024
·
6 revisions
View sofar2mqtt-python on Dockerhub
You can use version rpearce/sofar2mqtt-python:latest
to always have the latest version or pin to a specific release e.g rpearce/sofar2mqtt-python:3.0.4
docker run -d \
--name sofar2mqtt \
-e MQTT_HOST=192.168.0.x \
-e CONFIG_FILE=sofar-hyd-ep.json \
-e TTY_DEVICE=/dev/ttyUSB0 \
--device=/dev/ttyUSB0
rpearce/sofar2mqtt-python:latest
You can also use Docker compose:
services:
sofar2mqtt:
container_name: sofar2mqtt
image: rpearce/sofar2mqtt-python:latest
restart: unless-stopped
environment:
- MQTT_HOST=192.168.1.0
- MQTT_PORT=1883
- MQTT_USERNAME=mqtt
- MQTT_PASSWORD=redacted
- TTY_DEVICE=/dev/ttyUSB0
devices:
- /dev/ttyUSB0:/dev/ttyUSB0
docker compose up -d sofar2mqtt
-
Clone the repo
sudo apt-get install python-pip sudo pip install -r requirements.txt git clone https://github.com/rjpearce/sofar2mqtt-python.git cd sofar2mqtt-python
-
Test you can communicate with your inverter
python3 sofar2mqtt-v2.py --broker localhost --device /dev/ttyUSB0 # Example of normal output INFO - MQTT connecting to broker INFO - MQTT connected INFO - Subscribing to sofar/rw/eps_control INFO - Subscribing to sofar/rw/remote_on_off_control INFO - Subscribing to sofar/rw/power_control INFO - Subscribing to sofar/rw/active_power_export_limit INFO - Subscribing to sofar/rw/active_power_import_limit INFO - Subscribing to sofar/rw/reactive_power_setting INFO - Subscribing to sofar/rw/power_factor_setting INFO - Subscribing to sofar/rw/active_power_limit_speed INFO - Subscribing to sofar/rw/reactive_power_response_time INFO - Subscribing to sofar/rw/energy_storage_mode INFO - Subscribing to sofar/rw/time_of_use_charge_soc INFO - Subscribing to sofar/rw/passive_timeout INFO - Subscribing to sofar/rw/passive_timeout_action INFO - Subscribing to sofar/rw/desired_power INFO - Subscribing to sofar/rw/minimum_battery_power INFO - Subscribing to sofar/rw/maximum_battery_power INFO - Subscribing to sofar/rw/desired_power_grid INFO - Modbus Requests: 62 Retries: 1 (1.61%) Failures: 0 (0.0%)
NOTE: Modbus communication with HYD-EP model is rather unreliable, retry rates can be as high as 10%. However a retry is still a success if you get failures then something is probably wrong. If you have any problems trying running with
--log-level DEBUG
-
Install it as a service using systemd (optional)
If you want to override any setting you can set them in sofar2mqtt.service
# Symlink the git clone directory to /opt/sofar2mqtt sudo ln -s $(pwd) /opt/sofar2mqtt # Copy the file to lib/systemd/system sudo cp systemd/sofar2mqtt.service /lib/systemd/system sudo chmod 644 /lib/systemd/system/sofar2mqtt.service # Reload daemon sudo systemctl daemon-reload # Enable the service (starts on boot and on failure) sudo systemctl enable sofar2mqtt # Start the service sudo systemctl start sofar2mqtt
-
Check the logs for output
less /var/log/syslog