jmccrohan / pysolarmanv5

A python module to interact with Solarman Data Logging Sticks
MIT License
116 stars 25 forks source link

V5 compliance #47

Closed githubDante closed 7 months ago

githubDante commented 9 months ago

As for the latter I had a case with two daemons, one connected 24/7 collecting data/metrics and one used for inverter programming started by a timer.service / cronjob. Initially it was a mess when they overlaps.

Credited @Dummy0815 for the idea as a co-author.

githubDante commented 9 months ago

Multi-instance test example:

from pysolarmanv5 import PySolarmanV5
from time import sleep
import threading

sol = PySolarmanV5('192.168.100.210', 2729999999, auto_reconnect=True, verbose=True)
sol2 = PySolarmanV5('192.168.100.210', 2729999999, auto_reconnect=True, verbose=True)

def start_threads():
    thr.start()
    sleep(.05) # allows request consumption by the logger
    thr2.start()

def read_solarman(s, addr, length):
    print(f'Reading from {s}')
    res = s.read_holding_registers(addr, length)
    print(f'{s} {res}')

thr = threading.Thread(target=read_solarman, args=(sol, 60, 120), daemon=True)
thr2 = threading.Thread(target=read_solarman, args=(sol2, 60, 120), daemon=True)

start_threads()
smurfy commented 9 months ago

Seems to fix an issue i was having with latest firmware for a SUN300/Bosswerk 300.

I also see no issues with HA solarman polling data and console command to update settings in paralel anymore.

jmccrohan commented 8 months ago

Hi @githubDante, @dummy0815, @barfooos, @smurfy,

I intend to merge this later this week and release a new version.

@githubDante I see you've been working on a frame-reuse branch too. Is that something that you want to include in this PR?

Cheers, Jon

githubDante commented 8 months ago

Hi Jon,

The frame-reuse branch is intended to solve the issues reported by the users of the HA plugin, but yes, I think they can be combined here.

jmccrohan commented 7 months ago

Pushed to main. Thanks all for your contributions.