sunrise-sunset

n8n node to work with the Sunrise-Sunset API

Package Information

Released: 5/4/2025
Downloads: 1 weekly / 22 monthly
Latest Version: 0.1.2
Author: Your Name

Documentation

n8n-nodes-sunrise-sunset

This is an n8n community node that integrates with the Sunrise-Sunset API to trigger workflows based on sunrise, sunset, and twilight times for specific geographical locations.

The node fetches data every Sunday for the upcoming week and can be used to trigger workflows at specific times based on natural light events.

Installation

Follow these steps to install this community node:

  1. Go to Settings > Community Nodes
  2. Select Install
  3. Enter n8n-nodes-sunrise-sunset in the npm package name field
  4. Click Install

Alternatively, you can install via npm:

npm install n8n-nodes-sunrise-sunset

Node Configuration

Basic Configuration

  • Latitude: The latitude of the location in decimal degrees (e.g., 36.7201600).
  • Longitude: The longitude of the location in decimal degrees (e.g., -4.4203400).

Event Selection

  • Event Type: Choose between sunrise or sunset.
  • Time Event: Select the specific moment:
    • Actual Time: The actual sunrise or sunset time
    • Civil Twilight Begin: When civil twilight begins
    • Civil Twilight End: When civil twilight ends
    • Nautical Twilight Begin: When nautical twilight begins
    • Nautical Twilight End: When nautical twilight ends
    • Astronomical Twilight Begin: When astronomical twilight begins
    • Astronomical Twilight End: When astronomical twilight ends

Additional Options

  • Timezone: Specify a timezone (e.g., Europe/Madrid). If left empty, the system timezone will be used.

How It Works

  1. The node runs every Sunday at midnight to fetch data for the upcoming week.
  2. For each day, it requests data from the Sunrise-Sunset API based on your location settings.
  3. The node returns an array of objects containing the times for each day of the week.

Output Data

The node returns an array of objects (one for each day of the week) with the following properties:

{
  "date": "2023-05-21",
  "utcTime": "2023-05-21T05:05:35+00:00",
  "localTime": "2023-05-21T07:05:35+02:00",
  "event": "sunrise",
  "timeEvent": "actual",
  "timezone": "Europe/Madrid",
  "raw": {
    "results": {
      "sunrise": "2023-05-21T05:05:35+00:00",
      "sunset": "2023-05-21T19:22:59+00:00",
      "solar_noon": "2023-05-21T12:14:17+00:00",
      "day_length": 51444,
      "civil_twilight_begin": "2023-05-21T04:36:17+00:00",
      "civil_twilight_end": "2023-05-21T19:52:17+00:00",
      "nautical_twilight_begin": "2023-05-21T04:00:13+00:00",
      "nautical_twilight_end": "2023-05-21T20:28:21+00:00",
      "astronomical_twilight_begin": "2023-05-21T03:20:49+00:00",
      "astronomical_twilight_end": "2023-05-21T21:07:45+00:00"
    },
    "status": "OK",
    "tzid": "UTC"
  }
}

Use Cases

  • Automate smart home devices based on natural light events
  • Schedule outdoor activities around daylight hours
  • Send notifications at sunrise or sunset
  • Control lighting systems based on twilight times
  • Schedule agricultural operations based on natural light cycles

Resources

Discussion