nathanmarlor / foxess_modbus

FoxESS inverter integration. Connect directly to your FoxESS inverter (no cloud!) for real-time status and control.
MIT License
105 stars 14 forks source link

Switch KH to Input registers #512

Closed canton7 closed 5 months ago

canton7 commented 6 months ago

See: #505

canton7 commented 6 months ago

I'm probably not going to merge this -- I'd rather do something intelligent using the manager version if we do get confirmation that input registers are gone for good on the KH.

williamjeccles commented 6 months ago

@canton7 agree, hold off until I hear back to from Fox, if they fix it in the next version this patch isn't needed. I will update you.

canton7 commented 6 months ago

Apparently Fox are working on a fix.

canton7 commented 6 months ago

@williamjeccles give that a try, see if it re-enables min/max soc, max charge/discharge current and work mode

williamjeccles commented 6 months ago

@canton7 appears to not work, all my values are unavailable and I see the following in the logs:

This error originated from a custom integration.

Logger: custom_components.foxess_modbus.modbus_controller Source: custom_components/foxess_modbus/modbus_controller.py:221 Integration: FoxESS - Modbus (documentation, issues) First occurred: 17:42:58 (1 occurrences) Last logged: 17:42:58

tcp://192.168.1.164:502 247 - 5 failed poll attempts: now not connected. Last error: Error reading registers. Type: RegisterType.HOLDING; start: 41000; count: 8; slave: 247 from tcp://192.168.1.164:502: Exception Response(131, 3, IllegalAddress)

canton7 commented 6 months ago

Are you comfortable using modpoll? If so, can you try reading register 41000 on its own, and as part of a block of registers?

We've found that some holding registers on the H3 can only be read 1-by-1, so maybe that's what's happening here.

williamjeccles commented 6 months ago

@canton7 can you confirm the modpoll command?

I'm using:

`c:\Users\willi\Downloads>modpoll.exe -m tcp -p 502 -a 247 -r 41000 192.168.1.164 modpoll 3.10 - FieldTalk(tm) Modbus(R) Master Simulator Copyright (c) 2002-2021 proconX Pty Ltd Visit https://www.modbusdriver.com for Modbus libraries and tools.

Protocol configuration: MODBUS/TCP, FC3 Slave configuration...: address = 247, start reference = 41000, count = 1 Communication.........: 192.168.1.164, port 502, t/o 1.00 s, poll rate 1000 ms Data type.............: 16-bit register, output (holding) register table

Can't reach server/slave! Check TCP/IP and firewall settings.`

canton7 commented 6 months ago

That suggests the ip address is wrong, or your modbus adapter is offline? Or maybe HA is connected to it, and is tying it up?

williamjeccles commented 6 months ago

@canton7 any better?

c:\Users\willi\Downloads>modpoll.exe -m tcp -p 502 -a 247 -r 41000 192.168.1.164 modpoll 3.10 - FieldTalk(tm) Modbus(R) Master Simulator Copyright (c) 2002-2021 proconX Pty Ltd Visit https://www.modbusdriver.com for Modbus libraries and tools.

Protocol configuration: MODBUS/TCP, FC3 Slave configuration...: address = 247, start reference = 41000, count = 1 Communication.........: 192.168.1.164, port 502, t/o 1.00 s, poll rate 1000 ms Data type.............: 16-bit register, output (holding) register table

-- Polling slave... (Ctrl-C to stop) Illegal Data Address exception response! -- Polling slave... (Ctrl-C to stop) Illegal Data Address exception response! -- Polling slave... (Ctrl-C to stop) Illegal Data Address exception response! -- Polling slave... (Ctrl-C to stop) Illegal Data Address exception response! -- Polling slave... (Ctrl-C to stop) Illegal Data Address exception response! -- Polling slave... (Ctrl-C to stop) Illegal Data Address exception response! -- Polling slave... (Ctrl-C to stop)

canton7 commented 6 months ago

That looks more promising...

Can you try with -0 -1 -t 3 and -0 -1 -t 4? If either of those works (manages to read a value), add in -c 2, see if it still works.

williamjeccles commented 6 months ago

@canton7 Results:

c:\Users\willi\Downloads>modpoll.exe -m tcp -p 502 -a 247 -0 -1 -t 3 -r 41000 192.168.1.164
modpoll 3.10 - FieldTalk(tm) Modbus(R) Master Simulator
Copyright (c) 2002-2021 proconX Pty Ltd
Visit https://www.modbusdriver.com for Modbus libraries and tools.

Protocol configuration: MODBUS/TCP, FC4
Slave configuration...: address = 247, start reference = 41000 (PDU), count = 1
Communication.........: 192.168.1.164, port 502, t/o 1.00 s, poll rate 1000 ms
Data type.............: 16-bit register, input register table

-- Polling slave...
[41000]: 0
c:\Users\willi\Downloads>modpoll.exe -m tcp -p 502 -a 247 -0 -1 -t 4 -r 41000 192.168.1.164
modpoll 3.10 - FieldTalk(tm) Modbus(R) Master Simulator
Copyright (c) 2002-2021 proconX Pty Ltd
Visit https://www.modbusdriver.com for Modbus libraries and tools.

