Node-red-contrib-aggregator fires at wrong time

I'm using node-red-contrib-aggregator (v1.5.0) to calculate the daily average ad a temperature value.
Node-RED v1.2.1
It is installed in an IOCage jail (FreeBSD 11.3-RELEASE-p14)

I expected that it would fire at 0:00 to show the average value of the last day.
But it starts at 0:59:59 that is (almost) 1 hour to late.

I already verified the time zone if the IOCage jail which is correct:

root@NodeRed:~ # date
Wed Jan  6 13:09:31 CET 2021

I also added the timezone to settings.js as suggested on several places
process.env.TZ = 'Europe/Amsterdam';
just above module.exports = {

node-red-contrib-timerswitch does fire at the proper time so I'm kinda stuck now

Any help would be appreciated!

Just in case I just upgraded the IOCage to Freebsd 12.1-RELEASE
And also updated Node-RED to 1.2.7 as for some reason I assumed there would be an update notice if a new version came out and I therefor missed the later releases

As a test I set the aggregater at 2 hours.
If I understand it correctly it should fire every even hours (2:00, 4:00, 6:00, 8:00 etc)
But, during this test it didn't fire at 14:00 but on 14:59:58 so again an hour to late.

In my opinion it looks like it is using utc time instead of CET, could this be the case?
And if so, how can I resolve this?

Are the timestamps shown above events in the debug pane showing the correct local time?
What version of nodejs are you using (node -v)?

If you restart node-red without rebooting the server does it then fire at the right time?

[Edit] Have you changed the system time or zone since starting node-red?

The timestamps in the debug pane are correct.
Also the timestamps shown in the flows (nodes that show a time(date) that is) are correct.

As for the version
root@NodeRed:~ # pkg info | grep node
node10-10.22.1 V8 JavaScript for client and server
npm-node10-6.14.8 Node package manager
root@NodeRed:~ # node -v
v10.22.1

This isn't the latest, but the 10.x is still supported and the changelogs don't show any interesting fixes.
None the less after the manual start test i can update it to the latetst LTS release available in the freebsd package manager (14.13.0) if that could be interesting?

Never restarted node-red manually (auto start with server) so I'm testing that now, will update this post as soon as I have an answer.

The time zone settings have never been changed, the iocage jail was created with the proper time zone settings.

I would run a test here to see if I can replicate the problem, but, being in the UK I am now on UTC and haven't got a spare system I can setup with a different timezone.

Thanks for the assistance.

Though I think I might have found something that might be part of my issue.
I'm not sure yet as I still have to test it but am out of time for today.

The code of node-red-contrib-aggregator uses new Date().getTime()
This gives the time back as EPOCH which is as far as I know always UTC and the interpretor needs to convert it to something else if needed (for example to the correct time zone).
I haven't found anything in the code for aggregator to correct for the time zone, but i could've missed it.

Probably worth raising an issue against the node on its github page.

Looking briefly at the code I also can't see anything attempting to adjust the intervals to local time.

Created an issue for it.

Hopefully it is something that is wrong with the node and that they can fix it.

So far still no update on the issue I created on github.

So for now I changed to code myself to correct the timezone.
If they are going to follow up I will share it with them (or anybody else that wants it).

Would be great to read how you changed the code.

Did you do it 'properly' by forking the git repository and modifying it on your fork? If so then others can install it direct from your fork by using
npm install <your git id>/node-red-contrib-...

Yes, ofcourse I created a fork on github.
You can find it on the repository pull requests where i published my changes.

Or you can find it in my repository, i just created a public fork so you can access it directly in there.
AcEIoXx/node-red-contrib-aggregator

See my reply to Colin.

You should be able to get the changed version that way, or you can make the changes by yourself.

I suppose you mean https://github.com/jaggr2/node-red-contrib-aggregator/pull/16? Thanks!

He Hans,

Yes i do, but you can also just pull my fork. Whatever you prefer.

1 Like

Just to clarify, the modified version can be installed by going to your .node-red folder and running
npm install AcEIoXx/node-red-contrib-aggregator
then restart node-red.

If you ever want to revert to the standard one then
npm remove node-red-contrib-aggregator
npm install node-red-contrib-aggregator

Sorry, I wasn't intending to imply any criticism, that is why I put 'proper' in quotes. Often people make such changes by editing the file in node_modules. I had no way of knowing your experience level.

I took no offence, was in a hurry when I typed my reply and didn't meen to offend you.

everybody that wants to use my change..
It works, that's it, the code isn't as nice as I would want it, but I wanted it working will making as litle changes to the original code as possible.
The edit's could be made cleaner, but for me this works for now.

1 Like

No offence taken. I was concerned that I had offended you :slight_smile: