sun position - rdmtc/node-red-contrib-sun-position GitHub Wiki

The node calculates the current sun position on any input message. This node is compatible to node-red-contrib-blindcontroller.

sun-position-example

[{"id":"fc962ea1.197a3","type":"inject","z":"de4e9c38.0d942","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":120,"y":300,"wires":["56265aeb.99f034"](/rdmtc/node-red-contrib-sun-position/wiki/"56265aeb.99f034")},{"id":"a0d0e562.7ad1d8","type":"debug","z":"de4e9c38.0d942","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":570,"y":300,"wires":[]},{"id":"56265aeb.99f034","type":"sun-position","z":"de4e9c38.0d942","name":"","positionConfig":"2831ba70.55a636","rules":[{"valueLow":"10","valueLowType":"num","valueHigh":"100","valueHighType":"num"}],"onlyOnChange":"true","topic":"","outputs":2,"x":330,"y":300,"wires":["a0d0e562.7ad1d8","9cc2d51.4ac0828","28e91.9d63d16f6"],["e921e01a.a0fa3"](/rdmtc/node-red-contrib-sun-position/wiki/"a0d0e562.7ad1d8","9cc2d51.4ac0828","28e91.9d63d16f6"],["e921e01a.a0fa3")},{"id":"9cc2d51.4ac0828","type":"change","z":"de4e9c38.0d942","name":"azimuth","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.azimuth","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":340,"wires":["e866e950.a7f798"](/rdmtc/node-red-contrib-sun-position/wiki/"e866e950.a7f798")},{"id":"28e91.9d63d16f6","type":"change","z":"de4e9c38.0d942","name":"altitude","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.altitude","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":380,"wires":["5b085e1b.4ec8a"](/rdmtc/node-red-contrib-sun-position/wiki/"5b085e1b.4ec8a")},{"id":"e921e01a.a0fa3","type":"debug","z":"de4e9c38.0d942","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":550,"y":420,"wires":[]},{"id":"e866e950.a7f798","type":"debug","z":"de4e9c38.0d942","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":750,"y":340,"wires":[]},{"id":"5b085e1b.4ec8a","type":"debug","z":"de4e9c38.0d942","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":750,"y":380,"wires":[]},{"id":"2831ba70.55a636","type":"position-config","z":"","name":"Kap-Halbinsel","longitude":"-34.357051","latitude":"18.473782","angleType":"deg"}]

sun-position - Node settings

sun-position-settings

  • Position connects to the central configuration node, which contains the current position, but also handles internal shared functions
  • Topic defines the topic of the first output
  • position container here you can define multiple lower and upper limits for azimuth. If the calculated value of the azimuth is inside the defined limit the input message will send to the associated output.
  • Name name of the Node

sun-position - Node Input

The Input is for triggering the calculation. If limits are defined the input message will send to the output associated to the limit.

It is possible that the incoming message have properties msg.latitude and msg.longitude (or msg.lat and msg.lon) defined to override settings in configuration node. The configuration node still needs to be configured properly.

sun-position - Node Output

  • first output

    • msg.payload.azimuth the azimuth of the sun position relative to the given coordinates.
    • msg.payload.altitude the altitude/elevation of the sun position relative to the given coordinates.
    • msg.payload.times the sun times as object.
      • msg.payload.times.astronomicalDawn night ends (morning astronomical twilight starts)
      • msg.payload.times.amateurDawn amateur astronomical dawn (sun at 12° before sunrise)
      • msg.payload.times.nauticalDawn nautical dawn (morning nautical twilight starts)
      • msg.payload.times.blueHourDawnStart blue Hour start (time for special photography photos starts)
      • msg.payload.times.civilDawn dawn (morning nautical twilight ends, morning civil twilight starts)
      • msg.payload.times.blueHourDawnEnd blue Hour end (time for special photography photos starts)
      • msg.payload.times.sunrise sunrise (top edge of the sun appears on the horizon)
      • msg.payload.times.sunriseEnd sunrise ends (bottom edge of the sun touches the horizon)
      • msg.payload.times.goldenHourDawnEnd morning golden hour (soft light, best time for photography) ends
      • msg.payload.times.solarNoon solar noon (sun is in the highest position)
      • msg.payload.times.goldenHourDuskStart evening golden hour starts
      • msg.payload.times.sunsetStart sunset starts (bottom edge of the sun touches the horizon)
      • msg.payload.times.sunset sunset (sun disappears below the horizon, evening civil twilight starts)
      • msg.payload.times.blueHourDuskStart nautical dusk start (evening astronomical twilight starts)
      • msg.payload.times.civilDusk dusk (evening nautical twilight starts)
      • msg.payload.times.blueHourDuskEnd nautical dusk end (evening astronomical twilight starts)
      • msg.payload.times.amateurDusk amateur astronomical dusk (sun at 12° after sunrise)
      • msg.payload.times.astronomicalDusk night starts (dark enough for astronomical observations)
      • msg.payload.times.nadir nadir (darkest moment of the night, sun is in the lowest position)
    • msg.payload.pos array with a boolean of every defined limit of the azimuth, which is true if the azimuth is inside the limit.
    • msg.payload.posChanged boolean which is true if any of the defined limit of the azimuth has changed to the last calculation.
    • msg.payload.startTime if a start time is defined the start timestamp (inclusive of offset).
    • msg.payload.endTime if a end time is defined the end timestamp (inclusive of offset).
    • msg.payload.sunInSky if a start and an end time is defined a boolean value indicating whether it is currently considered daylight hours.
    • msg.payload.altitudePercent gives the altitude in percent between horizon (0%) and solar noon (100%) (will not calculated if sun position for a time is calculated which is not today or tomorrow).
  • second output to ... output if limits for azimuth are defined the incoming message will send to this output. It adds a msg.posChanged property of type boolean which is true if in the previous calculation no message was send to this output.