Motion Sensor / Switch Automation

In my kitchen, I want to automate my kitchen ceiling light. So far all is working fine but I have the issue that if I need the light during the day and turn it on with my switch it turns off again once motion is detected. I am using NodeRed for most of my automation. What I would like to know: Could I get info on which device (entity) did fire the last event?

Maybe there’s even a better solution than mine :blush:

Here’s my NodeRed flow:

[
    {
        "id": "8d43f64b.f88a08",
        "type": "comment",
        "z": "753f1f86.f884c",
        "name": "Automate Kitchen Ceiling Light",
        "info": "",
        "x": 170,
        "y": 40,
        "wires": []
    },
    {
        "id": "c3872927.31d3e8",
        "type": "server-state-changed",
        "z": "753f1f86.f884c",
        "name": "Motion Sensor Kitchen",
        "server": "b39d51c7.0e2ba",
        "version": 1,
        "entityidfilter": "binary_sensor.kitchen",
        "entityidfiltertype": "exact",
        "outputinitially": true,
        "state_type": "str",
        "haltifstate": "",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "outputs": 1,
        "output_only_on_state_change": true,
        "x": 140,
        "y": 100,
        "wires": [
            [
                "7b83986b.133d08"
            ]
        ]
    },
    {
        "id": "7b83986b.133d08",
        "type": "switch",
        "z": "753f1f86.f884c",
        "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": 330,
        "y": 100,
        "wires": [
            [
                "47619826.3934a8",
                "2214d719.873b58"
            ],
            []
        ]
    },
    {
        "id": "669d87bd.cc3848",
        "type": "api-call-service",
        "z": "753f1f86.f884c",
        "name": "Turn On Kitchen Ceiling",
        "server": "b39d51c7.0e2ba",
        "service_domain": "switch",
        "service": "turn_on",
        "data": "{\"entity_id\":\"switch.kitchen_ceiling\"}",
        "mergecontext": "",
        "output_location": "",
        "output_location_type": "none",
        "mustacheAltTags": false,
        "x": 810,
        "y": 200,
        "wires": [
            [
                "ba6310d3.77f29"
            ]
        ]
    },
    {
        "id": "ba6310d3.77f29",
        "type": "stoptimer",
        "z": "753f1f86.f884c",
        "duration": "5",
        "units": "Minute",
        "payloadtype": "num",
        "payloadval": "0",
        "name": "Timer: 5 minutes",
        "x": 790,
        "y": 140,
        "wires": [
            [
                "669d87bd.cc3848"
            ],
            [
                "d707082d.6e0d28"
            ]
        ],
        "outputLabels": [
            "Loop",
            "Stop"
        ]
    },
    {
        "id": "d707082d.6e0d28",
        "type": "api-call-service",
        "z": "753f1f86.f884c",
        "name": "Turn Off Kitchen Ceiling",
        "server": "b39d51c7.0e2ba",
        "service_domain": "switch",
        "service": "turn_off",
        "data": "{\"entity_id\":\"switch.kitchen_ceiling\"}",
        "mergecontext": "",
        "output_location": "",
        "output_location_type": "none",
        "mustacheAltTags": false,
        "x": 1070,
        "y": 140,
        "wires": [
            []
        ]
    },
    {
        "id": "82a6f1e0.03185",
        "type": "switch",
        "z": "753f1f86.f884c",
        "name": "Sun down?",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "down",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "up",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 530,
        "y": 200,
        "wires": [
            [
                "669d87bd.cc3848"
            ],
            [
                "88382e9c.7612f"
            ]
        ]
    },
    {
        "id": "47619826.3934a8",
        "type": "api-current-state",
        "z": "753f1f86.f884c",
        "name": "Sun Sensor",
        "server": "b39d51c7.0e2ba",
        "version": 1,
        "outputs": 1,
        "halt_if": "",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "override_topic": false,
        "entity_id": "sensor.sun_state",
        "state_type": "str",
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "data",
        "override_data": "msg",
        "blockInputOverrides": false,
        "x": 530,
        "y": 140,
        "wires": [
            [
                "82a6f1e0.03185"
            ]
        ]
    },
    {
        "id": "88382e9c.7612f",
        "type": "api-current-state",
        "z": "753f1f86.f884c",
        "name": "Check weather",
        "server": "b39d51c7.0e2ba",
        "version": 1,
        "outputs": 1,
        "halt_if": "",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "override_topic": false,
        "entity_id": "sensor.dark_sky_summary_0h",
        "state_type": "str",
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "data",
        "override_data": "msg",
        "blockInputOverrides": false,
        "x": 540,
        "y": 260,
        "wires": [
            [
                "f7f0b671.5addc8",
                "880c3ff0.01257"
            ]
        ]
    },
    {
        "id": "f7f0b671.5addc8",
        "type": "switch",
        "z": "753f1f86.f884c",
        "name": "Weather condition",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "Mostly Cloudy",
                "vt": "str"
            },
            {
                "t": "cont",
                "v": "cloudy",
                "vt": "str"
            },
            {
                "t": "cont",
                "v": "Rain",
                "vt": "str"
            },
            {
                "t": "cont",
                "v": "rain",
                "vt": "str"
            },
            {
                "t": "cont",
                "v": "Overcast",
                "vt": "str"
            },
            {
                "t": "cont",
                "v": "overcast",
                "vt": "str"
            }
        ],
        "checkall": "false",
        "repair": false,
        "outputs": 6,
        "x": 790,
        "y": 300,
        "wires": [
            [
                "669d87bd.cc3848",
                "27e0f323.be311c"
            ],
            [
                "669d87bd.cc3848",
                "27e0f323.be311c"
            ],
            [
                "669d87bd.cc3848",
                "27e0f323.be311c"
            ],
            [
                "669d87bd.cc3848",
                "27e0f323.be311c"
            ],
            [
                "669d87bd.cc3848"
            ],
            [
                "669d87bd.cc3848"
            ]
        ]
    },
    {
        "id": "880c3ff0.01257",
        "type": "debug",
        "z": "753f1f86.f884c",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "x": 770,
        "y": 380,
        "wires": []
    },
    {
        "id": "3e9f9e83.87b1e2",
        "type": "inject",
        "z": "753f1f86.f884c",
        "name": "",
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 340,
        "y": 260,
        "wires": [
            [
                "88382e9c.7612f"
            ]
        ]
    },
    {
        "id": "27e0f323.be311c",
        "type": "debug",
        "z": "753f1f86.f884c",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "x": 1030,
        "y": 280,
        "wires": []
    },
    {
        "id": "2214d719.873b58",
        "type": "debug",
        "z": "753f1f86.f884c",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "x": 530,
        "y": 100,
        "wires": []
    },
    {
        "id": "b39d51c7.0e2ba",
        "type": "server",
        "z": "",
        "name": "Hass.io",
        "legacy": false,
        "hassio": true,
        "rejectUnauthorizedCerts": true,
        "ha_boolean": "y|yes|true|on|home|open",
        "connectionDelay": true
    }
]

Thanks in advance!