A plugin for Seneca
This plugin will expose actions to calculate the position of the sun or moon.
Since Seneca and this service are built on top of Node.js you will need to have it installed. To install run the following commands:
npm install seneca
npm install seneca-suncalculator
Make sure you have already done the install steps to get the seneca and seneca-suncalculator modules in your working folder.
var seneca = require('seneca')();
seneca.use('suncalculator');
// Uses today's date for the calcuation
seneca.act({role: 'suncalculator', cmd: 'calc', lat: 35.227085, long: -80.843124}, console.log);
// Uses a passed in date for the calcuation
seneca.act({role: 'suncalculator', cmd: 'calc', lat: 35.227085, long: -80.843124, date: new Date('Wed Mar 23 2017 22:40:23 GMT-0400 (Eastern Daylight Time)')}, console.log)
Calculates the sun and moon details for a specified date, lat, long.
- lat: the latitude for the calculation
- long: the longitude for the calculation
- date: the date for the calculation. If this is omitted then the current date is used.
Returns an answer object with times as a result of the calculation.
Calculates the sun and moon details for a specified date, lat, long and numberOfDays.
- lat: the latitude for the calculation
- long: the longitude for the calculation
- date: the date for the calculation. If this is omitted then the current date is used.
- numberOfDays: the number of days to calculate the times for starting with the date as the first day.
Returns an answer object with an array of times as a result of the calculation.
Calculates the sun and moon details for a specified date, time, lat and long. Uses this date & time to return a value that indicates if a specific event is currently occuring.
- lat: the latitude for the calculation
- long: the longitude for the calculation
- date: the date for the calculation. If this is omitted then the current date is used.
- offset: optional parameter to add an offset in minutes (+ or -) to the check so that you can delay the eventcheck trigger.
Returns an answer of the following: none, sunrise, sunset, dawn, dusk, night, sunriseEnd, sunsetStart, nightEnd, or solarNoon.
These are a few items I think this module could use to make it more useful. I don't have any plans on when the following will be done or in what order.
- Allow for the lat and long be set as an options
- Add support for more suncalc actions