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

 找回密码
 立即注册
查看: 10915|回复: 8

[教程系列] 早上播报与前一天同时间的温度,提醒添减衣物

[复制链接]

4

主题

56

帖子

1360

积分

金牌会员

Rank: 6Rank: 6

积分
1360
金钱
1304
HASS币
0
QQ
发表于 2021-3-26 10:39:12 | 显示全部楼层 |阅读模式
早上起来后,被人体感应到以后,提醒与昨天同一时间温度变化,根据参考可以适当添减衣物。请教一下,我只想让他提醒一次,需要添加什么节点?



[{"id":"263ec102.098a6e","type":"tab","label":"开灯播报与昨天同时间温差","disabled":false,"info":""},{"id":"cff13234.5d9ce","type":"api-get-history","z":"263ec102.098a6e","name":"获取昨天同时间温度","server":"5d51d3bd.9c86fc","startdate":"","enddate":"","entityid":"sensor.4c65a8d0b061_temperature","entityidtype":"includes","useRelativeTime":true,"relativeTime":"1day","flatten":false,"output_type":"array","output_location_type":"msg","output_location":"payload","x":1060,"y":220,"wires":[["91cca1c6.ce01c"]]},{"id":"9e63c1e5.e81c5","type":"api-current-state","z":"263ec102.098a6e","name":"客厅当前温度","server":"5d51d3bd.9c86fc","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"sensor.4c65a8d0b061_temperature","state_type":"num","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":600,"y":400,"wires":[["b658fd8d.d7d4b","132990cb.dd89af"]]},{"id":"132990cb.dd89af","type":"debug","z":"263ec102.098a6e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":810,"y":320,"wires":[]},{"id":"91cca1c6.ce01c","type":"change","z":"263ec102.098a6e","name":"转移变量","rules":[{"t":"move","p":"payload[0][0].state","pt":"msg","to":"temp_1day","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":400,"wires":[["9e63c1e5.e81c5"]]},{"id":"b658fd8d.d7d4b","type":"function","z":"263ec102.098a6e","name":"判断当前与昨天的温差","func":"let d_value = msg.temp_1day - msg.payload\nif(Math.abs(d_value) >=0){\n if(d_value<0){\n msg.d_result = `比昨天同时间升温${Math.abs(d_value).toFixed(1)}摄氏度`;\n }\n else if(d_value>0){\n msg.d_result = `比昨天同时间降温${Math.abs(d_value).toFixed(1)}摄氏度`;\n }\n else{\n msg.d_reslut = '';\n }\n}\nelse{\n msg.d_reslut = '';\n }\nmsg.temp_today = msg.payload;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":840,"y":400,"wires":[["495e7ef8.e3817","31a0e811.b19798"]]},{"id":"31a0e811.b19798","type":"debug","z":"263ec102.098a6e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1090,"y":300,"wires":[]},{"id":"c06a8b2e.c70218","type":"comment","z":"263ec102.098a6e","name":"开灯播报当前温度与昨天同时间的温差","info":"","x":150,"y":60,"wires":[]},{"id":"fb12f9e4.83e6f8","type":"rbe","z":"263ec102.098a6e","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":430,"y":180,"wires":[["39680da4.735072"]]},{"id":"8c3d7d37.2486c","type":"server-state-changed","z":"263ec102.098a6e","name":"客厅人体感应","server":"5d51d3bd.9c86fc","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.54ef44e1ec2d_motion","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":false,"for":"","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"x":90,"y":180,"wires":[[]]},{"id":"766b6dc2.82cf54","type":"switch","z":"263ec102.098a6e","name":"感应到有人","property":"data.new_state.state","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":790,"y":200,"wires":[["cff13234.5d9ce"]]},{"id":"5898f714.7e07c8","type":"switch","z":"263ec102.098a6e","name":"无人状态","property":"data.new_state.state","propertyType":"msg","rules":[{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":800,"y":120,"wires":[[]]},{"id":"39680da4.735072","type":"switch","z":"263ec102.098a6e","name":"排除原状态为未知","property":"data.old_state.state","propertyType":"msg","rules":[{"t":"neq","v":"unavailable","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":590,"y":180,"wires":[["766b6dc2.82cf54","5898f714.7e07c8"]]},{"id":"d8740cde.c616","type":"api-call-service","z":"263ec102.098a6e","name":"小爱TTS","server":"5d51d3bd.9c86fc","version":1,"debugenabled":false,"service_domain":"hello_miai","service":"add2msgqueue","entityId":"","data":"","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":1340,"y":360,"wires":[[]]},{"id":"f435e9b6.bffd18","type":"function","z":"263ec102.098a6e","name":"推送内容","func":"\nvar message = `早上好,现在室内温度是${msg.temp_today}摄氏度,${msg.d_result}`;\nmsg.payload = {};\nmsg.payload.data = {"message":message,};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1180,"y":400,"wires":[["d8740cde.c616"]]},{"id":"495e7ef8.e3817","type":"switch","z":"263ec102.098a6e","name":"","property":"d_reslut","propertyType":"msg","rules":[{"t":"neq","v":"","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1030,"y":400,"wires":[["f435e9b6.bffd18"]]},{"id":"a9c366c3.c8f4e8","type":"time-range-switch","z":"263ec102.098a6e","name":"","lat":"","lon":"","startTime":"07:00","endTime":"9:00","startOffset":0,"endOffset":0,"x":290,"y":180,"wires":[["fb12f9e4.83e6f8"],[]]},{"id":"dda38bf9.92f248","type":"inject","z":"263ec102.098a6e","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"num","x":690,"y":260,"wires":[["cff13234.5d9ce"]]},{"id":"5d51d3bd.9c86fc","type":"server","name":"金星中央城","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]


播报1.jpg
回复

使用道具 举报

5

主题

122

帖子

2589

积分

金牌会员

Rank: 6Rank: 6

积分
2589
金钱
2467
HASS币
0
发表于 2021-3-26 14:39:40 | 显示全部楼层
get history节点有用吗 ?在Home Assistant 2021.3.4中 这个节点没有用了。
回复

使用道具 举报

4

主题

56

帖子

1360

积分

金牌会员

Rank: 6Rank: 6

积分
1360
金钱
1304
HASS币
0
QQ
 楼主| 发表于 2021-3-26 14:55:13 | 显示全部楼层
yt16301 发表于 2021-3-26 14:39
get history节点有用吗 ?在Home Assistant 2021.3.4中 这个节点没有用了。

可以用的,我的系统就是2021.3.4
回复

使用道具 举报

17

主题

357

帖子

2084

积分

论坛DIY达人

积分
2084
金钱
1717
HASS币
40
发表于 2021-3-26 15:19:00 | 显示全部楼层
我是用的trigger,接收到前面的信息随便发送一个信息,然后等待重置,再搞一个inject定时到每天早上某个时间发送重置词 未命名1616743097.png
回复

使用道具 举报

4

主题

56

帖子

1360

积分

金牌会员

Rank: 6Rank: 6

积分
1360
金钱
1304
HASS币
0
QQ
 楼主| 发表于 2021-3-26 17:05:19 | 显示全部楼层
hugh_jie 发表于 2021-3-26 15:19
我是用的trigger,接收到前面的信息随便发送一个信息,然后等待重置,再搞一个inject定时到每天早上某个时 ...

此法可行,已使用,不知道可有更好办法?
回复

使用道具 举报

7

主题

151

帖子

1697

积分

金牌会员

Rank: 6Rank: 6

积分
1697
金钱
1546
HASS币
0
发表于 2021-9-9 20:08:55 | 显示全部楼层
楼主节点导入不了
回复

使用道具 举报

56

主题

929

帖子

4077

积分

论坛元老

Rank: 8Rank: 8

积分
4077
金钱
3148
HASS币
0
发表于 2022-3-3 10:09:25 | 显示全部楼层
同样节点导入不了
回复

使用道具 举报

0

主题

152

帖子

1456

积分

金牌会员

Rank: 6Rank: 6

积分
1456
金钱
1304
HASS币
0
发表于 2022-5-20 11:14:10 | 显示全部楼层
你好能把进门的温度播报完整的代码分享一下吗
回复

使用道具 举报

6

主题

31

帖子

242

积分

中级会员

Rank: 3Rank: 3

积分
242
金钱
211
HASS币
0
发表于 2023-7-17 14:47:09 | 显示全部楼层
请问服务 hello_miai是哪里来的,我怎么不行,有空回答下。感谢大佬!
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-11-25 12:15 , Processed in 0.328564 second(s), 34 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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