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

Setting Location based on GPS/Message #20

Closed nmbath closed 3 years ago

nmbath commented 3 years ago

Hello,

I am thinking of using this on board my yacht, as a result my location can change. Rather than having to modify the Lat/Long in the configuration, have you thought about being able to send the event a message to set its location. Another option might be to pick the location from a file or persistent storage?

freakent commented 3 years ago

Oh cool, actually I had thought of adding that to the node. Plus I found a GPS board in my drawer of bits earlier this week. What's the use case you are thinking of? It might be something I am interested for my boat.

Pics here if you are interested https://www.instagram.com/mr.martin.jarvis/

nmbath commented 3 years ago

My use case is simple. Being able to bring dusk, dawn, night, day status into my Node Red flows. I have just started playing with this, as Victron have added Node Red two their VenusOS capability and brings the ability to control various bits of Victron kit into Node Red. So being able to make energy decisions based on the sun events brings another angle to energy management.

My issue is as I head out blue water cruising is the ability too change teh location and therefore get the correct sun events, based on where I am without modifying the flow.

freakent commented 3 years ago

Now you are talking. I also have a Victron set up on board, but I have the Color Control GX which I am led to believe can not run the extended Venus OS that includes Node Red. I am tempted to upgrade to the newer Cerbox GX and separate screen but there are so many other projects that are higher up my list.

freakent commented 3 years ago

Can you send me a sample GPS lat long data structure you would get from your GPS source? Basically I am wondering what the input payload to the sunevents node would look like.

nmbath commented 3 years ago

You are correct the Color Control will not run the large image. That said you an always add the Victron Node into a Raspberry Pi that is onboard and still get the benefit. I believe that it can use either direct dBus calls (what happens in a large image install) or dBus over TCP to allow other Node Red devices to make use of it.

I am not sure how to get the GPS position into Node Red. My Cerbo does have a GPS attached to it and off course when all systems are on the NMEA2000 network and Signal K will now the position.

freakent commented 3 years ago

The other issue is that the sunevents node performs all it's calculations once a day so if you move position significantly your events might be slightly wrong by the end of the day, depending on how far you sailed of course. However, a hundred or so nautical miles is probably not going to make a huge amount of difference. But I am also considering a change to this node that will calculate for 2 days ahead to avoid missing the nadir event that others have asked for.

nmbath commented 3 years ago

Just done some searching....

https://flows.nodered.org/flow/97b27fd31dc142459fdf talks about a model for getting it from SignalK

There are lots of others. I might see if Victron could add it to their data output?

Regarding moving, I agree that a few hundred miles isn't a great deal of difference for energy management. If you work on 8 knots boat speed (that's high IMO), then for say a 14 hour daylight period in summer, you re going to be less than 100 miles out. Is there anything to say you cant trigger the calculation twice in a day?

For me the main one is not the passage, but getting somewhere new and updating to get the full benefit at the new location.

freakent commented 3 years ago

The underlying suncalc library that actually performs all the calculations calculates all the sun times for a 24 hour period. I just turn what it spits out into a set of timers. I would need a major rewrite to change this basic way of working.

nmbath commented 3 years ago

I think once a day would be fine, based on position at midnight.

Lets face it most live aboard and blue water cruisers probably spend 80-90% of their time fairly static at anchorages or within a similar time zone. It is just that move a few hundred or thousand miles and not have to re-program the node that I am trying to resolve.

nmbath commented 3 years ago

Hi,

Not sure if this will help. https://github.com/victronenergy/dbus_gps/blob/master/software/src/gps.c

This is the code that Victron uses to parse the GPS from the USB interface and insert it into the dBus.

nmbath commented 3 years ago

Hi again,

It would seem that Victron have already created a node that will output GPS....

image image

So Lat and Long are of type Number

freakent commented 3 years ago

Hi, I have a new Beta version of this SunEvents node that I think does what you asked for. Want to test it?

nmbath commented 3 years ago

Sure

nmbath commented 3 years ago

Do I clone this repository? How do I then load it into NodeRed?

freakent commented 3 years ago

To try the V3 Beta follow the link to this issue: https://github.com/freakent/node-red-contrib-sunevents/issues/21#issue-807990667 Thanks!

freakent commented 3 years ago

This requirement has been addressed in 3.0.0