Skip to content

Commit

Permalink
Reorganise registers into 125 blocks
Browse files Browse the repository at this point in the history
The new 1.5 version of the integration uses the pysolarman library which
is stricter with the protocol. In this case, we were requesting more
than 125 registers at a time, so it failed on the new update. So we
need to restructure the requests to only request a max of 125 registers.
  • Loading branch information
frsantos committed Sep 8, 2023
1 parent b141943 commit fe261dd
Showing 1 changed file with 22 additions and 19 deletions.
41 changes: 22 additions & 19 deletions custom_components/solarman/inverter_definitions/kstar_hybrid.yaml
Original file line number Diff line number Diff line change
@@ -1,37 +1,40 @@
# KSTAR Hybrid Inverter
# Modbus information taken from "MODBUS RS485 Communication Protocol V2.5" document provided by KSTAR

#INPUT_REGISTERS = 3000 - 3660 # 0x0BB8 - 0x0E4C
#HOLDING_REGISTERS = 3200 - 3237 # 0x0C80 - 0x0C9B
# This inverter exposes its data in the following registers (although not all of them are used by this definition file):
#
# - INPUT_REGISTERS 3000 - 3660 decimal, 0x0BB8 - 0x0E4C hexadecimal
# - HOLDING_REGISTERS 3200 - 3237 decimal. 0x0C80 - 0x0C9B hexadecimal
#
# Each request can get a maximum of 125 registers as per modbus protocol (start and end included), so we need to
# split up the list of used registers into multiple requests of maximum 125 registers each.

requests:
# Input registers 3000 - 3667
# Start requesting from the first needed register (3000)
- start: 3000
end: 3125
end: 3124
mb_functioncode: 0x04

# Input registers 3200 - 3228 not read as they would clash with holding registers
# Input registers 3200 - 3227 can't be read as they would clash with holding registers of same number
- start: 3125
end: 3200
end: 3199
mb_functioncode: 0x04

# Change to holding registers 3200 - 3237 (mb_functioncode 3) for the inverter system information.
- start: 3200
end: 3217
mb_functioncode: 0x03

# Continue with the needed input registers
- start: 3228
end: 3250
end: 3249
mb_functioncode: 0x04

# Last input register currently used by this definition file is 3301, so we can skip the rest for now.
- start: 3250
end: 3375
mb_functioncode: 0x04

- start: 3375
end: 3500
end: 3301
mb_functioncode: 0x04

# Holding registers 3200 - 3237. Inverter system information.
- start: 3200
end: 3218
mb_functioncode: 0x03

parameters:
- group: solar
items:
Expand Down Expand Up @@ -699,7 +702,7 @@ parameters:
scale: 0.01
rule: 1
registers: [ 3098 ]
icon: 'mdi:home-lightning-bolt'
icon: 'mdi:sine-wave'

- name: "R-phase Meter Current"
class: "current"
Expand Down Expand Up @@ -744,7 +747,7 @@ parameters:
scale: 0.01
rule: 1
registers: [ 3125 ]
icon: 'mdi:home-lightning-bolt'
icon: 'mdi:sine-wave'

- name: "R-phase Inverter Power"
class: "power"
Expand Down

0 comments on commit fe261dd

Please sign in to comment.