『瀚思彼岸』» 智能家居技术论坛

 找回密码
 立即注册
查看: 11731|回复: 13

[流程系列] {求助}如何识别多个状态之后做判断?

[复制链接]

40

主题

313

帖子

3093

积分

论坛元老

Rank: 8Rank: 8

积分
3093
金钱
2780
HASS币
0
发表于 2020-8-28 11:12:50 | 显示全部楼层 |阅读模式
求前辈帮忙
如果识别多个灯的状态,并做判断?
想要灯0;灯1;灯2;灯3全亮才做出触发1
如果有任意灯状态不是亮的做出触发2

任意.png


回复

使用道具 举报

40

主题

3056

帖子

1万

积分

超级版主

Nero

Rank: 8Rank: 8

积分
11149
金钱
8042
HASS币
182
发表于 2020-8-28 14:39:16 | 显示全部楼层
用触发,然后分开N路查询, join 之后判断就好了啊。
Nero
回复

使用道具 举报

40

主题

313

帖子

3093

积分

论坛元老

Rank: 8Rank: 8

积分
3093
金钱
2780
HASS币
0
 楼主| 发表于 2020-8-28 15:35:55 | 显示全部楼层
neroxps 发表于 2020-8-28 14:39
用触发,然后分开N路查询, join 之后判断就好了啊。

前辈能不能给个例子?我自己只能用最基础的方式做些流程.......


回复

使用道具 举报

40

主题

3056

帖子

1万

积分

超级版主

Nero

Rank: 8Rank: 8

积分
11149
金钱
8042
HASS币
182
发表于 2020-8-28 15:54:41 | 显示全部楼层
dizherui 发表于 2020-8-28 15:35
前辈能不能给个例子?我自己只能用最基础的方式做些流程.......

就你自己画出来这个图差不多。
Nero
回复

使用道具 举报

40

主题

313

帖子

3093

积分

论坛元老

Rank: 8Rank: 8

积分
3093
金钱
2780
HASS币
0
 楼主| 发表于 2020-8-28 16:03:57 | 显示全部楼层
neroxps 发表于 2020-8-28 15:54
就你自己画出来这个图差不多。

我只会用switch这种做判断,连最简单的开关状态二次确认都需要做好几个流程。。。
突然不能上传照片了,不然就给你看下我现有的其他流程有多繁琐了
回复

使用道具 举报

23

主题

660

帖子

3110

积分

论坛元老

Rank: 8Rank: 8

积分
3110
金钱
2450
HASS币
10
发表于 2020-9-4 18:09:07 | 显示全部楼层
本帖最后由 wshc1216 于 2020-9-4 18:11 编辑

刚好我有个一样的,不过我的没有技术含量
下载.png

回复

使用道具 举报

3

主题

117

帖子

772

积分

高级会员

Rank: 4

积分
772
金钱
655
HASS币
0
发表于 2020-9-15 09:04:22 | 显示全部楼层
我也在找这种方式,你的问题解决了吗?
回复

使用道具 举报

15

主题

124

帖子

936

积分

高级会员

Rank: 4

积分
936
金钱
812
HASS币
0
发表于 2020-10-15 17:17:34 | 显示全部楼层
本帖最后由 meiki 于 2020-10-15 20:04 编辑

全亮就是与的关系,把每个灯节点设置条件is on,在把所有的节点“真”串连接起来
任意灯状态不是亮就是或的关系,如你图片连接这是并连,这里的灯结点不需要设置条件,把所有灯输出接到一个Filter过滤节点,条件设置OFF,有一只灯是OFF就会触发输出,因为是是或非的关系过滤只能设置一个条件,不达条件过滤结点是没有输出的,所以就是把前面任意灯的OFF状态用一个结点输出提供后面的结点就行操作
所以在你触发条件后面分别连接一如你图的并联结点,在建一条所有灯的串联连接设置条件ON就可以了
nodered我也是在研究中,刚好自己也需要这个功能,只是我的需要和你正好相反,有灯亮就角发关闭,全OFF就开灯。我的结点太多不知道怎么导出单个结点,就不贴我的flows了,供你参考






flows.jpg
回复

使用道具 举报

3

主题

73

帖子

500

积分

论坛积极会员

积分
500
金钱
427
HASS币
0
发表于 2020-10-30 11:03:06 | 显示全部楼层
本帖最后由 mrjc0331 于 2020-10-30 11:04 编辑

触发--使用多个current state节点获取每个实体的状态,然后分别保存到流程中,然后在用function统一进行判断.写了个例子,给您参考一下。

                               
登录/注册后可看大图

[{"id":"6e11a160.6d6be","type":"api-current-state","z":"f5950339.f19eb","name":"1","server":"19170cf5.155303","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"switch.3dda_yin_ji","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":230,"y":600,"wires":[["2c1c2fbe.6e96b"]]},{"id":"cb413974.57de98","type":"inject","z":"f5950339.f19eb","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":90,"y":600,"wires":[["6e11a160.6d6be"]]},{"id":"136cad8f.c63692","type":"debug","z":"f5950339.f19eb","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":730,"y":720,"wires":[]},{"id":"2c1c2fbe.6e96b","type":"change","z":"f5950339.f19eb","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"state1","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":410,"y":600,"wires":[["1779c547.64fceb"]]},{"id":"1779c547.64fceb","type":"api-current-state","z":"f5950339.f19eb","name":"2","server":"19170cf5.155303","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"switch.zhu_wo_dian_feng_shan","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":230,"y":660,"wires":[["fb97adc9.a3515"]]},{"id":"1d6752b6.771ebd","type":"api-current-state","z":"f5950339.f19eb","name":"3","server":"19170cf5.155303","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"switch.chuang_tou_cha_zuo","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":230,"y":720,"wires":[["f6b17eac.be82f"]]},{"id":"fb97adc9.a3515","type":"change","z":"f5950339.f19eb","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"state2","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":410,"y":660,"wires":[["1d6752b6.771ebd"]]},{"id":"f6b17eac.be82f","type":"change","z":"f5950339.f19eb","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"state3","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":410,"y":720,"wires":[["5b059ca6.aa2474"]]},{"id":"5b059ca6.aa2474","type":"function","z":"f5950339.f19eb","name":"","func":"if(flow.get('state1') == 'on' && flow.get('state2') == 'on' && flow.get('state3') == 'on'){\n    msg.payload = '你想发送的东西'\n    return msg;\n}else{\n    msg.state1 = flow.get('state1')\n    msg.state2 = flow.get('state2')\n    msg.state3 = flow.get('state3')\n    return msg\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":590,"y":720,"wires":[["136cad8f.c63692"]]},{"id":"19170cf5.155303","type":"server","name":"Home Assistant"}]

回复

使用道具 举报

40

主题

313

帖子

3093

积分

论坛元老

Rank: 8Rank: 8

积分
3093
金钱
2780
HASS币
0
 楼主| 发表于 2020-10-31 10:15:41 | 显示全部楼层
mrjc0331 发表于 2020-10-30 11:03
触发--使用多个current state节点获取每个实体的状态,然后分别保存到流程中,然后在用function统一进行判 ...

我等下导入试试,十分感谢
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-11-25 00:19 , Processed in 0.102867 second(s), 34 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表