Only proceed with flow if first condition is true for a specific duration

Hello, once again folks.

I am attempting to create an automation to notify household if the dryer is complete. I happened to have a spare Samsung Multi-Purpose Sensor which I decided to attach to my dryer. Using the vibration/accelerometer sensor.

Current problem is that it will get triggered to "on" for like 10s, 30s, and some small amount of time because the washer next to it is causing enough vibrations on the floor.

Ideally I would want my flow automation to proceed if vibration state is 'on' for at least 1 minute (or what I will most likely pick 5 minutes).

[
    {
        "id": "a01e8da2.77e7a",
        "type": "server-state-changed",
        "z": "b8c8e0cb.1ab21",
        "name": "Washer Vibrating",
        "server": "a274340c.664f08",
        "version": 1,
        "exposeToHomeAssistant": false,
        "haConfig": [
            {
                "property": "name",
                "value": ""
            },
            {
                "property": "icon",
                "value": ""
            }
        ],
        "entityidfilter": "binary_sensor.samjin_multi_31710601_accelerometer",
        "entityidfiltertype": "exact",
        "outputinitially": false,
        "state_type": "str",
        "haltifstate": "on",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "outputs": 2,
        "output_only_on_state_change": true,
        "x": 120,
        "y": 520,
        "wires": [
            [
                "55b6cbca.d7bb54"
            ],
            []
        ]
    },
    {
        "id": "a274340c.664f08",
        "type": "server",
        "z": "",
        "name": "Home Assistant",
        "addon": true
    }
]
1 Like

Trigger node will likely do what you want.

image

I tried it but I cant seem to get it to do anything. I don't quite understand how the flow works. Can you take a look at my settings?

