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

标题: 【Node-RED】 天气推送(支持3Dtouch停止推送) [打印本页]

作者: neroxps    时间: 2018-9-17 16:03
标题: 【Node-RED】 天气推送(支持3Dtouch停止推送)

效果图


[attach]9793[/attach]


[attach]9792[/attach]


前置需求



  1. home-assistant 部署彩云天气

  2. 部署 nodered(废话啦)


其实这个nodered是一个很简单的例子,我只是结合nodered的http 特性根据 ios 推送做了一些按钮罢了,其他更有趣的需求和玩法大家可以参考这种做法。




[attach]9794[/attach]
作者: angelyangw    时间: 2018-9-17 16:43
居然抢到沙发 !
作者: 囧    时间: 2018-9-17 18:01
岂是一个“酷”字了得!
作者: xieahui    时间: 2018-9-17 18:56
我现在看到node教程眼睛发光啊
作者: czweb    时间: 2018-9-17 20:14
发现node-red之美了吧?早之前我研究的不亦乐乎
作者: neroxps    时间: 2018-9-17 21:03
czweb 发表于 2018-9-17 20:14
发现node-red之美了吧?早之前我研究的不亦乐乎

研究的不亦乐乎的话来点干货罚?
作者: czweb    时间: 2018-9-17 21:09
neroxps 发表于 2018-9-17 21:03
研究的不亦乐乎的话来点干货罚?

截图给你看过的,就是项目上使用的中控,主要是设备开关。
没有用其它复杂的事件。
作者: 咸味土豆    时间: 2018-9-18 08:31
大佬们都玩node-red了,有时间了学习学习,顶一下先。
作者: aaa    时间: 2018-9-22 14:46
感谢分享!
作者: showphi    时间: 2018-9-25 20:25
大神说的详细点啊,初次接触node-red,stop_weather_push.yaml是放在packages?导入天气推送.json后,降雨概率、分钟级概况和APP推送都显示unknow(已经安装彩云天气SE),如何部署?
作者: neroxps    时间: 2018-9-26 08:00
showphi 发表于 2018-9-25 20:25
大神说的详细点啊,初次接触node-red,stop_weather_push.yaml是放在packages?导入天气推送.json后,降雨概 ...

debug调下呗。是不是有东西没配置好?例如 ha 密码什么的。
作者: showphi    时间: 2018-9-26 18:26
neroxps 发表于 2018-9-26 08:00
debug调下呗。是不是有东西没配置好?例如 ha 密码什么的。

哪里设置密码?stop_weather_push.yaml里的          nodered_url: !secret nodered_url
          nodered_user: !secret nodered_user
          nodered_password: !secret nodered_password
设置了没效果
作者: neroxps    时间: 2018-9-27 08:41
showphi 发表于 2018-9-26 18:26
哪里设置密码?stop_weather_push.yaml里的          nodered_url: !secret nodered_url
          noder ...

nodered_url:  http://nodered_url
nodered_user: nodred 的登陆用户名
nodered_password: nodered的密码
作者: neroxps    时间: 2018-9-27 08:42
showphi 发表于 2018-9-26 18:26
哪里设置密码?stop_weather_push.yaml里的          nodered_url: !secret nodered_url
          noder ...

拉个debug调试下就好了,nodered恨容易的,自己研究下~
作者: aimei    时间: 2018-9-29 21:42
service名ios_iphone,能给下配置内容吗?
作者: wudijushi    时间: 2018-11-27 20:33
版主,IOS的HA现在什么版本啦,在App Store上的好像很久了?
作者: neroxps    时间: 2018-11-27 21:11
wudijushi 发表于 2018-11-27 20:33
版主,IOS的HA现在什么版本啦,在App Store上的好像很久了?

我发这个应该在App Store 的版本也适用

说起这,官方折腾了很久 TF版本现在还没发新版。。。。
作者: fineemb    时间: 2019-7-7 10:11
我想模拟降水概率这个state node, 用inject来模拟, 用来调试 应该怎么配置. 谢谢!!
作者: fineemb    时间: 2019-7-7 11:07
自己搞定了...[attach]16845[/attach]

作者: fineemb    时间: 2019-7-8 16:23
我还是遇到了问题。尝试用sonos的快照功能实现暂停播放之前的音乐,然后播报tts,完成后继续播放之前的音乐。我这个流只会重复播放天气情况,之前的快照好像并不成功。
作者: neroxps    时间: 2019-7-8 17:18
fineemb 发表于 2019-7-8 16:23
我还是遇到了问题。尝试用sonos的快照功能实现暂停播放之前的音乐,然后播报tts,完成后继续播放之前的音乐 ...

