One of the issues with using the motion detection trigger of the ring doorbell to turn on a light is that, well, it gets stuck in a loop:
Motion Detected – Turn on Light – Turn off light – Turning off light triggers motion.
We can get around this in Node Red by disabling the trigger for a few seconds when we turn off the light, preventing this loop.
Here we can see that our flow now goes through a process to check the time of day (no point turning it on in the day time), turns the light on, wait 3 minutes, then simultaneously turn the light off and disable the trigger. We then wait 5 seconds and re-enable motion detection
You can use the code below to import this flow, and edit it for your entities.
[
{
"id": "db5176a.9d3a888",
"type": "tab",
"label": "Front Door Light",
"disabled": false,
"info": ""
},
{
"id": "664a9f4d.96843",
"type": "trigger-state",
"z": "db5176a.9d3a888",
"name": "Motion",
"server": "c825ba41.c58c48",
"entityid": "binary_sensor.ring_front_door_motion",
"entityidfiltertype": "exact",
"debugenabled": false,
"constraints": [],
"constraintsmustmatch": "all",
"outputs": 2,
"customoutputs": [],
"outputinitially": false,
"state_type": "str",
"x": 150,
"y": 100,
"wires": [
[
"1b4bbd2c.237343"
],
[]
]
},
{
"id": "1b4bbd2c.237343",
"type": "time-range-switch",
"z": "db5176a.9d3a888",
"name": "Dusk",
"lat": "53.20622",
"lon": "-0.46285",
"startTime": "dusk",
"endTime": "sunrise",
"startOffset": "0",
"endOffset": 0,
"x": 330,
"y": 120,
"wires": [
[
"47cceba4.1ddea4"
],
[]
]
},
{
"id": "bac5cfb.50c5f3",
"type": "api-call-service",
"z": "db5176a.9d3a888",
"name": "",
"server": "c825ba41.c58c48",
"version": 1,
"service_domain": "light",
"service": "turn_off",
"entityId": "light.outside_front",
"data": "",
"dataType": "json",
"mergecontext": "",
"output_location": "",
"output_location_type": "none",
"mustacheAltTags": false,
"x": 770,
"y": 80,
"wires": [
[
"b060426d.a51a2"
]
]
},
{
"id": "47cceba4.1ddea4",
"type": "api-call-service",
"z": "db5176a.9d3a888",
"name": "",
"server": "c825ba41.c58c48",
"version": 1,
"service_domain": "light",
"service": "turn_on",
"entityId": "light.outside_front",
"data": "",
"dataType": "json",
"mergecontext": "",
"output_location": "",
"output_location_type": "none",
"mustacheAltTags": false,
"x": 470,
"y": 60,
"wires": [
[
"e6ff2bff.cd0bf8"
]
]
},
{
"id": "f6eb6f2b.aa62",
"type": "change",
"z": "db5176a.9d3a888",
"name": "Disable",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "Disable",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 620,
"y": 220,
"wires": [
[
"664a9f4d.96843"
]
]
},
{
"id": "63ce28b8.7baf48",
"type": "change",
"z": "db5176a.9d3a888",
"name": "Enable",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "Enable",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1100,
"y": 20,
"wires": [
[
"664a9f4d.96843"
]
]
},
{
"id": "b060426d.a51a2",
"type": "delay",
"z": "db5176a.9d3a888",
"name": "",
"pauseType": "delay",
"timeout": "5",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"x": 920,
"y": 160,
"wires": [
[
"63ce28b8.7baf48"
]
]
},
{
"id": "e6ff2bff.cd0bf8",
"type": "delay",
"z": "db5176a.9d3a888",
"name": "",
"pauseType": "delay",
"timeout": "3",
"timeoutUnits": "minutes",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"x": 620,
"y": 140,
"wires": [
[
"bac5cfb.50c5f3",
"f6eb6f2b.aa62"
]
]
},
{
"id": "c825ba41.c58c48",
"type": "server",
"z": "",
"name": "Home Assistant",
"legacy": false,
"hassio": true,
"rejectUnauthorizedCerts": true,
"ha_boolean": "y|yes|true|on|home|open",
"connectionDelay": false
}
]