This one has me stumped.
I have a flow to open/control blinds. Well the software part of it at this point.
Today I was doing a check to see what it was saying and I am seeing weird things on the screen.
The flow gets the azimuth an "AM/PM" indicator and a "Sunset" indicator.
If it is AM, and the azimuth is greater than a value, it partly opens the blinds.
If the azimuth is less than the value, it fully opens the blinds.
Then, when "SUNSET" occurs, it closes the blinds.
Yes, I haven't done the bit of code from Mid-night to sunrise, but......
Today I am looking at the output and the flow is saying FULLY OPEN blinds, yet when I look at the data, it is saying PARTLY OPEN blinds.
You can see on the function node it has a green dot saying PART OPEN, yet to the right, you can see message packets saying OPEN, and the colour is CYAN, not GREEN.
DISCLAIMER
Ok, I accept I have goofed with a bit of the code and the context.get( ) part.
I accept that, but even knowing that why is the flow/screen showing me this disparity with what is happening?
Code below.
And there is another thing which has me confused also.
Setting the "azimuth reference" value.
I have a few nodes.
An inject, a slider, a number entry, a function node and a debug node.
The inject injects the value I want at "startup" and the slider/number input allow me to adjust it (if that is ever needed) from a GUI perspective.
The debug is simply so I can see all that is going on from the edit window.
The function node does the flow.set( ) part.
While messing around and looking at the values initially, I saw the "reference azimuth" was wrong.
I clicked the inject node: NOTHING.
I added a node.warn( ) to the function node. Pressed the inject: NOTHING.
So putting aside the "partial deploy" vs "full deploy" problem that was told to me....
What is happening?
Code:
[{"id":"33cd2f07.ce1bb8","type":"comment","z":"81be69fa.79ac","name":"Sun, window and blind status.","info":"","x":1130,"y":440,"wires":[]},{"id":"27d40d15.06a34a","type":"ui_slider","z":"81be69fa.79ac","name":"","label":"Azimuth","group":"fa56eacf.d53b78","order":1,"width":"4","height":"1","passthru":true,"topic":"azimuth","min":"30","max":"70","step":"0.5","x":930,"y":200,"wires":[["4ac3b17.7ec8c5","4a1b6f7b.cf23c8","c5d15b80.5fd55"]]},{"id":"4ac3b17.7ec8c5","type":"function","z":"81be69fa.79ac","name":"","func":"node.warn(\"********************\");\nnode.warn(\"Azimuth set to \" + msg.payload);\nflow.set('azimuth',msg.payload);\nreturn msg;","outputs":1,"noerr":0,"x":1100,"y":200,"wires":[["fb7a2d2a.b3f838"]]},{"id":"4a1b6f7b.cf23c8","type":"ui_numeric","z":"81be69fa.79ac","name":"","label":"Value","group":"fa56eacf.d53b78","order":2,"width":"4","height":"1","passthru":false,"topic":"","format":"{{value}}","min":0,"max":"70","step":"0.5","x":1100,"y":240,"wires":[["27d40d15.06a34a"]]},{"id":"39b4c2c6.b164e6","type":"comment","z":"81be69fa.79ac","name":"Sun clear of blinds tweak","info":"","x":1030,"y":160,"wires":[]},{"id":"fb7a2d2a.b3f838","type":"debug","z":"81be69fa.79ac","name":"Sun angle","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":1260,"y":200,"wires":[]},{"id":"92bc331a.1932e","type":"sunpos","z":"81be69fa.79ac","name":"","lon":"151.12","lat":"-33.51","start":"sunrise","startoffset":0,"end":"sunset","endoffset":0,"x":240,"y":280,"wires":[["79d17999.a716b8","b10daeff.6ee2"]]},{"id":"79d17999.a716b8","type":"change","z":"81be69fa.79ac","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":410,"y":280,"wires":[["6b6d2eaa.a7dac","ec9f93c2.2bb3c8"]]},{"id":"6b6d2eaa.a7dac","type":"function","z":"81be69fa.79ac","name":"Check TOD (HS and HJ)","func":"var azimuth = flow.get('azimuth');\n//node.warn(\"Reference Azimuth is \" + azimuth);\nvar AmPm;\n\nif (msg.topic == \"DAYTIME\")\n{\n AmPm = msg.payload;\n context.set('daytime',msg.payload);\n //node.warn(AmPm);\n}\n\nvar AmPm = context.get('daytime') || \"pm\";\n\n// Check DAYTIME change.\n//if (msg.topic == \"DAYTIME\")\n\n// Needs work\n//if (msg.topic == \"sunset\")\n//{\n// context.set('daytime',msg.payload);\n//}\n// Morning.\nif (AmPm == \"am\")\n{\n //node.warn(\"***********\");\n if (msg.topic == \"azimuth\")\n {\n //node.warn(\"Incoming azimuth data is \" + msg.payload);\n if (msg.payload > azimuth)\n {\n msg = {payload: \"Open\", background: \"cyan\"};\n node.status({fill:\"green\",shape:\"dot\",text:\"Part Open\"});\n //return msg;\n } else\n if (msg.payload < azimuth)\n {\n msg = {payload: \"Open\", background: \"cyan\"};\n node.status({fill:\"blue\",shape:\"dot\",text:\"Open\"});\n //return msg;\n }\n return msg;\n }\n} else\n// Afternoon.\nif (AmPm == \"pm\")\n{\n if (msg.topic == \"sunset\")\n {\n //\n msg = {payload: \"Closed\",background: \"brown\"};\n node.status({fill:\"black\",shape:\"dot\",text:\"Closed\"});\n return msg;\n }\n}\n","outputs":1,"noerr":0,"x":650,"y":460,"wires":[["ed634442.cb3f8","8791d0c3.fa8e48"]]},{"id":"d03d361d.acd6e","type":"moment","z":"81be69fa.79ac","name":"HJ","topic":"","input":"","inputType":"msg","inTz":"Australia/Sydney","adjAmount":0,"adjType":"days","adjDir":"add","format":"H:mm","locale":"en_AU","output":"","outputType":"msg","outTz":"Australia/Sydney","x":670,"y":330,"wires":[["5a295eef.ec9f38","d5774f64.3f8e4"]]},{"id":"b10daeff.6ee2","type":"change","z":"81be69fa.79ac","name":"Get Sunset","rules":[{"t":"set","p":"payload","pt":"msg","to":"sunTimes.sunset","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"sunset","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":240,"y":330,"wires":[["d3f96cf0.d1587"]]},{"id":"d3f96cf0.d1587","type":"link out","z":"81be69fa.79ac","name":"TEMP_SUNSET","links":["bf6c9631.94d49"],"x":345,"y":330,"wires":[]},{"id":"bf6c9631.94d49","type":"link in","z":"81be69fa.79ac","name":"TEMP_SUNSET","links":["d3f96cf0.d1587"],"x":585,"y":330,"wires":[["d03d361d.acd6e"]]},{"id":"714d3120.dbf998","type":"link in","z":"81be69fa.79ac","name":"TEMP AMPM","links":["cf2e5765.272998"],"x":585,"y":370,"wires":[["6b6d2eaa.a7dac","b2d77988.b890d"]]},{"id":"cf2e5765.272998","type":"link out","z":"81be69fa.79ac","name":"TEMP AMPM","links":["714d3120.dbf998"],"x":345,"y":370,"wires":[]},{"id":"ec5b31a4.29ef08","type":"moment","z":"81be69fa.79ac","name":"AM/PM","topic":"DAYTIME","input":"","inputType":"msg","inTz":"Australia/Sydney","adjAmount":0,"adjType":"days","adjDir":"add","format":"a","locale":"en_AU","output":"","outputType":"msg","outTz":"Australia/Sydney","x":250,"y":370,"wires":[["cd147d17.d2bef","cf2e5765.272998"]]},{"id":"cd147d17.d2bef","type":"debug","z":"81be69fa.79ac","name":"TOD","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":260,"y":410,"wires":[]},{"id":"b2d77988.b890d","type":"debug","z":"81be69fa.79ac","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":810,"y":370,"wires":[]},{"id":"5a295eef.ec9f38","type":"debug","z":"81be69fa.79ac","name":"SunSet TIme","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":830,"y":330,"wires":[]},{"id":"62fe98cf.7d31e8","type":"comment","z":"81be69fa.79ac","name":"Sunset stuff","info":"","x":700,"y":290,"wires":[]},{"id":"bca3cf20.f6c75","type":"comment","z":"81be69fa.79ac","name":"Better","info":"","x":670,"y":510,"wires":[]},{"id":"f85f3152.9b9378","type":"comment","z":"81be69fa.79ac","name":"Blind control","info":"","x":870,"y":500,"wires":[]},{"id":"c876a625.00abf","type":"comment","z":"81be69fa.79ac","name":"Get Sun Azimuth","info":"","x":410,"y":200,"wires":[]},{"id":"b3897dce.11c488","type":"link in","z":"81be69fa.79ac","name":"TimePi Readings Enable","links":["c696427a.67dac8"],"x":135,"y":280,"wires":[["92bc331a.1932e","ec5b31a4.29ef08"]]},{"id":"ed634442.cb3f8","type":"debug","z":"81be69fa.79ac","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":850,"y":460,"wires":[]},{"id":"5f49b515.8c2b64","type":"inject","z":"81be69fa.79ac","name":"","topic":"","payload":"55","payloadType":"num","repeat":"","crontab":"","once":true,"onceDelay":"2","x":850,"y":160,"wires":[["27d40d15.06a34a"]]},{"id":"474d2056.f5a208","type":"inject","z":"81be69fa.79ac","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":180,"y":240,"wires":[["92bc331a.1932e"]]},{"id":"8791d0c3.fa8e48","type":"ui_button","z":"81be69fa.79ac","name":"","group":"e90f0218.708328","order":0,"width":0,"height":0,"passthru":false,"label":"{{msg.payload}}","color":"","bgcolor":"{{msg.background}}","icon":"","payload":"","payloadType":"str","topic":"","x":850,"y":540,"wires":[[]]},{"id":"d5774f64.3f8e4","type":"function","z":"81be69fa.79ac","name":"","func":"if (msg.payload = \"SUNSET\")\n{\n return msg;\n}","outputs":1,"noerr":0,"x":620,"y":420,"wires":[["6b6d2eaa.a7dac","22821419.cb4514"]]},{"id":"22821419.cb4514","type":"debug","z":"81be69fa.79ac","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":790,"y":420,"wires":[]},{"id":"ec9f93c2.2bb3c8","type":"debug","z":"81be69fa.79ac","name":"Azimuth","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":560,"y":250,"wires":[]},{"id":"c5d15b80.5fd55","type":"debug","z":"81be69fa.79ac","name":"Sun angle","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":1110,"y":290,"wires":[]},{"id":"fa56eacf.d53b78","type":"ui_group","z":"","name":"Sun Azimuth tweak","tab":"c4158e69.633b08","order":2,"disp":true,"width":"8","collapse":false},{"id":"e90f0218.708328","type":"ui_group","z":"","name":"Sun Window Blind status","tab":"961307de.db94a8","order":1,"disp":true,"width":"6","collapse":false},{"id":"c4158e69.633b08","type":"ui_tab","z":"","name":"Tweak","icon":"dashboard","order":9},{"id":"961307de.db94a8","type":"ui_tab","z":"","name":"Real World Control","icon":"dashboard","order":12}]