计数每日自动归零
通过感应器触发每日指定之间内的开灯,通过counter节点统计触发的次数,并将switch设置为1,即每天只允许这个自动化执行一次。现在想要让每天凌晨5点将counter恢复为0,改如何设置?
本帖最后由 ciasdmxhxjjpd@c 于 2023-2-6 22:56 编辑
简单搜了下,使用 ha rest api 的 post 可以实现。
https://community.home-assistant ... ng-nodered/96373/15
参考官方rest api 文档
https://developers.home-assistant.io/docs/api/rest/
nodered 代码,以 person 为例
msg.headers = {};
msg.payload = {};
msg.headers={
'Content-Type': 'application/json'
};
msg.payload = '{"state":"home"}';
msg.url = 'https://your_ha_domain:8123/api/states/person.xxxx';
return msg;
本帖最后由 sctale 于 2023-2-6 22:18 编辑
你counter up limit写1,然后前面加个每天5点循环的inject节点,用decrement,数字填1就行,这样就置零了。
NR的节点都有使用说明的,你自己可以看看学习。
sctale 发表于 2023-2-6 22:16
你counter up limit写1,然后前面加个每天5点循环的inject节点,用decrement,数字填1就行,这样就置零了 ...
感谢感谢,其实也看了NRcounter节点的使用说明,也看到了以下使用说明:
Control
It's possible to control the counter with incoming msg properties:
msg.increment: counter will be incremented by the given value.
msg.decrement: counter will be decremented by the given value.
msg.reset: resets the counter to it's initial count, or to the given value, when it's a number.
看完没理解要怎么设置,你发的截图让我明白了这个使用说明的意思,同时也尝试了用reset来重置。
页:
[1]