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

 找回密码
 立即注册
查看: 2875|回复: 13

[教程系列] Node-RED时间慢8小时HA里的时间是对的

[复制链接]

150

主题

2324

帖子

7191

积分

元老级技术达人

积分
7191
金钱
4862
HASS币
30
发表于 2023-3-23 19:02:56 | 显示全部楼层 |阅读模式
不知道是哪里没有设置对。
回复

使用道具 举报

21

主题

524

帖子

3229

积分

论坛元老

Rank: 8Rank: 8

积分
3229
金钱
2705
HASS币
30
发表于 2023-3-23 21:05:10 | 显示全部楼层
nr是直接用ha的addons安装的嘛?
如果是用docker安装的,确实有这个可能,可以在环境变量里加一个TZ=Asia/Shanghai试试
回复

使用道具 举报

150

主题

2324

帖子

7191

积分

元老级技术达人

积分
7191
金钱
4862
HASS币
30
 楼主| 发表于 2023-3-23 22:24:01 | 显示全部楼层
wdmywm3 发表于 2023-3-23 21:05
nr是直接用ha的addons安装的嘛?
如果是用docker安装的,确实有这个可能,可以在环境变量里加一个TZ=Asia/S ...

addons,haos加载项里的安装的nr,应该不是ha设置问题,可能是nr设置的问题,不知道是哪里有问题
回复

使用道具 举报

23

主题

658

帖子

4643

积分

元老级技术达人

积分
4643
金钱
3970
HASS币
30

教程狂人

QQ
发表于 2023-3-24 16:27:12 | 显示全部楼层
没有描述清楚问题,调试输出时间不对的话,可以参考这贴NR时间问题
回复

使用道具 举报

150

主题

2324

帖子

7191

积分

元老级技术达人

积分
7191
金钱
4862
HASS币
30
 楼主| 发表于 2023-3-24 16:35:44 | 显示全部楼层
alei643 发表于 2023-3-24 16:27
没有描述清楚问题,调试输出时间不对的话,可以参考这贴NR时间问题

调用这个代码,获取更新时间,慢8小时,请求大佬指点,ha里已经设置了正确的时区,更新时间 {{ states.sensor.nodered_53b393b7bbc8cb9c.last_changed.strftime('%Y-%m-%d %H:%M:%S') }}
1.jpg
2.jpg
回复

使用道具 举报

23

主题

658

帖子

4643

积分

元老级技术达人

积分
4643
金钱
3970
HASS币
30

教程狂人

QQ
发表于 2023-3-24 16:49:03 | 显示全部楼层
看第一行节点的输出时间是正确的,所以NR时间没有问题,这个跟HA时间也没有关系,胎里带的问题,把消息重新封装一下,把时间改一下就好了
回复

使用道具 举报

150

主题

2324

帖子

7191

积分

元老级技术达人

积分
7191
金钱
4862
HASS币
30
 楼主| 发表于 2023-3-24 16:51:48 | 显示全部楼层
alei643 发表于 2023-3-24 16:49
看第一行节点的输出时间是正确的,所以NR时间没有问题,这个跟HA时间也没有关系,胎里带的问题,把消息重新 ...

大佬,我应该怎么操作,我就想获取这个更新时间,是不是我的函数获取时间的方法不对,last_changed.strftime('%Y-%m-%d %H:%M:%S') }}
回复

使用道具 举报

23

主题

658

帖子

4643

积分

元老级技术达人

积分
4643
金钱
3970
HASS币
30

教程狂人

QQ
发表于 2023-3-24 17:19:48 | 显示全部楼层
把整个流程贴上来
回复

使用道具 举报

150

主题

2324

帖子

7191

积分

元老级技术达人

积分
7191
金钱
4862
HASS币
30
 楼主| 发表于 2023-3-24 17:22:39 | 显示全部楼层
alei643 发表于 2023-3-24 17:19
把整个流程贴上
[{"id":"9f7bc6d2.1403b8","type":"tab","label":"流程4","disabled":false,"info":""},{"id":"aebb6f6e.de34e","type":"http request","z":"9f7bc6d2.1403b8","name":"获取古诗词","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://v1.jinrishici.com/all.json","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":587,"y":384,"wires":[["6a470f6f.5a52b","aee69402.c4c838","daa5669594d717e7"]]},{"id":"1b07ae22.997312","type":"inject","z":"9f7bc6d2.1403b8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"18000","crontab":"","once":true,"onceDelay":"","topic":"","payload":"","payloadType":"date","x":408,"y":384,"wires":[["aebb6f6e.de34e"]]},{"id":"6a470f6f.5a52b","type":"debug","z":"9f7bc6d2.1403b8","name":"调试节点","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":758,"y":205,"wires":[]},{"id":"aee69402.c4c838","type":"mqtt out","z":"9f7bc6d2.1403b8","name":"mqtt发送","topic":"node-red/guishi","qos":"0","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"dcde9dc2.ca785","x":778,"y":375,"wires":[]},{"id":"daa5669594d717e7","type":"ha-sensor","z":"9f7bc6d2.1403b8","name":"gushici","entityConfig":"53b393b7bbc8cb9c","version":0,"state":"payload.content","stateType":"msg","attributes":[{"property":"content","value":"payload.content","valueType":"msg"},{"property":"origin","value":"payload.origin","valueType":"msg"},{"property":"author","value":"payload.author","valueType":"msg"},{"property":"category","value":"payload.category","valueType":"msg"},{"property":"gxtime","value":"","valueType":"date"}],"inputOverride":"allow","outputProperties":[],"x":780,"y":440,"wires":[[]]},{"id":"dcde9dc2.ca785","type":"mqtt-broker","name":"mqtt","broker":"localhost","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""},{"id":"53b393b7bbc8cb9c","type":"ha-entity-config","server":"6c2a919b.53acf","deviceConfig":"","name":"sensor config for gushici","version":"6","entityType":"sensor","haConfig":[{"property":"name","value":"每日古诗词"},{"property":"icon","value":"mdi:message-text-outline"},{"property":"entity_category","value":""},{"property":"device_class","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""},{"property":"last_reset","value":"2023-03-22T11:08:00.000Z"}],"resend":true,"debugEnabled":false},{"id":"6c2a919b.53acf","type":"server","name":"Home Assistant","addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"","connectionDelay":false,"cacheJson":false,"heartbeat":false,"heartbeatInterval":"","statusSeparator":"","enableGlobalContextStore":false}]

代码已发
回复

使用道具 举报

23

主题

658

帖子

4643

积分

元老级技术达人

积分
4643
金钱
3970
HASS币
30

教程狂人

QQ
发表于 2023-3-25 13:53:53 | 显示全部楼层
没发现问题。。。我还以为你用的是5楼帖子里NR调试输出header下面的date值,结果不是,你直接用的是这个NR虚拟实体的更改时间,但是NR的时间也对啊。
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-12-22 11:11 , Processed in 0.099720 second(s), 36 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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