freakent / node-red-contrib-sunevents

A node for node-red that generates events based on the position of the Sun at the appropriate time of day.
Apache License 2.0
15 stars 14 forks source link

latitude and longitude #1

Closed lightx closed 9 years ago

lightx commented 9 years ago

Would it be possible to add a feature where we can input a msg.latitude+longitude. I use owntracks and travel a bit. To have sunevents calculate based on where I am would be great.

freakent commented 9 years ago

The underlying sunevents module should handle this use case, but it would be quite a big change to the node-red node. What would be your trigger to start the node-red flow and how often would it fire?

lightx commented 9 years ago

You can take a look at this workflow to get a sense of it

http://flows.nodered.org/flow/ab31cd939f2e73503fb0

lightx commented 9 years ago

ohh and I just setup a context.global.location with my current latitude and longitude

freakent commented 9 years ago

owntracks looks cool but I use prowl instead of pushover in my own flows.

I don't think this node is what you are looking for. Each night at midnight it uses SunCalc to perform the calculations for the next 24 hours. Timers are used to emit the events at the appropriate time. If you moved the lat and long during that time you would have to recalculate the events for that day, cancel the existing events then re-create the timers for the day. If you are using a GPS to continually update your coordinates you would be continually creating timers unnecessarily.

Couldn't you just invoke SunCalc from your function node?

// Must install suncalc using npm before using it
var SunCalc = require('suncalc');

// get today's sunlight times for London
var times = SunCalc.getTimes(new Date(), 51.5, -0.1);

// format sunrise time from the Date object
var sunriseStr = times.sunrise.getHours() + ':' + times.sunrise.getMinutes();
freakent commented 9 years ago

Closing...

freakent commented 3 years ago

Hi, I have a new Beta version of this SunEvents node that I think addresses this issue. Want to test it?

freakent commented 3 years ago

To try the V3 Beta follow the link to this issue:

21 V3 Beta Testers

Thanks!