Skip to content

Instantly share code, notes, and snippets.

@gsdevme
Created November 22, 2021 09:05
Show Gist options
  • Save gsdevme/d6b9424002088e32798bc9df9b3216de to your computer and use it in GitHub Desktop.
Save gsdevme/d6b9424002088e32798bc9df9b3216de to your computer and use it in GitHub Desktop.
Solar Shed to MQTT
from solarshed.controllers.renogy_rover import RenogyRover
import paho.mqtt.client as mqtt
import time
from gpiozero import CPUTemperature
while True:
time.sleep(5)
rover = RenogyRover('/dev/ttyUSB0', 1)
client = mqtt.Client("P1")
client.connect("mqtt.home.gsdev.me")
client.publish("shed/battery_voltage", rover.battery_voltage())
client.publish("shed/battery_temp", rover.battery_temperature())
client.publish("shed/controller_temp", rover.controller_temperature())
client.publish("shed/controller_status", rover.charging_status_label())
client.publish("shed/charge_voltage", rover.solar_voltage())
client.publish("shed/charge_current", rover.solar_current())
client.publish("shed/charge_power", rover.solar_power())
client.publish("shed/charge_today_kwh", rover.power_generation_today())
client.publish("shed/charge_amp_hours_today", rover.charging_amp_hours_today())
cpu = CPUTemperature()
client.publish("shed/pi_temp", cpu.temperature)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment