[{"id":"9e7e5724.c78fd8","type":"trigger-state","z":"5879f2b4.6f914c","name":"主卧温度变化","server":"5ef70ae9.2b1354","entityid":"sensor.air_purifier_temp_zhuwo","entityidfiltertype":"exact","debugenabled":false,"constraints":[],"constraintsmustmatch":"all","outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","x":260,"y":660,"wires":[["8c434058.aaebb","466f6fe8.cedd9"],[]]},{"id":"3e26d022.2b60e","type":"trigger-state","z":"5879f2b4.6f914c","name":"主卧湿度变化","server":"5ef70ae9.2b1354","entityid":"sensor.air_purifier_humid_zhuwo","entityidfiltertype":"exact","debugenabled":false,"constraints":[],"constraintsmustmatch":"all","outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","x":260,"y":740,"wires":[["466f6fe8.cedd9","8c434058.aaebb"],[]]},{"id":"8c434058.aaebb","type":"api-current-state","z":"5879f2b4.6f914c","name":"主卧温度","server":"5ef70ae9.2b1354","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"sensor.air_purifier_temp_zhuwo","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"","override_data":"none","blockInputOverrides":false,"x":480,"y":660,"wires":[["63cdbb54.601604"]]},{"id":"466f6fe8.cedd9","type":"api-current-state","z":"5879f2b4.6f914c","name":"主卧湿度","server":"5ef70ae9.2b1354","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"sensor.air_purifier_humid_zhuwo","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"","override_data":"none","blockInputOverrides":false,"x":480,"y":740,"wires":[["63cdbb54.601604"]]},{"id":"63cdbb54.601604","type":"join","z":"5879f2b4.6f914c","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":710,"y":660,"wires":[["5312faee.0d6634"]]},{"id":"5312faee.0d6634","type":"function","z":"5879f2b4.6f914c","name":"体感温度","func":"var T = msg.payload['sensor.air_purifier_temp_zhuwo'];\nvar RH = msg.payload['sensor.air_purifier_humid_zhuwo'];\nif (RH < 1)\n{\n RH = RH * 100;\n}\nT = 1.8 * T + 32;\nHI = 0.5 * (T + 61 + (T - 68) * 1.2 + RH * 0.094);\nif (HI >= 80)\n{\n HI = -42.379 + 2.04901523 * T + 10.14333127 * RH - .22475541 * T * RH - .00683783 * T * T - .05481717 * RH * RH + .00122874 * T * T * RH + .00085282 * T * RH * RH - .00000199 * T * T * RH * RH;\n\n if ((RH < 13) && (T > 80) && (T < 122))\n {\n ADJUSTMENT = (13 - RH) / 4 * math.sqrt((17 - abs(T - 95)) / 17) \n HI -= ADJUSTMENT \n }\n else if ((RH > 85) && (T > 80) && (T < 87))\n {\n ADJUSTMENT = (RH - 85) * (87 - T) / 50 \n HI += ADJUSTMENT \n }\n}\n\nfunction keepXDecimalFull(num, x) {\n var result = parseFloat(num);\n if (isNaN(result)) {\n console.log('传递参数错误,请检查!');\n return false;\n }\n var times = Math.pow(10, x);\n result = Math.round(num * times) / times;\n var s_x = result.toString();\n var pos_decimal = s_x.indexOf('.');\n if (pos_decimal < 0) {\n pos_decimal = s_x.length;\n s_x += '.';\n }\n while (s_x.length <= pos_decimal + x) {\n s_x += '0';\n }\n return s_x;\n }\n \n\nHI = (HI - 32)/1.8;\nHI = keepXDecimalFull(HI,1)\nmsg.payload = HI;\n//msg.payload = `${(new Date()).toLocaleTimeString()} heat n xi ${msg.payload['sensor.air_purifier_temp_xiwo']} ke ${msg.payload['sensor.air_purifier_temp_pro']} zhu ${msg.payload['sensor.air_purifier_temp_zhuwo']}`\n//toLocaleTimeString 17:42:28\n//toLocaleString 2019-1-20 16:23:59\nreturn msg\n","outputs":1,"noerr":0,"x":960,"y":660,"wires":[["7828ba92.779de4","5420e1e2.44884","6d9fa28d.de4f3c","61959f13.a504c"]]},{"id":"5420e1e2.44884","type":"function","z":"5879f2b4.6f914c","name":"mqtt消息整理","func":"var payload = {}\npayload.zhuwo_AT = msg.payload;\n\nmsg.payload = payload;\n\nreturn msg;","outputs":1,"noerr":0,"x":1240,"y":760,"wires":[["96da8c17.7bf35"]]},{"id":"96da8c17.7bf35","type":"mqtt out","z":"5879f2b4.6f914c","name":"mqtt转发主卧体感温度","topic":"/node-red/zhuwo_AT","qos":"0","retain":"","broker":"ef2f2af4.c25da8","x":1460,"y":760,"wires":[]},{"id":"5ef70ae9.2b1354","type":"server","z":"","name":"Home Assistant 2","legacy":false,"hassio":false,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true},{"id":"ef2f2af4.c25da8","type":"mqtt-broker","z":"","name":"","broker":"192.168.1.6","port":"1883","clientid":"red2","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]