Hi Julian, it’s quite easy and runs very robust on my xubuntu based machine.
I’ve an pv.items
file that contains all related items like:
Number:Power PV_Input_A_Watt "solar power [%.1f W]" (gWatt, gWattChart, gPV) { channel="mqtt:topic:solar:PV_Input_A_Watt", unit="W"}
and the MQTT things are defined like (some with tranformations to get the desired format/scale):
Thing mqtt:topic:solar "Solaranlage" (mqtt:broker:mqttBroker) {
Channels:
// Monitoring/PV/Current
Type number : PV_Input_A_Volt "Input A in Volt" [ stateTopic="solar/B55BA2CE" ]
Type number : PV_Input_A_Watt "Input A in Watt" [ stateTopic="solar/DB11855B", transformationPattern="JS:| parseFloat(input) * 1" ]
and the MQTT messages come from the following script:
#!/bin/bash
RctId="959930BF B55BA2CE DB11855B DB2D69AE A7FA5C5D 8B9FF008 959930BF 400F015B 4BC0F974 902AFAFB 1AC87AA0 91617C58 2AE703F2 3C87C4F5 867DEF7D 2F3C1D7D 81AE960B 65B624AB 126ABC86 F0BE6429"
RctIP="192.168.1.XX"
# Iterate the string variable using for loop
for val in $RctId; do
RctVal=$(/home/XXX/.venvs/MyEnv/bin/rctclient read-value --host $RctIP --id 0x$val)
# RctVal=$(rctclient read-value --host $RctIP --id 0x$val)
mosquitto_pub -h "192.168.1.YY" -u "mqtt" -P "myMQTTpassword" -t "solar/$val" -m "$RctVal"
done
which runs every minute by a cron job:
sudo crontab -e
* * * * * openhab /pathtothescript/pv2mqtt.sh
The script calls the rctclient
script, that I managed to install with these commands:
mkdir -p $HOME/.venvs
python3 -m venv ~/.venvs/MyEnv
cd ~/.venvs/MyEnv/
~/.venvs/MyEnv/bin/python --version
~/.venvs/MyEnv/bin/python -m pip install ~/Downloads/python-rctclient-0.0.4.tar.gz
~/.venvs/MyEnv/bin/python -m pip install ~/Downloads/click-8.1.7.tar.gz
After install, you can check if it works by calling it on the command line to get the battery state of charge
~/.venvs/MyEnv/bin/rctclient rctclient read-value --host 192.168.1.XX --id 0x959930BF
The content of the different hex values is documented in the file that you have linked before.