mirror of
https://github.com/alexhopeoconnor/SunGather.git
synced 2026-10-23 02:52:10 +10:00
Merge branch 'main' into reduce-docker-image-size
This commit is contained in:
@@ -25,7 +25,7 @@ jobs:
|
|||||||
uses: docker/build-push-action@v2
|
uses: docker/build-push-action@v2
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
platforms: linux/amd64,linux/arm64 #,linux/arm/v7
|
||||||
push: true
|
push: true
|
||||||
tags: ${{ secrets.DOCKERHUB_USERNAME }}/sungather:${{ steps.version.outputs.tag }},${{ secrets.DOCKERHUB_USERNAME }}/sungather:latest
|
tags: ${{ secrets.DOCKERHUB_USERNAME }}/sungather:${{ steps.version.outputs.tag }},${{ secrets.DOCKERHUB_USERNAME }}/sungather:latest
|
||||||
- uses: "marvinpinto/action-automatic-releases@latest"
|
- uses: "marvinpinto/action-automatic-releases@latest"
|
||||||
|
|||||||
@@ -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):
|
||||||
logging.info(f"MQTT: Connected to {client._host}:{client._port}")
|
if reason_code == 0:
|
||||||
|
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:
|
||||||
|
|||||||
+225
-124
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
|
||||||
success = inverter.scrape()
|
try:
|
||||||
|
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
|
requests~=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