How to stop automation from runnung if the parameter was changed manually in HomeAssistant UI?

Good evening!

I have roller blinds with tuned automation to open/partially close depending on sun azimuth/elevation, cloud coverage etc.

However, I sometimes want to manually open/close the particular blind by setting the percentage using the slider in UI.

Is there any way to determine that position was set manually (and pause automation for like 2 hours) without adding any separate switches/flags into UI as it would be very inconvenient.

In short, I want Node red to know that the position was set manually via slider in UI (the rest is easy to do).

Just a brief idea is to make a logical slider not directly connected to roller and used as an indication of manual input, BUT in this case the question is 1) how to make it 2) how to make it to reflect the actual position of the roller set by automation 3) how to distinguish whether the difference between its valua and actual position of the roller was caused by manual input and not the automation changing the roller position right now. There should be more elegant solution…

Please help! Thanks in advance

Here’s the flow I have now…

[{"id":"eebabdea17bf9ae3","type":"tab","label":"Rollers","disabled":false,"info":"","env":[]},{"id":"26575e9e67e1e518","type":"inject","z":"eebabdea17bf9ae3","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"1800","crontab":"","once":true,"onceDelay":"0.5","topic":"","payload":"","payloadType":"date","x":170,"y":120,"wires":[["3c80c9fd97bc5c85"]]},{"id":"3c80c9fd97bc5c85","type":"function","z":"eebabdea17bf9ae3","name":"","func":"flow.set(\"hall1\", 180);\nflow.set(\"hall2\", 225);\nflow.set(\"hall3\", 260);\nflow.set(\"hall4\", 275);\nflow.set(\"hall5\", 330);\nreturn msg;","outputs":1,"noerr":0,"initialize":"// Добавленный здесь код будет исполняться\n// однократно при развертывании узла.\nif (flow.get(\"hall1\") === undefined) {\n    flow.set(\"hall1\", 0);\n}\nif (flow.get(\"hall2\") === undefined) {\n    flow.set(\"hall3\", 0);\n}\nif (flow.get(\"hall3\") === undefined) {\n    flow.set(\"hall3\", 0);\n}\nif (flow.get(\"hall4\") === undefined) {\n    flow.set(\"hall4\", 0);\n}\nif (flow.get(\"hall5\") === undefined) {\n    flow.set(\"hall5\", 0);\n}\nif (flow.get(\"clouds\") === undefined) {\n    flow.set(\"clouds\", 0);\n}\nif (flow.get(\"lightness\") === undefined) {\n    flow.set(\"lightness\", 0);\n}\nif (flow.get(\"elevation\") === undefined) {\n    flow.set(\"elevation\", 0);\n}\nif (flow.get(\"movement\") === undefined) {\n    flow.set(\"movement\", 0);\n}","finalize":"","libs":[],"x":420,"y":120,"wires":[[]]},{"id":"7bc5e56f7c372fe8","type":"comment","z":"eebabdea17bf9ae3","name":"azimuth ranges and variables","info":"245 - закрываем center, left 50%","x":200,"y":60,"wires":[]},{"id":"7157213a4121eaaf","type":"time-range-switch","z":"eebabdea17bf9ae3","name":"","lat":"55.897368","lon":"37.464647","startTime":"07:30","endTime":"22:30","startOffset":0,"endOffset":0,"x":630,"y":300,"wires":[["f7fc78e9fd5f47c9","f84e62410783498c"],[]]},{"id":"375d1f43bbb676a4","type":"inject","z":"eebabdea17bf9ae3","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"900","crontab":"","once":true,"onceDelay":"1","topic":"","payload":"","payloadType":"date","x":170,"y":300,"wires":[["fc6952d4759b40a4","82849d31dfbbc320"]]},{"id":"f7fc78e9fd5f47c9","type":"api-current-state","z":"eebabdea17bf9ae3","name":"","server":"9db60f84.2719c","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"weather.sweethome_2","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":910,"y":300,"wires":[["3699a5fdd69ee135"]]},{"id":"026236af82e0e144","type":"delay","z":"eebabdea17bf9ae3","name":"wait for 45 minutes","pauseType":"delay","timeout":"45","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":1250,"y":300,"wires":[["7bd4e601b327b78c"]]},{"id":"3699a5fdd69ee135","type":"switch","z":"eebabdea17bf9ae3","name":"Cloudy?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"sunny","vt":"str"},{"t":"eq","v":"mostlysunny","vt":"str"},{"t":"eq","v":"partlysunny","vt":"str"},{"t":"eq","v":"partlycloudy","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":5,"x":980,"y":220,"wires":[["93e11aebea9ddf80"],["93e11aebea9ddf80"],["93e11aebea9ddf80"],["93e11aebea9ddf80"],["026236af82e0e144"]]},{"id":"7bd4e601b327b78c","type":"api-current-state","z":"eebabdea17bf9ae3","name":"","server":"9db60f84.2719c","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"weather.sweethome","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1580,"y":300,"wires":[["c2b1ad96ae5e74de"]]},{"id":"c2b1ad96ae5e74de","type":"switch","z":"eebabdea17bf9ae3","name":"Still?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"sunny","vt":"str"},{"t":"eq","v":"mostlysunny","vt":"str"},{"t":"eq","v":"partlysunny","vt":"str"},{"t":"eq","v":"partlycloudy","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":5,"x":1850,"y":300,"wires":[[],[],[],[],["9309af21caa9c984"]]},{"id":"9309af21caa9c984","type":"function","z":"eebabdea17bf9ae3","name":"Cloudy!","func":"flow.set(\"clouds\", 1);\nreturn msg;","outputs":1,"noerr":0,"initialize":"// Добавленный здесь код будет исполняться\n// однократно при развертывании узла.\nif (flow.get(\"hall1\") === undefined) {\n    flow.set(\"hall1\", 0);\n}\nif (flow.get(\"hall2\") === undefined) {\n    flow.set(\"hall3\", 0);\n}\nif (flow.get(\"hall3\") === undefined) {\n    flow.set(\"hall3\", 0);\n}\nif (flow.get(\"hall4\") === undefined) {\n    flow.set(\"hall4\", 0);\n}\nif (flow.get(\"hall5\") === undefined) {\n    flow.set(\"hall5\", 0);\n}","finalize":"","libs":[],"x":2080,"y":300,"wires":[[]]},{"id":"93e11aebea9ddf80","type":"delay","z":"eebabdea17bf9ae3","name":"wait for 45 minutes","pauseType":"delay","timeout":"45","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":1250,"y":220,"wires":[["6153d77bfc386b96"]]},{"id":"6153d77bfc386b96","type":"api-current-state","z":"eebabdea17bf9ae3","name":"","server":"9db60f84.2719c","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"weather.sweethome","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1580,"y":220,"wires":[["08e5a8d2edd45e7c"]]},{"id":"08e5a8d2edd45e7c","type":"switch","z":"eebabdea17bf9ae3","name":"Still?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"sunny","vt":"str"},{"t":"eq","v":"mostlysunny","vt":"str"},{"t":"eq","v":"partlysunny","vt":"str"},{"t":"eq","v":"partlycloudy","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":5,"x":1850,"y":220,"wires":[["0709715327f0f007"],["0709715327f0f007"],["0709715327f0f007"],["0709715327f0f007"],[]]},{"id":"0709715327f0f007","type":"function","z":"eebabdea17bf9ae3","name":"Not cloudy!","func":"flow.set(\"clouds\", 0);\nreturn msg;","outputs":1,"noerr":0,"initialize":"// Добавленный здесь код будет исполняться\n// однократно при развертывании узла.\nif (flow.get(\"hall1\") === undefined) {\n    flow.set(\"hall1\", 0);\n}\nif (flow.get(\"hall2\") === undefined) {\n    flow.set(\"hall3\", 0);\n}\nif (flow.get(\"hall3\") === undefined) {\n    flow.set(\"hall3\", 0);\n}\nif (flow.get(\"hall4\") === undefined) {\n    flow.set(\"hall4\", 0);\n}\nif (flow.get(\"hall5\") === undefined) {\n    flow.set(\"hall5\", 0);\n}","finalize":"","libs":[],"x":2090,"y":220,"wires":[[]]},{"id":"a40829c734341660","type":"comment","z":"eebabdea17bf9ae3","name":"Clouds or not?","info":"Clouds or not","x":160,"y":200,"wires":[]},{"id":"ba9ddb7fe845a3cf","type":"comment","z":"eebabdea17bf9ae3","name":"is it really bright?","info":"Clouds or not","x":160,"y":480,"wires":[]},{"id":"6a8cc6d3100774e4","type":"function","z":"eebabdea17bf9ae3","name":"It's Bright","func":"flow.set(\"lightness\", 1);\nreturn msg;","outputs":1,"noerr":0,"initialize":"// Добавленный здесь код будет исполняться\n// однократно при развертывании узла.\nif (flow.get(\"hall1\") === undefined) {\n    flow.set(\"hall1\", 0);\n}\nif (flow.get(\"hall2\") === undefined) {\n    flow.set(\"hall3\", 0);\n}\nif (flow.get(\"hall3\") === undefined) {\n    flow.set(\"hall3\", 0);\n}\nif (flow.get(\"hall4\") === undefined) {\n    flow.set(\"hall4\", 0);\n}\nif (flow.get(\"hall5\") === undefined) {\n    flow.set(\"hall5\", 0);\n}","finalize":"","libs":[],"x":1160,"y":580,"wires":[["e98780198c80b7b9"]]},{"id":"f84e62410783498c","type":"api-current-state","z":"eebabdea17bf9ae3","name":"Bedroom > 4000","server":"9db60f84.2719c","version":3,"outputs":2,"halt_if":"4000","halt_if_type":"num","halt_if_compare":"gt","entity_id":"sensor.bedroom_lightness","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":850,"y":580,"wires":[["6a8cc6d3100774e4"],[]]},{"id":"e98780198c80b7b9","type":"stoptimer","z":"eebabdea17bf9ae3","duration":"30","units":"Minute","payloadtype":"num","payloadval":"0","name":"Stoptimer for 30 minutes","x":1450,"y":580,"wires":[["2e9f0961fedc82ef"],[]]},{"id":"2e9f0961fedc82ef","type":"function","z":"eebabdea17bf9ae3","name":"Not anymore","func":"flow.set(\"lightness\", 0);\nreturn msg;","outputs":1,"noerr":0,"initialize":"// Добавленный здесь код будет исполняться\n// однократно при развертывании узла.\nif (flow.get(\"hall1\") === undefined) {\n    flow.set(\"hall1\", 0);\n}\nif (flow.get(\"hall2\") === undefined) {\n    flow.set(\"hall3\", 0);\n}\nif (flow.get(\"hall3\") === undefined) {\n    flow.set(\"hall3\", 0);\n}\nif (flow.get(\"hall4\") === undefined) {\n    flow.set(\"hall4\", 0);\n}\nif (flow.get(\"hall5\") === undefined) {\n    flow.set(\"hall5\", 0);\n}","finalize":"","libs":[],"x":1690,"y":580,"wires":[[]]},{"id":"019744cab4f1148a","type":"comment","z":"eebabdea17bf9ae3","name":"is the sun up?","info":"Clouds or not","x":150,"y":700,"wires":[]},{"id":"fc6952d4759b40a4","type":"api-current-state","z":"eebabdea17bf9ae3","name":"","server":"9db60f84.2719c","version":3,"outputs":2,"halt_if":"above_horizon","halt_if_type":"str","halt_if_compare":"is","entity_id":"sun.sun","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":420,"y":300,"wires":[["7157213a4121eaaf","12b1e2cb52eba8b0"],[]]},{"id":"520f59c5bdd00432","type":"change","z":"eebabdea17bf9ae3","name":"Sun is high enough","rules":[{"t":"set","p":"elevation","pt":"flow","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":890,"y":760,"wires":[[]]},{"id":"12b1e2cb52eba8b0","type":"switch","z":"eebabdea17bf9ae3","name":"Elevation > 10deg","property":"data.attributes.elevation","propertyType":"msg","rules":[{"t":"gt","v":"10","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":610,"y":780,"wires":[["520f59c5bdd00432"],["58987404832c6285"]]},{"id":"58987404832c6285","type":"change","z":"eebabdea17bf9ae3","name":"Sun is low enough","rules":[{"t":"set","p":"elevation","pt":"flow","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":890,"y":800,"wires":[[]]},{"id":"5e0a72b37afe2551","type":"comment","z":"eebabdea17bf9ae3","name":"Should we close blinds on schedule?","info":"Clouds or not","x":220,"y":960,"wires":[]},{"id":"82849d31dfbbc320","type":"time-range-switch","z":"eebabdea17bf9ae3","name":"","lat":"55.897368","lon":"37.464647","startTime":"05:30","endTime":"23:30","startOffset":0,"endOffset":0,"x":390,"y":1040,"wires":[["9577b4dc05585d02"],["5a1fe6e401547958"]]},{"id":"9577b4dc05585d02","type":"switch","z":"eebabdea17bf9ae3","name":"Elevated?","property":"elevation","propertyType":"flow","rules":[{"t":"eq","v":"1","vt":"str"},{"t":"eq","v":"0","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":580,"y":1040,"wires":[["73b49eda856c2cdb","744996fa0d59d469"],["5a1fe6e401547958"]]},{"id":"73b49eda856c2cdb","type":"switch","z":"eebabdea17bf9ae3","name":"Bright?","property":"lightness","propertyType":"flow","rules":[{"t":"eq","v":"1","vt":"str"},{"t":"eq","v":"0","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":780,"y":1020,"wires":[["0f253ac07b1b089e"],["49bedd1996d67289"]]},{"id":"c9ec0e0c398a1870","type":"sunrise","z":"eebabdea17bf9ae3","name":"","lat":"55.897368","lon":"37.464647","start":"dawn","end":"goldenHour","soff":0,"eoff":0,"x":110,"y":1860,"wires":[[],["31ca9fdbb1f2eb21"]]},{"id":"744996fa0d59d469","type":"switch","z":"eebabdea17bf9ae3","name":"No clouds?","property":"clouds","propertyType":"flow","rules":[{"t":"eq","v":"0","vt":"str"},{"t":"eq","v":"1","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":790,"y":1060,"wires":[["0f253ac07b1b089e"],["758a65b2824c9380"]]},{"id":"5a1fe6e401547958","type":"change","z":"eebabdea17bf9ae3","name":"Dont move!","rules":[{"t":"set","p":"movement","pt":"flow","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":990,"y":1260,"wires":[[]]},{"id":"0f253ac07b1b089e","type":"change","z":"eebabdea17bf9ae3","name":"Lets move!","rules":[{"t":"set","p":"movement","pt":"flow","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":1430,"y":1020,"wires":[[]]},{"id":"31ca9fdbb1f2eb21","type":"debug","z":"eebabdea17bf9ae3","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":350,"y":1860,"wires":[]},{"id":"758a65b2824c9380","type":"change","z":"eebabdea17bf9ae3","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"path_1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":980,"y":1140,"wires":[["94fdb5ea666442d4"]]},{"id":"94fdb5ea666442d4","type":"join-wait","z":"eebabdea17bf9ae3","name":"","paths":"[\"path_1\", \"path_2\"]","pathsToExpire":"","useRegex":false,"warnUnmatched":true,"pathTopic":"topic","pathTopicType":"msg","correlationTopic":"","correlationTopicType":"undefined","timeout":"10","timeoutUnits":"1000","exactOrder":"false","firstMsg":"true","mapPayload":"false","disableComplete":false,"persistOnRestart":false,"x":1260,"y":1160,"wires":[["5a1fe6e401547958"],[]]},{"id":"49bedd1996d67289","type":"change","z":"eebabdea17bf9ae3","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"path_1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":980,"y":1180,"wires":[["94fdb5ea666442d4"]]},{"id":"485e24a5b24e1217","type":"comment","z":"eebabdea17bf9ae3","name":"Actual roller movement","info":"Clouds or not","x":140,"y":1540,"wires":[]},{"id":"cf44f6e406f4875b","type":"inject","z":"eebabdea17bf9ae3","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"900","crontab":"","once":true,"onceDelay":"1","topic":"","payload":"","payloadType":"date","x":130,"y":1600,"wires":[["1160308127fd84d2"]]},{"id":"9609f205263d5cd7","type":"api-current-state","z":"eebabdea17bf9ae3","name":"","server":"9db60f84.2719c","version":3,"outputs":2,"halt_if":"above_horizon","halt_if_type":"str","halt_if_compare":"is","entity_id":"sun.sun","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":880,"y":1600,"wires":[["bf45362fb265c76a"],[]]},{"id":"2307f4aa4bd23a56","type":"switch","z":"eebabdea17bf9ae3","name":"Should we close?","property":"movement","propertyType":"flow","rules":[{"t":"eq","v":"1","vt":"str"},{"t":"eq","v":"0","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":590,"y":1600,"wires":[["9609f205263d5cd7"],["f0401bafb3771e33"]]},{"id":"1160308127fd84d2","type":"change","z":"eebabdea17bf9ae3","name":"movement?","rules":[{"t":"set","p":"payload","pt":"msg","to":"movement","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":350,"y":1600,"wires":[["2307f4aa4bd23a56"]]},{"id":"bf45362fb265c76a","type":"switch","z":"eebabdea17bf9ae3","name":"ranges of azimuths","property":"data.attributes.azimuth","propertyType":"msg","rules":[{"t":"btwn","v":"hall1","vt":"flow","v2":"hall2","v2t":"flow"},{"t":"btwn","v":"hall2","vt":"flow","v2":"hall3","v2t":"flow"},{"t":"btwn","v":"hall3","vt":"flow","v2":"hall4","v2t":"flow"},{"t":"btwn","v":"hall4","vt":"flow","v2":"hall5","v2t":"flow"},{"t":"gt","v":"hall5","vt":"flow"}],"checkall":"true","repair":false,"outputs":5,"x":1130,"y":1600,"wires":[["043b659ffdb5fcb0"],["26b887cea393b9fa"],["e706865fa21411cc"],["225bb9cc8d6d4050"],[]]},{"id":"043b659ffdb5fcb0","type":"function","z":"eebabdea17bf9ae3","name":"1","func":"var HL = {payload: \"20\", topic: \"1\"};\nvar HC = {payload: \"70\", topic: \"2\"};\nvar HR = {payload: \"30\", topic: \"3\"};\nvar KL = {payload: \"0\", topic: \"4\"};\nvar KR = {payload: \"70\", topic: \"5\"};\nreturn [HL, HC, HR, KL, KR];","outputs":5,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1530,"y":1480,"wires":[["975c9ac437a68b43"],["7eb6df8f9736df14"],["4217dbf7bf193e91"],["3d418b538ef3d60e"],["ce83bd7eeaf49e5d"]]},{"id":"2a3a56b9a2a5d1a5","type":"api-call-service","z":"eebabdea17bf9ae3","name":"center_position","server":"9db60f84.2719c","version":5,"debugenabled":false,"domain":"cover","service":"set_cover_position","areaId":[],"deviceId":["c3f9bfef584a8243178ef64304fdba09"],"entityId":["cover.0x00158d0007007abb"],"data":"{ \"position\": msg.payload}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":2080,"y":1580,"wires":[[]]},{"id":"bd58eb043ce09b07","type":"api-call-service","z":"eebabdea17bf9ae3","name":"left_position","server":"9db60f84.2719c","version":5,"debugenabled":false,"domain":"cover","service":"set_cover_position","areaId":[],"deviceId":["fbb3c2d4997fac54fab6bf37d1286bf3"],"entityId":["cover.0x00158d00069c5f26"],"data":"{ \"position\": msg.payload}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":2070,"y":1540,"wires":[[]]},{"id":"5f5f392bd649313a","type":"api-call-service","z":"eebabdea17bf9ae3","name":"right_position","server":"9db60f84.2719c","version":5,"debugenabled":false,"domain":"cover","service":"set_cover_position","areaId":[],"deviceId":["538f4173f8b33a605bf1610757932b52"],"entityId":["cover.0x00158d0007073978"],"data":"{ \"position\": msg.payload}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":2070,"y":1620,"wires":[[]]},{"id":"b7375a44dc2249af","type":"comment","z":"eebabdea17bf9ae3","name":"Hall","info":"Clouds or not","x":2050,"y":1480,"wires":[]},{"id":"ae720925b8eab1f4","type":"comment","z":"eebabdea17bf9ae3","name":"Kids","info":"Clouds or not","x":2050,"y":1680,"wires":[]},{"id":"bd7449b5fd55c7d7","type":"api-call-service","z":"eebabdea17bf9ae3","name":"right_position","server":"9db60f84.2719c","version":5,"debugenabled":false,"domain":"cover","service":"set_cover_position","areaId":[],"deviceId":["7d497ddacdaecdccecccf4e972381082"],"entityId":["cover.0x00158d0007012bed"],"data":"{ \"position\": msg.payload}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":2070,"y":1800,"wires":[[]]},{"id":"f7d698d317a53774","type":"api-call-service","z":"eebabdea17bf9ae3","name":"left_position","server":"9db60f84.2719c","version":5,"debugenabled":false,"domain":"cover","service":"set_cover_position","areaId":[],"deviceId":["ce6b920a3284020e2f9b12c19ccc18a7"],"entityId":["cover.0x00158d0007007a91"],"data":"{ \"position\": msg.payload}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":2070,"y":1740,"wires":[[]]},{"id":"26b887cea393b9fa","type":"function","z":"eebabdea17bf9ae3","name":"2","func":"var HL = {payload: \"40\", topic: \"1\"};\nvar HC = {payload: \"0\", topic: \"2\"};\nvar HR = {payload: \"60\", topic: \"3\"};\nvar KL = {payload: \"20\", topic: \"4\"};\nvar KR = {payload: \"20\", topic: \"5\"};\nreturn [HL, HC, HR, KL, KR];","outputs":5,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1530,"y":1600,"wires":[["975c9ac437a68b43"],["7eb6df8f9736df14"],["4217dbf7bf193e91"],["3d418b538ef3d60e"],["ce83bd7eeaf49e5d"]]},{"id":"e706865fa21411cc","type":"function","z":"eebabdea17bf9ae3","name":"3","func":"var HL = {payload: \"80\", topic: \"1\"};\nvar HC = {payload: \"0\", topic: \"2\"};\nvar HR = {payload: \"100\", topic: \"3\"};\nvar KL = {payload: \"80\", topic: \"4\"};\nvar KR = {payload: \"50\", topic: \"5\"};\nreturn [HL, HC, HR, KL, KR];","outputs":5,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1530,"y":1700,"wires":[["975c9ac437a68b43"],["7eb6df8f9736df14"],["4217dbf7bf193e91"],["3d418b538ef3d60e"],["ce83bd7eeaf49e5d"]]},{"id":"225bb9cc8d6d4050","type":"function","z":"eebabdea17bf9ae3","name":"4","func":"var HL = {payload: \"100\", topic: \"1\"};\nvar HC = {payload: \"100\", topic: \"2\"};\nvar HR = {payload: \"100\", topic: \"3\"};\nvar KL = {payload: \"100\", topic: \"4\"};\nvar KR = {payload: \"100\", topic: \"5\"};\nreturn [HL, HC, HR, KL, KR];","outputs":5,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1530,"y":1800,"wires":[["975c9ac437a68b43"],["7eb6df8f9736df14"],["4217dbf7bf193e91"],["3d418b538ef3d60e"],["ce83bd7eeaf49e5d"]]},{"id":"f0401bafb3771e33","type":"change","z":"eebabdea17bf9ae3","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"100","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":1470,"y":1900,"wires":[["975c9ac437a68b43","7eb6df8f9736df14","4217dbf7bf193e91","3d418b538ef3d60e","ce83bd7eeaf49e5d"]]},{"id":"975c9ac437a68b43","type":"rbe","z":"eebabdea17bf9ae3","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":false,"property":"payload","topi":"topic","x":1890,"y":1540,"wires":[["bd58eb043ce09b07"]]},{"id":"7eb6df8f9736df14","type":"rbe","z":"eebabdea17bf9ae3","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":false,"property":"payload","topi":"topic","x":1890,"y":1580,"wires":[["2a3a56b9a2a5d1a5"]]},{"id":"4217dbf7bf193e91","type":"rbe","z":"eebabdea17bf9ae3","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":false,"property":"payload","topi":"topic","x":1890,"y":1620,"wires":[["5f5f392bd649313a"]]},{"id":"3d418b538ef3d60e","type":"rbe","z":"eebabdea17bf9ae3","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":false,"property":"payload","topi":"topic","x":1890,"y":1740,"wires":[["f7d698d317a53774"]]},{"id":"ce83bd7eeaf49e5d","type":"rbe","z":"eebabdea17bf9ae3","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":false,"property":"payload","topi":"topic","x":1890,"y":1800,"wires":[["bd7449b5fd55c7d7"]]},{"id":"9db60f84.2719c","type":"server","name":"Home Assistant","addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"","connectionDelay":false,"cacheJson":false,"heartbeat":false,"heartbeatInterval":""}]

So the way I do that is by using context. When a state change occurs HA sets context for it based on what changed the state. So I separate UI based changes from automation based changes by looking at context.parent_id in the state change object since it’s only set if the change was done by an HA automation and not in the UI or by Google assistant or whatever.

However you use node red so that rules that out. When node red changes a light or whatever then it does not get a parent_id and does get a user_id (the system user associated with changes made via supervisor). So it looks identical to a UI driven change.

When I used node red what I used to do to account for this was have my automation set the state to imperceptibly off numbers. So if I wanted the lights set to 50% I would have the automation set it to brightness 126. Humans aren’t going to notice that it’s one brightness off but then you can track that and assume all other brightnesses we’re set by humans. I assume same would apply to a cover (have automation set it to 49% or 51% instead of 50%).

Off was always tricky though for me. Can’t separate that from a manual change so easily since humans and automation set it to off. For lights I handled that by listening specifically for the Google assistant voice command event and treating that as an override for the device regardless of value. The UI did not override the light if set to off but we rarely did that, we usually just told Google. Perhaps in your case is 1% open close enough to closed that you could have your automation use that instead of actually closing it?

Although in all cases for me I used that information to set an override toggle that blocked automation changes for two hours. Since you can’t actually learn anything from the context of the state object if you look at it later like you can with HA automations making changes, you have to record that information somewhere (input helper, nr created sensor, etc). I used to use helpers so I could change it manually in the UI occasionally, either to set it to manual override or turn off the override.

This was probably my second favorite part of moving from NR to HA automations personally. Separating automation changes from user changes became trivial with context. I was able to remove so much NR logic around that. My favorite part was traces but that’s unrelated.

Create a new user, “node-red”, and generate an access token with that user. Use that newly created access token to connect NR to HA. Now when NR changes the state of an entity in HA the context.user_id will be set that that user id.

2 Likes

Oh that’s what makes it constant? Well I’ll be damned. I just saw it was a giant guid and it didn’t seem predictable so I gave up. Yea that works great then :+1:

Thanks for the advice!

Created an NR account, removed flag “using addon”, set up the token and IP address, connection works. BUT, I still don’t see context with user ID, it keeps showing null either the state was changed automatically or manually (under different account of course):

cover payload

I’m guessing that’s output from a current-state node. You’re going to need to track it from an event.

1 Like

[{"id":"13461350adf1af00","type":"trigger-state","z":"d9ce4199023a6517","name":"cover changed (not with node-red user id)","server":"","version":2,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"cover.blinds","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"targetType":"this_entity","targetValue":"","propertyType":"property","propertyValue":"new_state.context.user_id","comparatorType":"is_not","comparatorValueDatatype":"str","comparatorValue":"0812322"}],"inputs":0,"outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","enableInput":false,"x":240,"y":160,"wires":[["7c295cb2fbca4b3a","b3842f59cd486ca4"],[]]},{"id":"7c295cb2fbca4b3a","type":"function","z":"d9ce4199023a6517","name":"block?","func":"let blocking = context.get(\"blocking\") ?? false;\n\nif(typeof msg.payload?.block === 'boolean') {\n    blocking = msg.payload.block;\n    context.set(\"blocking\", msg.payload.block);\n    const status = blocking ? \"blocking\" : {}\n    node.status(status);\n    return;\n}\n\nif(blocking) return;\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":498,"y":208,"wires":[["0f13764f7260e10f"]]},{"id":"fd437e192909f21a","type":"inject","z":"d9ce4199023a6517","name":"automation to change cover","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":216,"y":208,"wires":[["7c295cb2fbca4b3a"]]},{"id":"b3842f59cd486ca4","type":"trigger","z":"d9ce4199023a6517","name":"","op1":"{\"block\": true}","op2":"{\"block\": false}","op1type":"json","op2type":"json","duration":"5","extend":true,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":508,"y":160,"wires":[["7c295cb2fbca4b3a"]]},{"id":"adb144c79ded16a5","type":"inject","z":"d9ce4199023a6517","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":340,"y":112,"wires":[["b3842f59cd486ca4"]]},{"id":"0f13764f7260e10f","type":"debug","z":"d9ce4199023a6517","name":"rest of automation","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":686,"y":208,"wires":[]}]
1 Like

Thank you so much! This way it actually works perfectly!