extarct s3 data with decompression

This commit is contained in:
kostas 2024-05-30 12:29:36 +02:00
parent 933f895a67
commit 5813ecfee3
1 changed files with 194 additions and 215 deletions

View File

@ -1,18 +1,16 @@
#!/usr/bin/python3 -u
#!/usr/bin/python2 -u
# coding=utf-8
import logging
import re
import socket
import sys
import typing
from gi.repository import GLib as glib
import gobject
import signals
import config as cfg
from dbus.mainloop.glib import DBusGMainLoop
from pymodbus.client import ModbusSerialClient as Modbus
from pymodbus.client.sync import ModbusSerialClient as Modbus
from pymodbus.exceptions import ModbusException, ModbusIOException
from pymodbus.other_message import ReportSlaveIdRequest
from pymodbus.pdu import ExceptionResponse
@ -25,10 +23,8 @@ from python_libs.ie_dbus.dbus_service import DBusService
if False:
from typing import Callable, List, Iterable, NoReturn
RESET_REGISTER = 0x2087
SETTINGS_SERVICE_PREFIX = 'com.victronenergy.settings'
INVERTER_SERVICE_PREFIX = 'com.victronenergy.vebus.'
RESET_REGISTER = 0x2087
def init_modbus(tty):
@ -186,7 +182,6 @@ def publish_aggregates(service, signals, battery_statuses):
continue
values = [s.get_value(battery_status) for battery_status in battery_statuses]
value = s.aggregate(values)
service.own_properties.set(s.dbus_path, value, s.unit)
@ -278,14 +273,6 @@ def create_update_task(modbus, service, batteries):
logging.debug('starting update cycle')
# Checking if we have excess power and if so charge batteries more
target = service.remote_properties.get(get_service(SETTINGS_SERVICE_PREFIX) + '/Settings/CGwacs/AcPowerSetPoint').value or 0
actual = service.remote_properties.get(get_service(INVERTER_SERVICE_PREFIX) + '/Ac/Out/P').value or 0
if actual>target:
service.own_properties.set('/Info/MaxChargeCurrent').value = min([battery.i_max for battery in batteries])
if service.own_properties.get('/ResetBatteries').value == 1:
reset_batteries(modbus, batteries)
@ -310,7 +297,6 @@ def create_watchdog_task(main_loop):
The watchdog kills the main loop if the alive flag is not periodically reset by the update task.
Who watches the watchdog?
"""
def watchdog_task():
# type: () -> bool
@ -327,13 +313,6 @@ def create_watchdog_task(main_loop):
return watchdog_task
def get_service(self, prefix: str) -> Optional[unicode]:
service = next((s for s in self.available_services if s.startswith(prefix)), None)
if service is None:
raise Exception('no service matching ' + prefix + '* available')
return service
def main(argv):
# type: (List[str]) -> ()
@ -353,7 +332,7 @@ def main(argv):
service.own_properties.set('/ResetBatteries', value=False, writable=True) # initial value = False
main_loop = GLib.MainLoop()
main_loop = gobject.MainLoop()
service_signals = signals.init_service_signals(batteries)
publish_service_signals(service, service_signals)
@ -362,8 +341,8 @@ def main(argv):
update_task() # run it right away, so that all props are initialized before anyone can ask
watchdog_task = create_watchdog_task(main_loop)
GLib.timeout_add(cfg.UPDATE_INTERVAL * 2, watchdog_task, priority = GLib.PRIORITY_LOW) # add watchdog first
GLib.timeout_add(cfg.UPDATE_INTERVAL, update_task, priority = GLib.PRIORITY_LOW) # call update once every update_interval
gobject.timeout_add(cfg.UPDATE_INTERVAL * 2, watchdog_task, priority = gobject.PRIORITY_LOW) # add watchdog first
gobject.timeout_add(cfg.UPDATE_INTERVAL, update_task, priority = gobject.PRIORITY_LOW) # call update once every update_interval
logging.info('starting gobject.MainLoop')
main_loop.run()