Renogy Devices and Raspberry Pi - bluetooth/WiFi

SolarShed

Solar Enthusiast
Joined
Jul 20, 2021
Messages
108
Does anyone know if you can change the resolution of the data messages sent over MQTT.
I'm getting values that seem to be integers except for voltages. So for example power (for load power) is either 1 or 2 when I know on the app it would read 1.54W for example.
The same is true for current and I posted this question on the Creator's website. I was planning on troubleshooting this once I got my system up and running but I'm not there yet...
 

aps1602

New Member
Joined
Dec 24, 2021
Messages
9
I'll have to try to polish my Python and dig into the code.
I'm getting 10ths of current, but I saw someone mentioning the debug messages and the data they produced seemed to have greater accuracy
 

SolarShed

Solar Enthusiast
Joined
Jul 20, 2021
Messages
108
I asked the author about increasing the decimal places on the values and this is what he has to say:

If you look at the class PowerDevice in solaredevice.py you can find the definitions of the various monitored values.

You will mostly see that values are stored as "high resolution" (e.g. millivolt, temperature in kelvin etc), but it will report/log on more "human friendly" values (volt, temperature in celsius etc). I also have various checks in place because quite often these devices report crazy values for a short time, so I try to filter out values that are obviously bad.

I think (but it's bee a while since I worked on this) that line 209-212 and further down in solaredevice.py contains a list of all items that should be logged remotely.

So you could change the list on line 209... so that e.g. input_voltage changed to input_mvoltage wich would get you the value in milivolts instead of volts. You could then do any roundings and calculations in the receiving end and use as many decimals as you need.
And if you want fahrenheit instead of celsius, you could change line 223 from self.entities.temperature_celsius to self.entities.temperature_fahrenheit.


I havent tried the above instruction it yet, but im close to up and running... just getting the Grafana MQTT-datasource plugin to show up in Grafana desktop is proving to be a challenge now, but i figure it out eventually....
 

aps1602

New Member
Joined
Dec 24, 2021
Messages
9
Ok I see the Class Power Device at line 312 onward, and I see the properties from where he defines the "higher level" values from 477 onward, shouldn't be too hard to experiment.
I do always get zero for charge power which I assumed was a coding error and I calculate based on charge voltage and current, but it should be there......line 634

...... Nope I get 0 for charge_mpower as well.
 
Last edited:

SolarShed

Solar Enthusiast
Joined
Jul 20, 2021
Messages
108
Ok I see the Class Power Device at line 312 onward, and I see the properties from where he defines the "higher level" values from 477 onward, shouldn't be too hard to experiment.
I do always get zero for charge power which I assumed was a coding error and I calculate based on charge voltage and current, but it should be there......line 634

...... Nope I get 0 for charge_mpower as well.

charge power, I believe is your charging power in watts. Mine is not zero when the sun is out
 
Last edited:

SolarShed

Solar Enthusiast
Joined
Jul 20, 2021
Messages
108
im trying to code a subscriber to list the data the publisher is sending using my broker.

When I run the script below, all I get is that
"Connected with result code 0"

and waits...but its not listing the data the the publisher is sending....any know now how to tweak this script?


Python:
import paho.mqtt.client as mqtt

# This is the Subscriber

def on_connect(client, userdata, flags, rc):
  print("Connected with result code "+str(rc))
  client.subscribe("solar/regulator")

def on_message(client, userdata, msg):
  print("received data is :")
  print(str(message.payload.decode("utf-8")) ) #printing Received message
  print("")

client = mqtt.Client()
client.connect("localhost",1883,60)

client.on_connect = on_connect
client.on_message = on_message

client.loop_forever()
 
Last edited:

smoothJoey

Hoop Dee Doo!
Joined
Nov 30, 2019
Messages
9,944
im trying to code a subscriber to list the data the publisher is sending using my broker.

When I run the script below, all I get is that
"Connected with result code 0"

and waits...but its not listed the data the the publisher is sending....any know now how to tweat this script?


Python:
import paho.mqtt.client as mqtt

# This is the Subscriber

def on_connect(client, userdata, flags, rc):
  print("Connected with result code "+str(rc))
  client.subscribe("solar/regulator")

def on_message(client, userdata, msg):
  print("received data is :")
  print(str(message.payload.decode("utf-8")) ) #printing Received message
  print("")

client = mqtt.Client()
client.connect("localhost",1883,60)

client.on_connect = on_connect
client.on_message = on_message

client.loop_forever()
Is the publisher actually sending?
 

SolarShed

Solar Enthusiast
Joined
Jul 20, 2021
Messages
108
So I'm using MQTT, sending to OpenHab and persisting that to InfluxDB and Grafana is reading the data from InfluxDB to chart. There are multiple options to get a similar configuration, for instance I think everything is integrated with HomeAssistant if you went that direction.

There is a logger option in solar-monitor for sending data to a URL via JSON. I don't see any documentation about any specific service it uses and I'm only seeing binary data that can be written to influx over http: https://docs.influxdata.com/influxdb/v1.8/guides/write_data/

Ultimately your goal is to get this data into a database that is compatible with Grafana. It looks to me like you can probably take several steps out altogether and:
  1. Install an MQTT server like Mosquitto somewhere; could even be on the Pi Zero W as long as it doesn't end up consuming too many resources
  2. Configure solar-monitor to connect to MQTT
    • If you're on Windows you can verify the data is logging with something like MQTT Explorer rather than troubleshooting with the CLI tools on the MQTT host
  3. Install Grafana somewhere, could also be on the Pi Zero W. Keep in mind that this is not have as many resources as something like a Pi4 with extra RAM, but to get started with just this one project I can absolutely see you installing all of this on the Pi Zero W
  4. Install and configure this mqtt-datasource plugin for Grafana: https://github.com/grafana/mqtt-datasource

There are many ways you can accomplish your goal, this just seems like a lighter weight solution that I'm more familiar with.

Mosquitto: https://www.instructables.com/Installing-MQTT-BrokerMosquitto-on-Raspberry-Pi/
Grafana: https://grafana.com/tutorials/install-grafana-on-raspberry-pi/
- MQTT Grafana plugin: https://github.com/grafana/mqtt-datasource
So, finally got Grafana MQTT installed on my Ubuntu Machine.

Question for you @oedo808: The script seems to be optimized for Home Assistant, so, when im on my Ubuntu machine (broker) and type this in the command line

Code:
mosquitto_sub -v -h broker_ip -p 1883 -t '#'

i get all this:

Code:
homeassistant/sensor/regulator/charge_current/config {"name": "Solar            # all topics are prefixed by \"prefix/\" Regulator Charge Current", "ud": "solar            # All topics are prefixed by \"prefix/\"_regulator_charge_current", "state_topic": "solar            # All topics are prefixed bfix/\"/regulator/charge_current/state", "force_update": true, "icon": "mdi:current-dc", "unit_of_measurement": "A"}
homeassistant/sensor/regulator/voltage/config {"name": "Solar            # all topics are prefixed by \"prefix/\" Regulator Voltage", "unique_id": "so        # All topics are prefixed by \"prefix/\"_regulator_voltage", "state_topic": "solar            # All topics are prefixed by \"prefix/\"/regulatage/state", "force_update": true, "icon": "mdi:flash", "unit_of_measurement": "V"}
homeassistant/sensor/regulator/input_voltage/config {"name": "Solar            # all topics are prefixed by \"prefix/\" Regulator Input Voltage", "uni: "solar            # All topics are prefixed by \"prefix/\"_regulator_input_voltage", "state_topic": "solar            # All topics are prefixed by \/\"/regulator/input_voltage/state", "force_update": true, "icon": "mdi:flash", "unit_of_measurement": "V"}
homeassistant/sensor/regulator/charge_voltage/config {"name": "Solar            # all topics are prefixed by \"prefix/\" Regulator Charge Voltage", "ud": "solar            # All topics are prefixed by \"prefix/\"_regulator_charge_voltage", "state_topic": "solar            # All topics are prefixed bfix/\"/regulator/charge_voltage/state", "force_update": true, "icon": "mdi:flash", "unit_of_measurement": "V"}
homeassistant/sensor/regulator/power/config {"name": "Solar            # all topics are prefixed by \"prefix/\" Regulator Power", "unique_id": "solar     # All topics are prefixed by \"prefix/\"_regulator_power", "state_topic": "solar            # All topics are prefixed by \"prefix/\"/regulator/powe", "force_update": true, "device_class": "power", "unit_of_measurement": "W"}
homeassistant/sensor/regulator/input_power/config {"name": "Solar            # all topics are prefixed by \"prefix/\" Regulator Input Power", "unique_olar            # All topics are prefixed by \"prefix/\"_regulator_input_power", "state_topic": "solar            # All topics are prefixed by \"prefigulator/input_power/state", "force_update": true, "device_class": "power", "unit_of_measurement": "W"}
homeassistant/sensor/regulator/charge_power/config {"name": "Solar            # all topics are prefixed by \"prefix/\" Regulator Charge Power", "uniqu"solar            # All topics are prefixed by \"prefix/\"_regulator_charge_power", "state_topic": "solar            # All topics are prefixed by \"pr/regulator/charge_power/state", "force_update": true, "device_class": "power", "unit_of_measurement": "W"}
homeassistant/sensor/regulator/soc/config {"name": "Solar            # all topics are prefixed by \"prefix/\" Regulator Soc", "unique_id": "solar     # All topics are prefixed by \"prefix/\"_regulator_soc", "state_topic": "solar            # All topics are prefixed by \"prefix/\"/regulator/soc/statece_update": true, "device_class": "battery", "unit_of_measurement": "%"}
homeassistant/sensor/regulator/capacity/config {"name": "Solar            # all topics are prefixed by \"prefix/\" Regulator Capacity", "unique_id": "          # All topics are prefixed by \"prefix/\"_regulator_capacity", "state_topic": "solar            # All topics are prefixed by \"prefix/\"/reguapacity/state", "force_update": true, "icon": "mdi:solar-power"}
homeassistant/sensor/regulator/temperature/config {"name": "Solar            # all topics are prefixed by \"prefix/\" Regulator Temperature", "unique_olar            # All topics are prefixed by \"prefix/\"_regulator_temperature", "state_topic": "solar            # All topics are prefixed by \"prefigulator/temperature/state", "force_update": true, "device_class": "temperature", "unit_of_measurement": "\u00b0C"}
homeassistant/switch/regulator/power_switch/config {"name": "Solar            # all topics are prefixed by \"prefix/\" Regulator Power Switch", "uniqu"solar            # All topics are prefixed by \"prefix/\"_regulator_power_switch", "state_topic": "solar            # All topics are prefixed by \"pr/regulator/power_switch/state", "command_topic": "solar            # All topics are prefixed by \"prefix/\"/regulator/power_switch/set", "payload_on":yload_off": 0}

How do I modify the output so that the Grafana MQTT can read it (not Home Assistant)?

EDIT: turns out I need the remove the comments from the ini file. Now its works quite well. Gragana is ploting the values.....all right, thanks for bringing this to my attention.
 
Last edited:

SolarShed

Solar Enthusiast
Joined
Jul 20, 2021
Messages
108
well, after a while, here's the money shot. All local.
 

Attachments

  • Renogy Screenshot1.jpg
    Renogy Screenshot1.jpg
    189.2 KB · Views: 8
  • Renogy Screenshot2.jpg
    Renogy Screenshot2.jpg
    189.8 KB · Views: 7

aps1602

New Member
Joined
Dec 24, 2021
Messages
9
Cool @SolarShed
Does anyone know the parameters that define MPPT, Float, Boost etc or whether it's exposed in the code
There seems to be a 'State' item but it never gets reported or "Health" for that matter
 
Last edited:

SolarShed

Solar Enthusiast
Joined
Jul 20, 2021
Messages
108
Cool @SolarShed
Does anyone know the parameters that define MPPT, Float, Boost etc or whether it's exposed in the code
There seems to be a 'State' item but it never gets reported or "Health" for that matter
are you referring to the settings or when you Rover is in MPPT, float, boost mode?....either way, I have not seen that in the code, or haven't identified it yet....its good point and would be nice to have as another data stream.
 

SolarShed

Solar Enthusiast
Joined
Jul 20, 2021
Messages
108
Using InfluxDB (on Ubuntu in Grafana) and Red-NODE (on RPi Zero 2W), here's the dashboard for a true data logging and remote (and locally-based) access system

 
Last edited:
Top