你參考看看
[{"id":"66eba66da742b1ac","type":"comment","z":"e05bb790.045998","name":"Xiaomi Purifier 2S","info":"Function node can send multiple messages to output ports by returning an array of messages. \n\nSee Node-RED user guide about [functions](https://nodered.org/docs/user-guide/writing-functions).","x":130,"y":840,"wires":[]},{"id":"6f61068fdade14a1","type":"server-state-changed","z":"e05bb790.045998","name":"Xiaomi purifier","server":"2caefc09.0b4a04","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"fan.kong_qi_jing_hua_qi","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":false,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":110,"y":920,"wires":[["e9a22d1fa9d05b23"]]},{"id":"5f4b98269db6b1b8","type":"server-state-changed","z":"e05bb790.045998","name":"Auto/ Maunal","server":"2caefc09.0b4a04","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_select.xiaomi_airpurifier_mode","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":false,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":110,"y":980,"wires":[["da215ae3d856f8ae"]]},{"id":"da215ae3d856f8ae","type":"change","z":"e05bb790.045998","name":"轉換","rules":[{"t":"change","p":"payload","pt":"msg","from":"Auto","fromt":"str","to":"{\"TargetAirPurifierState\":1}","tot":"json"},{"t":"change","p":"payload","pt":"msg","from":"Favorite","fromt":"str","to":"{\"TargetAirPurifierState\":0}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":980,"wires":[["43451b7056f5684f"]]},{"id":"e9a22d1fa9d05b23","type":"change","z":"e05bb790.045998","name":"轉換","rules":[{"t":"change","p":"payload","pt":"msg","from":"on","fromt":"str","to":"{\"CurrentAirPurifierState\":2,\"Active\":1}","tot":"json"},{"t":"change","p":"payload","pt":"msg","from":"off","fromt":"str","to":"{\"CurrentAirPurifierState\":0,\"Active\":0}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":920,"wires":[["43451b7056f5684f"]]},{"id":"49a9fdb84a51f3b0","type":"change","z":"e05bb790.045998","name":"轉換","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"RotationSpeed\": $number(msg.payload) * 7}\t\t","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":270,"y":1100,"wires":[["43451b7056f5684f"]]},{"id":"1d87767e44bf3012","type":"server-state-changed","z":"e05bb790.045998","name":"Speed","server":"2caefc09.0b4a04","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"number.kong_qi_jing_hua_qi_favorite_level","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":90,"y":1100,"wires":[["49a9fdb84a51f3b0"]]},{"id":"84a8854f55a0b1ac","type":"server-state-changed","z":"e05bb790.045998","name":"Lock","server":"2caefc09.0b4a04","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"switch.kong_qi_jing_hua_qi_child_lock","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":false,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":90,"y":1040,"wires":[["05d42249202b6794"]]},{"id":"43451b7056f5684f","type":"homekit-service","z":"e05bb790.045998","isParent":true,"hostType":"0","bridge":"3d5ca1527ce61722","accessoryId":"","parentService":"","name":"Xiaomi Purifier","serviceName":"AirPurifier","topic":"","filter":false,"manufacturer":"Xiaomi","model":"zhimi.airpurifier.mb1","serialNo":"Default Serial Number","firmwareRev":"1.3.6","hardwareRev":"1.3.6","softwareRev":"1.3.6","cameraConfigVideoProcessor":"ffmpeg","cameraConfigSource":"","cameraConfigStillImageSource":"","cameraConfigMaxStreams":2,"cameraConfigMaxWidth":1280,"cameraConfigMaxHeight":720,"cameraConfigMaxFPS":10,"cameraConfigMaxBitrate":300,"cameraConfigVideoCodec":"libx264","cameraConfigAudioCodec":"libfdk_aac","cameraConfigAudio":false,"cameraConfigPacketSize":1316,"cameraConfigVerticalFlip":false,"cameraConfigHorizontalFlip":false,"cameraConfigMapVideo":"0:0","cameraConfigMapAudio":"0:1","cameraConfigVideoFilter":"scale=1280:720","cameraConfigAdditionalCommandLine":"-tune zerolatency","cameraConfigDebug":false,"cameraConfigSnapshotOutput":"disabled","cameraConfigInterfaceName":"","characteristicProperties":"{\"LockPhysicalControls\":true,\"TargetAirPurifierState\":true,\"RotationSpeed\":{\"minValue\":0,\"maxValue\":100,\"minStep\":7}}","waitForSetupMsg":false,"outputs":2,"x":490,"y":1020,"wires":[["448ec1892b2ed9a8"],[]]},{"id":"05d42249202b6794","type":"change","z":"e05bb790.045998","name":"轉換","rules":[{"t":"change","p":"payload","pt":"msg","from":"on","fromt":"str","to":"{\"LockPhysicalControls\":1}","tot":"json"},{"t":"change","p":"payload","pt":"msg","from":"off","fromt":"str","to":"{\"LockPhysicalControls\":0}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":1040,"wires":[["43451b7056f5684f"]]},{"id":"448ec1892b2ed9a8","type":"function","z":"e05bb790.045998","name":"BridgeTransfer","func":"\n//Switch\nif (msg.payload.Active === 1) {\n msg.payload = 'on';\n node.send([msg, null, null, null, null]);\n}\n\nif (msg.payload.Active === 0) {\n msg.payload = 'off';\n node.send([null, msg, null, null, null]);\n}\n//Auto mode\nif (msg.payload.TargetAirPurifierState === 1) {\n msg.payload = 'Auto';\n node.send([null, null, msg, null, null]);\n} \nif (msg.payload.TargetAirPurifierState === 0) {\n msg.payload = 'Favorite';\n node.send([null, null, msg, null, null]);\n}\n//Lock\nif (msg.payload.LockPhysicalControls === 1) {\n msg.payload = 'on';\n node.send([null, null, null, msg, null]);\n} \nif (msg.payload.LockPhysicalControls === 0) {\n msg.payload = 'off';\n node.send([null, null, null, msg, null]);\n}\n//Speed\nif (msg.payload.RotationSpeed) {\n node.send([null, null, null, null, msg]);\n} \n\n","outputs":5,"noerr":0,"initialize":"","finalize":"","libs":[],"x":690,"y":1020,"wires":[["5b7ff22fcba46bca","2b374bf028bffd8f","d38eaab06e1b1642"],["d38eaab06e1b1642"],["44a5ab4c18d6dd76"],["ed5a9c873592007e"],["f67ba08c13d775cf"]],"outputLabels":["on","off","auto/manual","lock","speed"]},{"id":"d38eaab06e1b1642","type":"api-call-service","z":"e05bb790.045998","name":"on/ off","server":"2caefc09.0b4a04","version":3,"debugenabled":false,"service_domain":"fan","service":"turn_{{payload}}","entityId":"fan.kong_qi_jing_hua_qi","data":"","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":910,"y":960,"wires":[["92ad15825d931da4"]]},{"id":"44a5ab4c18d6dd76","type":"api-call-service","z":"e05bb790.045998","name":"Auto","server":"2caefc09.0b4a04","version":3,"debugenabled":false,"service_domain":"fan","service":"set_preset_mode","entityId":"fan.kong_qi_jing_hua_qi","data":"{\"preset_mode\":payload}","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":910,"y":1020,"wires":[["92ad15825d931da4"]]},{"id":"ed5a9c873592007e","type":"api-call-service","z":"e05bb790.045998","name":"Lock","server":"2caefc09.0b4a04","version":3,"debugenabled":false,"service_domain":"switch","service":"turn_{{payload}}","entityId":"switch.kong_qi_jing_hua_qi_child_lock","data":"","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":910,"y":1080,"wires":[["92ad15825d931da4"]]},{"id":"2b374bf028bffd8f","type":"trigger","z":"e05bb790.045998","name":"5 sec to on","op1":"","op2":"{\"CurrentAirPurifierState\":2}","op1type":"nul","op2type":"json","duration":"5","extend":false,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":930,"y":900,"wires":[["88dfe918a25780a9"]]},{"id":"5b7ff22fcba46bca","type":"trigger","z":"e05bb790.045998","name":"2 sec to idle","op1":"","op2":"{\"CurrentAirPurifierState\":1}","op1type":"nul","op2type":"json","duration":"2","extend":false,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":930,"y":860,"wires":[["88dfe918a25780a9"]]},{"id":"f67ba08c13d775cf","type":"api-call-service","z":"e05bb790.045998","name":"Speed Set","server":"2caefc09.0b4a04","version":3,"debugenabled":false,"service_domain":"number","service":"set_value","entityId":"number.kong_qi_jing_hua_qi_favorite_level","data":"{\"value\":payload.RotationSpeed / 7}","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":930,"y":1140,"wires":[["92ad15825d931da4"]]},{"id":"16a661c1a6685e74","type":"homekit-service","z":"e05bb790.045998","isParent":false,"hostType":"0","bridge":"","accessoryId":"","parentService":"43451b7056f5684f","name":"AirQuality","serviceName":"AirQualitySensor","topic":"","filter":false,"manufacturer":"Default Manufacturer","model":"Default Model","serialNo":"Default Serial Number","firmwareRev":"","hardwareRev":"","softwareRev":"","cameraConfigVideoProcessor":"ffmpeg","cameraConfigSource":"","cameraConfigStillImageSource":"","cameraConfigMaxStreams":2,"cameraConfigMaxWidth":1280,"cameraConfigMaxHeight":720,"cameraConfigMaxFPS":10,"cameraConfigMaxBitrate":300,"cameraConfigVideoCodec":"libx264","cameraConfigAudioCodec":"libfdk_aac","cameraConfigAudio":false,"cameraConfigPacketSize":1316,"cameraConfigVerticalFlip":false,"cameraConfigHorizontalFlip":false,"cameraConfigMapVideo":"0:0","cameraConfigMapAudio":"0:1","cameraConfigVideoFilter":"scale=1280:720","cameraConfigAdditionalCommandLine":"-tune zerolatency","cameraConfigDebug":false,"cameraConfigSnapshotOutput":"disabled","cameraConfigInterfaceName":"","characteristicProperties":"{\"AirQuality\":true}","waitForSetupMsg":false,"outputs":2,"x":640,"y":1200,"wires":[[],[]]},{"id":"0ba41c9fc0a6ef8b","type":"server-state-changed","z":"e05bb790.045998","name":"Filter Status","server":"2caefc09.0b4a04","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.kong_qi_jing_hua_qi_filter_life_remaining","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"}],"x":90,"y":1260,"wires":[["7308d9a85434f4cc"]]},{"id":"10bbd50eed7a931d","type":"homekit-service","z":"e05bb790.045998","isParent":false,"hostType":"0","bridge":"","accessoryId":"","parentService":"43451b7056f5684f","name":"FilterMaintenance","serviceName":"FilterMaintenance","topic":"","filter":false,"manufacturer":"Default Manufacturer","model":"Default Model","serialNo":"Default Serial Number","firmwareRev":"","hardwareRev":"","softwareRev":"","cameraConfigVideoProcessor":"","cameraConfigSource":"","cameraConfigStillImageSource":"","cameraConfigMaxStreams":"","cameraConfigMaxWidth":"","cameraConfigMaxHeight":"","cameraConfigMaxFPS":"","cameraConfigMaxBitrate":"","cameraConfigVideoCodec":"","cameraConfigAudioCodec":"","cameraConfigAudio":false,"cameraConfigPacketSize":"","cameraConfigVerticalFlip":false,"cameraConfigHorizontalFlip":false,"cameraConfigMapVideo":"","cameraConfigMapAudio":"","cameraConfigVideoFilter":"","cameraConfigAdditionalCommandLine":"","cameraConfigDebug":false,"cameraConfigInterfaceName":"","characteristicProperties":"{\"FilterChangeIndication\":true,\"FilterLifeLevel\":true}","waitForSetupMsg":false,"outputs":2,"x":670,"y":1260,"wires":[[],[]]},{"id":"02d4e7ed4c8de0a0","type":"link in","z":"e05bb790.045998","name":"","links":["88dfe918a25780a9"],"x":385,"y":1120,"wires":[["43451b7056f5684f"]]},{"id":"88dfe918a25780a9","type":"link out","z":"e05bb790.045998","name":"","links":["02d4e7ed4c8de0a0"],"x":1085,"y":880,"wires":[]},{"id":"92ad15825d931da4","type":"debug","z":"e05bb790.045998","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1180,"y":1020,"wires":[]},{"id":"a5e3052ceb09ca2c","type":"homekit-service","z":"e05bb790.045998","isParent":false,"hostType":"0","bridge":"","accessoryId":"","parentService":"43451b7056f5684f","name":"Humidity","serviceName":"HumiditySensor","topic":"","filter":false,"manufacturer":"Default Manufacturer","model":"Default Model","serialNo":"Default Serial Number","firmwareRev":"","hardwareRev":"","softwareRev":"","cameraConfigVideoProcessor":"","cameraConfigSource":"","cameraConfigStillImageSource":"","cameraConfigMaxStreams":"","cameraConfigMaxWidth":"","cameraConfigMaxHeight":"","cameraConfigMaxFPS":"","cameraConfigMaxBitrate":"","cameraConfigVideoCodec":"","cameraConfigAudioCodec":"","cameraConfigAudio":false,"cameraConfigPacketSize":"","cameraConfigVerticalFlip":false,"cameraConfigHorizontalFlip":false,"cameraConfigMapVideo":"","cameraConfigMapAudio":"","cameraConfigVideoFilter":"","cameraConfigAdditionalCommandLine":"","cameraConfigDebug":false,"cameraConfigInterfaceName":"","characteristicProperties":"","waitForSetupMsg":false,"outputs":2,"x":640,"y":1320,"wires":[[],[]]},{"id":"7e3ef20fcaa92146","type":"homekit-service","z":"e05bb790.045998","isParent":false,"hostType":"0","bridge":"","accessoryId":"","parentService":"43451b7056f5684f","name":"Temperature ","serviceName":"TemperatureSensor","topic":"","filter":false,"manufacturer":"Default Manufacturer","model":"Default Model","serialNo":"Default Serial Number","firmwareRev":"","hardwareRev":"","softwareRev":"","cameraConfigVideoProcessor":"","cameraConfigSource":"","cameraConfigStillImageSource":"","cameraConfigMaxStreams":"","cameraConfigMaxWidth":"","cameraConfigMaxHeight":"","cameraConfigMaxFPS":"","cameraConfigMaxBitrate":"","cameraConfigVideoCodec":"","cameraConfigAudioCodec":"","cameraConfigAudio":false,"cameraConfigPacketSize":"","cameraConfigVerticalFlip":false,"cameraConfigHorizontalFlip":false,"cameraConfigMapVideo":"","cameraConfigMapAudio":"","cameraConfigVideoFilter":"","cameraConfigAdditionalCommandLine":"","cameraConfigDebug":false,"cameraConfigInterfaceName":"","characteristicProperties":"","waitForSetupMsg":false,"outputs":2,"x":650,"y":1380,"wires":[[],[]]},{"id":"e592d018ff4214f0","type":"api-call-service","z":"e05bb790.045998","name":"on","server":"2caefc09.0b4a04","version":3,"debugenabled":false,"service_domain":"switch","service":"turn_{{payload}}","entityId":"switch.kong_qi_jing_hua_qi_buzzer","data":"","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":910,"y":1440,"wires":[[]]},{"id":"69181a3423f199df","type":"function","z":"e05bb790.045998","name":"on/off","func":"\n//Switch\nif (msg.payload.On === true) {\n msg.payload = 'on';\n} else {\n msg.payload = 'off';\n}\n\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":770,"y":1440,"wires":[["e592d018ff4214f0"]],"outputLabels":["on","off"]},{"id":"24c550b042d9a05b","type":"debug","z":"e05bb790.045998","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":630,"y":1500,"wires":[]},{"id":"dae56e1bc1bba3b1","type":"homekit-service","z":"e05bb790.045998","isParent":false,"hostType":"0","bridge":"","accessoryId":"","parentService":"43451b7056f5684f","name":"Buzzer","serviceName":"Switch","topic":"","filter":false,"manufacturer":"NRCHKB","model":"1.3.6","serialNo":"Default Serial Number","firmwareRev":"1.3.6","hardwareRev":"1.3.6","softwareRev":"1.3.6","cameraConfigVideoProcessor":"ffmpeg","cameraConfigSource":"","cameraConfigStillImageSource":"","cameraConfigMaxStreams":2,"cameraConfigMaxWidth":1280,"cameraConfigMaxHeight":720,"cameraConfigMaxFPS":10,"cameraConfigMaxBitrate":300,"cameraConfigVideoCodec":"libx264","cameraConfigAudioCodec":"libfdk_aac","cameraConfigAudio":false,"cameraConfigPacketSize":1316,"cameraConfigVerticalFlip":false,"cameraConfigHorizontalFlip":false,"cameraConfigMapVideo":"0:0","cameraConfigMapAudio":"0:1","cameraConfigVideoFilter":"scale=1280:720","cameraConfigAdditionalCommandLine":"-tune zerolatency","cameraConfigDebug":false,"cameraConfigSnapshotOutput":"disabled","cameraConfigInterfaceName":"","characteristicProperties":"","waitForSetupMsg":false,"outputs":2,"x":630,"y":1440,"wires":[["69181a3423f199df"],[]]},{"id":"66d4810256f27438","type":"server-state-changed","z":"e05bb790.045998","name":"pm2_5","server":"2caefc09.0b4a04","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.kong_qi_jing_hua_qi_pm2_5","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"}],"x":110,"y":1200,"wires":[["7427ca27f63d9a18"]]},{"id":"78220e8053faba8c","type":"server-state-changed","z":"e05bb790.045998","name":"Humidity","server":"2caefc09.0b4a04","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.kong_qi_jing_hua_qi_humidity","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"}],"x":100,"y":1320,"wires":[["62bb5cfc364d2191"]]},{"id":"ee478ec49c3831bf","type":"server-state-changed","z":"e05bb790.045998","name":"Temperature","server":"2caefc09.0b4a04","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.kong_qi_jing_hua_qi_temperature","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"}],"x":90,"y":1380,"wires":[["4d2a6c3059ba703c"]]},{"id":"eb4e9a6a55198eb6","type":"server-state-changed","z":"e05bb790.045998","name":"Buzzer","server":"2caefc09.0b4a04","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"switch.kong_qi_jing_hua_qi_buzzer","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"}],"x":110,"y":1440,"wires":[["5aca5d11ec3666ed"]]},{"id":"21c88647a86b939b","type":"function","z":"e05bb790.045998","name":"Xiaomi_info","func":"//Definition of output Object\nvar PM2_5Density = {};//PM2.5\nvar AirQuality = {};//空氣質量\nvar StatusActive = {};//sensor狀態,這邊跟著主機走,可用可不用\nvar FilterLifeLevel = {};//濾網狀態\nvar FilterChangeIndication = {};//濾網更換提示<=10\nvar CurrentRelativeHumidity = {};//濕度\nvar CurrentTemperature = {};//溫度\nvar Buzzer = {}; //按鍵音\n//Definition of xiaomi output parameters \nvar pm2_5 = msg.payload.pm2_5;\nvar status = msg.payload.pm2_5; //這邊用2_5來看是否unavailable\nvar filter = msg.payload.filterstatus;\nvar humidity = msg.payload.humidity;\nvar temperature = msg.payload.temperature;\nvar buzzer = msg.payload.buzzer;\n//變數\nvar airQualityPM2_5, statusActive, filterStatus, switchBuzzer;\n\n//AirQuality\n// Banding AirQiality based on US AQI to provide HomeKit Levels\n// Source: https://aqicn.org/calculator\nif (pm2_5 < 12) {\n airQualityPM2_5 = 1;\n} else if (pm2_5 < 35.5) {\n airQualityPM2_5 = 2\n} else if (pm2_5 < 55.5) {\n airQualityPM2_5 = 3\n} else if (pm2_5 < 150.5) {\n airQualityPM2_5 = 4\n} else if (pm2_5 >= 250.5) {\n airQualityPM2_5 = 5;\n} else {\n airQualityPM2_5 = 0; \n}\nPM2_5Density.payload = {\n \"PM2_5Density\" : Number(pm2_5)\n}\nAirQuality.payload = {\n \"AirQuality\" : airQualityPM2_5\n}\n//StatusActive\nif (status === \"unavailable\") {\n statusActive = false;\n} else {\n statusActive = true\n}\nStatusActive.payload ={\n \"StatusActive\" : statusActive\n}\n//FilterMaintenance\nif (filter <= 10) {\n filterStatus = 1;\n} else {\n filterStatus = 0\n}\n\nFilterChangeIndication.payload = {\n \"FilterChangeIndication\" : filterStatus\n}\nFilterLifeLevel.payload = {\n \"FilterLifeLevel\" : Number(filter)\n}\n//Humidity \nCurrentRelativeHumidity.payload = {\n \"CurrentRelativeHumidity\" : Number(humidity)\n}\n//Temperature \nCurrentTemperature.payload = {\n \"CurrentTemperature\" : Number(temperature)\n}\n//Switch_buzzer\nif (buzzer === \"on\") {\n switchBuzzer = \"true\";\n} else {\n switchBuzzer = \"false\"\n}\n\nBuzzer.payload = {\n \"On\" : switchBuzzer\n}\n\nreturn [ [PM2_5Density, AirQuality, StatusActive], [FilterChangeIndication, FilterLifeLevel], [CurrentRelativeHumidity, StatusActive], [CurrentTemperature, StatusActive], [Buzzer] ];\n","outputs":5,"noerr":0,"initialize":"","finalize":"","libs":[],"x":450,"y":1320,"wires":[["16a661c1a6685e74","24c550b042d9a05b"],["10bbd50eed7a931d"],["a5e3052ceb09ca2c"],["7e3ef20fcaa92146"],["dae56e1bc1bba3b1"]],"outputLabels":["AirQuality","FilterMaintenance","Humidity ","Temperature ","Buzzer"]},{"id":"7427ca27f63d9a18","type":"change","z":"e05bb790.045998","name":"轉換","rules":[{"t":"move","p":"payload","pt":"msg","to":"payload.pm2_5","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":270,"y":1200,"wires":[["21c88647a86b939b","24c550b042d9a05b"]]},{"id":"7308d9a85434f4cc","type":"change","z":"e05bb790.045998","name":"轉換","rules":[{"t":"move","p":"payload","pt":"msg","to":"payload.filterstatus","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":270,"y":1260,"wires":[["21c88647a86b939b"]]},{"id":"62bb5cfc364d2191","type":"change","z":"e05bb790.045998","name":"轉換","rules":[{"t":"move","p":"payload","pt":"msg","to":"payload.humidity","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":270,"y":1320,"wires":[["21c88647a86b939b"]]},{"id":"4d2a6c3059ba703c","type":"change","z":"e05bb790.045998","name":"轉換","rules":[{"t":"move","p":"payload","pt":"msg","to":"payload.temperature","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":270,"y":1380,"wires":[["21c88647a86b939b"]]},{"id":"5aca5d11ec3666ed","type":"change","z":"e05bb790.045998","name":"轉換","rules":[{"t":"move","p":"payload","pt":"msg","to":"payload.buzzer","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":270,"y":1440,"wires":[["21c88647a86b939b"]]},{"id":"2caefc09.0b4a04","type":"server","name":"Home Assistant","version":1,"legacy":true,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true},{"id":"3d5ca1527ce61722","type":"homekit-bridge","bridgeName":"Purifier_Xiaomi","pinCode":"168-16-188","port":"","advertiser":"bonjour-hap","allowInsecureRequest":false,"manufacturer":"NRCHKB","model":"1.3.6","serialNo":"Default Serial Number","firmwareRev":"1.3.6","hardwareRev":"1.3.6","softwareRev":"1.3.6","customMdnsConfig":false,"mdnsMulticast":true,"mdnsInterface":"","mdnsPort":"","mdnsIp":"","mdnsTtl":"","mdnsLoopback":true,"mdnsReuseAddr":true,"allowMessagePassthrough":true}]