Sun position question

I have the SunPos Node, and BigTimer, but I don't think they can quite get what I want.

With SunPos, I can nearly get what I want, but for the fact that at mid-day the numbers start to rise again.

Situation:
I have an Easterly facing window with obstructions to the North. No big deal there.
At Sunrise, I open the blinds part way so the sun doesn't come directly into the room.

With the azimuth below 55 the sun no longer has direct light into the room, so I can open the blinds all the way.

Nice, but in the afternoon, the azimuth increases past 55 and the blinds close.

They don't need to close until SunSet.

How can I get around the afternoon azimuth triggering the false positive?

Could you not just wrap it in a time function/calculation (obviously adjust as appropriate in terms of the hours.

If hour < 12;

  • check for Azimuth and proceed if less than 55

Put that into a loop and check it every minute or so

Craig

1 Like

Yeah, I hadn't thought of that at the time of posting.

I am working on that now but also including "SunSet" time to close the blinds also.

It is annoying that simple things become complicated most of the times. (wink)

Yep exactly - sometimes just take a step back and think of an easy way to do it !

Once you have a handle on it all - maybe take a look at Peter Scargills big timer node - will handle the Sunset side of things easily

Craig

Thanks.

Yeah, that is handy as it sends a message at sunset time and I just need to capture that message (one off) to close the blinds.

Where as SunPos is nice in that it has the sun's azimuth which is needed to fully open the blinds.

This is the final flow that does what I want.

It may be handy for others if they want to do something similar.

[{"id":"f15f8bcd.7c043","type":"sunpos","z":"7c7f2d66.26e524","name":"","lon":"151.12","lat":"-33.51","start":"sunrise","startoffset":0,"end":"sunset","endoffset":0,"x":170,"y":330,"wires":[["5094f22d.d86584","76749b7e.a4e6dc"]]},{"id":"5094f22d.d86584","type":"change","z":"7c7f2d66.26e524","name":"Get Azimuth","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.azimuth","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"azimuth","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":330,"wires":[["385bf587.3b3742","cfaeae24.e073b"]]},{"id":"385bf587.3b3742","type":"function","z":"7c7f2d66.26e524","name":"Check TOD (HS and HJ)","func":"var azimuth = flow.get('azimuth');\n//node.warn(\"Reference Azimuth is \" + azimuth);\n//node.warn(\"Incoming message is \" + msg.payload);\n\n//  If it is sunrise open blinds to first stage.\n//if (msg.topic == \"sunrise\")\nif (msg.payload == \"RISE\")\n{\n\n\tmsg = {payload: \"Open\", background: \"green\", font: \"black\"};\n\tnode.status({fill:\"green\",shape:\"dot\",text:\"Part Open\"});\n}\n\n//  After a certain time (set by azimuth?) open blinds fully.\n//if (msg.payload < azimuth)\nif (msg.payload > azimuth)\n{\n\t//\n\tmsg = {payload: \"Open\", background: \"cyan\", font: \"black\"};\n\tnode.status({fill:\"blue\",shape:\"dot\",text:\"Open\"});\n}\n\n//  Sunset has occured.  Close blinds.\n//if (msg.topic == \"sunset\")\nif (msg.payload == \"SET\")\n{\n\t//\n\t//node.warn(\"Sunset detected\");\n\tmsg = {payload: \"Closed\",background: \"brown\", font: \"black\"};\n\tnode.status({fill:\"black\",shape:\"dot\",text:\"Closed\"});\n}\nreturn msg;\n","outputs":1,"noerr":0,"x":620,"y":330,"wires":[["371d3b9c.af9614","ef23ba5.7923bc8"]]},{"id":"588212e.866b16c","type":"comment","z":"7c7f2d66.26e524","name":"Sunrise/set stuff","info":"","x":700,"y":290,"wires":[]},{"id":"371d3b9c.af9614","type":"debug","z":"7c7f2d66.26e524","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":820,"y":330,"wires":[]},{"id":"c80fa815.5af6c","type":"inject","z":"7c7f2d66.26e524","name":"","topic":"","payload":"","payloadType":"date","repeat":"3","crontab":"","once":false,"onceDelay":0.1,"x":120,"y":290,"wires":[["f15f8bcd.7c043"]]},{"id":"ef23ba5.7923bc8","type":"ui_button","z":"7c7f2d66.26e524","name":"","group":"44285b5d.4ef84c","order":0,"width":0,"height":0,"passthru":false,"label":"{{msg.payload}}","color":"{{msg.font}}","bgcolor":"{{msg.background}}","icon":"","payload":"","payloadType":"str","topic":"","x":820,"y":370,"wires":[[]]},{"id":"cfaeae24.e073b","type":"debug","z":"7c7f2d66.26e524","name":"Azimuth","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":490,"y":290,"wires":[]},{"id":"76749b7e.a4e6dc","type":"function","z":"7c7f2d66.26e524","name":"Sun in sky detector","func":"var foo = msg.payload.sunInSky;\n//node.warn(\"From the message \" + foo);\n\nif (foo === true)\n{\n    //node.warn(\"Sun is in the sky\");\n    node.status({fill:\"yellow\",shape:\"dot\",text:\"Sun in sky\"});\n    msg = {payload: \"SUN\", topic:\"SUN\"};\n} else\nif (foo === false)\n{\n    //node.warn(\"Sun is not in the sky\");\n    node.status({fill:\"black\",shape:\"dot\",text:\"Sun not in sky\"});\n    msg = {payload: \"SET\", topic:\"SUN\"};\n\n}\nreturn msg;","outputs":1,"noerr":0,"x":320,"y":380,"wires":[["385bf587.3b3742"]]},{"id":"44285b5d.4ef84c","type":"ui_group","z":"","name":"Sun Window Blind status","tab":"86714871.654fd8","order":1,"disp":true,"width":"6","collapse":false},{"id":"86714871.654fd8","type":"ui_tab","z":"","name":"Real World Control","icon":"dashboard","order":12}]

Sorry folks,

I know it is bad form to post non-working flows, and that is what I just did.

I have too many computers and I got the NEARLY WORKING one posted.

This one does work.

[{"id":"c80fa815.5af6c","type":"inject","z":"7c7f2d66.26e524","name":"","topic":"","payload":"","payloadType":"date","repeat":"3","crontab":"","once":false,"onceDelay":0.1,"x":120,"y":290,"wires":[["f15f8bcd.7c043"]]},{"id":"f15f8bcd.7c043","type":"sunpos","z":"7c7f2d66.26e524","name":"","lon":"151.12","lat":"-33.51","start":"sunrise","startoffset":0,"end":"sunset","endoffset":0,"x":170,"y":330,"wires":[["5094f22d.d86584","76749b7e.a4e6dc","aaecda23.6d2a3"]]},{"id":"5094f22d.d86584","type":"change","z":"7c7f2d66.26e524","name":"Get Azimuth","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.azimuth","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"azimuth","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":330,"wires":[["385bf587.3b3742","cfaeae24.e073b"]]},{"id":"76749b7e.a4e6dc","type":"function","z":"7c7f2d66.26e524","name":"Sun in sky detector","func":"var foo = msg.payload.sunInSky;\n//node.warn(\"From the message \" + foo);\n\nif (foo === true)\n{\n    //node.warn(\"Sun is in the sky\");\n    node.status({fill:\"yellow\",shape:\"dot\",text:\"Sun in sky\"});\n    msg = {payload: \"SUN\", topic:\"SUN\"};\n} else\nif (foo === false)\n{\n    //node.warn(\"Sun is not in the sky\");\n    node.status({fill:\"black\",shape:\"dot\",text:\"Sun not in sky\"});\n    msg = {payload: \"SET\", topic:\"SUN\"};\n\n}\nreturn msg;","outputs":1,"noerr":0,"x":320,"y":380,"wires":[["385bf587.3b3742"]]},{"id":"aaecda23.6d2a3","type":"debug","z":"7c7f2d66.26e524","name":"Suntime","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":330,"y":290,"wires":[]},{"id":"385bf587.3b3742","type":"function","z":"7c7f2d66.26e524","name":"Check TOD (HS and HJ)","func":"var azimuth = flow.get('azimuth');\n//node.warn(\"Reference Azimuth is \" + azimuth);\n//node.warn(\"Incoming message is \" + msg.payload);\n\n//  If it is sunrise open blinds to first stage.\n//if (msg.topic == \"SUN\")\nif (msg.topic !== \"azimuth\")\n{\n    if (msg.payload == \"SUN\")\n    {\n        //node.warn(\"Sunrise detected\");\n    \tmsg = {payload: \"Partly Open\", background: \"green\", font: \"black\"};\n    \tnode.status({fill:\"green\",shape:\"dot\",text:\"Part Open\"});\n    }\n    \n    //  After a certain time (set by azimuth?) open blinds fully.\n    //if (msg.payload < azimuth)\n    if (msg.payload < azimuth)\n    {\n    \t//node.warn(\"Blinds fully open\");\n    \tmsg = {payload: \"Open\", background: \"cyan\", font: \"black\"};\n    \tnode.status({fill:\"blue\",shape:\"dot\",text:\"Open\"});\n    }\n    \n    //  Sunset has occured.  Close blinds.\n    //if (msg.topic == \"sunset\")\n    if (msg.payload == \"SET\")\n    {\n    \t//\n    \t//node.warn(\"Sunset detected\");\n    \tmsg = {payload: \"Closed\",background: \"brown\", font: \"black\"};\n    \tnode.status({fill:\"black\",shape:\"dot\",text:\"Closed\"});\n    }\n    return msg;\n}","outputs":1,"noerr":0,"x":620,"y":330,"wires":[["371d3b9c.af9614","ef23ba5.7923bc8"]]},{"id":"cfaeae24.e073b","type":"debug","z":"7c7f2d66.26e524","name":"Azimuth","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":490,"y":290,"wires":[]},{"id":"371d3b9c.af9614","type":"debug","z":"7c7f2d66.26e524","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":820,"y":330,"wires":[]},{"id":"ef23ba5.7923bc8","type":"ui_button","z":"7c7f2d66.26e524","name":"","group":"44285b5d.4ef84c","order":0,"width":0,"height":0,"passthru":false,"label":"{{msg.payload}}","color":"{{msg.font}}","bgcolor":"{{msg.background}}","icon":"","payload":"","payloadType":"str","topic":"","x":820,"y":370,"wires":[[]]},{"id":"44285b5d.4ef84c","type":"ui_group","z":"","name":"Sun Window Blind status","tab":"86714871.654fd8","order":1,"disp":true,"width":"6","collapse":false},{"id":"86714871.654fd8","type":"ui_tab","z":"","name":"Real World Control","icon":"dashboard","order":12}]