Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mohankumargupta/1f32cac022b8ccb80bb081ee1cf7e418 to your computer and use it in GitHub Desktop.
Save mohankumargupta/1f32cac022b8ccb80bb081ee1cf7e418 to your computer and use it in GitHub Desktop.
[
{
"id": "75b64b94.0fd5b4",
"type": "tab",
"label": "sunposition",
"disabled": false,
"info": ""
},
{
"id": "4bffb431.af3aac",
"type": "function",
"z": "75b64b94.0fd5b4",
"name": "",
"func": "var suncalc = global.get('suncalcModule')\nvar position = suncalc.getPosition(new Date(), msg.latitude, msg.longitude)\nvar azimuth = (180 * position.azimuth )/ Math.PI\nvar altitude = (180 * position.altitude) / Math.PI\nmsg.payload = {\n azimuth: azimuth + 180,\n altitude: altitude\n}\nreturn msg",
"outputs": 1,
"noerr": 0,
"x": 442.5,
"y": 95.39999389648438,
"wires": [
[
"8c3a54f0.0bf9b8"
]
]
},
{
"id": "8c3a54f0.0bf9b8",
"type": "debug",
"z": "75b64b94.0fd5b4",
"name": "",
"active": true,
"console": "false",
"complete": "false",
"x": 475.5,
"y": 205.59999084472656,
"wires": []
},
{
"id": "1fccb304.4e7695",
"type": "inject",
"z": "75b64b94.0fd5b4",
"name": "",
"topic": "",
"payload": "",
"payloadType": "date",
"repeat": "",
"crontab": "",
"once": false,
"x": 109.5,
"y": 116,
"wires": [
[
"27084bfd.dbe484"
]
]
},
{
"id": "81076cc7.cf43e8",
"type": "comment",
"z": "75b64b94.0fd5b4",
"name": "Calculate azimuth and elevation of sun",
"info": "Setup in NodeRed is complex:\n\n1. cd to ~/.node-red directory\n2. npm install suncalc\n3. edit ~/.node-red/settings.js with:\n functionGlobalContext: {\n suncalcModule:require('suncalc')\n }\n4. Then run this flow.",
"x": 250.49998474121094,
"y": 279.4000244140625,
"wires": []
},
{
"id": "27084bfd.dbe484",
"type": "change",
"z": "75b64b94.0fd5b4",
"name": "Set latitude and longitude",
"rules": [
{
"t": "set",
"p": "latitude",
"pt": "msg",
"to": "-37.9778",
"tot": "num"
},
{
"t": "set",
"p": "longitude",
"pt": "msg",
"to": "145.2598",
"tot": "num"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 279.5,
"y": 39.399993896484375,
"wires": [
[
"4bffb431.af3aac"
]
]
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment