Enable light when door open (between times and set duration)

OK try this flow

[{"id":"41fafddd.381444","type":"comment","z":"56d3c1c6.0d901","name":"Door Open","info":"Send to the Ligth Node to switch on","x":920,"y":600,"wires":[]},{"id":"4f75983f.a459c8","type":"comment","z":"56d3c1c6.0d901","name":"Door Closed - Switch off light - Change Colour","info":"Turn the light off","x":1030,"y":760,"wires":[]},{"id":"e6cb300a.a589f","type":"inject","z":"56d3c1c6.0d901","name":"Door Open","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"On","payloadType":"str","x":160,"y":500,"wires":[["4c5be29d.2f8a0c"]]},{"id":"279cd515.c5d3ba","type":"change","z":"56d3c1c6.0d901","name":"Set COntext for Door to Open","rules":[{"t":"set","p":"DoorState","pt":"flow","to":"Open","tot":"str"},{"t":"set","p":"LightColour","pt":"flow","to":"LightColour","tot":"msg"},{"t":"set","p":"LightColour","pt":"msg","to":"Red","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":650,"y":640,"wires":[["9de4da00.350d58"]]},{"id":"4c5be29d.2f8a0c","type":"mytimeout","z":"56d3c1c6.0d901","name":"Check for Door Open too long","outtopic":"","outsafe":"Open","outwarning":"","outunsafe":"OpenTooLong","warning":"-","timer":"300","debug":false,"ndebug":false,"ignoreCase":true,"repeat":false,"again":false,"x":390,"y":500,"wires":[["632e19a9.3651d8"],[]]},{"id":"a486dfec.e2fde","type":"inject","z":"56d3c1c6.0d901","name":"Door Closed","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Cancel","payloadType":"str","x":150,"y":560,"wires":[["4c5be29d.2f8a0c","632e19a9.3651d8"]]},{"id":"632e19a9.3651d8","type":"switch","z":"56d3c1c6.0d901","name":"Monitor Door State","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"Open","vt":"str"},{"t":"eq","v":"Cancel","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":370,"y":680,"wires":[["279cd515.c5d3ba"],["74665c94.85bf04"]]},{"id":"74665c94.85bf04","type":"change","z":"56d3c1c6.0d901","name":"Set COntext for Door to Closed","rules":[{"t":"set","p":"DoorState","pt":"flow","to":"Closed","tot":"str"},{"t":"set","p":"LightColour","pt":"msg","to":"LightColour","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":650,"y":720,"wires":[["cb7daab.ea53558"]]},{"id":"cb7daab.ea53558","type":"debug","z":"56d3c1c6.0d901","name":"Door CLosed Debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":960,"y":720,"wires":[]},{"id":"9de4da00.350d58","type":"debug","z":"56d3c1c6.0d901","name":"Door Open","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":930,"y":640,"wires":[]}]

I have used a Contrib node - My Timeout by Neil Cherry - you will need to download and install this

I have assumed the following

  1. Your incoming message from the Light Websocket will have information about the Colour and State of the switch - you can see the values i have used - you can adjust those values accordingly

  2. I have used debug nodes as output - you will need to include the Websocket nodes to communicate your light state and colour - again this will need to be adjusted as appropriate.

Craig

Looks great, thank you.
One last question. the output of the change node is send to the debug node.
I have added the light now, but how do I configure the light to receive the correct output of the change node ?
Now the light node is configured with a specific color, but there is no intelligence added to adjust the color.

[

    {

        "id": "6b3c2aac85c94b44",

        "type": "api-call-service",

        "z": "f6f2187d.f17ca8",

        "name": "Onder",

        "server": "76e2ef2e0bfaa238",

        "version": 3,

        "debugenabled": false,

        "service_domain": "light",

        "service": "turn_on",

        "entityId": "light.eettafel_onder",

        "data": "",

        "dataType": "jsonata",

        "mergecontext": "",

        "mustacheAltTags": false,

        "outputProperties": [],

        "queue": "none",

        "x": 970,

        "y": 1040,

        "wires": [

            []

        ]

    },

    {

        "id": "d69eafe69d998078",

        "type": "comment",

        "z": "f6f2187d.f17ca8",

        "name": "Door Open",

        "info": "Send to the Ligth Node to switch on",

        "x": 980,

        "y": 960,

        "wires": []

    },

    {

        "id": "4f043794bc8398a2",

        "type": "comment",

        "z": "f6f2187d.f17ca8",

        "name": "Door Closed - Switch off light - Change Colour",

        "info": "Turn the light off",

        "x": 1090,

        "y": 1120,

        "wires": []

    },

    {

        "id": "789515953c6cce8b",

        "type": "inject",

        "z": "f6f2187d.f17ca8",

        "name": "Door Open",

        "props": [

            {

                "p": "payload"

            },

            {

                "p": "topic",

                "vt": "str"

            }

        ],

        "repeat": "",

        "crontab": "",

        "once": false,

        "onceDelay": 0.1,

        "topic": "",

        "payload": "On",

        "payloadType": "str",

        "x": 180,

        "y": 920,

        "wires": [

            [

                "e98a45a6118c805a"

            ]

        ]

    },

    {

        "id": "b99797c32e6ffb72",

        "type": "change",

        "z": "f6f2187d.f17ca8",

        "name": "Set COntext for Door to Open",

        "rules": [

            {

                "t": "set",

                "p": "DoorState",

                "pt": "flow",

                "to": "Open",

                "tot": "str"

            },

            {

                "t": "set",

                "p": "LightColour",

                "pt": "flow",

                "to": "LightColour",

                "tot": "msg"

            },

            {

                "t": "set",

                "p": "LightColour",

                "pt": "msg",

                "to": "Red",

                "tot": "str"

            }

        ],

        "action": "",

        "property": "",

        "from": "",

        "to": "",

        "reg": false,

        "x": 690,

        "y": 1040,

        "wires": [

            [

                "d8a08591a0fde469",

                "6b3c2aac85c94b44"

            ]

        ]

    },

    {

        "id": "3aa0894571362c3a",

        "type": "inject",

        "z": "f6f2187d.f17ca8",

        "name": "Door Closed",

        "props": [

            {

                "p": "payload"

            },

            {

                "p": "topic",

                "vt": "str"

            }

        ],

        "repeat": "",

        "crontab": "",

        "once": false,

        "onceDelay": 0.1,

        "topic": "",

        "payload": "Cancel",

        "payloadType": "str",

        "x": 170,

        "y": 1080,

        "wires": [

            [

                "e98a45a6118c805a",

                "647e81110266134c"

            ]

        ]

    },

    {

        "id": "647e81110266134c",

        "type": "switch",

        "z": "f6f2187d.f17ca8",

        "name": "Monitor Door State",

        "property": "payload",

        "propertyType": "msg",

        "rules": [

            {

                "t": "eq",

                "v": "Open",

                "vt": "str"

            },

            {

                "t": "eq",

                "v": "Cancel",

                "vt": "str"

            }

        ],

        "checkall": "true",

        "repair": false,

        "outputs": 2,

        "x": 410,

        "y": 1080,

        "wires": [

            [

                "b99797c32e6ffb72"

            ],

            [

                "3044635c66218313"

            ]

        ]

    },

    {

        "id": "3044635c66218313",

        "type": "change",

        "z": "f6f2187d.f17ca8",

        "name": "Set COntext for Door to Closed",

        "rules": [

            {

                "t": "set",

                "p": "DoorState",

                "pt": "flow",

                "to": "Closed",

                "tot": "str"

            },

            {

                "t": "set",

                "p": "LightColour",

                "pt": "msg",

                "to": "LightColour",

                "tot": "flow"

            }

        ],

        "action": "",

        "property": "",

        "from": "",

        "to": "",

        "reg": false,

        "x": 690,

        "y": 1160,

        "wires": [

            [

                "b0419bcd10ef1bb1",

                "e58d279209886bf2"

            ]

        ]

    },

    {

        "id": "b0419bcd10ef1bb1",

        "type": "debug",

        "z": "f6f2187d.f17ca8",

        "name": "Door CLosed Debug",

        "active": true,

        "tosidebar": true,

        "console": false,

        "tostatus": false,

        "complete": "true",

        "targetType": "full",

        "statusVal": "",

        "statusType": "auto",

        "x": 1020,

        "y": 1160,

        "wires": []

    },

    {

        "id": "d8a08591a0fde469",

        "type": "debug",

        "z": "f6f2187d.f17ca8",

        "name": "Door Open",

        "active": true,

        "tosidebar": true,

        "console": false,

        "tostatus": false,

        "complete": "true",

        "targetType": "full",

        "statusVal": "",

        "statusType": "auto",

        "x": 990,

        "y": 1000,

        "wires": []

    },

    {

        "id": "e98a45a6118c805a",

        "type": "mytimeout",

        "z": "f6f2187d.f17ca8",

        "name": "Check for Door Open too long",

        "outtopic": "",

        "outsafe": "Open",

        "outwarning": "",

        "outunsafe": "OpenTooLong",

        "warning": "-",

        "timer": "3",

        "debug": false,

        "ndebug": false,

        "ignoreCase": true,

        "repeat": false,

        "again": false,

        "x": 410,

        "y": 1000,

        "wires": [

            [

                "647e81110266134c"

            ],

            []

        ]

    },

    {

        "id": "6722d850486aab21",

        "type": "server-state-changed",

        "z": "f6f2187d.f17ca8",

        "name": "Tussendeur",

        "server": "76e2ef2e0bfaa238",

        "version": 3,

        "exposeToHomeAssistant": false,

        "haConfig": [

            {

                "property": "name",

                "value": ""

            },

            {

                "property": "icon",

                "value": ""

            }

        ],

        "entityidfilter": "binary_sensor.deurcontact_tussendeur_contact",

        "entityidfiltertype": "exact",

        "outputinitially": false,

        "state_type": "str",

        "haltifstate": "",

        "halt_if_type": "str",

        "halt_if_compare": "is",

        "outputs": 1,

        "output_only_on_state_change": true,

        "for": 0,

        "forType": "num",

        "forUnits": "minutes",

        "ignorePrevStateNull": false,

        "ignorePrevStateUnknown": false,

        "ignorePrevStateUnavailable": false,

        "ignoreCurrentStateUnknown": false,

        "ignoreCurrentStateUnavailable": false,

        "outputProperties": [

            {

                "property": "payload",

                "propertyType": "msg",

                "value": "",

                "valueType": "entityState"

            },

            {

                "property": "data",

                "propertyType": "msg",

                "value": "",

                "valueType": "eventData"

            },

            {

                "property": "topic",

                "propertyType": "msg",

                "value": "",

                "valueType": "triggerId"

            }

        ],

        "x": 130,

        "y": 1000,

        "wires": [

            [

                "e98a45a6118c805a"

            ]

        ]

    },

    {

        "id": "e58d279209886bf2",

        "type": "api-call-service",

        "z": "f6f2187d.f17ca8",

        "name": "Onder",

        "server": "76e2ef2e0bfaa238",

        "version": 3,

        "debugenabled": false,

        "service_domain": "light",

        "service": "turn_on",

        "entityId": "light.eettafel_onder",

        "data": "",

        "dataType": "jsonata",

        "mergecontext": "",

        "mustacheAltTags": false,

        "outputProperties": [],

        "queue": "none",

        "x": 970,

        "y": 1200,

        "wires": [

            []

        ]

    },

    {

        "id": "76e2ef2e0bfaa238",

        "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"

    }

]

I can not import that flow - please format it correctly you need the

```
Flow Here
```
For this to work correctly

You need to identify and capture the incoming property that specifies what you current light colour is (thats what the flow context saving does) , then you need to set it to whatever colour you require to show the door is open

I can not tell you what these variables/entities/values are as they vary by type/brand of light that you are using

You will need to capture the incoming message from HA and put a debug on it so we can see what it contains

Craig

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