我没 senos 也不知道你的快照是指什么?
作者: fineemb    时间: 2019-7-14 00:17
原来是homeassistant的节点安装错了. 终于可以优雅地使用sonos进行TTS播报了.
后面还可以设置根据不同时间进行音量调整
[attach]16962[/attach]


  1. [{"id":"f509ea94.00f4e8","type":"tab","label":"sonos播报天气预警","disabled":false,"info":""},{"id":"d902b9e9.2f11c8","type":"function","z":"f509ea94.00f4e8","name":"推送内容","func":"var message = msg.payload;\nvar subtitle = "注意:" + msg.pr_data.old_state.attributes.friendly_name + "为" + msg.pr + "%";\nmsg.payload = {};\nmsg.payload.data = {"entity_id": "media_player.ban_gong_shi","message":subtitle+". "+message};\nreturn [msg,{}]; \n","outputs":2,"noerr":0,"x":420,"y":280,"wires":[["6aef6808.f41328"],["94278e64.1d56a","41af408a.37231"]]},{"id":"dda03b3e.0ae5b8","type":"api-current-state","z":"f509ea94.00f4e8","name":"分钟级概况","server":"9a56e1b1.84865","outputs":1,"halt_if":"","override_topic":true,"entity_id":"sensor.caiyun_minutely_description","override_payload":true,"x":250,"y":280,"wires":[["d902b9e9.2f11c8"]]},{"id":"eaa823dc.2a9eb","type":"server-state-changed","z":"f509ea94.00f4e8","name":"降雨概率","server":"9a56e1b1.84865","version":1,"entityidfilter":"sensor.caiyun_minutely_probability_*","entityidfiltertype":"regex","outputinitially":false,"state_type":"str","haltifstate":"60","halt_if_type":"num","halt_if_compare":"gt","outputs":2,"output_only_on_state_change":false,"x":60,"y":160,"wires":[["c67f2151.e58a1"],[]]},{"id":"84013166.8e634","type":"function","z":"f509ea94.00f4e8","name":"筛选消息","func":"// 检查全局变量,判断是否推送。\n\n//if (flow.get('notice') === false){\n//    return null;\n//}\n\nfunction compare(property){\n    return function(a,b){\n        var value1 = a[property];\n        var value2 = b[property];\n        return value1 > value2;\n    }\n}\n// 根据 entity_id 来排序,确保先检查30分钟降雨概率传感器\nmsg.data = msg.data.sort(compare('entity_id'));\n\nfor (var datas in msg.data){\n    if ( msg.data[datas].old_state.state < 60 && msg.data[datas].new_state.state > 60 ){\n        msg.pr = msg.data[datas].new_state.state;\n        msg.pr_data= msg.data[datas];\n        break; \n    }\n}\nif (!msg.pr){\n    return null;\n}\nelse{\n    return msg;\n}","outputs":1,"noerr":0,"x":240,"y":220,"wires":[["dda03b3e.0ae5b8"]]},{"id":"c67f2151.e58a1","type":"join","z":"f509ea94.00f4e8","name":"消息汇聚","mode":"custom","build":"array","property":"data","propertyType":"msg","key":"pr_all","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"5","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"num","reduceFixup":"","x":240,"y":160,"wires":[["84013166.8e634"]]},{"id":"bf61adfa.7fd7d","type":"api-call-service","z":"f509ea94.00f4e8","name":"TTS","server":"9a56e1b1.84865","service_domain":"tts","service":"baidu_say","data":"{"entity_id":"media_player.ban_gong_shi"}","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":710,"y":240,"wires":[["fc304a2.c6a80b8"]]},{"id":"efc0df2d.cd1d6","type":"inject","z":"f509ea94.00f4e8","name":"测试","topic":"sensor.caiyun_minutely_probability_5","payload":"50","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":70,"y":80,"wires":[["9510dd8b.cdfd8","2faf76ab.cee30a"]]},{"id":"9510dd8b.cdfd8","type":"function","z":"f509ea94.00f4e8","name":"模拟数据2","func":"msg.data = {"entity_id":"sensor.caiyun_minutely_probability_4","old_state":{"entity_id":"sensor.caiyun_minutely_probability_4","state":"45","attributes":{"unit_of_measurement":"%","friendly_name":"180分钟降雨概率","icon":"mdi:weather-pouring","homebridge_hidden":true},"last_changed":"2019-07-07T02:00:23.029663+00:00","last_updated":"2019-07-07T02:00:23.029663+00:00","context":{"id":"f07d188af171494185d7b7c28c0d575a","parent_id":null,"user_id":null}},"new_state":{"entity_id":"sensor.caiyun_minutely_probability_4","state":"55","attributes":{"unit_of_measurement":"%","friendly_name":"180分钟降雨概率","icon":"mdi:weather-pouring","homebridge_hidden":true},"last_changed":"2019-07-07T02:21:40.722299+00:00","last_updated":"2019-07-07T02:21:40.722299+00:00","context":{"id":"94c939155fb44a94a92dd9ddb4330074","parent_id":null,"user_id":null}}};\nreturn msg; ","outputs":1,"noerr":0,"x":200,"y":60,"wires":[["c67f2151.e58a1"]]},{"id":"2faf76ab.cee30a","type":"function","z":"f509ea94.00f4e8","name":"模拟数据1","func":"msg.data = {"entity_id":"sensor.caiyun_minutely_probability_5","old_state":{"entity_id":"sensor.caiyun_minutely_probability_4","state":"35","attributes":{"unit_of_measurement":"%","friendly_name":"60分钟降雨概率","icon":"mdi:weather-pouring","homebridge_hidden":true},"last_changed":"2019-07-07T02:00:23.029663+00:00","last_updated":"2019-07-07T02:00:23.029663+00:00","context":{"id":"f07d188af171494185d7b7c28c0d575a","parent_id":null,"user_id":null}},"new_state":{"entity_id":"sensor.caiyun_minutely_probability_5","state":"65","attributes":{"unit_of_measurement":"%","friendly_name":"180分钟降雨概率","icon":"mdi:weather-pouring","homebridge_hidden":true},"last_changed":"2019-07-07T02:21:40.722299+00:00","last_updated":"2019-07-07T02:21:40.722299+00:00","context":{"id":"94c939155fb44a94a92dd9ddb4330074","parent_id":null,"user_id":null}}};\nreturn msg; ","outputs":1,"noerr":0,"x":200,"y":100,"wires":[["c67f2151.e58a1"]]},{"id":"601a4bb5.eb6134","type":"api-call-service","z":"f509ea94.00f4e8","name":"播放","server":"9a56e1b1.84865","service_domain":"media_player","service":"media_play","data":"{"entity_id":"media_player.ban_gong_shi"}","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":890,"y":440,"wires":[["ce4f9415.550e58"]]},{"id":"a43538a3.5807c8","type":"api-call-service","z":"f509ea94.00f4e8","name":"还原播放列表","server":"9a56e1b1.84865","service_domain":"sonos","service":"restore","data":"{"entity_id":"media_player.ban_gong_shi"}","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":580,"y":420,"wires":[["e3fb7cdb.99dec"]]},{"id":"6aef6808.f41328","type":"delay","z":"f509ea94.00f4e8","name":"","pauseType":"delay","timeout":"3","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":580,"y":240,"wires":[["bf61adfa.7fd7d"]]},{"id":"94278e64.1d56a","type":"api-call-service","z":"f509ea94.00f4e8","name":"快照播放列表","server":"9a56e1b1.84865","service_domain":"sonos","service":"snapshot","data":"{"entity_id":"media_player.ban_gong_shi"}","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":600,"y":280,"wires":[[]]},{"id":"1c84f851.26d678","type":"server-state-changed","z":"f509ea94.00f4e8","name":"sonos播放状态改变","server":"9a56e1b1.84865","version":1,"entityidfilter":"media_player.ban_gong_shi","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"x":90,"y":420,"wires":[["f3793d32.80e38"]]},{"id":"f3793d32.80e38","type":"switch","z":"f509ea94.00f4e8","name":"播放停止","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"paused","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":260,"y":420,"wires":[["2a4ed87d.000298"]]},{"id":"2a4ed87d.000298","type":"switch","z":"f509ea94.00f4e8","name":"TTS播报结束","property":"tts","propertyType":"flow","rules":[{"t":"eq","v":"stop","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":410,"y":420,"wires":[["a43538a3.5807c8"]]},{"id":"fc304a2.c6a80b8","type":"function","z":"f509ea94.00f4e8","name":"设置变量","func":"flow.set("tts","stop")","outputs":1,"noerr":0,"x":840,"y":240,"wires":[[]]},{"id":"ce4f9415.550e58","type":"function","z":"f509ea94.00f4e8","name":"设置变量","func":"flow.set("tts","play")","outputs":1,"noerr":0,"x":980,"y":400,"wires":[[]]},{"id":"41af408a.37231","type":"api-current-state","z":"f509ea94.00f4e8","name":"暂停状态","server":"9a56e1b1.84865","version":1,"outputs":2,"halt_if":"paused","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"media_player.ban_gong_shi","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":580,"y":340,"wires":[["6a70523c.d54a4c"],["542c1b06.b2d354"]]},{"id":"6a70523c.d54a4c","type":"function","z":"f509ea94.00f4e8","name":"设置变量","func":"flow.set("sonos","paused")","outputs":1,"noerr":0,"x":740,"y":320,"wires":[[]]},{"id":"542c1b06.b2d354","type":"function","z":"f509ea94.00f4e8","name":"设置变量","func":"flow.set("sonos","player")","outputs":1,"noerr":0,"x":740,"y":360,"wires":[[]]},{"id":"e3fb7cdb.99dec","type":"switch","z":"f509ea94.00f4e8","name":"原来状态","property":"sonos","propertyType":"flow","rules":[{"t":"eq","v":"paused","vt":"str"},{"t":"eq","v":"player","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":760,"y":420,"wires":[["ce4f9415.550e58"],["601a4bb5.eb6134"]]},{"id":"9a56e1b1.84865","type":"server","z":"","name":"Home Assistant","legacy":false,"hassio":false,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true}]
复制代码




作者: dukejunior    时间: 2019-8-2 18:16
现在ha是越来越牛B了




欢迎光临 『瀚思彼岸』» 智能家居技术论坛 (https://bbs.hassbian.com/) Powered by Discuz! X3.5