I managed to get a modbus connection running via the wi-fi dongle now.
Here’s how to reproduce it:
Add modbus connection in configuration.yaml:
modbus: !include modbus.yaml
Create modbus.yaml in the config dir and enter this (just one POC command for now to retrieve active power)
- name: modbus_solplanet
type: rtuovertcp
host: 127.0.0.1
port: 502
sensors:
- name: Active Power
unit_of_measurement: W
slave: 3
address: 1370
input_type: input
data_type: int32
min_value: 0
Built a Node Red flow like below. It opens a tcp port 502 on the HA system and convert to and from hex string and JSON, basically behaving like a proxy translater service (just replace with your inverter IP in the http request:
[
{
"id": "094fa30b52f0902e",
"type": "tab",
"label": "Solplanet modbus via FDBG.CGI",
"disabled": false,
"info": "",
"env": []
},
{
"id": "8e966d69e2e7fffa",
"type": "http request",
"z": "094fa30b52f0902e",
"name": "",
"method": "POST",
"ret": "obj",
"paytoqs": "query",
"url": "http://192.168.1.127:8484/fdbg.cgi",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [
{
"keyType": "Content-Type",
"keyValue": "",
"valueType": "application/json",
"valueValue": ""
}
],
"x": 170,
"y": 240,
"wires": [
[
"fba4c181689f43f5"
]
],
"info": "Call FDBG.CGI"
},
{
"id": "f7175970bcfa5bc0",
"type": "tcp in",
"z": "094fa30b52f0902e",
"name": "",
"server": "server",
"host": "",
"port": "502",
"datamode": "stream",
"datatype": "buffer",
"newline": "",
"topic": "",
"trim": false,
"base64": false,
"tls": "",
"x": 130,
"y": 100,
"wires": [
[
"3af19067e5e83ce9",
"fcb1504cb7d64448"
]
]
},
{
"id": "082c048a0f2b256f",
"type": "tcp out",
"z": "094fa30b52f0902e",
"name": "",
"host": "",
"port": "",
"beserver": "reply",
"base64": false,
"end": false,
"tls": "",
"x": 150,
"y": 360,
"wires": []
},
{
"id": "3af19067e5e83ce9",
"type": "debug",
"z": "094fa30b52f0902e",
"name": "modbus input",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "true",
"targetType": "full",
"statusVal": "payload",
"statusType": "auto",
"x": 340,
"y": 100,
"wires": []
},
{
"id": "fcb1504cb7d64448",
"type": "function",
"z": "094fa30b52f0902e",
"name": "form JSON",
"func": "var Hexstring = msg.payload.toString('hex');\nmsg.payload = {\n \"data\": Hexstring\n}\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 150,
"y": 180,
"wires": [
[
"8e966d69e2e7fffa"
]
]
},
{
"id": "fba4c181689f43f5",
"type": "function",
"z": "094fa30b52f0902e",
"name": "form buffer",
"func": "var Response = msg.payload;\nmsg.payload = Buffer.from(msg.payload.data, \"hex\");\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 170,
"y": 300,
"wires": [
[
"a6a8edf93eff2972",
"082c048a0f2b256f"
]
]
},
{
"id": "a6a8edf93eff2972",
"type": "debug",
"z": "094fa30b52f0902e",
"name": "Inverter response",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 370,
"y": 300,
"wires": []
}
]
If all goes well, you now have an active power sensor.
From here it’s just a matter of adding more functions to the modbus.yaml file.
All the functions in the document shared by derkorte can be implemented wihtout any additional hardware.