Help with Flow (Arrive at home and open garage door)

I'm trying to create a Flow that will detect when I get home and open my garage door (if it is closed) based on which vehicle is present.

I have separate flows for the following:

  • When I arrive at home
[
    {
        "id": "264dfde8ecb5ecec",
        "type": "tab",
        "label": "Presense",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "e92fe96b6eed18ca",
        "type": "trigger-state",
        "z": "264dfde8ecb5ecec",
        "name": "Shane Away -> Home",
        "server": "032233dc1a525626",
        "version": 2,
        "exposeToHomeAssistant": false,
        "haConfig": [
            {
                "property": "name",
                "value": ""
            },
            {
                "property": "icon",
                "value": ""
            }
        ],
        "entityid": "person.shane",
        "entityidfiltertype": "exact",
        "debugenabled": false,
        "constraints": [
            {
                "targetType": "this_entity",
                "targetValue": "",
                "propertyType": "current_state",
                "propertyValue": "new_state.state",
                "comparatorType": "is",
                "comparatorValueDatatype": "str",
                "comparatorValue": "home"
            },
            {
                "targetType": "this_entity",
                "targetValue": "",
                "propertyType": "previous_state",
                "propertyValue": "old_state.state",
                "comparatorType": "is",
                "comparatorValueDatatype": "str",
                "comparatorValue": "not_home"
            }
        ],
        "inputs": 0,
        "outputs": 2,
        "customoutputs": [],
        "outputinitially": true,
        "state_type": "str",
        "enableInput": false,
        "x": 180,
        "y": 80,
        "wires": [
            [],
            []
        ]
    },
    {
        "id": "032233dc1a525626",
        "type": "server",
        "name": "Home Assistant",
        "version": 2,
        "addon": false,
        "rejectUnauthorizedCerts": true,
        "ha_boolean": "y|yes|true|on|home|open",
        "connectionDelay": true,
        "cacheJson": true,
        "heartbeat": false,
        "heartbeatInterval": "30"
    }
]
  • If garage door is closed
[
    {
        "id": "35fbd0dda3afb47c",
        "type": "tab",
        "label": "Garage Status",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "06b183aaf177d634",
        "type": "api-current-state",
        "z": "35fbd0dda3afb47c",
        "name": "",
        "server": "032233dc1a525626",
        "version": 3,
        "outputs": 2,
        "halt_if": "open",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "entity_id": "binary_sensor.north_garage_status_contact",
        "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": 290,
        "y": 80,
        "wires": [
            [
                "9358f0ff3433cae4"
            ],
            [
                "9358f0ff3433cae4"
            ]
        ]
    },
    {
        "id": "9358f0ff3433cae4",
        "type": "debug",
        "z": "35fbd0dda3afb47c",
        "name": "garage door",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 610,
        "y": 80,
        "wires": []
    },
    {
        "id": "032233dc1a525626",
        "type": "server",
        "name": "Home Assistant",
        "version": 2,
        "addon": false,
        "rejectUnauthorizedCerts": true,
        "ha_boolean": "y|yes|true|on|home|open",
        "connectionDelay": true,
        "cacheJson": true,
        "heartbeat": false,
        "heartbeatInterval": "30"
    }
]
  • Which vehicle is present
