Tu macie gotowe rozwiązanie w NR dla RS485 TO ETH
mam ustawiony odczyt danych co 5 sek. dodatkowo Sun uruchamia od wschodu do zachodu co nie generuje błędów
[{"id":"48cc9a921a31d177","type":"group","z":"1a13f792a3e02171","name":"","style":{"fill":"#ffffff","label":true},"nodes":["364d4862b8c1c670","2c8da07d9aafbd54","7c66a5d045e74b55","f708bb943aa839b9","ada6aaec5b4d3b2d","091475ede0f94e70","82a4f926470cb144","4d55e89931ab77fa","ba6653977a578b5b","8b0ccf75bed20721","1b23e2367906fbef","f7a0e26d62af508a"],"x":34,"y":39,"w":1752,"h":282},{"id":"364d4862b8c1c670","type":"function","z":"1a13f792a3e02171","g":"48cc9a921a31d177","name":"Zakers","func":"msg.payload = { 'fc': 3, 'unitid': 1, 'address': 0, 'quantity': 29 }\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":430,"y":180,"wires":[["2c8da07d9aafbd54"]]},{"id":"2c8da07d9aafbd54","type":"modbus-flex-getter","z":"1a13f792a3e02171","g":"48cc9a921a31d177","name":"Modbus","showStatusActivities":true,"showErrors":true,"logIOActivities":false,"server":"8c10d23c6b3ade63","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":true,"keepMsgProperties":true,"x":600,"y":180,"wires":[["7c66a5d045e74b55"],[]]},{"id":"7c66a5d045e74b55","type":"change","z":"1a13f792a3e02171","g":"48cc9a921a31d177","name":"Buffer","rules":[{"t":"set","p":"payload","pt":"msg","to":"msg.responseBuffer.buffer","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":750,"y":180,"wires":[["f708bb943aa839b9"]]},{"id":"f708bb943aa839b9","type":"function","z":"1a13f792a3e02171","g":"48cc9a921a31d177","name":"KTL config","func":"var ratio =[1,1,1,1,1,1,0.1,0.01,0.1,0.01,\n 10,10,10,10,0.01,0.1,0.01,0.1,0.01,0.1,\n 0.01,1,1,1,1,0.01,1,1,1,1,1,1,1,1,1,1,1,1,1,1];\nvar state =[\"Oczekiwanie\",\"Weryfikacja wewn.\",\"Normalny\",\"BLAD\",\"Permanent\"];\nvar data ='{\"data\":[';\nvar val =0;\nvar Hi = 0;\nvar i = 0;\nfor (i=0; i<=28 ; i++){\n data +='{\"id\":\"'+i.toString()+'\",\"values\":[' \n switch(i) {\n case 21:\n Hi = msg.payload[i*2]*256 +msg.payload[i*2+1];\n i++;\n val = msg.payload[i*2]*256 +msg.payload[i*2+1];\n val += Hi*255;\n break;\n case 23:\n Hi = msg.payload[i*2]*256 +msg.payload[i*2+1];\n i++;\n val = msg.payload[i*2]*256 +msg.payload[i*2+1];\n val += Hi*255;\n break;\n default:\n val = msg.payload[i*2]*256 +msg.payload[i*2+1];\n }\n\n val = val*ratio[i]; \n data +=val.toFixed (2);\n\n data +=']},';\n\n}\n\nmsg.payload = data.slice(0,-1)+']}'; \nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":890,"y":180,"wires":[["ada6aaec5b4d3b2d"]]},{"id":"ada6aaec5b4d3b2d","type":"json","z":"1a13f792a3e02171","g":"48cc9a921a31d177","name":"Konwerter","property":"payload","action":"","pretty":false,"x":1050,"y":180,"wires":[["091475ede0f94e70"]]},{"id":"091475ede0f94e70","type":"change","z":"1a13f792a3e02171","g":"48cc9a921a31d177","name":"Payload","rules":[{"t":"move","p":"payload.data","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1200,"y":180,"wires":[["4d55e89931ab77fa"]]},{"id":"82a4f926470cb144","type":"mqtt out","z":"1a13f792a3e02171","g":"48cc9a921a31d177","name":"HAOS Mqtt","topic":"","qos":"","retain":"true","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"e395f9f9.d86858","x":1690,"y":180,"wires":[]},{"id":"4d55e89931ab77fa","type":"split","z":"1a13f792a3e02171","g":"48cc9a921a31d177","name":"Topic","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"topic","x":1330,"y":180,"wires":[["ba6653977a578b5b"]]},{"id":"ba6653977a578b5b","type":"function","z":"1a13f792a3e02171","g":"48cc9a921a31d177","name":"Sensory","func":"var topic ='RS485-SOFAR';\nvar idMap = {\n'0': topic+'/Status',\n'1': topic+'/Blad -1',\n'2': topic+'/Blad -2',\n'3': topic+'/Blad -3',\n'4': topic+'/Blad -4',\n'5': topic+'/Blad -5',\n'6': topic+'/Napiecie string 1',\n'7': topic+'/Prad string 1',\n'8': topic+'/Napiecie string 2',\n'9': topic+'/Prad string 2',\n'10': topic+'/Moc string 1',\n'11': topic+'/Moc string 2',\n'12': topic+'/Aktualna moc czynna',\n'13': topic+'/Aktualna moc pozorna',\n'14': topic+'/Czestotliwosc',\n'15': topic+'/Napiecie faza L1',\n'16': topic+'/Prad faza L1',\n'17': topic+'/Napiecie faza L2',\n'18': topic+'/Prad faza L2',\n'19': topic+'/Napiecie faza L3',\n'20': topic+'/Prad faza L3',\n'21': topic+'/Narastająca produkcja',\n'23': topic+'/Czas pracy falownika',\n'24': topic+ '/NIC',\n'25': topic+'/Dzisiejsza energia',\n'26': topic+'/Dzisiejszy czas pracy',\n'27': topic+'/Temperatura modulu',\n'28': topic+'/Temperatura falownika',\n};\n\nmsg.topic = idMap[msg.payload.id];\nmsg.payload = msg.payload.values[0];\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1480,"y":180,"wires":[["82a4f926470cb144"]]},{"id":"8b0ccf75bed20721","type":"function","z":"1a13f792a3e02171","g":"48cc9a921a31d177","name":"gate","func":"if (msg.topic == \"sun\"){\n context.set(\"Day\", msg.payload);\n return null;\n}\nif (msg.topic == \"time\"){\n var gate = context.get(\"Day\") || 0;\n if (gate ==1){\n return msg;\n }\n else {\n return null; \n }\n}\nreturn null;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":290,"y":180,"wires":[["364d4862b8c1c670"]]},{"id":"1b23e2367906fbef","type":"sunrise","z":"1a13f792a3e02171","g":"48cc9a921a31d177","name":"","lat":"51.784","lon":"19.299","start":"dawn","end":"sunset","soff":"0","eoff":"40","x":130,"y":80,"wires":[["8b0ccf75bed20721"],[]]},{"id":"f7a0e26d62af508a","type":"inject","z":"1a13f792a3e02171","g":"48cc9a921a31d177","name":"","props":[{"p":"topic","vt":"str"}],"repeat":"5","crontab":"","once":false,"onceDelay":0.1,"topic":"time","x":130,"y":280,"wires":[["8b0ccf75bed20721"]]},{"id":"8c10d23c6b3ade63","type":"modbus-client","name":"MODBUS","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":false,"queueLogEnabled":false,"failureLogEnabled":false,"tcpHost":"10.0.0.5","tcpPort":"503","tcpType":"TELNET","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","serialAsciiResponseStartDelimiter":"0x3A","unit_id":"1","commandDelay":"1","clientTimeout":"1000","reconnectOnTimeout":true,"reconnectTimeout":"2000","parallelUnitIdsAllowed":true},{"id":"e395f9f9.d86858","type":"mqtt-broker","name":"HAOS Mqqt","broker":"localhost","port":"1883","clientid":"","autoConnect":true,"usetls":false,"compatmode":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""}]
Dodatkowo przesyłam już gotowca w MQTT
####################################################################################################
## SofarSolar lokalnie ##
## NodeRed dane pobierane z falownika RS485-SOFAR ##
####################################################################################################
# - 0
- name: "MOD-BUS Status"
state_topic: "RS485-SOFAR/Status"
icon: mdi:alert
# 1,2,3,4,5
- name: "MOD-BUS Blad nr 1"
state_topic: "RS485-SOFAR/Blad -1"
icon: mdi:alert
- name: "MOD-BUS Blad nr 2"
state_topic: "RS485-SOFAR/Blad -2"
icon: mdi:alert
- name: "MOD-BUS Blad nr 3"
state_topic: "RS485-SOFAR/Blad -3"
icon: mdi:alert
- name: "MOD-BUS Blad nr 4"
state_topic: "RS485-SOFAR/Blad -4"
icon: mdi:alert
- name: "MOD-BUS Blad nr 5"
state_topic: "RS485-SOFAR/Blad -5"
icon: mdi:alert
# Sensory prądu stałego
- name: "MOD-BUS napięcie string 1"
state_topic: "RS485-SOFAR/Napiecie string 1"
device_class: voltage
unit_of_measurement: "V"
icon: mdi:alpha-v-circle-outline
- name: "MOD-BUS napięcie string 2"
state_topic: "RS485-SOFAR/Napiecie string 2"
device_class: voltage
unit_of_measurement: "V"
icon: mdi:alpha-v-circle-outline
- name: "MOD-BUS prąd string 1"
state_topic: "RS485-SOFAR/Prad string 1"
device_class: current
unit_of_measurement: "A"
icon: mdi:alpha-a-circle-outline
- name: "MOD-BUS prąd string 2"
state_topic: "RS485-SOFAR/Prad string 2"
device_class: current
unit_of_measurement: "A"
icon: mdi:alpha-a-circle-outline
- name: "MOD-BUS moc string 1"
state_topic: "RS485-SOFAR/Moc string 1"
device_class: power
unit_of_measurement: "W"
icon: mdi:alpha-w-circle
- name: "MOD-BUS moc string 2"
state_topic: "RS485-SOFAR/Moc string 2"
device_class: power
unit_of_measurement: "W"
icon: mdi:alpha-w-circle
# Sensory mocy
- name: "MOD-BUS Aktualna moc"
state_topic: "RS485-SOFAR/Aktualna moc czynna"
device_class: power
unit_of_measurement: "W"
icon: mdi:alpha-w-circle
- name: "MOD-BUS Aktualna moc pozorna"
state_topic: "RS485-SOFAR/Aktualna moc pozorna"
icon: mdi:alpha-w-circle
# Prąd zmienny
- name: "MOD-BUS Napiecie faza L1"
state_topic: "RS485-SOFAR/Napiecie faza L1"
device_class: voltage
unit_of_measurement: "V"
icon: mdi:alpha-v-circle-outline
- name: "MOD-BUS Napiecie faza L2"
state_topic: "RS485-SOFAR/Napiecie faza L2"
device_class: voltage
unit_of_measurement: "V"
icon: mdi:alpha-v-circle-outline
- name: "MOD-BUS Napiecie faza L3"
state_topic: "RS485-SOFAR/Napiecie faza L3"
device_class: voltage
unit_of_measurement: "V"
icon: mdi:alpha-v-circle-outline
- name: "MOD-BUS Prad faza L1"
state_topic: "RS485-SOFAR/Prad faza L1"
device_class: current
unit_of_measurement: "A"
icon: mdi:alpha-a-circle-outline
- name: "MOD-BUS Prad faza L2"
state_topic: "RS485-SOFAR/Prad faza L2"
device_class: current
unit_of_measurement: "A"
icon: mdi:alpha-a-circle-outline
- name: "MOD-BUS Prad faza L3"
state_topic: "RS485-SOFAR/Prad faza L3"
device_class: current
unit_of_measurement: "A"
icon: mdi:alpha-a-circle-outline
- name: "MOD-BUS Czestotliwosc"
state_topic: "RS485-SOFAR/Czestotliwosc"
device_class: frequency
unit_of_measurement: "Hz"
icon: mdi:sine-wave
# Temperatury
- name: "MOD-BUS Temperatura falownika"
state_topic: "RS485-SOFAR/Temperatura falownika"
device_class: temperature
unit_of_measurement: "°C"
icon: mdi:thermometer
- name: "MOD-BUS Temperatura modulu"
state_topic: "RS485-SOFAR/Temperatura modulu"
device_class: temperature
unit_of_measurement: "°C"
icon: mdi:thermometer
# Czasy pracy
- name: "MOD-BUS Czas pracy falownika narastająco"
state_topic: "RS485-SOFAR/Czas pracy falownika"
unit_of_measurement: "minuta"
icon: mdi:clock-time-eight
- name: "MOD-BUS Dzisiejszy czas pracy falownika"
state_topic: "RS485-SOFAR/Dzisiejszy czas pracy"
unit_of_measurement: "minuta"
icon: mdi:clock-time-eight
# Energia
- name: "MOD-BUS Energia dzisiaj"
state_topic: "RS485-SOFAR/Dzisiejsza energia"
state_class: total_increasing
device_class: energy
unit_of_measurement: "kWh"
icon: mdi:solar-power
- name: "MOD-BUS Energia narastająco"
state_topic: "RS485-SOFAR/Narastająca produkcja"
state_class: total_increasing
device_class: energy
unit_of_measurement: "kWh"
icon: mdi:solar-power