diff --git a/solis-template.yaml b/solis-template.yaml index 863d143..b7af9f7 100644 --- a/solis-template.yaml +++ b/solis-template.yaml @@ -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: >- diff --git a/umodbus_test.py b/umodbus_test.py index fe9df80..f62e983 100644 --- a/umodbus_test.py +++ b/umodbus_test.py @@ -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 = [ { @@ -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, @@ -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() + # %%