[
    {
        "id": "994066c5effa37ce",
        "type": "tab",
        "label": "which vehicle present",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "f85e19faa9ee933a",
        "type": "mqtt in",
        "z": "994066c5effa37ce",
        "name": "",
        "topic": "frigate/events",
        "qos": "2",
        "datatype": "json",
        "broker": "85ed64347aaa62b6",
        "nl": false,
        "rap": true,
        "rh": 0,
        "inputs": 0,
        "x": 250,
        "y": 80,
        "wires": [
            [
                "39e1489349409ab1"
            ]
        ]
    },
    {
        "id": "39e1489349409ab1",
        "type": "function",
        "z": "994066c5effa37ce",
        "name": "which vehicle present",
        "func": "if(msg.payload.before.camera == \"Garage\"&& msg.payload.before.stationary == true && msg.payload.before.label == \"car\"){\n    for (var x in msg.payload.before.entered_zones) {\n        if (msg.payload.before.entered_zones[x] == 'van_zone') {\n            msg.payload = \"van_present\";\n        }\n        else if(msg.payload.before.entered_zones[x] == 'accord_zone'){\n            msg.payload = \"car_present\";\n        }\n        else\n            msg.payload = false;\n    }    \n}\nelse{\n    msg.payload = false;\n}\n\n//msg.payload = (msg.payload===\"Garage\");\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 440,
        "y": 80,
        "wires": [
            [
                "6734039c3bee0f8d"
            ]
        ]
    },
    {
        "id": "6734039c3bee0f8d",
        "type": "switch",
        "z": "994066c5effa37ce",
        "name": "",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "van_present",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "accord_present",
                "vt": "str"
            },
            {
                "t": "false"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 3,
        "x": 610,
        "y": 80,
        "wires": [
            [],
            [],
            []
        ]
    },
    {
        "id": "85ed64347aaa62b6",
        "type": "mqtt-broker",
        "name": "MQTT Broker",
        "broker": "192.168.2.66",
        "port": "1883",
        "clientid": "",
        "autoConnect": true,
        "usetls": false,
        "protocolVersion": "4",
        "keepalive": "60",
        "cleansession": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "birthMsg": {},
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "closeMsg": {},
        "willTopic": "",
        "willQos": "0",
        "willPayload": "",
        "willMsg": {},
        "sessionExpiry": ""
    }
]

but I can't seem to wrap my head around how to get that to all work together, any help would be much appreciated!

Hi and welcome.

The logic is to store the states and on trigger use switch nodes to check the states,
As you are using Home Assistant, I know nothing about your incoming data, as I do not use HA (best ask on HA forum for help there).

Here is an example of storing the states and reading them in a switch node on a trigger from home. Hope you will see how to incorporate this with your HA nodes instead of the inject nodes i have used.

[{"id":"43f632b2.ed816c","type":"inject","z":"264dfde8ecb5ecec","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"home","payload":"home","payloadType":"str","x":220,"y":60,"wires":[["59281488.fd9b84"]]},{"id":"59281488.fd9b84","type":"switch","z":"264dfde8ecb5ecec","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"home","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":440,"y":100,"wires":[["4fc3b8c6.1a8c08"]]},{"id":"1933c16c.fefa57","type":"inject","z":"264dfde8ecb5ecec","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"home","payload":"away","payloadType":"str","x":220,"y":120,"wires":[["59281488.fd9b84"]]},{"id":"4fc3b8c6.1a8c08","type":"switch","z":"264dfde8ecb5ecec","name":"","property":"garage","propertyType":"flow","rules":[{"t":"eq","v":"closed","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":600,"y":100,"wires":[["90254c8a.f78d58"]]},{"id":"90254c8a.f78d58","type":"switch","z":"264dfde8ecb5ecec","name":"","property":"vehicle","propertyType":"flow","rules":[{"t":"eq","v":"car","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":760,"y":100,"wires":[["d4f584e5.a5b388"]]},{"id":"d4f584e5.a5b388","type":"debug","z":"264dfde8ecb5ecec","name":"open garage","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":790,"y":160,"wires":[]},{"id":"6f6183e5.0096fc","type":"inject","z":"264dfde8ecb5ecec","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"garage","payload":"closed","payloadType":"str","x":230,"y":180,"wires":[["65c711da.7e74c"]]},{"id":"db17932a.d2ab08","type":"inject","z":"264dfde8ecb5ecec","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"garage","payload":"open","payloadType":"str","x":220,"y":220,"wires":[["65c711da.7e74c"]]},{"id":"65c711da.7e74c","type":"change","z":"264dfde8ecb5ecec","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"garage","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":450,"y":180,"wires":[[]]},{"id":"5d14d9a2.be546","type":"inject","z":"264dfde8ecb5ecec","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"vehicle","payload":"van","payloadType":"str","x":220,"y":280,"wires":[["9c0cb7f3.286308"]]},{"id":"3a42b619.8e6b22","type":"inject","z":"264dfde8ecb5ecec","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"vehicle","payload":"car","payloadType":"str","x":210,"y":320,"wires":[["9c0cb7f3.286308"]]},{"id":"9c0cb7f3.286308","type":"change","z":"264dfde8ecb5ecec","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"vehicle","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":430,"y":280,"wires":[[]]}]

Thanks for the help that did the trick!

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