[分享] Nodered HK bridge節點實例分享(二)

NR HK bridge的另外一個強大的功能,就是他能把其他HA內的開關通通變成配件的方式,整合到已經整合在HK內的parent上,以我的dyson為例,HA內有另外一個air_quality實體,裡面有很多空氣品質資訊:

這邊就利用此節點的linked功能:

這邊一樣利用function直接將原有air_quality entity資訊全撈出來,避免在HA內額外建立一堆非必較的sensor或實體,也能簡化NR的節點流程:

Nodered code:

[{"id":"7a49717e73e1e481","type":"homekit-service","z":"e05bb790.045998","isParent":false,"hostType":"0","bridge":"","accessoryId":"","parentService":"2d4886c5ed10418c","name":"Dyson Filter","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":710,"y":520,"wires":[[],[]]},{"id":"ec352aa313b541e1","type":"poll-state","z":"e05bb790.045998","name":"Filter Status","server":"2caefc09.0b4a04","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"updateinterval":"12","updateIntervalUnits":"hours","outputinitially":true,"outputonchanged":true,"entity_id":"sensor.hepa_filter_life","state_type":"str","halt_if":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"x":110,"y":520,"wires":[["61247d31f88cf3b1"]]},{"id":"af5d05da6b558308","type":"homekit-service","z":"e05bb790.045998","isParent":false,"hostType":"0","bridge":"","accessoryId":"","parentService":"2d4886c5ed10418c","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":700,"y":460,"wires":[[],[]]},{"id":"e813fe8161e34878","type":"server-state-changed","z":"e05bb790.045998","name":"Dyson_air_quality","server":"2caefc09.0b4a04","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"air_quality.air_quality","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":"payload","propertyType":"msg","value":"","valueType":"eventData"}],"x":120,"y":460,"wires":[["debfb565e0983fc2"]]},{"id":"61247d31f88cf3b1","type":"change","z":"e05bb790.045998","name":"轉換","rules":[{"t":"move","p":"payload","pt":"msg","to":"payload.filtermaintenance","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":270,"y":520,"wires":[["debfb565e0983fc2"]]},{"id":"debfb565e0983fc2","type":"function","z":"e05bb790.045998","name":"Dyson_info","func":"//Definition  of output Object\nvar PM2_5Density = {};//PM2.5\nvar PM10Density = {};\nvar NitrogenDioxideDensity = {};\nvar VOCDensity = {};\nvar AirQuality = {};//空氣質量\nvar StatusActive = {};//sensor狀態,這邊跟著主機走,可用可不用\nvar FilterLifeLevel = {};//濾網狀態\nvar FilterChangeIndication = {};//濾網更換提示<=10\n\n\n//Definition of dyson output parameters \nvar airQualityPM2_5, airQualityPM10, airQuality, filterStatus, statusActive;\n\n\n//AirQuality\n// Banding AirQiality based on US AQI to provide HomeKit Levels\n//   Source: https://aqicn.org/calculator\nif (msg.payload.new_state.attributes.particulate_matter_2_5 < 12) {\n    airQualityPM2_5 = 1;\n} else if (msg.payload.new_state.attributes.particulate_matter_2_5 < 35.5) {\n    airQualityPM2_5 = 2\n} else if (msg.payload.new_state.attributes.particulate_matter_2_5 < 55.5) {\n    airQualityPM2_5 = 3\n} else if (msg.payload.new_state.attributes.particulate_matter_2_5 < 150.5) {\n    airQualityPM2_5 = 4\n} else if (msg.payload.new_state.attributes.particulate_matter_2_5 >= 250.5) {\n    airQualityPM2_5 = 5;\n} else {\n  airQualityPM2_5 = 0;  \n}\n\nif (msg.payload.new_state.attributes.particulate_matter_10 < 55) {\n    airQualityPM10 = 1;\n} else if (msg.payload.new_state.attributes.particulate_matter_10 < 155) {\n    airQualmsg.ityPM10 = 2\n} else if (msg.payload.new_state.attributes.particulate_matter_10 < 255) {\n    airQualityPM10 = 3\n} else if (msg.payload.new_state.attributes.particulate_matter_10 < 355) {\n    airQualityPM10 = 4\n} else if (msg.payload.new_state.attributes.particulate_matter_10 >= 425) {\n    airQualityPM10 = 5;\n} else {\n  airQualityPM10 = 0;  \n}\n\nairQuality = (airQualityPM10 + airQualityPM2_5) / 2;\n\nAirQuality.payload = {\n    \"AirQuality\" : Number(airQuality.toFixed(0))\n}\n//PM2.5\nPM2_5Density.payload = {\n    \"PM2_5Density\" : Number(msg.payload.new_state.attributes.particulate_matter_2_5)\n}\n//PM10\nPM10Density.payload = {\n    \"PM10Density\" : Number(msg.payload.new_state.attributes.particulate_matter_10)\n}\n//VOC\nVOCDensity.payload = {\n    \"VOCDensity\" : Number(msg.payload.new_state.attributes.volatile_organic_compounds)\n}\n//NO\nNitrogenDioxideDensity.payload = {\n    \"NitrogenDioxideDensity\" : Number(msg.payload.new_state.attributes.nitrogen_dioxide)\n}\n//StatusActive\nif (msg.payload.new_state.state === \"unavailable\") {\n    statusActive = false;\n} else {\n    statusActive = true\n}\nStatusActive.payload ={\n    \"StatusActive\" : statusActive\n}\n//FilterMaintenance\nif (msg.payload.filtermaintenance <= 10) {\n    filterStatus = 1;\n} else {\n    filterStatus = 0\n}\n\nFilterChangeIndication.payload = {\n    \"FilterChangeIndication\" : filterStatus\n}\nFilterLifeLevel.payload = {\n    \"FilterLifeLevel\" : Number(msg.payload.filtermaintenance)\n}\nreturn [ [PM2_5Density, PM10Density, NitrogenDioxideDensity, VOCDensity, AirQuality], [FilterChangeIndication, FilterLifeLevel] ];\n","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":450,"y":480,"wires":[["af5d05da6b558308"],["7a49717e73e1e481"]],"outputLabels":["AirQuality","FilterMaintenance"]},{"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}]

接下來我們就能在HK內的Dyson上看到空氣品質和濾網配件的所有資訊:


全部都整合在一主體上,讓HK能夠更簡潔!
JSON語法我不會,如果此分享有更好的簡化方式歡迎大家教教我!

5個讚

可以看一下另外兩個節點的設置嗎?
可能是很新手問題,之前很少基本上不曾用nodered,我以前都直接寫HA的自動化,所以很不熟

是想參考哪兩個節點?當然可以分享!

我重新將最後優化版本的code貼上來了,圖示內的節點code都更新在文章內囉

1個讚

請問nodered可以寫出空調的控制器嗎? 嘗試後,失敗告終

我自己是用原生的接入,但理論上可行,你參考官方的指令看看https://nrchkb.github.io/wiki/service/thermostat/

前輩 想問一個問題 關於要啟動哪一個CALL service 才能觸發兒童鎖呢

然後關於風速該如何從段位改為百分比

Homekit node裡面的特性要先打開



打開後你在Homekit 裡面應該就能看到這個按鈕

一樣去觸發看看他跑什麼出來,把msg指定給淨化器的童鎖開關就可以了,反之亦然,把淨化器的童鎖語法指定給Homekit node

想請問一下唷 我能看出來APP裡面風速調整時產生的payload
但是我該怎樣去做function讓call service去連動呢


如果方便的話能否借給我看一下箭頭內的內容?

我在第一篇的文內跟留言處都有貼code你看一下

我有去看 只是因為我很菜… 其實看不太懂那些內容

您可否拍個function 跟 Temperature 裡面的內容圖 我大概就可以理解了 感激

我把code整理一下直接貼在這,等我處理一下!

你參考看看

[{"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}]

想請問遺下 一般來說 都怎麼看這個code呢?
因為我複製下來 就是很多的代碼@@
抱歉 我真的很菜><

直接到node red裡面的匯入,貼上就會輸出成node red流程圖了

太棒了!!!我會了 謝謝