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

 找回密码
 立即注册
查看: 340|回复: 2

[流程系列] nodered判断节假日流

[复制链接]

2

主题

39

帖子

358

积分

中级会员

Rank: 3Rank: 3

积分
358
金钱
319
HASS币
0
发表于 2024-10-10 16:50:05 | 显示全部楼层 |阅读模式
家里窗帘自动化比较傻,只能定时开关,研读了论坛里几个帖子,最终实验成功了一个,效果不错分享出来首先在辅助元素里面添加一个虚拟开关,名字自定义,你自己知道就行,然后导入下面的流,修改一下最后一步“需要上班”和“不需要上班”模块里面entity为你创建的虚拟开关就行。

这个流每天早上5点发出一个请求来判断今天是不是工作日,如果是工作日,你自定义的虚拟开关为开,否则为关,根据这个就可以做相关自动化了。

[{"id":"ffd70b99.0310e8","type":"tab","label":"流程 1","disabled":false,"info":""},{"id":"8e4f2156.d5eee","type":"inject","z":"ffd70b99.0310e8","name":"03文本图片","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"00 05 * * *","once":false,"onceDelay":"2","topic":"","payload":"iso","payloadType":"date","x":130,"y":260,"wires":[["016c11df1498ac9a"]]},{"id":"16d7d2cf.88a9fd","type":"http request","z":"ffd70b99.0310e8","name":"GET请求","method":"GET","ret":"obj","paytoqs":"ignore","url":"http://tool.bitefu.net/jiari/?d={{{payload}}}&info=1","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":610,"y":260,"wires":[["8be96e27.57ba7"]]},{"id":"8be96e27.57ba7","type":"function","z":"ffd70b99.0310e8","name":"判断","func":"//声明新的变量date=msg.payload(上个节点的值)。\n//date.type为上个节点msg.payload.type的值。\nvar date=msg.payload \nif (date.type==0)  \n{\n    msg.payload = "工作日"\n}\nelse if (date.type==1)\n{\n    msg.payload = "周末"\n}\nelse if (date.type==2)\n{\n    msg.payload = "节假日"\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":750,"y":260,"wires":[["94c11e05.e6571"]]},{"id":"94c11e05.e6571","type":"switch","z":"ffd70b99.0310e8","name":"工作日","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"工作日","vt":"str"},{"t":"neq","v":"工作日","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":890,"y":260,"wires":[["ea836bd9da07fa1e"],["6485aea7e97c015c"]]},{"id":"016c11df1498ac9a","type":"moment","z":"ffd70b99.0310e8","name":"","topic":"","input":"payload","inputType":"msg","inTz":"Asia/Shanghai","adjAmount":0,"adjType":"days","adjDir":"add","format":"YYYYMMDD","locale":"C","output":"payload","outputType":"msg","outTz":"Asia/Shanghai","x":380,"y":260,"wires":[["16d7d2cf.88a9fd"]]},{"id":"ea836bd9da07fa1e","type":"api-call-service","z":"ffd70b99.0310e8","name":"需要上班","server":"69d1bd5a.b24714","version":7,"debugenabled":false,"action":"input_boolean.turn_on","floorId":[],"areaId":[],"deviceId":[],"entityId":["input_boolean.jie_jia_ri_pan_duan"],"labelId":[],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","blockInputOverrides":false,"domain":"input_boolean","service":"turn_on","x":1060,"y":220,"wires":[[]]},{"id":"6485aea7e97c015c","type":"api-call-service","z":"ffd70b99.0310e8","name":"不需要上班","server":"69d1bd5a.b24714","version":7,"debugenabled":false,"action":"input_boolean.turn_off","floorId":[],"areaId":[],"deviceId":[],"entityId":["input_boolean.jie_jia_ri_pan_duan"],"labelId":[],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","blockInputOverrides":false,"domain":"input_boolean","service":"turn_off","x":1070,"y":300,"wires":[[]]},{"id":"69d1bd5a.b24714","type":"server","name":"Home Assistant","addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"","connectionDelay":false,"cacheJson":false,"heartbeat":false,"heartbeatInterval":"","areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"","enableGlobalContextStore":true}]



回复

使用道具 举报

20

主题

352

帖子

1991

积分

金牌会员

Rank: 6Rank: 6

积分
1991
金钱
1639
HASS币
0
发表于 2024-10-10 17:49:05 | 显示全部楼层
导入提示有错误,是否可以上传一下json文件呢?
回复

使用道具 举报

9

主题

242

帖子

1792

积分

金牌会员

Rank: 6Rank: 6

积分
1792
金钱
1550
HASS币
0
发表于 2024-10-11 04:51:25 | 显示全部楼层
gx19970920 发表于 2024-10-10 17:49
导入提示有错误,是否可以上传一下json文件呢?

http://tool.bitefu.net/jiari/?d={{{payload}}}&info=1   通过接口拿的自己可以去测试一下,然后跟据自己的需求操作就可以了。
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-12-22 01:13 , Processed in 0.044961 second(s), 24 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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