Node-RED node-suncalc

raw JSON →
1.2.0 verified Sat May 09 auth: no javascript

A Node-RED node that triggers signals at sunrise and sunset using the suncalc library. Current version 1.2.0. It calculates times based on a specified location and provides configurable definitions of sunrise/sunset with minute offsets. Outputs day/night status every minute and emits transitions. Also supplies sun/moon position data. Differentiators: integrated into Node-RED ecosystem, simple setup, two outputs for continuous state and edge triggers.

error Error: Cannot find module 'suncalc'
cause Missing suncalc dependency; often because npm install was run in the wrong directory.
fix
Run 'npm install node-red-node-suncalc' from the Node-RED user directory (~/.node-red).
error Node not found in palette after install
cause Node-RED not restarted or palette not refreshed.
fix
Restart Node-RED or use the Manage Palette option to refresh.
breaking In version 1.0, msg.moon changed from a number to an object containing detailed moon data.
fix Update flows that rely on msg.moon being a number to access properties like msg.moon.illumination or msg.moon.phase.
gotcha The node only outputs once per minute; state changes may be delayed up to 60 seconds.
fix If you need sub-minute precision, consider using a different node or external cron.
gotcha Latitude and longitude must be in decimal degrees; using degrees/minutes/seconds will produce incorrect times.
fix Convert coordinates to decimal degrees (e.g., 40.7128, -74.0060).
npm install node-red-node-suncalc
yarn add node-red-node-suncalc
pnpm add node-red-node-suncalc

Install the node via Node-RED palette manager, then drag into workspace, configure latitude/longitude, and connect to debug.

// No code example for Node-RED flow - install the palette node and configure in editor.
// Typical flow: inject -> suncalc node -> debug
// Sets lat/lon in node config. Outputs msg.payload 1 (day) or 0 (night).