重新优化过的,功率因为数据是KW所以需要乘以1000变为W
[{“id”:“d9b93914a707aa85”,“type”:“mqtt out”,“z”:“2c507211.89ab3e”,“name”:“”,“topic”:“stat/power2/V1”,“qos”:“2”,“retain”:“true”,“respTopic”:“”,“contentType”:“”,“userProps”:“”,“correl”:“”,“expiry”:“”,“broker”:“84108b1c.bb18c8”,“x”:880,“y”:1920,“wires”:[]},{“id”:“23eb3a9a.33d1de”,“type”:“debug”,“z”:“2c507211.89ab3e”,“name”:“”,“active”:true,“tosidebar”:true,“console”:false,“tostatus”:false,“complete”:“false”,“x”:930,“y”:2180,“wires”:[]},{“id”:“46308ee.bf226f”,“type”:“function”,“z”:“2c507211.89ab3e”,“name”:“瞬时电压”,“func”:“var data_hex1 = ‘0000’ + msg.payload[0].toString(16);\nvar data_hex2 = ‘0000’ + msg.payload[1].toString(16);\n\nvar data_hex = data_hex1.substr(-4) + data_hex2.substr(-4);\n\nmsg.payload = Buffer.from(data_hex, ‘hex’).readFloatBE().toFixed(2) * 1;\n\nreturn msg;\n”,“outputs”:1,“noerr”:3,“initialize”:“”,“finalize”:“”,“libs”:[],“x”:520,“y”:1920,“wires”:[[“2157d580.48ee42”,“23eb3a9a.33d1de”]]},{“id”:“2157d580.48ee42”,“type”:“rbe”,“z”:“2c507211.89ab3e”,“name”:“”,“func”:“rbe”,“gap”:“”,“start”:“”,“inout”:“out”,“property”:“payload”,“x”:650,“y”:1920,“wires”:[[“d9b93914a707aa85”]]},{“id”:“eee3b2b7.cccc8”,“type”:“function”,“z”:“2c507211.89ab3e”,“name”:“瞬时电流”,“func”:“var data_hex1 = ‘0000’ + msg.payload[2].toString(16);\nvar data_hex2 = ‘0000’ + msg.payload[3].toString(16);\n\nvar data_hex = data_hex1.substr(-4) + data_hex2.substr(-4);\n\nmsg.payload = Buffer.from(data_hex, ‘hex’).readFloatBE().toFixed(4) * 1;\n\nreturn msg;\n”,“outputs”:1,“noerr”:3,“initialize”:“”,“finalize”:“”,“libs”:[],“x”:520,“y”:1980,“wires”:[[“76b62388.f9a77c”,“23eb3a9a.33d1de”]]},{“id”:“76b62388.f9a77c”,“type”:“rbe”,“z”:“2c507211.89ab3e”,“name”:“”,“func”:“rbe”,“gap”:“”,“start”:“”,“inout”:“out”,“property”:“payload”,“x”:650,“y”:1980,“wires”:[[]]},{“id”:“bb05fa57.1f35c”,“type”:“function”,“z”:“2c507211.89ab3e”,“name”:“有功功率”,“func”:“var data_hex1 = ‘0000’ + msg.payload[4].toString(16);\nvar data_hex2 = ‘0000’ + msg.payload[5].toString(16);\n\nvar data_hex = data_hex1.substr(-4) + data_hex2.substr(-4);\n\nmsg.payload = parseFloat((Buffer.from(data_hex, ‘hex’).readFloatBE() * 1000).toFixed(2));\n\nreturn msg;\n\n”,“outputs”:1,“noerr”:0,“initialize”:“”,“finalize”:“”,“libs”:[],“x”:520,“y”:2040,“wires”:[[“fa1e670e.dc3f9”,“23eb3a9a.33d1de”]]},{“id”:“fa1e670e.dc3f9”,“type”:“rbe”,“z”:“2c507211.89ab3e”,“name”:“”,“func”:“rbe”,“gap”:“”,“start”:“”,“inout”:“out”,“property”:“payload”,“x”:650,“y”:2040,“wires”:[[]]},{“id”:“f4a2f9ce.03a61”,“type”:“function”,“z”:“2c507211.89ab3e”,“name”:“无功功率”,“func”:“var data_hex1 = ‘0000’ + msg.payload[6].toString(16);\nvar data_hex2 = ‘0000’ + msg.payload[7].toString(16);\n\nvar data_hex = data_hex1.substr(-4) + data_hex2.substr(-4);\n\nmsg.payload = parseFloat((Buffer.from(data_hex, ‘hex’).readFloatBE() * 1000).toFixed(2));\n\nreturn msg;\n”,“outputs”:1,“noerr”:0,“initialize”:“”,“finalize”:“”,“libs”:[],“x”:520,“y”:2100,“wires”:[[“53e5a4be.0aed6c”]]},{“id”:“53e5a4be.0aed6c”,“type”:“rbe”,“z”:“2c507211.89ab3e”,“name”:“”,“func”:“rbe”,“gap”:“”,“start”:“”,“inout”:“out”,“property”:“payload”,“x”:650,“y”:2100,“wires”:[[]]},{“id”:“4444d5e3.6c39fc”,“type”:“function”,“z”:“2c507211.89ab3e”,“name”:“视在功率”,“func”:“var data_hex1 = ‘0000’ + msg.payload[8].toString(16);\nvar data_hex2 = ‘0000’ + msg.payload[9].toString(16);\n\nvar data_hex = data_hex1.substr(-4) + data_hex2.substr(-4);\n\nmsg.payload = parseFloat((Buffer.from(data_hex, ‘hex’).readFloatBE() * 1000).toFixed(2));\n\nreturn msg;\n”,“outputs”:1,“noerr”:0,“initialize”:“”,“finalize”:“”,“libs”:[],“x”:520,“y”:2160,“wires”:[[“1c38bac5.68d96d”]]},{“id”:“1c38bac5.68d96d”,“type”:“rbe”,“z”:“2c507211.89ab3e”,“name”:“”,“func”:“rbe”,“gap”:“”,“start”:“”,“inout”:“out”,“property”:“payload”,“x”:650,“y”:2160,“wires”:[[]]},{“id”:“a6c19189.af6c2”,“type”:“function”,“z”:“2c507211.89ab3e”,“name”:“功率因数”,“func”:“var data_hex1 = ‘0000’ + msg.payload[10].toString(16);\nvar data_hex2 = ‘0000’ + msg.payload[11].toString(16);\n\nvar data_hex = data_hex1.substr(-4) + data_hex2.substr(-4);\n\nmsg.payload = Buffer.from(data_hex, ‘hex’).readFloatBE().toFixed(2) * 1;\n\nreturn msg;\n”,“outputs”:1,“noerr”:3,“initialize”:“”,“finalize”:“”,“libs”:[],“x”:520,“y”:2220,“wires”:[[“aac74e5c.ecc75”]]},{“id”:“aac74e5c.ecc75”,“type”:“rbe”,“z”:“2c507211.89ab3e”,“name”:“”,“func”:“rbe”,“gap”:“”,“start”:“”,“inout”:“out”,“property”:“payload”,“x”:650,“y”:2220,“wires”:[[]]},{“id”:“71251d46.7de6ac”,“type”:“modbus-getter”,“z”:“2c507211.89ab3e”,“name”:“”,“showStatusActivities”:false,“showErrors”:false,“showWarnings”:true,“logIOActivities”:false,“unitid”:“9”,“dataType”:“HoldingRegister”,“adr”:“8192”,“quantity”:“12”,“server”:“902e06fe3e85f8f8”,“useIOFile”:false,“ioFile”:“”,“useIOForPayload”:false,“emptyMsgOnFail”:false,“keepMsgProperties”:false,“delayOnStart”:false,“startDelayTime”:“”,“x”:260,“y”:1980,“wires”:[[“46308ee.bf226f”,“eee3b2b7.cccc8”,“bb05fa57.1f35c”,“f4a2f9ce.03a61”,“4444d5e3.6c39fc”,“a6c19189.af6c2”],[]]},{“id”:“6caba6b7.f6748”,“type”:“inject”,“z”:“2c507211.89ab3e”,“name”:“start”,“props”:[{“p”:“payload”},{“p”:“topic”,“vt”:“str”}],“repeat”:“5”,“crontab”:“”,“once”:false,“onceDelay”:0.1,“topic”:“”,“payload”:“”,“payloadType”:“date”,“x”:70,“y”:1980,“wires”:[[“71251d46.7de6ac”,“a2e9f0e2.757058”,“a7f005c5.002b38”]]},{“id”:“a2e9f0e2.757058”,“type”:“modbus-getter”,“z”:“2c507211.89ab3e”,“name”:“”,“showStatusActivities”:false,“showErrors”:false,“showWarnings”:true,“logIOActivities”:false,“unitid”:“9”,“dataType”:“HoldingRegister”,“adr”:“8206”,“quantity”:“2”,“server”:“902e06fe3e85f8f8”,“useIOFile”:false,“ioFile”:“”,“useIOForPayload”:false,“emptyMsgOnFail”:false,“keepMsgProperties”:false,“delayOnStart”:false,“startDelayTime”:“”,“x”:180,“y”:2280,“wires”:[[“43fbf015e97a1901”],[]]},{“id”:“4b11f216.74c22c”,“type”:“function”,“z”:“2c507211.89ab3e”,“name”:“电网频率”,“func”:“var data_hex1 = ‘0000’ + msg.payload[0].toString(16);\nvar data_hex2 = ‘0000’ + msg.payload[1].toString(16);\n\nvar data_hex = data_hex1.substr(-4) + data_hex2.substr(-4);\n\nmsg.payload = Buffer.from(data_hex, ‘hex’).readFloatBE().toFixed(2) * 1;\n\nreturn msg;\n”,“outputs”:1,“noerr”:3,“initialize”:“”,“finalize”:“”,“libs”:[],“x”:520,“y”:2280,“wires”:[[“7473f78.3e10a08”,“23eb3a9a.33d1de”]]},{“id”:“7473f78.3e10a08”,“type”:“rbe”,“z”:“2c507211.89ab3e”,“name”:“”,“func”:“rbe”,“gap”:“”,“start”:“”,“inout”:“out”,“property”:“payload”,“x”:650,“y”:2280,“wires”:[[]]},{“id”:“a7f005c5.002b38”,“type”:“modbus-getter”,“z”:“2c507211.89ab3e”,“name”:“”,“showStatusActivities”:false,“showErrors”:false,“showWarnings”:true,“logIOActivities”:false,“unitid”:“9”,“dataType”:“HoldingRegister”,“adr”:“16384”,“quantity”:“2”,“server”:“902e06fe3e85f8f8”,“useIOFile”:false,“ioFile”:“”,“useIOForPayload”:false,“emptyMsgOnFail”:false,“keepMsgProperties”:false,“delayOnStart”:false,“startDelayTime”:“”,“x”:180,“y”:2340,“wires”:[[“4dd233bc9d7042a1”],[]]},{“id”:“1d5de1de.232736”,“type”:“function”,“z”:“2c507211.89ab3e”,“name”:“总用电量”,“func”:“var data_hex1 = ‘0000’ + msg.payload[0].toString(16);\nvar data_hex2 = ‘0000’ + msg.payload[1].toString(16);\n\nvar data_hex = data_hex1.substr(-4) + data_hex2.substr(-4);\n\nmsg.payload = Buffer.from(data_hex, ‘hex’).readFloatBE().toFixed(2) * 1;\n\nreturn msg;\n”,“outputs”:1,“noerr”:3,“initialize”:“”,“finalize”:“”,“libs”:[],“x”:520,“y”:2340,“wires”:[[“54cca990.6e2ef”,“23eb3a9a.33d1de”]]},{“id”:“54cca990.6e2ef”,“type”:“rbe”,“z”:“2c507211.89ab3e”,“name”:“”,“func”:“rbe”,“gap”:“”,“start”:“”,“inout”:“out”,“property”:“payload”,“x”:650,“y”:2340,“wires”:[[]]},{“id”:“de0cf31c.e52d08”,“type”:“comment”,“z”:“2c507211.89ab3e”,“name”:“DDSU666 modbus电表数据读取 地址98”,“info”:“”,“x”:150,“y”:1920,“wires”:[]},{“id”:“43fbf015e97a1901”,“type”:“delay”,“z”:“2c507211.89ab3e”,“name”:“”,“pauseType”:“delay”,“timeout”:“10”,“timeoutUnits”:“milliseconds”,“rate”:“1”,“nbRateUnits”:“1”,“rateUnits”:“second”,“randomFirst”:“1”,“randomLast”:“5”,“randomUnits”:“seconds”,“drop”:false,“allowrate”:false,“outputs”:1,“x”:370,“y”:2280,“wires”:[[“4b11f216.74c22c”]]},{“id”:“4dd233bc9d7042a1”,“type”:“delay”,“z”:“2c507211.89ab3e”,“name”:“”,“pauseType”:“delay”,“timeout”:“10”,“timeoutUnits”:“milliseconds”,“rate”:“1”,“nbRateUnits”:“1”,“rateUnits”:“second”,“randomFirst”:“1”,“randomLast”:“5”,“randomUnits”:“seconds”,“drop”:false,“allowrate”:false,“outputs”:1,“x”:370,“y”:2340,“wires”:[[“1d5de1de.232736”]]},{“id”:“84108b1c.bb18c8”,“type”:“mqtt-broker”,“name”:“hass”,“broker”:“192.168.31.34”,“port”:“1883”,“clientid”:“”,“autoConnect”:true,“usetls”:false,“protocolVersion”:“4”,“keepalive”:“60”,“cleansession”:true,“birthTopic”:“”,“birthQos”:“0”,“birthPayload”:“”,“birthMsg”:{},“closeTopic”:“”,“closeQos”:“0”,“closePayload”:“”,“closeMsg”:{},“willTopic”:“”,“willQos”:“0”,“willPayload”:“”,“willMsg”:{},“userProps”:“”,“sessionExpiry”:“”},{“id”:“902e06fe3e85f8f8”,“type”:“modbus-client”,“name”:“”,“clienttype”:“tcp”,“bufferCommands”:true,“stateLogEnabled”:false,“queueLogEnabled”:false,“failureLogEnabled”:true,“tcpHost”:“192.168.31.154”,“tcpPort”:“502”,“tcpType”:“DEFAULT”,“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,“showWarnings”:true,“showLogs”:true}]