|
楼主 |
发表于 2023-9-26 15:52:57
|
显示全部楼层
应该是可以了。
[{"id":"8e1c0dcad409ff41","type":"server-state-changed","z":"6082b4a4fd16afa4","name":"主卧灯关","server":"7dc8fb2a.fc0804","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"switch.zimi_dhkg05_3c92_left_switch_service","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"off","halt_if_type":"str","halt_if_compare":"is","outputs":2,"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":120,"y":80,"wires":[["d5c4be9f63b44b47"],[]]},{"id":"aeb417f54a8a9951","type":"debug","z":"6082b4a4fd16afa4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1030,"y":320,"wires":[]},{"id":"dc80635a56711a87","type":"inject","z":"6082b4a4fd16afa4","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":130,"y":140,"wires":[["d5c4be9f63b44b47"]]},{"id":"d5c4be9f63b44b47","type":"api-current-state","z":"6082b4a4fd16afa4","name":"客厅温度","server":"7dc8fb2a.fc0804","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"sensor.tuyatec_1wzznw9a_rh3052_temperature","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":320,"y":80,"wires":[["3514ebd19f21c012"]]},{"id":"9ed6557e47e7d921","type":"api-current-state","z":"6082b4a4fd16afa4","name":"主卧温度","server":"7dc8fb2a.fc0804","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"sensor.tuyatec_1wzznw9a_rh3052_temperature_3","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":320,"y":140,"wires":[["15ea924598c1203b"]]},{"id":"0e894d4c433f309f","type":"api-current-state","z":"6082b4a4fd16afa4","name":"卧室温度","server":"7dc8fb2a.fc0804","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"sensor.tuyatec_1wzznw9a_rh3052_temperature_4","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":320,"y":200,"wires":[["75e30f947727eddf"]]},{"id":"d5a88713da6940aa","type":"api-current-state","z":"6082b4a4fd16afa4","name":"次卧温度","server":"7dc8fb2a.fc0804","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"sensor.tuyatec_1wzznw9a_rh3052_temperature_2","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":320,"y":260,"wires":[["b02fbe62079eef4f"]]},{"id":"3514ebd19f21c012","type":"change","z":"6082b4a4fd16afa4","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"state1","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":530,"y":80,"wires":[["9ed6557e47e7d921"]]},{"id":"15ea924598c1203b","type":"change","z":"6082b4a4fd16afa4","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"state2","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":530,"y":140,"wires":[["0e894d4c433f309f"]]},{"id":"a51059eda9233301","type":"debug","z":"6082b4a4fd16afa4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":890,"y":200,"wires":[]},{"id":"001f0a390214dd70","type":"function","z":"6082b4a4fd16afa4","name":"赋值","func":"msg.state1 = flow.get('state1'); \nmsg.state2 = flow.get('state2'); \nmsg.state3 = flow.get('state3'); \nmsg.state4 = flow.get('state4');\n//msg.state = flow.get('state');\nreturn msg; \n\n/*\nif ((flow.get('state') - flow.get('state1')) > 2){\n msg.payload = '主人,客厅温度偏低,可能没有关空调哦'\n}\nif ((flow.get('state') - flow.get('state2')) > 2) {\n msg.payload = '主人,客厅温度偏低,可能没有关空调哦'\n}\nif ((flow.get('state') - flow.get('state3')) > 2) {\n msg.payload = '主人,客厅温度偏低,可能没有关空调哦'\n}\n*/\n/*\nif ((flow.get('state') - flow.get('state4')) > 2) {\n msg.payload = '主人,客厅温度偏低,可能没有关空调哦'\n}else { \n// msg.state1 = flow.get('state1'); \n // msg.state2 = flow.get('state2'); \n// msg.state3 = flow.get('state3'); \n msg.state4 = flow.get('state4'); \n msg.state = flow.get('state'); \n return msg; \n}\nreturn msg; \n*/\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":730,"y":260,"wires":[["902db897806d74de","a51059eda9233301"]]},{"id":"75e30f947727eddf","type":"change","z":"6082b4a4fd16afa4","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"state3","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":530,"y":200,"wires":[["d5a88713da6940aa"]]},{"id":"b02fbe62079eef4f","type":"change","z":"6082b4a4fd16afa4","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"state4","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":530,"y":260,"wires":[["001f0a390214dd70"]]},{"id":"902db897806d74de","type":"function","z":"6082b4a4fd16afa4","name":"判断温度","func":"var max = Math.max(msg.state1, msg.state2, msg.state3, msg.state4);\nvar extracted = [];\n\n// 遍历每个温度值,并将比最大值小1的值提取出来\nif (msg.state1 < max - 2) {\n extracted.push({ name: \"客厅温度\", value: msg.state1 });\n}\nif (msg.state2 < max - 2) {\n extracted.push({ name: \"主卧温度\", value: msg.state2 });\n}\nif (msg.state3 < max - 2) {\n extracted.push({ name: \"卧室温度\", value: msg.state3 });\n}\nif (msg.state4 < max - 2) {\n extracted.push({ name: \"次卧温度\", value: msg.state4 });\n}\n// 将提取的温度数据发送到输出\nmsg.payload = extracted;\nreturn msg;\n\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":880,"y":260,"wires":[["29bb995582f47899","aeb417f54a8a9951"]]},{"id":"29bb995582f47899","type":"function","z":"6082b4a4fd16afa4","name":"播报格式","func":"if (msg.payload.length === 1) {\n msg.payload = msg.payload[0].name + '为' + msg.payload[0].value + '摄氏度,可能没有关空调。';\n} else if (msg.payload.length === 2) {\n msg.payload = msg.payload[0].name + '为' + msg.payload[0].value + '摄氏度,' + msg.payload[1].name + '为' + msg.payload[1].value + '摄氏度,可能没有关空调。';\n} else if (msg.payload.length === 3) {\n msg.payload = msg.payload[0].name + '为' + msg.payload[0].value + '摄氏度,' + msg.payload[1].name + '为' + \n msg.payload[1].value + '摄氏度,' + msg.payload[2].name + '为' + msg.payload[2].value + '摄氏度,可能没有关空调。';\n} else {\n msg.payload = \"\"; // 当msg.payload数组的长度为0时返回空\n}\nreturn msg;\n\n\n/*if (msg.payload && msg.payload.length > 0) \nif (msg.payload.length == 1) \n msg.payload = msg.payload[0].name + ',为' + msg.payload[0].value + '摄氏度,可能没有关空调。'\nif (msg.payload.length == 2)\n msg.payload = msg.payload[0].name + ',为' + msg.payload[0].value + msg.payload[1].name + ',为' + msg.payload[1].value + '摄氏度,可能没有关空调。'\nif (msg.payload.length == 3)\n msg.payload = msg.payload[0].name + ',为' + msg.payload[0].value + msg.payload[2].name + \n ',为' + msg.payload[3].value + msg.payload[2].name + ',为' + msg.payload[3].value + '摄氏度,可能没有关空调。'\n//if (msg.payload.length = 4)\n// msg.payload = msg.payload[0].name + ',为' + msg.payload[0].value + msg.payload[2].name +\n// ',为' + msg.payload[3].value + msg.payload[2].name + ',为' + msg.payload[3].value + \n// + msg.payload[4].value + msg.payload[4].name + ',为' + msg.payload[4].value +'摄氏度,可能没有关空调。'\nreturn msg;\n*/","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1040,"y":260,"wires":[["c04305e4e356b7af","5374732819612303"]]},{"id":"5374732819612303","type":"xiaoai-tts","z":"6082b4a4fd16afa4","name":"","xiaoai":"","tts":"","device":"","x":1190,"y":200,"wires":[[],[]]},{"id":"7dc8fb2a.fc0804","type":"server","name":"Jason Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":"30","areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true}] |
|