|
flow变量
- flow变量可在同一个flow读取/写入,方便不同的流程互相传递数据.
魔方同时控制3组灯
- 读取flow变量,当变量为on时,关三组灯,否则开三组灯
- 开灯的时候,将flow变量设置为on,关的时候设置为off
为何需要flow变量
- 当未通过魔方控制灯的时候,不会干扰到本流程的执行
- 比如,手动按开关,开关灯
[{"id":"26f6c878.c71868","type":"server-events","z":"59f4d8aa.25fef8","name":"获取所有事件","server":"94f0c0a9.629b6","event_type":"xiaomi_aqara.cube_action","x":370,"y":1240,"wires":[["a19f23ca.91e73","4d0db3fe.5b336c"]]},{"id":"a19f23ca.91e73","type":"switch","z":"59f4d8aa.25fef8","name":"获取魔方动作事件","property":"payload.event.action_type","propertyType":"msg","rules":[{"t":"eq","v":"tap_twice","vt":"str"},{"t":"eq","v":"rotate","vt":"str"},{"t":"eq","v":"move","vt":"str"},{"t":"eq","v":"flip90","vt":"str"}],"checkall":"true","repair":false,"outputs":4,"x":590,"y":1240,"wires":[["cab2106d.306d5","4d0db3fe.5b336c"],[],[],[]]},{"id":"cab2106d.306d5","type":"function","z":"59f4d8aa.25fef8","name":"获取study_light变量状态","func":"if(flow.get('study_light')==='on'){\n return [msg,null];\n}\nelse{\n return [null,msg];}\n","outputs":2,"noerr":0,"x":850,"y":1220,"wires":[["5c035c16.a23a34","63e71ed6.b46e6","5567fdb.c9aec04","4d0db3fe.5b336c"],["54da9730.835f88","1bd5906f.a7b2","77eb6cf2.8b2514","4d0db3fe.5b336c"]]},{"id":"5c035c16.a23a34","type":"api-call-service","z":"59f4d8aa.25fef8","name":"","server":"94f0c0a9.629b6","service_domain":"switch","service":"turn_off","data":"{\"entity_id\":\"switch.wall_switch_ln_left_158d000239c546\"}","render_data":false,"mergecontext":"","x":1150,"y":1020,"wires":[["fb408198.59b41"]]},{"id":"63e71ed6.b46e6","type":"api-call-service","z":"59f4d8aa.25fef8","name":"","server":"94f0c0a9.629b6","service_domain":"switch","service":"turn_off","data":"{\"entity_id\":\"switch.wall_switch_ln_right_158d000239c546\"}","render_data":false,"mergecontext":"","x":1150,"y":1060,"wires":[["fb408198.59b41"]]},{"id":"5567fdb.c9aec04","type":"api-call-service","z":"59f4d8aa.25fef8","name":"","server":"94f0c0a9.629b6","service_domain":"switch","service":"turn_off","data":"{\"entity_id\":\"light.xiaomi_philips_eyecare_smart_lamp_2\"}","render_data":false,"mergecontext":"","x":1150,"y":1100,"wires":[["fb408198.59b41"]]},{"id":"54da9730.835f88","type":"api-call-service","z":"59f4d8aa.25fef8","name":"","server":"94f0c0a9.629b6","service_domain":"switch","service":"turn_on","data":"{\"entity_id\":\"switch.wall_switch_ln_left_158d000239c546\"}","render_data":false,"mergecontext":"","x":1170,"y":1180,"wires":[["e45bc4d0.292bd8"]]},{"id":"1bd5906f.a7b2","type":"api-call-service","z":"59f4d8aa.25fef8","name":"","server":"94f0c0a9.629b6","service_domain":"switch","service":"turn_on","data":"{\"entity_id\":\"switch.wall_switch_ln_right_158d000239c546\"}","render_data":false,"mergecontext":"","x":1170,"y":1220,"wires":[["e45bc4d0.292bd8"]]},{"id":"77eb6cf2.8b2514","type":"api-call-service","z":"59f4d8aa.25fef8","name":"","server":"94f0c0a9.629b6","service_domain":"switch","service":"turn_on","data":"{\"entity_id\":\"light.xiaomi_philips_eyecare_smart_lamp_2\"}","render_data":false,"mergecontext":"","x":1170,"y":1260,"wires":[["e45bc4d0.292bd8"]]},{"id":"fb408198.59b41","type":"function","z":"59f4d8aa.25fef8","name":"设置study_light变量状态为off","func":"flow.set('study_light','off');\nreturn null;","outputs":1,"noerr":0,"x":1480,"y":1060,"wires":[[]]},{"id":"e45bc4d0.292bd8","type":"function","z":"59f4d8aa.25fef8","name":"获取study_light变量状态为on","func":"flow.set('study_light','on');\nreturn null;","outputs":1,"noerr":0,"x":1480,"y":1280,"wires":[[]]},{"id":"4d0db3fe.5b336c","type":"debug","z":"59f4d8aa.25fef8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":730,"y":1040,"wires":[]},{"id":"94f0c0a9.629b6","type":"server","z":"","name":"Home Assistant","legacy":true,"hassio":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open"}]
|
|