Closed ROSTOCHE closed 2 years ago
Interesting. I will. take a look over the code to ensure values are being written as they should.
Can I ask what are you trying to achieve by writing the values to a file? It maybe simpler to use the Suncalc library directly to give you what you need.
Below is what I do to keep a history in the file.
[{"id":"44baac90.80f2f4","type":"sun events","z":"ce465749.b19e08","testmode":false,"verbose":"N","topic":"","name":"","x":210,"y":130,"wires":[["172a9c8f.5c35c3","cf144fac.9b785"]]},{"id":"14a9a83b.60d198","type":"signalk-subscribe","z":"ce465749.b19e08","name":"Position","mode":"sendChanges","flatten":true,"context":"vessels.self","path":"navigation.position","source":"","period":1000,"x":60,"y":140,"wires":[["44baac90.80f2f4"]]},{"id":"cf144fac.9b785","type":"switch","z":"ce465749.b19e08","name":"Sunevent","property":"sunevent","propertyType":"msg","rules":[{"t":"nnull"}],"checkall":"true","repair":false,"outputs":1,"x":370,"y":130,"wires":[["182715f0.ea9aaa"]]},{"id":"182715f0.ea9aaa","type":"file","z":"ce465749.b19e08","name":"SunEvents","filename":"/home/pi/Marine/SunEvents","appendNewline":true,"createDir":false,"overwriteFile":"false","encoding":"none","x":530,"y":130,"wires":[[]]}]
Have you had a look at SunCalc library ? You can call it with any date and will give you the list of events. Using this Sunevents node to just store a number of values doesn’t seem quite the right solution.
Regards, Martin
On 3 May 2021, at 11:37, ROSTOCHE @.***> wrote:
Below is what I do to keep a history in the file.
[{"id":"44baac90.80f2f4","type":"sun events","z":"ce465749.b19e08","testmode":false,"verbose":"N","topic":"","name":"","x":210,"y":130,"wires":[["172a9c8f.5c35c3","cf144fac.9b785"]]},{"id":"14a9a83b.60d198","type":"signalk-subscribe","z":"ce465749.b19e08","name":"Position","mode":"sendChanges","flatten":true,"context":"vessels.self","path":"navigation.position","source":"","period":1000,"x":60,"y":140,"wires":[["44baac90.80f2f4"]]},{"id":"cf144fac.9b785","type":"switch","z":"ce465749.b19e08","name":"Sunevent","property":"sunevent","propertyType":"msg","rules":[{"t":"nnull"}],"checkall":"true","repair":false,"outputs":1,"x":370,"y":130,"wires":[["182715f0.ea9aaa"]]},{"id":"182715f0.ea9aaa","type":"file","z":"ce465749.b19e08","name":"SunEvents","filename":"/home/pi/Marine/SunEvents","appendNewline":true,"createDir":false,"overwriteFile":"false","encoding":"none","x":530,"y":130,"wires":[[]]}]
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.
[ { @.": "http://schema.org", @.": "EmailMessage", "potentialAction": { @.": "ViewAction", "target": "https://github.com/freakent/node-red-contrib-sunevents/issues/27#issuecomment-831175634", "url": "https://github.com/freakent/node-red-contrib-sunevents/issues/27#issuecomment-831175634", "name": "View Issue" }, "description": "View this Issue on GitHub", "publisher": { @.": "Organization", "name": "GitHub", "url": "https://github.com" } } ]
I'll give the SunCalc library a try and see what I get in my file.
I will put my information here.
Thank you
See the example using a function node I gave in https://github.com/freakent/node-red-contrib-sunevents/issues/28#issuecomment-877872960
After using the sun event node (V3) I use a function which checks that the msg.sunevent payload is not empty then injects the information into a file through a file_in node. On reading my file, I see that I did not have the date and time of the event as indicated in the documentation, as well as the name of the event. I find the longitude and latitude for which the calculations are made and the name of the event. Is it the new version that wants this?