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

 找回密码
 立即注册
楼主: 360341024

[进阶教程] 求助,Function之多设备同时满足条件的写法

[复制链接]

11

主题

182

帖子

1454

积分

金牌会员

Rank: 6Rank: 6

积分
1454
金钱
1272
HASS币
10
 楼主| 发表于 2023-9-3 10:21:50 | 显示全部楼层
大致上应该是这样写了,但怎么把最重结果做成一个输出,而不是输出2次啊
微信截图_20230903102011.jpg
回复

使用道具 举报

17

主题

357

帖子

2084

积分

论坛DIY达人

积分
2084
金钱
1717
HASS币
40
发表于 2023-9-4 16:56:31 | 显示全部楼层
return写到条件里面去,每个条件一个return
回复

使用道具 举报

11

主题

182

帖子

1454

积分

金牌会员

Rank: 6Rank: 6

积分
1454
金钱
1272
HASS币
10
 楼主| 发表于 2023-9-5 10:59:12 | 显示全部楼层
hugh_jie 发表于 2023-9-4 16:56
return写到条件里面去,每个条件一个return

微信截图_20230905105843.jpg
不行呢,还是输出了2次
回复

使用道具 举报

7

主题

105

帖子

1049

积分

金牌会员

Rank: 6Rank: 6

积分
1049
金钱
944
HASS币
0
发表于 2023-9-5 11:41:08 | 显示全部楼层
这样的
捕获.PNG
回复

使用道具 举报

11

主题

182

帖子

1454

积分

金牌会员

Rank: 6Rank: 6

积分
1454
金钱
1272
HASS币
10
 楼主| 发表于 2023-9-6 12:45:34 | 显示全部楼层

微信截图_20230906124452.png
试过了,不行的
回复

使用道具 举报

7

主题

105

帖子

1049

积分

金牌会员

Rank: 6Rank: 6

积分
1049
金钱
944
HASS币
0
发表于 2023-9-7 15:56:29 | 显示全部楼层

把你的流程贴出来呀,这样才看得出来,光是图片不行
回复

使用道具 举报

11

主题

182

帖子

1454

积分

金牌会员

Rank: 6Rank: 6

积分
1454
金钱
1272
HASS币
10
 楼主| 发表于 2023-9-8 16:23:42 | 显示全部楼层
hungheo 发表于 2023-9-7 15:56
把你的流程贴出来呀,这样才看得出来,光是图片不行

flows.rar (1.17 KB, 下载次数: 3)
回复

使用道具 举报

22

主题

612

帖子

2757

积分

金牌会员

Rank: 6Rank: 6

积分
2757
金钱
2145
HASS币
0
发表于 2023-9-8 16:42:22 | 显示全部楼层
是谁说NR不需要编程基础的?我这项进来学习一看,这还是需要自己写代码的嘛。
还是HA自带自动化简单易懂。
回复

使用道具 举报

7

主题

105

帖子

1049

积分

金牌会员

Rank: 6Rank: 6

积分
1049
金钱
944
HASS币
0
发表于 2023-9-10 22:01:28 | 显示全部楼层
[{"id":"c840862b52305784","type":"api-current-state","z":"f7f2d3c3b9a5a56a","name":"床左人体传感器","server":"82097e214d37b9e6","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"binary_sensor.lu_mi_ren_ti_chuan_gan_qi_occupancy","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"chuangzuo","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":340,"y":280,"wires":[["fba1b5bea15df45c"]]},{"id":"fba1b5bea15df45c","type":"api-current-state","z":"f7f2d3c3b9a5a56a","name":"床右人体传感器","server":"82097e214d37b9e6","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"binary_sensor.lu_mi_ren_ti_chuan_gan_qi_chuang_you_occupancy","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"chuangyou","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":520,"y":280,"wires":[["3fbd872068cf3231"]]},{"id":"6a8dff3136cce887","type":"inject","z":"f7f2d3c3b9a5a56a","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":190,"y":280,"wires":[["c840862b52305784"]]},{"id":"8aa6f2acc9eb4e8f","type":"debug","z":"f7f2d3c3b9a5a56a","name":"debug 29","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":860,"y":280,"wires":[]},{"id":"3fbd872068cf3231","type":"function","z":"f7f2d3c3b9a5a56a","name":"function 4","func":"var a = msg.chuangzuo\nvar b = msg.chuangyou\n\nif(a == "on" ){\n    return { payload: "youren" }\n} else if(b == "on" ){\n    return { payload: "youren" }\n}else{\n    return { payload: "wuren" }\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":700,"y":280,"wires":[["8aa6f2acc9eb4e8f"]]},{"id":"82097e214d37b9e6","type":"server","name":"Home Assistant","version":5,"addon":false,"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":": ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"default","statusTimeFormat":"h:m","enableGlobalContextStore":false}]


回复

使用道具 举报

11

主题

182

帖子

1454

积分

金牌会员

Rank: 6Rank: 6

积分
1454
金钱
1272
HASS币
10
 楼主| 发表于 2023-9-10 22:56:38 | 显示全部楼层
本帖最后由 360341024 于 2023-9-11 10:50 编辑

已导入,我试试
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-11-26 21:19 , Processed in 0.085561 second(s), 32 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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