lorenwest / node-red-contrib-state

Node-RED shared logical state with persistence, notification, and history
MIT License
7 stars 6 forks source link

nodes that reference history[0].val or history[0].ts not getting the expected data #13

Open VisualReversal opened 1 year ago

VisualReversal commented 1 year ago

@lorenwest - For months I've been referencing history[0].val and history[0].ts for a variety of things without issue. Today, I saw that I had an update for node-red-contrib-state, so I updated. After the update all kinds of weird stuff started happening. After some debugging I discovered that I was not getting the expected output from nodes that referenced any global.state variable history[0] data. history[1].val and history[1].ts will work as expected however. After changing all of the effected nodes to either "value" or "timestamp" as appropriate, everything works again as expected.

The other weird thing is that after checking here, the npm site and the node-red flows library I see no recent updates listed. All of my files in /home/pi/.node-red/node_modules/node-red-contrib-state show that they were updated on 8 Dec 2022 at 12:33pm. The current version number is 1.6.1. I didn't pay attention to the previous version number. I keep a pretty good eye on pallet updates and I update often, so I'm totally confused about this. I'm not a programmer; just a home automation enthusiast, so hopefully I'm not making a total fool of myself by bringing this issue up.

VisualReversal commented 1 year ago

So after a bit more tinkering I discovered that the data from history[0].val and "value" weren't always the same. I'm thinking the states either weren't saving to disc or not reading from the disc. Upon further inspection I saw that all of the nodes had the "Saving Interval" in red. Adding a time didn't seem to fix anything. So, I deleted each one and then put it back with the same name. I'm now able to access data from history[0] and that data seems to match the corresponding "value" and "timestamp" information. One odd thing though, there sometimes is a difference in what data shows up based on a restart of node-red vs. a reboot of my raspberry pi.