node-red / node-red/node-red-nodes

node-red timeswitch sunrise in UTC despite TZ

Open
#906 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
1.1k
Forks
612
Avg merge
13h 57m
Merged PRs (30d)
3

Description

Which node are you reporting an issue on?

timeswitch

What are the steps to reproduce?

Configure a timeswitch node leaving the Time On as the default 'Sunrise' where I live and deploy (I know this must my local issue but...)

What happens?

The node says "off until time", where `time' seems to be Zulu time for sunrise but is instead in my timezone (UTC-4).

What do you expect to happen?

The node should be on since time -4 hours.

Please tell us about your environment:

node-red-docker@2.2.2

  • Node-RED version: v2.2.2
  • node.js version: v14.18.2
  • npm version: 6.14.15
  • Platform/OS: Linux 5.15.0-27-generic x64 LE (docker/docker-compose running on Ubuntu 22.04)
  • Browser: Firefox 99.01

As suggested in #640 I pass the TZ variable in the docker-compose.yaml file, and I can echo $TZ inside the container with the correct result of America/Guyana. https://github.com/node-red/node-red-nodes/issues/177#issuecomment-185309456 suggests there's a way to make node-red print what it thinks Dawn/Dusk are, but I've set logging to "debug" in settings.js and still don't see it.

I think this screenshot captures my issue:

Screenshot 2022-04-29 at 09 10 13

  • On the left, the top timeswitch node says off until 09:40. The Properties panel is shown for this node is displayed in the center panel with On Sunrise, my correct timezone, Lat/Lon, and no Offsets.
  • On the left again, the second timeswitch node shows on until 09:15. This is configured to be on at 09:00, off at 09:15. The Debug output panel on the right shows the output for this node at 09:08:13 (2nd entry) with a payload of 1, indicating that timeswitch knows what time it is here and is working with it.
  • On the left again, the Sun rise/set node is from suncalc. According to my reading of the documentation, this node and timeswitch both use the npm suncalc module. The Debug panel on the right shows the output of this node at 09:08:12 localtime (1st entry) with 'start' as 09:40:00.000Z indicating sunrise at 09:40 UTC, which is 05:40 localtime. The payload is 1 and the node shows day at the bottom.

So, I think the first timeswitch node should be On since 05:40 localtime, but timeswitch isn't correcting the suncalc reported value for my timezone..

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the timeswitch node and compare how it interprets Sunrise values from the npm suncalc module with the behavior of the Sun rise/set node. Reproduce the issue using the provided America/Guyana timezone, coordinates, and Docker setup, then verify that Sunrise and the status message use local time consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.