Node red, how do I stop repeat messages?

Hi all,

I have an automation that opens and closes my exterior blinds depending on sun angle and cloud cover (reported from Darksky). The blinds do not report their position so I can’t use HA to see their status. At the moment I fire the flow every 15 minutes, during which time it checks if we are home or away, that ‘BSO auto mode’ is enabled in case we want to stop HA operating the blinds, then it checks the time of day and the sun angle to know which side of the house to operate, after that comes the cloud cover check, if the value is over 50% then the blinds are set in shade or venetian mode.


A simplified version of the flow

What I would like to do is stop sending redundant commands to the blinds every 15 minutes, meaning that if they are open and the parameters (cloud cover, sun angle) are within limits, then the open command is not resent.

I’ve been trying to think of a way of doing this using the RBE node which only passes on data if the payload has changed but I’ve run into these problems:

Current-State Node “cloud cover” either sends a numerical value which changes constantly or if I set state location to none, it will output “on” to the relevant blind control.

The blind control (in this example Salon 1 venetian or Salon 1 open) react to any message, even if I send them an “off” message.

I’ve been staring at it for so long I can’t see the wood for the trees, so any help or suggestion is welcome.

Here’s my flow:

[{"id":"3c86ddc4.7d1802","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"99680548.ce3758","type":"inject","z":"3c86ddc4.7d1802","name":"","topic":"","payload":"","payloadType":"date","repeat":"900","crontab":"","once":true,"onceDelay":0.1,"x":130,"y":140,"wires":[["3e2cd8f3.b2a8b8"]]},{"id":"3e2cd8f3.b2a8b8","type":"api-current-state","z":"3c86ddc4.7d1802","name":"Home/Away","server":"c1f30a8a.902738","version":1,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.home_away","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":310,"y":140,"wires":[["80779b71.2310b8"],[]]},{"id":"80779b71.2310b8","type":"api-current-state","z":"3c86ddc4.7d1802","name":"BSO Auto on?","server":"c1f30a8a.902738","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.auto_bso","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":500,"y":140,"wires":[["fd51e5e2.a633"],[]]},{"id":"c6b62330.1f11e","type":"sun-position","z":"3c86ddc4.7d1802","name":"","positionConfig":"7568ab8.efb35d4","rules":[{"valueLow":"60","valueLowType":"num","valueHigh":"154","valueHighType":"num"},{"valueLow":"155","valueLowType":"num","valueHigh":"229","valueHighType":"num"},{"valueLow":"230","valueLowType":"num","valueHigh":"280","valueHighType":"num"}],"onlyOnChange":"true","topic":"","outputs":4,"start":"","startType":"none","startOffset":0,"startOffsetType":"none","startOffsetMultiplier":60000,"end":"","endType":"none","endOffset":0,"endOffsetType":"none","endOffsetMultiplier":60000,"x":850,"y":140,"wires":[[],["fba5d8b.f95d9a8"],["9dcd5788.05f6"],["fba5d8b.f95d9a8"]]},{"id":"fd51e5e2.a633","type":"time-range-switch","z":"3c86ddc4.7d1802","name":"Day/Night","lat":"45.5006","lon":"7.4869","startTime":"sunrise","endTime":"sunset","startOffset":0,"endOffset":"+15","x":680,"y":140,"wires":[["c6b62330.1f11e"],[]]},{"id":"9dcd5788.05f6","type":"api-current-state","z":"3c86ddc4.7d1802","name":"Cloud cover","server":"c1f30a8a.902738","version":1,"outputs":2,"halt_if":"50","halt_if_type":"num","halt_if_compare":"gte","override_topic":false,"entity_id":"sensor.dark_sky_cloud_coverage","state_type":"str","state_location":"","override_payload":"none","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1050,"y":100,"wires":[["fba5d8b.f95d9a8"],["70a19dd5.07867c"]]},{"id":"70a19dd5.07867c","type":"api-call-service","z":"3c86ddc4.7d1802","name":"Salon 1 Venetian","server":"c1f30a8a.902738","version":1,"debugenabled":false,"service_domain":"scene","service":"turn_on","entityId":"scene.poolside_venetian","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1250,"y":220,"wires":[[]]},{"id":"fba5d8b.f95d9a8","type":"api-call-service","z":"3c86ddc4.7d1802","name":"Salon 1 Open","server":"c1f30a8a.902738","version":1,"debugenabled":false,"service_domain":"scene","service":"turn_on","entityId":"scene.poolside_open","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1240,"y":300,"wires":[[]]},{"id":"c1f30a8a.902738","type":"server","z":"","name":"Home Assistant","legacy":false,"hassio":false,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true},{"id":"7568ab8.efb35d4","type":"position-config","z":"","name":"","isValide":"true","longitude":"0","latitude":"0","angleType":"deg","timeZoneOffset":"99","timeZoneDST":"0","stateTimeFormat":"3","stateDateFormat":"12"}]

You could simply store a value in node red and check against it. Im doing the same to check if my lights were turned on by node red or manually:

[
    {
        "id": "37fba037.c7bf",
        "type": "api-current-state",
        "z": "dc7bdb4e.f7fc88",
        "name": "Light Off?",
        "server": "2fba4297.e4145e",
        "version": 1,
        "outputs": 2,
        "halt_if": "off",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "override_topic": true,
        "entity_id": "light.bedroom_dresser",
        "state_type": "str",
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "data",
        "override_data": "msg",
        "blockInputOverrides": false,
        "x": 540,
        "y": 60,
        "wires": [
            [
                "731caf30.698a7",
                "c99c9cf7.55e65"
            ],
            [
                "96c96b72.a0e6a8"
            ]
        ]
    },
    {
        "id": "731caf30.698a7",
        "type": "function",
        "z": "dc7bdb4e.f7fc88",
        "name": "Set Automation On",
        "func": "flow.set(\"dresser\", 1, \"storeInFile\");\n\n",
        "outputs": 1,
        "noerr": 0,
        "x": 710,
        "y": 60,
        "wires": [
            []
        ]
    },
    {
        "id": "96c96b72.a0e6a8",
        "type": "function",
        "z": "dc7bdb4e.f7fc88",
        "name": "Automation on?",
        "func": "var newmsg = {}\nvar bathflow = flow.get('dresser',\"storeInFile\");\nif (bathflow == 1)\n   newmsg.payload = \"True\";\nelse (newmsg = null)\n\nreturn newmsg;\n",
        "outputs": 1,
        "noerr": 0,
        "x": 700,
        "y": 120,
        "wires": [
            [
                "c99c9cf7.55e65",
                "78755220.cf653c"
            ]
        ]
    },
    {
        "id": "2fba4297.e4145e",
        "type": "server",
        "z": "",
        "name": "Home Assistant",
        "legacy": false,
        "addon": true,
        "rejectUnauthorizedCerts": true,
        "ha_boolean": "y|yes|true|on|home|open",
        "connectionDelay": true
    }
]

image

1 Like

Good idea, I’ll study what you’ve done and give it a go, and thank you for sharing your setup, that should help me on my way!