mirror of
https://github.com/alexhopeoconnor/SunGather.git
synced 2026-10-23 11:02:10 +10:00
0.5.2: paho-mqtt v2, LOTS of small bug fixes
This commit is contained in:
+4
-3
@@ -1,6 +1,7 @@
|
|||||||
FROM python:3-slim
|
FROM python:3-slim
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y build-essential python3-dev && rm -rf /var/lib/apt/lists/*
|
# pycryptodomex 3.14 currently fails to compile for arm64
|
||||||
|
#RUN apt-get update && apt-get install -y build-essential python3-dev && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
RUN useradd sungather
|
RUN useradd sungather
|
||||||
|
|
||||||
@@ -8,8 +9,8 @@ WORKDIR /usr/src/sungather
|
|||||||
|
|
||||||
COPY requirements.txt ./
|
COPY requirements.txt ./
|
||||||
# pycryptodomex 3.14 currently fails to compile for arm64
|
# pycryptodomex 3.14 currently fails to compile for arm64
|
||||||
#RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
#RUN pip install --no-cache-dir --upgrade pycryptodomex==3.11.0 -r requirements.txt
|
||||||
RUN pip install --no-cache-dir --upgrade pycryptodomex==3.11.0 -r requirements.txt
|
RUN pip install --no-cache-dir -r requirements.txt
|
||||||
|
|
||||||
COPY SunGather/ .
|
COPY SunGather/ .
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,10 @@ import requests
|
|||||||
import datetime
|
import datetime
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
#[16:24:21] INFO: Successfully send discovery information to Home Assistant.
|
||||||
|
#[16:24:21] INFO: Successfully send service information to the Supervisor.
|
||||||
|
|
||||||
|
|
||||||
class export_hassio(object):
|
class export_hassio(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.api_base = "http://supervisor/core/api"
|
self.api_base = "http://supervisor/core/api"
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ class export_mqtt(object):
|
|||||||
logging.info(f"MQTT: Host config is required")
|
logging.info(f"MQTT: Host config is required")
|
||||||
return False
|
return False
|
||||||
client_id = self.mqtt_config['client_id']
|
client_id = self.mqtt_config['client_id']
|
||||||
self.mqtt_client = mqtt.Client(client_id)
|
self.mqtt_client = mqtt.Client(mqtt.CallbackAPIVersion.VERSION2, client_id)
|
||||||
self.mqtt_client.on_connect = self.on_connect
|
self.mqtt_client.on_connect = self.on_connect
|
||||||
self.mqtt_client.on_disconnect = self.on_disconnect
|
self.mqtt_client.on_disconnect = self.on_disconnect
|
||||||
self.mqtt_client.on_publish = self.on_publish
|
self.mqtt_client.on_publish = self.on_publish
|
||||||
@@ -57,13 +57,20 @@ class export_mqtt(object):
|
|||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def on_connect(self, client, userdata, flags, rc):
|
def on_connect(self, client, userdata, flags, reason_code, properties):
|
||||||
|
if reason_code == 0:
|
||||||
logging.info(f"MQTT: Connected to {client._host}:{client._port}")
|
logging.info(f"MQTT: Connected to {client._host}:{client._port}")
|
||||||
|
if reason_code > 0:
|
||||||
|
logging.warn(f"MQTT: FAILED to connect {client._host}:{client._port}")
|
||||||
|
|
||||||
def on_disconnect(self, client, userdata, rc):
|
def on_disconnect(self, client, userdata, flags, reason_code, properties):
|
||||||
logging.info(f"MQTT: Server Disconnected code: {rc}")
|
if reason_code == 0:
|
||||||
|
logging.info(f"MQTT: Server Disconnected")
|
||||||
|
if reason_code > 0:
|
||||||
|
logging.warn(f"MQTT: FAILED to disconnect {reason_code}")
|
||||||
|
|
||||||
def on_publish(self, client, userdata, mid):
|
|
||||||
|
def on_publish(self, client, userdata, mid, reason_codes, properties):
|
||||||
try:
|
try:
|
||||||
self.mqtt_queue.remove(mid)
|
self.mqtt_queue.remove(mid)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
|
|||||||
+227
-126
File diff suppressed because it is too large
Load Diff
@@ -19,7 +19,8 @@ def main():
|
|||||||
try:
|
try:
|
||||||
opts, args = getopt.getopt(sys.argv[1:],"hc:r:l:v:", "runonce")
|
opts, args = getopt.getopt(sys.argv[1:],"hc:r:l:v:", "runonce")
|
||||||
except getopt.GetoptError:
|
except getopt.GetoptError:
|
||||||
logging.debug(f'No options passed via command line')
|
sys.exit(f'No options passed via command line, use -h to see all options')
|
||||||
|
|
||||||
|
|
||||||
for opt, arg in opts:
|
for opt, arg in opts:
|
||||||
if opt == '-h':
|
if opt == '-h':
|
||||||
@@ -151,7 +152,11 @@ def main():
|
|||||||
inverter.checkConnection()
|
inverter.checkConnection()
|
||||||
|
|
||||||
# Scrape the inverter
|
# Scrape the inverter
|
||||||
|
try:
|
||||||
success = inverter.scrape()
|
success = inverter.scrape()
|
||||||
|
except Exception as e:
|
||||||
|
logging.exception(f"Failed to scrape: {e}")
|
||||||
|
success = False
|
||||||
|
|
||||||
if(success):
|
if(success):
|
||||||
for export in exports:
|
for export in exports:
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
__version__ = '0.5.1'
|
__version__ = '0.5.2'
|
||||||
|
|||||||
+4
-4
@@ -1,5 +1,5 @@
|
|||||||
PyYAML>=6.0
|
PyYAML~=6.0
|
||||||
requests>=2.26.0
|
paho-mqtt~=2.0
|
||||||
paho-mqtt>=1.5.1
|
requested~=2.0
|
||||||
SungrowClient>=0.1.0
|
SungrowClient>=0.1.0
|
||||||
influxdb-client>=1.24.0
|
influxdb-client~=1.0
|
||||||
|
|||||||
Reference in New Issue
Block a user