Pho3niX90 / solis_modbus

Home Assistant HACS integration for Solis inverters
26 stars 5 forks source link

Time Synch Not Working #67

Closed cdensel closed 2 months ago

cdensel commented 5 months ago

Hi,

My inverter is Solis S5-EH1P5K-L. My datalogger is S2-WL-ST connected via LAN (Device serial number 7A* , Firmware: 10010171). I have blocked the S2-WL-ST from accessing the internet because I want to run everything locally. I've had this integration running for about a week, and I'm able to write to the Solis via Modbus no problem. However, I've noticed extreme time-drift happening which is throwing off the overnight charge windows. The clock on the inverter goes wrong very quickly. It loses about 5 mins every hour.

I believe this integration should set the time on the inverter if it drifts. ? I enabled debug and rebooted and didn't see any attempt to write to the clock read/write registers of 43003-43005. I see no instances of "async_set_value" in the logs either, unless I change something in HA which is then written to the inverter. How frequently should I expect to see solis_modbus correcting the time drift?

Looking at the code, this is the line that I think should be updating the time in clock_drift_test:

await controller.async_write_holding_registers(43003, [current_time.hour, current_time.minute, current_time.second])

43003 is the "Hour" clock register, but is it trying to assign hour, min second to it? Wondering if that's a problem? Let me know if you need any more info.

Thanks, Conor

Pho3niX90 commented 4 months ago

Hi,

My inverter is Solis S5-EH1P5K-L. My datalogger is S2-WL-ST connected via LAN (Device serial number 7A* , Firmware: 10010171). I have blocked the S2-WL-ST from accessing the internet because I want to run everything locally. I've had this integration running for about a week, and I'm able to write to the Solis via Modbus no problem. However, I've noticed extreme time-drift happening which is throwing off the overnight charge windows. The clock on the inverter goes wrong very quickly. It loses about 5 mins every hour.

I believe this integration should set the time on the inverter if it drifts. ? I enabled debug and rebooted and didn't see any attempt to write to the clock read/write registers of 43003-43005. I see no instances of "async_set_value" in the logs either, unless I change something in HA which is then written to the inverter. How frequently should I expect to see solis_modbus correcting the time drift?

Looking at the code, this is the line that I think should be updating the time in clock_drift_test:

await controller.async_write_holding_registers(43003, [current_time.hour, current_time.minute, current_time.second])

43003 is the "Hour" clock register, but is it trying to assign hour, min second to it? Wondering if that's a problem? Let me know if you need any more info.

Thanks, Conor

so the code is async_write_holding_registers is from a library, the starting register is 43003, 3 values are passed in an array, first would be assigned to the starting 43003, second to 43004, and third to 43005

how much time has drifted in your instance?

cdensel commented 4 months ago

Hi,

Ah ok sorry, that makes sense about the array. The time was drifting significantly, would be about 2 hours out after 24 hours, so it was missing my charge windows.

I modified ModbusController class to have a delay of 5 which I read on another forum fixed some people's issues with modbus commands. Seems to have done the job, I'm not getting issues with the clock drifting on the inverter anymore:

class ModbusController:
    def __init__(self, host, port=502, delay=5):
        self.host = host
        self.port = port
        #CD - Added Delay
        self.delay = delay
        self.client: AsyncModbusTcpClient = AsyncModbusTcpClient(self.host, port=self.port, reconnect_delay =self.delay)
        self.connect_failures = 0
        self._lock = asyncio.Lock()

Thanks for your work on this project, I'm delighted I can remove reliance on Solis cloud.

Thanks, Conor