Good evening
I am in possession of a PV from SMA and now also an AC-Thor 9s to control my 2 heating elements in the TWS. By default, the AC-Thor can be integrated into the plant via the SMA website, but unfortunately it has to be determined that the system is much too sluggish and unnecessarily strains the battery because the system is much too slow when the sun's radiation is changed.
Have node-red-contrib-modbus installed and now access it to the AC-Thor.
Please note: SMA Home Manager and Modbus connection do not work at the same time (many thanks to the friendly support of MY PV!)
There then the registers 1078, 1079 and 1080 must be addressed.
In general, it works so far (currently because of the bad weather but not yet fully tested), but I still have questions (for the purpose of improvement).
If I calculate the current value and pass it to the AC-Thor, in the next query maybe will no power exess (because completely run in the AC Thor) there and I would switch the output to zero, although it is actually with the same value could continue.
I would have to save the last value and then readjust with the newly calculated value.
Here's my flow, maybe it's a bit easier to understand
[
{
"id": "cbe0c8eb.39d538",
"type": "tab",
"label": "AC Thor",
"disabled": false,
"info": ""
},
{
"id": "8d9434b0.ada618",
"type": "function",
"z": "cbe0c8eb.39d538",
"name": "Ansteure Berechnung",
"func": "\nvar batterie = msg.batterieladung;\nvar netzbezug = msg.netzbezug;\nvar netzein = msg.netzeinspeisung;\nvar batteriepro = msg.batteriezustand\nvar ansteuer = 0;\nvar temp_oben = msg.tws_oben;\nvar temp_unten = msg.tws_unten;\n\nif (batterie>=60){\n ansteuer = netzein-netzbzug+(batterie/2)\n if (ansteuer<0){\n ansteuer=0;} \n if (temp_oben<60){\n if (ansteuer>3000){\n ansteuer= ansteuer+17480;\n if (ansteuer>23480){\n ansteuer = 23480;}\n }\n ansteuer = ansteuer+8192;\n }\n if (temp_oben>=60&temp_unten<60){\n if (ansteuer>3000){\n ansteuer= 7096;}\n ansteuer = ansteuer+4096;\n }\n if (temp_unten>=60){\n ansteuer = 0;}\n}\nmsg.payload = { \n value: [ 0, 0, ansteuer],\n 'fc': 16,\n 'unitid': 1,\n 'address': 1078 ,\n 'quantity': 3\n} \nreturn msg",
"outputs": 1,
"noerr": 0,
"x": 780,
"y": 240,
"wires": [
[
"220e6f42.3a783",
"d8b22813.2934d"
]
]
},
{
"id": "d8b22813.2934d",
"type": "modbus-flex-write",
"z": "cbe0c8eb.39d538",
"name": "",
"showStatusActivities": true,
"showErrors": true,
"server": "ca0608f4.4583b8",
"x": 710,
"y": 460,
"wires": [
[
"d94367f.f046698",
"5020a65b.5f5c8"
],
[]
]
},
{
"id": "d94367f.f046698",
"type": "debug",
"z": "cbe0c8eb.39d538",
"name": "",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"x": 410,
"y": 640,
"wires": []
},
{
"id": "220e6f42.3a783",
"type": "debug",
"z": "cbe0c8eb.39d538",
"name": "",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"x": 830,
"y": 360,
"wires": []
},
{
"id": "5020a65b.5f5c8",
"type": "modbus-response",
"z": "cbe0c8eb.39d538",
"name": "",
"registerShowMax": 20,
"x": 690,
"y": 600,
"wires": []
},
{
"id": "8c5481f3.33164",
"type": "ioBroker get",
"z": "cbe0c8eb.39d538",
"name": "Batterie in %",
"topic": "modbus.0.inputRegisters.30845_Batterieladezustand",
"attrname": "batteriezustand",
"payloadType": "value",
"x": 450,
"y": 180,
"wires": [
[
"8d9434b0.ada618"
]
]
},
{
"id": "9f0f418b.4518f8",
"type": "ioBroker get",
"z": "cbe0c8eb.39d538",
"name": "Netzbezug",
"topic": "modbus.0.inputRegisters.30865_Netzbezug",
"attrname": "netzbezug",
"payloadType": "value",
"x": 450,
"y": 240,
"wires": [
[
"8d9434b0.ada618"
]
]
},
{
"id": "574ff594.bd13ec",
"type": "ioBroker get",
"z": "cbe0c8eb.39d538",
"name": "Netzeinspeisung",
"topic": "modbus.0.inputRegisters.30867_Netzeinspeisung",
"attrname": "netzeinspeisung",
"payloadType": "value",
"x": 470,
"y": 300,
"wires": [
[
"8d9434b0.ada618"
]
]
},
{
"id": "fb8e95a6.77d72",
"type": "ioBroker get",
"z": "cbe0c8eb.39d538",
"name": "TWS_oben",
"topic": "parser.0.TWS_oben",
"attrname": "tws_oben",
"payloadType": "value",
"x": 450,
"y": 360,
"wires": [
[
"8d9434b0.ada618"
]
]
},
{
"id": "1356b7d1.7f0418",
"type": "ioBroker get",
"z": "cbe0c8eb.39d538",
"name": "TWS_unten",
"topic": "parser.0.TWS_unten",
"attrname": "tws_unten",
"payloadType": "value",
"x": 450,
"y": 420,
"wires": [
[
"8d9434b0.ada618"
]
]
},
{
"id": "f27aba08.8eaeb8",
"type": "ioBroker get",
"z": "cbe0c8eb.39d538",
"name": "Batterieladung",
"topic": "modbus.0.inputRegisters.31393_BatterieLadung",
"attrname": "batterieladung",
"payloadType": "value",
"x": 460,
"y": 100,
"wires": [
[
"8d9434b0.ada618"
]
],
"outputLabels": [
"ms"
]
},
{
"id": "422bc6e8.ec058",
"type": "inject",
"z": "cbe0c8eb.39d538",
"name": "",
"topic": "",
"payload": "",
"payloadType": "date",
"repeat": "5",
"crontab": "",
"once": true,
"onceDelay": "3",
"x": 130,
"y": 220,
"wires": [
[
"f27aba08.8eaeb8",
"8c5481f3.33164",
"9f0f418b.4518f8",
"574ff594.bd13ec",
"fb8e95a6.77d72",
"1356b7d1.7f0418"
]
]
},
{
"id": "ca0608f4.4583b8",
"type": "modbus-client",
"z": "",
"name": "Ac thor 9s",
"clienttype": "tcp",
"bufferCommands": true,
"stateLogEnabled": false,
"tcpHost": "192.168.1.210",
"tcpPort": "502",
"tcpType": "DEFAULT",
"serialPort": "/dev/ttyUSB",
"serialType": "RTU-BUFFERD",
"serialBaudrate": "9600",
"serialDatabits": "8",
"serialStopbits": "1",
"serialParity": "none",
"serialConnectionDelay": "100",
"unit_id": "1",
"commandDelay": "10",
"clientTimeout": "1000",
"reconnectTimeout": "2000"
}
Now to my questions:
- So, with the assignment of the variables at the function from Iobroker.get states, is this the correct way at function code?
- How can I save the value "ansteuer" from the function in a varible, so that I can read it in again next time.
- Variable "ansteuer" can not be negative yet, how can change this.
Thank you very much and I hope that one or the other can help this with his Ac-Thor