可视化网关编程系列教程-----(3)日落打开花园灯

日落打开花园灯,日出关闭花园灯

小伙伴们,今天来学习定时模块,让家庭设备实现自动化,节省更多的时间去睡觉。


可视化网关编程系列教程-----(3)日落打开花园灯_第1张图片
image.png

Ok,下面跟着我做。


可视化网关编程系列教程-----(3)日落打开花园灯_第2张图片
image.png

步骤

1. 安装suncalc节点

在节点管理器中搜索suncalc节点,然后进行安装即可。


可视化网关编程系列教程-----(3)日落打开花园灯_第3张图片
image.png
2. 使用suncalc节点

打开suncalc节点以后你会发现有LatitudeLongitudeStart, End
这里我们要知道你所在地区的经纬度,然后填进去,节点会自动定位到你所在的位置。比如我在上海,所以我的经纬度是121.48 31.22
start和end里的几个选项基本上都差不多,大家可以翻译一下。这里我们使用默认的配置(上海地区)。

可视化网关编程系列教程-----(3)日落打开花园灯_第4张图片
lc_shanghai.png

这个节点有两个输出,第一个输出是每分钟都会有输出,第二个是当变化的时候才有。所以,我们这里选择第二个即可。
因为,这个节点输出的数据是0和1,所以我们要将其变成true和false;另外,由于节点白天输出的是1晚上输出是0,而我们是晚上开灯,白天关灯,所以要进行取反。
可视化网关编程系列教程-----(3)日落打开花园灯_第5张图片
image.png

这样就实现了日落开花园灯,日出关闭花园灯。是不是so easy。

可视化网关编程系列教程-----(3)日落打开花园灯_第6张图片
image.png
3. 流程案例代码
[{"id":"72e80aab.6c13b4","type":"sunrise","z":"4c3af1c6.55c05","name":"日出日落","lat":"31.40","lon":"121.24","start":"sunrise","end":"sunsetStart","x":420,"y":880,"wires":[[],["692e634b.1ba64c"]]},{"id":"692e634b.1ba64c","type":"function","z":"4c3af1c6.55c05","name":"日出日落取反","func":"if(msg.payload === 1)\n{\n    //日出关灯\n    msg.payload = false;\n}\nelse {\n    // 日落开灯\n    msg.payload = true;\n}\nreturn msg;","outputs":1,"noerr":0,"x":660,"y":880,"wires":[["59d4e668.f26688","88ef400c.adc24","21f87d7d.d44962"]]},{"id":"59d4e668.f26688","type":"knxUltimate","z":"4c3af1c6.55c05","server":"7521b5a9.475d8c","topic":"1/1/1","dpt":"1.001","initialread":false,"notifyreadrequest":false,"notifyresponse":false,"notifywrite":true,"notifyreadrequestalsorespondtobus":false,"notifyreadrequestalsorespondtobusdefaultvalueifnotinitialized":"0","listenallga":false,"name":"草坪灯","outputtype":"write","outputRBE":true,"inputRBE":false,"x":910,"y":840,"wires":[[]]},{"id":"88ef400c.adc24","type":"knxUltimate","z":"4c3af1c6.55c05","server":"7521b5a9.475d8c","topic":"1/1/2","dpt":"1.001","initialread":false,"notifyreadrequest":false,"notifyresponse":false,"notifywrite":true,"notifyreadrequestalsorespondtobus":false,"notifyreadrequestalsorespondtobusdefaultvalueifnotinitialized":"0","listenallga":false,"name":"水池灯","outputtype":"write","outputRBE":true,"inputRBE":false,"x":910,"y":900,"wires":[[]]},{"id":"21f87d7d.d44962","type":"knxUltimate","z":"4c3af1c6.55c05","server":"7521b5a9.475d8c","topic":"1/1/3","dpt":"1.001","initialread":true,"notifyreadrequest":false,"notifyresponse":false,"notifywrite":true,"notifyreadrequestalsorespondtobus":false,"notifyreadrequestalsorespondtobusdefaultvalueifnotinitialized":"0","listenallga":false,"name":"墙壁灯带","outputtype":"write","outputRBE":true,"inputRBE":false,"x":920,"y":960,"wires":[[]]},{"id":"7521b5a9.475d8c","type":"knxUltimate-config","z":"","host":"224.0.23.12","port":"3671","physAddr":"15.15.22","suppressACKRequest":false,"csv":"\"Group name\"\t\"Address\"\t\"Central\"\t\"Unfiltered\"\t\"Description\"\t\"DatapointType\"\t\"Security\"\n\"灯光\"\t\"0/0/-\"\t\"\"\t\"\"\t\"\"\t\"\"\t\"Auto\"\n\"客厅吊灯\"\t\"0/0/1\"\t\"\"\t\"\"\t\"\"\t\"DPST-1-1\"\t\"Auto\"\n\"客厅筒灯\"\t\"0/0/2\"\t\"\"\t\"\"\t\"\"\t\"DPST-1-1\"\t\"Auto\"\n\"客厅灯带\"\t\"0/0/3\"\t\"\"\t\"\"\t\"\"\t\"DPST-1-1\"\t\"Auto\"\n\"//\"\t\"0/0/4\"\t\"\"\t\"\"\t\"\"\t\"DPST-1-1\"\t\"Auto\"\n\"餐厅吊灯\"\t\"0/0/5\"\t\"\"\t\"\"\t\"\"\t\"DPST-1-1\"\t\"Auto\"\n\"餐厅筒灯\"\t\"0/0/6\"\t\"\"\t\"\"\t\"\"\t\"DPST-1-1\"\t\"Auto\"\n\"餐厅灯带\"\t\"0/0/7\"\t\"\"\t\"\"\t\"\"\t\"DPST-1-1\"\t\"Auto\"\n\"空调\"\t\"0/1/-\"\t\"\"\t\"\"\t\"\"\t\"\"\t\"Auto\"\n\"客厅-空调-开关\"\t\"0/1/0\"\t\"\"\t\"\"\t\"\"\t\"DPST-1-1\"\t\"Auto\"\n\"客厅-空调-模式\"\t\"0/1/1\"\t\"\"\t\"\"\t\"\"\t\"DPT-5-2\"\t\"Auto\"\n\"客厅-空调-风速\"\t\"0/1/2\"\t\"\"\t\"\"\t\"\"\t\"DPT-5-2\"\t\"Auto\"\n\"客厅-空调-设置温度\"\t\"0/1/3\"\t\"\"\t\"\"\t\"\"\t\"DPST-9-1\"\t\"Auto\"\n\"客厅-空调-室内温度\"\t\"0/1/4\"\t\"\"\t\"\"\t\"\"\t\"DPST-9-1\"\t\"Auto\"\n","KNXEthInterface":"Auto","KNXEthInterfaceManuallyInput":"","statusDisplayLastUpdate":true,"statusDisplayDeviceNameWhenALL":true,"statusDisplayDataPoint":false}]
4. 更高级的定时功能

这里还有一个比日出日落的拓展节点


可视化网关编程系列教程-----(3)日落打开花园灯_第7张图片
image.png

支持更准确的时间段以及日期,我想哪天开就哪天开,哈哈哈。是不是更人性化。
这个模块叫timeswitch

可视化网关编程系列教程-----(3)日落打开花园灯_第8张图片
image.png

可视化网关编程系列教程-----(3)日落打开花园灯_第9张图片
image.png

这个大家可以自己玩一下,有问题下方评论区小板凳。

你可能感兴趣的:(可视化网关编程系列教程-----(3)日落打开花园灯)