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

标题: 计数每日自动归零 [打印本页]

作者: liy517    时间: 2023-2-6 21:31
标题: 计数每日自动归零
通过感应器触发每日指定之间内的开灯,通过counter节点统计触发的次数,并将switch设置为1,即每天只允许这个自动化执行一次。

现在想要让每天凌晨5点将counter恢复为0,改如何设置?





作者: ciasdmxhxjjpd@c    时间: 2023-2-6 21:54
本帖最后由 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 为例

  1. msg.headers = {};
  2. msg.payload = {};
  3. msg.headers={
  4.     'Content-Type': 'application/json'
  5. };
  6. msg.payload = '{"state":"home"}';
  7. msg.url = 'https://your_ha_domain:8123/api/states/person.xxxx';
  8. return msg;
复制代码








作者: sctale    时间: 2023-2-6 22:16
本帖最后由 sctale 于 2023-2-6 22:18 编辑

[attach]45153[/attach]

你counter up limit写1,然后前面加个每天5点循环的inject节点,用decrement,数字填1就行,这样就置零了。

NR的节点都有使用说明的,你自己可以看看学习。

作者: liy517    时间: 2023-2-7 09:08
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来重置。






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