Protocol configuration: MODBUS/TCP, FC3
Slave configuration...: address = 247, start reference = 41000 (PDU), count = 1
Communication.........: 192.168.1.164, port 502, t/o 1.00 s, poll rate 1000 ms
Data type.............: 16-bit register, output (holding) register table

-- Polling slave...
[41000]: 0
c:\Users\willi\Downloads>modpoll.exe -m tcp -p 502 -a 247 -0 -1 -t 4 -c2 -r 41000 192.168.1.164
modpoll 3.10 - FieldTalk(tm) Modbus(R) Master Simulator
Copyright (c) 2002-2021 proconX Pty Ltd
Visit https://www.modbusdriver.com for Modbus libraries and tools.

Protocol configuration: MODBUS/TCP, FC3
Slave configuration...: address = 247, start reference = 41000 (PDU), count = 2
Communication.........: 192.168.1.164, port 502, t/o 1.00 s, poll rate 1000 ms
Data type.............: 16-bit register, output (holding) register table

-- Polling slave...
Illegal Data Address exception response!
canton7 commented 6 months ago

Interesting that it's available to read as an input register. Can you try with -t 3 -c 2?

It lokos like we can read those registers 1-by-1 as holding registers, but the USR-W610 will really struggle to do that many individual polls.

canton7 commented 6 months ago

Actually, mind trying to read 41007 with -c 2, and both -t 3 and -t 4? The problem might be that register 41001 (which is TBD in their spec) is unreadable.

williamjeccles commented 6 months ago

@canton7

c:\Users\willi\Downloads>modpoll.exe -m tcp -p 502 -a 247 -0 -1 -t 3 -c 2 -r 41007 192.168.1.164
modpoll 3.10 - FieldTalk(tm) Modbus(R) Master Simulator
Copyright (c) 2002-2021 proconX Pty Ltd
Visit https://www.modbusdriver.com for Modbus libraries and tools.

Protocol configuration: MODBUS/TCP, FC4
Slave configuration...: address = 247, start reference = 41007 (PDU), count = 2
Communication.........: 192.168.1.164, port 502, t/o 1.00 s, poll rate 1000 ms
Data type.............: 16-bit register, input register table

-- Polling slave...
Invalid frame error!

c:\Users\willi\Downloads>modpoll.exe -m tcp -p 502 -a 247 -0 -1 -t 4 -c 2 -r 41007 192.168.1.164
modpoll 3.10 - FieldTalk(tm) Modbus(R) Master Simulator
Copyright (c) 2002-2021 proconX Pty Ltd
Visit https://www.modbusdriver.com for Modbus libraries and tools.

Protocol configuration: MODBUS/TCP, FC3
Slave configuration...: address = 247, start reference = 41007 (PDU), count = 2
Communication.........: 192.168.1.164, port 502, t/o 1.00 s, poll rate 1000 ms
Data type.............: 16-bit register, output (holding) register table

-- Polling slave...
Illegal Data Address exception response!
canton7 commented 6 months ago

So, looks like they can be read as input or holding registers, but they have to be read 1-by-1.

It's probably the same as the H3 in that respect. Have a try with that latest update, see if that works.

williamjeccles commented 6 months ago

@canton7 bingo, dino dna

image

michalzxc commented 5 months ago

My inverter stopped responding 2 days ago

./modpoll  -m tcp -p 502 -a 247 -t 3 -0 -1 -c 16 -r 11000  10.0.0.253 
modpoll 3.10 - FieldTalk(tm) Modbus(R) Master Simulator
Copyright (c) 2002-2021 proconX Pty Ltd
Visit https://www.modbusdriver.com for Modbus libraries and tools.

Protocol configuration: MODBUS/TCP, FC4
Slave configuration...: address = 247, start reference = 11000 (PDU), count = 16
Communication.........: 10.0.0.253, port 502, t/o 1.00 s, poll rate 1000 ms
Data type.............: 16-bit register, input register table

-- Polling slave...
Invalid frame error!

It works with 3100 only now:

./modpoll  -m tcp -p 502 -a 247 -t 3 -0 -1 -c 16 -r 31000  10.0.0.253 
modpoll 3.10 - FieldTalk(tm) Modbus(R) Master Simulator
Copyright (c) 2002-2021 proconX Pty Ltd
Visit https://www.modbusdriver.com for Modbus libraries and tools.

Protocol configuration: MODBUS/TCP, FC4
Slave configuration...: address = 247, start reference = 31000 (PDU), count = 16
Communication.........: 10.0.0.253, port 502, t/o 1.00 s, poll rate 1000 ms
Data type.............: 16-bit register, input register table

-- Polling slave...
[31000]: 1
[31001]: 0
[31002]: 0
[31003]: 0
[31004]: 0
[31005]: 0
[31006]: 0
[31007]: 0
[31008]: 0
[31009]: 0
[31010]: 0
[31011]: 0
[31012]: 0
[31013]: 0
[31014]: 0
[31015]: 0

I have KH10

canton7 commented 5 months ago

Released in the beta v1.10.0b3.

(It'll be a little while before I can get a proper release out, as we're in the middle of figuring out force charge/discharge).