756641156 发表于 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.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}]

yt16301 发表于 2021-3-26 14:39:40

get history节点有用吗 ?在Home Assistant 2021.3.4中 这个节点没有用了。

756641156 发表于 2021-3-26 14:55:13

yt16301 发表于 2021-3-26 14:39
get history节点有用吗 ?在Home Assistant 2021.3.4中 这个节点没有用了。

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

hugh_jie 发表于 2021-3-26 15:19:00

我是用的trigger,接收到前面的信息随便发送一个信息,然后等待重置,再搞一个inject定时到每天早上某个时间发送重置词

756641156 发表于 2021-3-26 17:05:19

hugh_jie 发表于 2021-3-26 15:19
我是用的trigger,接收到前面的信息随便发送一个信息,然后等待重置,再搞一个inject定时到每天早上某个时 ...

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

zeze247 发表于 2021-9-9 20:08:55

楼主节点导入不了

bainiu 发表于 2022-3-3 10:09:25

同样节点导入不了

13990973177 发表于 2022-5-20 11:14:10

你好能把进门的温度播报完整的代码分享一下吗

gutao3800 发表于 2023-7-17 14:47:09

请问服务 hello_miai是哪里来的,我怎么不行,有空回答下。感谢大佬!
页: [1]
查看完整版本: 早上播报与前一天同时间的温度,提醒添减衣物