Here’s a PIR sensor and timer which might help. It takes and input from a sensor and the output is gated based on a scheduler connected to the bottom left.
[
{
"id": "9e14513570739b4d",
"type": "gate",
"z": "837c7ac2f814d114",
"name": "",
"controlTopic": "control",
"defaultState": "open",
"openCmd": "open",
"closeCmd": "close",
"toggleCmd": "toggle",
"defaultCmd": "default",
"statusCmd": "status",
"persist": false,
"storeName": "memory",
"x": 410,
"y": 240,
"wires": [
[
"1b2f1ccf20977f7b",
"936c17174a4a0cff"
]
]
},
{
"id": "284ab4f72dd957e2",
"type": "change",
"z": "837c7ac2f814d114",
"name": "translate scheduler",
"rules": [
{
"t": "change",
"p": "payload",
"pt": "msg",
"from": "ON",
"fromt": "str",
"to": "close",
"tot": "str"
},
{
"t": "change",
"p": "payload",
"pt": "msg",
"from": "OFF",
"fromt": "str",
"to": "open",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 530,
"y": 500,
"wires": [
[
"071a721b4a6139b2"
]
]
},
{
"id": "071a721b4a6139b2",
"type": "function",
"z": "837c7ac2f814d114",
"name": "add gate control command",
"func": "msg.topic=\"control\"\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 560,
"y": 460,
"wires": [
[
"9e14513570739b4d",
"9acd1f0910122186"
]
]
},
{
"id": "1b2f1ccf20977f7b",
"type": "api-call-service",
"z": "837c7ac2f814d114",
"name": "",
"server": "657645c6ebda1a8b",
"version": 5,
"debugenabled": false,
"domain": "light",
"service": "turn_on",
"areaId": [],
"deviceId": [
"3fbbd5115e7a6eb442eda3a036d6a86c"
],
"entityId": [],
"data": "{}",
"dataType": "json",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"x": 1070,
"y": 240,
"wires": [
[]
]
},
{
"id": "281c2fd8d50c759c",
"type": "inject",
"z": "837c7ac2f814d114",
"name": "Force Off",
"props": [
{
"p": "payload"
},
{
"p": "reset",
"v": "",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 100,
"y": 340,
"wires": [
[
"9139c72539d4cf7b",
"936c17174a4a0cff"
]
]
},
{
"id": "9139c72539d4cf7b",
"type": "api-call-service",
"z": "837c7ac2f814d114",
"name": "",
"server": "657645c6ebda1a8b",
"version": 5,
"debugenabled": false,
"domain": "light",
"service": "turn_off",
"areaId": [],
"deviceId": [
"3fbbd5115e7a6eb442eda3a036d6a86c"
],
"entityId": [],
"data": "{}",
"dataType": "json",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"x": 1070,
"y": 300,
"wires": [
[]
]
},
{
"id": "604c83570e8d0274",
"type": "switch",
"z": "837c7ac2f814d114",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "ON",
"vt": "str"
},
{
"t": "eq",
"v": "OFF",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 870,
"y": 280,
"wires": [
[
"1b2f1ccf20977f7b"
],
[
"9139c72539d4cf7b"
]
]
},
{
"id": "936c17174a4a0cff",
"type": "trigger",
"z": "837c7ac2f814d114",
"name": "",
"op1": "1",
"op2": "OFF",
"op1type": "str",
"op2type": "str",
"duration": "180",
"extend": true,
"overrideDelay": true,
"units": "s",
"reset": "",
"bytopic": "all",
"topic": "topic",
"outputs": 1,
"x": 570,
"y": 280,
"wires": [
[
"9acd1f0910122186"
]
]
},
{
"id": "9acd1f0910122186",
"type": "gate",
"z": "837c7ac2f814d114",
"name": "",
"controlTopic": "control",
"defaultState": "open",
"openCmd": "open",
"closeCmd": "close",
"toggleCmd": "toggle",
"defaultCmd": "default",
"statusCmd": "status",
"persist": false,
"storeName": "memory",
"x": 730,
"y": 280,
"wires": [
[
"604c83570e8d0274"
]
]
},
{
"id": "3c970a8ab0fad0f3",
"type": "link in",
"z": "837c7ac2f814d114",
"name": "Global dusk to 23:45",
"links": [
"ab3e3bbd31ed88cc"
],
"x": 335,
"y": 460,
"wires": [
[
"604c83570e8d0274",
"284ab4f72dd957e2"
]
]
},
{
"id": "93bb3a954a4bb7f8",
"type": "link in",
"z": "837c7ac2f814d114",
"name": "Office desk light",
"links": [
"cd6dabb4e648ea8e"
],
"x": 125,
"y": 40,
"wires": [
[
"6c6073f6e0744f5c"
]
]
},
{
"id": "54be4594d5c58e31",
"type": "change",
"z": "837c7ac2f814d114",
"name": "Set delay 180s",
"rules": [
{
"t": "set",
"p": "delay",
"pt": "msg",
"to": "180000",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 420,
"y": 80,
"wires": [
[
"9e14513570739b4d"
]
]
},
{
"id": "5e7bef2a4bfb3017",
"type": "inject",
"z": "837c7ac2f814d114",
"name": "OFF (NP)",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "OFF",
"payloadType": "str",
"x": 100,
"y": 260,
"wires": [
[
"6c6073f6e0744f5c"
]
]
},
{
"id": "52d238f0adf50908",
"type": "inject",
"z": "837c7ac2f814d114",
"name": "ON",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "ON",
"payloadType": "str",
"x": 90,
"y": 220,
"wires": [
[
"6c6073f6e0744f5c"
]
]
},
{
"id": "6c6073f6e0744f5c",
"type": "switch",
"z": "837c7ac2f814d114",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "on",
"vt": "str"
},
{
"t": "eq",
"v": "OFF",
"vt": "str"
},
{
"t": "else"
}
],
"checkall": "true",
"repair": false,
"outputs": 3,
"x": 230,
"y": 80,
"wires": [
[
"54be4594d5c58e31"
],
[],
[
"54be4594d5c58e31"
]
]
},
{
"id": "bb978d3bc9349fbc",
"type": "inject",
"z": "837c7ac2f814d114",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 100,
"y": 300,
"wires": [
[
"6c6073f6e0744f5c"
]
]
},
{
"id": "57642f5f563075a1",
"type": "comment",
"z": "837c7ac2f814d114",
"name": "INPUT",
"info": "payload - trigger\n-----------------\ntimestamp - On\nON command - On\nOFF command - dropped/ignored",
"x": 90,
"y": 80,
"wires": []
},
{
"id": "657645c6ebda1a8b",
"type": "server",
"name": "Home Assistant",
"version": 4,
"addon": false,
"rejectUnauthorizedCerts": true,
"ha_boolean": "y|yes|true|on|home|open",
"connectionDelay": true,
"cacheJson": true,
"heartbeat": false,
"heartbeatInterval": "30",
"areaSelector": "friendlyName",
"deviceSelector": "friendlyName",
"entitySelector": "friendlyName",
"statusSeparator": ": ",
"statusYear": "hidden",
"statusMonth": "short",
"statusDay": "numeric",
"statusHourCycle": "default",
"statusTimeFormat": "h:m"
}
]