请选择 进入手机版 | 继续访问电脑版

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

 找回密码
 立即注册
查看: 130|回复: 1

[教程系列] NodeRed版留言板(无需配置企业微信外网域名)

[复制链接]

29

主题

176

帖子

963

积分

高级会员

Rank: 4

积分
963
金钱
787
HASS币
0
发表于 2022-8-1 13:39:16 | 显示全部楼层 |阅读模式
本帖最后由 silas3082 于 2022-8-1 13:42 编辑

今天突发奇想在ha里弄个留言板玩玩,家庭成员有谁到家了可以用客厅小爱音箱提醒。之前看过大神帖子实现语音留言板需要企业微信需要外网域名,第三方域名还不行,于是就放下了。
本方案是在ha概览里边选好需要留言的人员,留言内容后,待其到家后,小爱自动播报留言内容。

实现思路:

1.在ha的辅助元素里边建立2个实体,一个是文本输入,一个是人员选择,将建立好的实体添加到概览界面。


2.nr配置如图,代码如下。最前边链接的是人员到家触发,有多种触发,自行解决。

[{"id":"b9469a122e7e4147","type":"api-call-service","z":"102c735e16644b20","name":"","server":"94f0c0a9.629b6","version":5,"debugenabled":false,"domain":"xiaomi_miot","service":"intelligent_speaker","areaId":[],"deviceId":[],"entityId":["remote.xiao_ai_yin_xiang_mo_neng_yao_kong_ban"],"data":"{\"text\":msg.payload}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":2110,"y":1460,"wires":[["183c84b85877cc1b"]]},{"id":"598755877c095a60","type":"api-current-state","z":"102c735e16644b20","name":"小爱tts输入","server":"94f0c0a9.629b6","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_text.xiao_ai_tts","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","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":970,"y":1420,"wires":[["f0c464deea8d6fff"]]},{"id":"183c84b85877cc1b","type":"api-call-service","z":"102c735e16644b20","name":"","server":"94f0c0a9.629b6","version":5,"debugenabled":false,"domain":"notify","service":"wework","areaId":[],"deviceId":[],"entityId":[],"data":"{\"message\":\"小爱提醒成功\"}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":2380,"y":1460,"wires":[[]]},{"id":"47ba58460ac6279c","type":"delay","z":"102c735e16644b20","name":"","pauseType":"delay","timeout":"10","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"x":580,"y":1360,"wires":[["8c0cf214b860f20f"]]},{"id":"f0c464deea8d6fff","type":"function","z":"102c735e16644b20","name":"判断和之前文本是否一样","func":"var oldstate = global.get('xiaoaitts_input');\nif (oldstate != msg.payload){\n    global.set('xiaoaitts_input',oldstate);\n    return[null,msg] \n}else{\n    \n    return[msg,null]\n}\n\n\n\nreturn msg;","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1250,"y":1420,"wires":[[],["7f454086e9b089bd"]]},{"id":"7f454086e9b089bd","type":"function","z":"102c735e16644b20","name":"设置环境变量","func":"\n  global.set('xiaoaitts_input',msg.payload);\n \nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1480,"y":1440,"wires":[["b8ca9e14e3af9ad1"]]},{"id":"52cd1651c8142aee","type":"api-current-state","z":"102c735e16644b20","name":"人员选择","server":"94f0c0a9.629b6","version":3,"outputs":2,"halt_if":"ma","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_select.ren_yuan","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","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":360,"y":1320,"wires":[["47ba58460ac6279c"],[]]},{"id":"e1d10bb65ba8860a","type":"link in","z":"102c735e16644b20","name":"","links":["0d36f6ac27203fd5"],"x":195,"y":1320,"wires":[["52cd1651c8142aee"]]},{"id":"8d013e7399f04335","type":"link in","z":"102c735e16644b20","name":"","links":["4c3bba90b0d791a1"],"x":195,"y":1380,"wires":[["c25833f83ae638b6"]]},{"id":"0b23631c0ffe56c7","type":"link in","z":"102c735e16644b20","name":"","links":["c38d4cd795391261"],"x":195,"y":1440,"wires":[["8ce50f80e277f8cc"]]},{"id":"c25833f83ae638b6","type":"api-current-state","z":"102c735e16644b20","name":"人员选择","server":"94f0c0a9.629b6","version":3,"outputs":2,"halt_if":"我","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_select.ren_yuan","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","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":1380,"wires":[["47ba58460ac6279c"],[]]},{"id":"8ce50f80e277f8cc","type":"api-current-state","z":"102c735e16644b20","name":"人员选择","server":"94f0c0a9.629b6","version":3,"outputs":2,"halt_if":"lp","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_select.ren_yuan","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","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":320,"y":1440,"wires":[["47ba58460ac6279c"],[]]},{"id":"bd11531a4a9ec829","type":"comment","z":"102c735e16644b20","name":"留言板","info":"","x":130,"y":1200,"wires":[]},{"id":"bd55bf22a44c1048","type":"ha-entity","z":"102c735e16644b20","name":"","server":"94f0c0a9.629b6","version":2,"debugenabled":false,"outputs":2,"entityType":"switch","config":[{"property":"name","value":"留言板开关"},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"","outputPayloadType":"str","x":320,"y":1200,"wires":[[],[]]},{"id":"8c0cf214b860f20f","type":"api-current-state","z":"102c735e16644b20","name":"留言板开关为开","server":"94f0c0a9.629b6","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"switch.liu_yan_ban_kai_guan","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","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":760,"y":1420,"wires":[["598755877c095a60"],[]]},{"id":"b8ca9e14e3af9ad1","type":"function","z":"102c735e16644b20","name":"","func":"msg.payload=\"您有一条新留言,内容为,\"+msg.payload;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1690,"y":1440,"wires":[["2aeb55b8d64d59d0"]]},{"id":"2aeb55b8d64d59d0","type":"xiaoai-volume","z":"102c735e16644b20","name":"客厅小爱音量","xiaoai":"XXXXXX","volume":"45","device":"XXXXXXXXXX","x":1860,"y":1440,"wires":[["b9469a122e7e4147"],[]]},{"id":"94f0c0a9.629b6","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":false,"cacheJson":true,"heartbeat":false,"heartbeatInterval":"30"},{"id":"aea8514ac03e7fb4","type":"xiaoai-tts-configurator","name":""}]


微信截图_20220801133322.png
微信截图_20220801133358.png
4.png
回复

使用道具 举报

29

主题

1671

帖子

3495

积分

论坛元老

Rank: 8Rank: 8

积分
3495
金钱
1824
HASS币
40
QQ
发表于 2022-8-1 22:11:06 | 显示全部楼层
膜拜大神。
我不生产技术,我只是技术的搬运工。
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2022-8-10 03:22 , Processed in 0.050373 second(s), 27 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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