[
    {
        "id": "b8c8e0cb.1ab21",
        "type": "tab",
        "label": "Garage",
        "disabled": false,
        "info": ""
    },
    {
        "id": "c3957b93.718d88",
        "type": "server-state-changed",
        "z": "b8c8e0cb.1ab21",
        "name": "Washer Watts != 0",
        "server": "a274340c.664f08",
        "version": 1,
        "exposeToHomeAssistant": false,
        "haConfig": [
            {
                "property": "name",
                "value": ""
            },
            {
                "property": "icon",
                "value": ""
            }
        ],
        "entityidfilter": "sensor.zooz_zen15_power_switch_power",
        "entityidfiltertype": "exact",
        "outputinitially": false,
        "state_type": "str",
        "haltifstate": "0",
        "halt_if_type": "num",
        "halt_if_compare": "is_not",
        "outputs": 2,
        "output_only_on_state_change": true,
        "x": 130,
        "y": 280,
        "wires": [
            [
                "ccb5ade3.9256d"
            ],
            []
        ]
    },
    {
        "id": "ccb5ade3.9256d",
        "type": "stoptimer",
        "z": "b8c8e0cb.1ab21",
        "duration": "2",
        "units": "Minute",
        "payloadtype": "num",
        "payloadval": "0",
        "name": "5 Min Delay",
        "x": 130,
        "y": 220,
        "wires": [
            [
                "cf9d87ff.232c28"
            ],
            []
        ]
    },
    {
        "id": "f5f23bd9.a7f468",
        "type": "comment",
        "z": "b8c8e0cb.1ab21",
        "name": "Washer",
        "info": "If Watts value is not 0. Automation starts and goes to top flow. \nTop flow will verify there has been watts > 0 for at least 5 minutes before proceeding.\n\nMay need to add washer is not 0 - > wait 5 minutes-> washer is at 0 > proceed, if not it should go back.\n\nHopefully no loop crashes\n",
        "x": 90,
        "y": 160,
        "wires": []
    },
    {
        "id": "756d2c4b.1b7b54",
        "type": "api-call-service",
        "z": "b8c8e0cb.1ab21",
        "name": "Flash bedroom lights",
        "server": "a274340c.664f08",
        "version": 1,
        "debugenabled": false,
        "service_domain": "light",
        "service": "turn_on",
        "entityId": "light.br2_white_2",
        "data": "",
        "dataType": "json",
        "mergecontext": "",
        "output_location": "",
        "output_location_type": "none",
        "mustacheAltTags": false,
        "x": 820,
        "y": 160,
        "wires": [
            [
                "8b036e20.45a14"
            ]
        ]
    },
    {
        "id": "8b036e20.45a14",
        "type": "debug",
        "z": "b8c8e0cb.1ab21",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "x": 950,
        "y": 340,
        "wires": []
    },
    {
        "id": "16c20237.056bae",
        "type": "alexa-remote-init",
        "z": "b8c8e0cb.1ab21",
        "name": "",
        "account": "61198ebd.dfed7",
        "option": "initialise",
        "x": 100,
        "y": 40,
        "wires": [
            []
        ]
    },
    {
        "id": "a28f41d5.f6628",
        "type": "alexa-remote-routine",
        "z": "b8c8e0cb.1ab21",
        "name": "Washer-Notification",
        "account": "61198ebd.dfed7",
        "routineNode": {
            "type": "speakAtVolume",
            "payload": {
                "type": "regular",
                "text": {
                    "type": "str",
                    "value": "Washer Cycle Complete"
                },
                "volume": {
                    "type": "num",
                    "value": "75"
                },
                "mode": "set",
                "devices": [
                    "16d64dd16a304d90b1b00624b5900952"
                ]
            }
        },
        "x": 630,
        "y": 260,
        "wires": [
            [
                "756d2c4b.1b7b54"
            ]
        ]
    },
    {
        "id": "a01e8da2.77e7a",
        "type": "server-state-changed",
        "z": "b8c8e0cb.1ab21",
        "name": "Washer Vibrating",
        "server": "a274340c.664f08",
        "version": 1,
        "exposeToHomeAssistant": false,
        "haConfig": [
            {
                "property": "name",
                "value": ""
            },
            {
                "property": "icon",
                "value": ""
            }
        ],
        "entityidfilter": "binary_sensor.samjin_multi_31710601_accelerometer",
        "entityidfiltertype": "exact",
        "outputinitially": false,
        "state_type": "str",
        "haltifstate": "on",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "outputs": 2,
        "output_only_on_state_change": true,
        "x": 120,
        "y": 400,
        "wires": [
            [
                "70f2539c.eaa05c"
            ],
            []
        ]
    },
    {
        "id": "55b6cbca.d7bb54",
        "type": "stoptimer",
        "z": "b8c8e0cb.1ab21",
        "duration": "5",
        "units": "Minute",
        "payloadtype": "num",
        "payloadval": "0",
        "name": "5 Min Delay",
        "x": 450,
        "y": 700,
        "wires": [
            [],
            []
        ]
    },
    {
        "id": "45097f67.afdd3",
        "type": "alexa-remote-routine",
        "z": "b8c8e0cb.1ab21",
        "name": "Washer-Notification",
        "account": "61198ebd.dfed7",
        "routineNode": {
            "type": "speakAtVolume",
            "payload": {
                "type": "regular",
                "text": {
                    "type": "str",
                    "value": "Dryer Cycle Complete"
                },
                "volume": {
                    "type": "num",
                    "value": "40"
                },
                "mode": "set",
                "devices": [
                    "G090LA097463063H",
                    "6030883874cf487a9cd9c02f529a0da4"
                ]
            }
        },
        "x": 750,
        "y": 420,
        "wires": [
            [
                "becc8f03.a5f6e"
            ]
        ]
    },
    {
        "id": "becc8f03.a5f6e",
        "type": "debug",
        "z": "b8c8e0cb.1ab21",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "x": 930,
        "y": 420,
        "wires": []
    },
    {
        "id": "cf9d87ff.232c28",
        "type": "ha-wait-until",
        "z": "b8c8e0cb.1ab21",
        "name": "Washer Watts = 0",
        "server": "a274340c.664f08",
        "outputs": 1,
        "entityId": "sensor.zooz_zen15_power_switch_power",
        "entityIdFilterType": "exact",
        "property": "attributes.power_consumption",
        "comparator": "is",
        "value": "0",
        "valueType": "num",
        "timeout": 0,
        "timeoutType": "num",
        "timeoutUnits": "seconds",
        "entityLocation": "",
        "entityLocationType": "none",
        "checkCurrentState": true,
        "blockInputOverrides": true,
        "x": 390,
        "y": 260,
        "wires": [
            [
                "a28f41d5.f6628"
            ]
        ]
    },
    {
        "id": "f137512c.525",
        "type": "ha-wait-until",
        "z": "b8c8e0cb.1ab21",
        "name": "Dryer != Vibrating",
        "server": "a274340c.664f08",
        "outputs": 1,
        "entityId": "binary_sensor.samjin_multi_31710601_accelerometer",
        "entityIdFilterType": "exact",
        "property": "state",
        "comparator": "is",
        "value": "off",
        "valueType": "str",
        "timeout": 0,
        "timeoutType": "num",
        "timeoutUnits": "seconds",
        "entityLocation": "",
        "entityLocationType": "none",
        "checkCurrentState": true,
        "blockInputOverrides": true,
        "x": 550,
        "y": 420,
        "wires": [
            [
                "45097f67.afdd3"
            ]
        ]
    },
    {
        "id": "67b13a.f72dfec8",
        "type": "server-state-changed",
        "z": "b8c8e0cb.1ab21",
        "name": "LR-Color1 On to Off",
        "server": "a274340c.664f08",
        "version": 1,
        "exposeToHomeAssistant": false,
        "haConfig": [
            {
                "property": "name",
                "value": ""
            },
            {
                "property": "icon",
                "value": ""
            }
        ],
        "entityidfilter": "light.lr_color_1",
        "entityidfiltertype": "exact",
        "outputinitially": false,
        "state_type": "str",
        "haltifstate": "on",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "outputs": 2,
        "output_only_on_state_change": true,
        "x": 270,
        "y": 100,
        "wires": [
            [
                "f837b378.e2362"
            ],
            []
        ]
    },
    {
        "id": "7ca62748.13ed98",
        "type": "alexa-remote-routine",
        "z": "b8c8e0cb.1ab21",
        "name": "Washer-Notification",
        "account": "61198ebd.dfed7",
        "routineNode": {
            "type": "speakAtVolume",
            "payload": {
                "type": "regular",
                "text": {
                    "type": "str",
                    "value": "Test Successful"
                },
                "volume": {
                    "type": "num",
                    "value": "75"
                },
                "mode": "set",
                "devices": [
                    "16d64dd16a304d90b1b00624b5900952"
                ]
            }
        },
        "x": 730,
        "y": 60,
        "wires": [
            [
                "dbedd5e9.9a70e8"
            ]
        ]
    },
    {
        "id": "dbedd5e9.9a70e8",
        "type": "debug",
        "z": "b8c8e0cb.1ab21",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "x": 923,
        "y": 62,
        "wires": []
    },
    {
        "id": "f837b378.e2362",
        "type": "ha-wait-until",
        "z": "b8c8e0cb.1ab21",
        "name": "Test Simple Things",
        "server": "a274340c.664f08",
        "outputs": 1,
        "entityId": "light.lr_color_1",
        "entityIdFilterType": "exact",
        "property": "state",
        "comparator": "is",
        "value": "off",
        "valueType": "str",
        "timeout": 0,
        "timeoutType": "num",
        "timeoutUnits": "seconds",
        "entityLocation": "",
        "entityLocationType": "none",
        "checkCurrentState": true,
        "blockInputOverrides": true,
        "x": 470,
        "y": 60,
        "wires": [
            [
                "7ca62748.13ed98"
            ]
        ]
    },
    {
        "id": "70f2539c.eaa05c",
        "type": "trigger",
        "z": "b8c8e0cb.1ab21",
        "op1": "",
        "op2": "off",
        "op1type": "nul",
        "op2type": "str",
        "duration": "30",
        "extend": true,
        "units": "s",
        "reset": "on",
        "bytopic": "all",
        "name": "Test edit trigger",
        "x": 360,
        "y": 420,
        "wires": [
            [
                "f137512c.525"
            ]
        ]
    },
    {
        "id": "a274340c.664f08",
        "type": "server",
        "z": "",
        "name": "Home Assistant",
        "addon": true
    },
    {
        "id": "61198ebd.dfed7",
        "type": "alexa-remote-account",
        "z": "",
        "name": "",
        "authMethod": "proxy",
        "proxyOwnIp": "192.168.1.41",
        "proxyPort": "3456",
        "cookieFile": "AlexaRemote2File",
        "refreshInterval": "3",
        "alexaServiceHost": "pitangui.amazon.com",
        "amazonPage": "amazon.com",
        "acceptLanguage": "en-US",
        "userAgent": "",
        "useWsMqtt": "on",
        "autoInit": "on"
    }
]

you could try using node-red-contrib-timeframerlt

You can set it to trigger if enough events (dryer shaking) has happened in a certain amount of time

Thank you for your suggestion.
It seems like it would work however my sensor would only send one notification when it switches state. Vibrating or not vibrating which results in just two messages.What I kind of imagine would be vibrating at second 1, vibrating at second 10, vibrating at 20, vibrating at 30 seconds in total has generated 4 messages or whatever number of times it has been checking the device.

tried it but I cant seem to get it to do anything. I don't quite understand how the flow works. Can you take a look at my settings?

The trigger node triggers, based on conditions.

When you keep injecting it with the "vibration" signal, it will not trigger anything and will wait for 30seconds and extends those 30s every time a signal is received (within these 30 seconds), when 30s elapsed while no more vibration was received, it will send "off".

Yeah that should definitely work. I maybe did not configure it correctly the first time. I will need a few weeks to do some runs on both washer and dryer. Will post back with my results and my flow in order for others to use it.

You can "emulate" the data/flow, if you know what the output is for the "Washer Vibrating"

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.