Skip to content

Commit

Permalink
Bug Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
fboundy committed Jun 21, 2023
1 parent cedc718 commit 400ab77
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 20 deletions.
2 changes: 1 addition & 1 deletion solis-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ template:
+ 32 * (states('input_boolean.solis_storage_mode_grid_charge') == 'on') | int
}}
- name: "Solis Eco7 Hours Remaining"
- name: "Solis Eco7 Time Remaining"
unique_id: "Solis Eco7 Time Remaining"
state_class: measurement
state: >-
Expand Down
51 changes: 32 additions & 19 deletions umodbus_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,25 @@
from umodbus.client import tcp

# configuration
CFG_IP = "192.168.4.236" # Update with your inverter IP
CFG_PORT = 8899 # old series 1920xxxxxx DLS-L
CFG_PORT = 502 # new S2-WL-ST stick serial number 7Axxx
CFG = {
'Waveshare': {
'IP': "192.168.4.40",
'PORT': 502,
},

'S2-WL': {
'IP': "192.168.4.237",
'PORT': 502,
},

'DLS-L': {
'IP': "192.168.4.79",
'PORT': 8899,
}

} # Update with your inverter IP

devices = ['S2-WL', 'Waveshare', ]

payloads = [
{
Expand All @@ -37,13 +52,6 @@
"scale": 1,
"uom": "%",
},
{
"desc": "Battery Storage Mode (W)",
"addrs": 43110,
"len": 1,
"scale": 1,
"uom": "",
},
{
"desc": "Battery Storage Mode (R)",
"addrs": 33132,
Expand All @@ -55,14 +63,19 @@

# Enable values to be signed (default is False).
conf.SIGNED_VALUES = True
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((CFG_IP, CFG_PORT))

for payload in payloads:
message = tcp.read_input_registers(slave_id=1, starting_address=payload["addrs"], quantity=payload["len"])
response = tcp.send_message(message, sock)
val = float(response[0]) * payload["scale"]
print(f"{(payload['desc']+':'):25s}{val:5.1f} {payload['uom']}")
sock = {}
for device in devices:
sock[device] = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock[device].connect((CFG[device]['IP'], CFG[device]['PORT']))
print(f"Device: {device}")
print('-' * 32 + '\n')
for payload in payloads:
message = tcp.read_input_registers(slave_id=1, starting_address=payload["addrs"], quantity=payload["len"])
response = tcp.send_message(message, sock[device])
val = float(response[0]) * payload["scale"]
print(f"{(payload['desc']+':'):25s}{val:5.1f} {payload['uom']}")

sock.close()
print("\n\n")
sock[device].close()

# %%

0 comments on commit 400ab77

Please sign in to comment.