# Timerswitch ... how to stop/forward other message based on timerswitch?

**URL:** <https://discourse.nodered.org/t/timerswitch-how-to-stop-forward-other-message-based-on-timerswitch/75419>\
**Category:** General\
**Created:** [19 February 2023 12:54 UTC](https://discourse.nodered.org/t/timerswitch-how-to-stop-forward-other-message-based-on-timerswitch/75419 "2023-02-19T12:54:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![AndKe](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andke/32/73023_2.png) [@AndKe](https://discourse.nodered.org/u/AndKe)\
**Post date:** [19 February 2023 12:54 UTC](https://discourse.nodered.org/t/timerswitch-how-to-stop-forward-other-message-based-on-timerswitch/75419/1 "2023-02-19T12:54:59Z")

</div>

I thought timwerswitch would simple stop a chain of events depending on time - no such luck.  
It's apparently not working this way - the "edit change node" is preparing a msg.payload.alarm  
..then the idea is NOT to forward it further to the siren/debug if time is outside the defined range.  
What is the proper way to do this?

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/9/997212e9b4f43a3fcd9a510deab8f13064788377.png)

```auto
[
    {
        "id": "d3759ed41626ef03",
        "type": "mqtt in",
        "z": "f6f2187d.f17ca8",
        "name": "",
        "topic": "zigbee2mqtt/Garage-door",
        "qos": "2",
        "datatype": "json",
        "broker": "f1e35a75c0e044b3",
        "nl": false,
        "rap": true,
        "rh": 0,
        "inputs": 0,
        "x": 150,
        "y": 420,
        "wires": [
            [
                "2dfcf4a934bd3411"
            ]
        ]
    },
    {
        "id": "2dfcf4a934bd3411",
        "type": "rbe",
        "z": "f6f2187d.f17ca8",
        "name": "",
        "func": "rbe",
        "gap": "",
        "start": "",
        "inout": "out",
        "septopics": true,
        "property": "payload.contact",
        "topi": "topic",
        "x": 370,
        "y": 420,
        "wires": [
            [
                "a51870e4e4a57988",
                "29c10c7b22b20fee"
            ]
        ]
    },
    {
        "id": "a51870e4e4a57988",
        "type": "debug",
        "z": "f6f2187d.f17ca8",
        "name": "debug 4",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 940,
        "y": 460,
        "wires": []
    },
    {
        "id": "beb8cc5d23e06a73",
        "type": "timerswitch",
        "z": "f6f2187d.f17ca8",
        "name": "Inhibit day",
        "ontopic": "",
        "offtopic": "",
        "onpayload": "",
        "offpayload": "",
        "disabled": false,
        "schedules": [
            {
                "on_h": "06",
                "on_m": "30",
                "on_s": "00",
                "off_h": "14",
                "off_m": "30",
                "off_s": "00",
                "valid": true
            }
        ],
        "x": 710,
        "y": 540,
        "wires": [
            [
                "a18775ac8b5754c9",
                "bfa846944a6506ec"
            ]
        ]
    },
    {
        "id": "a18775ac8b5754c9",
        "type": "debug",
        "z": "f6f2187d.f17ca8",
        "name": "debug 5",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 940,
        "y": 540,
        "wires": []
    },
    {
        "id": "bfa846944a6506ec",
        "type": "mqtt out",
        "z": "f6f2187d.f17ca8",
        "name": "",
        "topic": "zigbee2mqtt/Garage-siren/set",
        "qos": "",
        "retain": "",
        "respTopic": "",
        "contentType": "",
        "userProps": "",
        "correl": "",
        "expiry": "",
        "broker": "f1e35a75c0e044b3",
        "x": 1010,
        "y": 600,
        "wires": []
    },
    {
        "id": "ea3895bffdf0ef9a",
        "type": "inject",
        "z": "f6f2187d.f17ca8",
        "name": "",
        "props": [
            {
                "p": "payload.alarm",
                "v": "true",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "x": 490,
        "y": 600,
        "wires": [
            [
                "beb8cc5d23e06a73"
            ]
        ]
    },
    {
        "id": "29c10c7b22b20fee",
        "type": "change",
        "z": "f6f2187d.f17ca8",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload.alarm",
                "pt": "msg",
                "to": "true",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.duration",
                "pt": "msg",
                "to": "5",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 500,
        "y": 540,
        "wires": [
            [
                "beb8cc5d23e06a73"
            ]
        ],
        "info": "Based on:\nhttps://www.zigbee2mqtt.io/devices/NAS-AB02B2.html"
    },
    {
        "id": "f1e35a75c0e044b3",
        "type": "mqtt-broker",
        "name": "Garasjelys",
        "broker": "192.168.4.1",
        "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": {},
        "userProps": "",
        "sessionExpiry": ""
    }
]

```

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [19 February 2023 13:25 UTC](https://discourse.nodered.org/t/timerswitch-how-to-stop-forward-other-message-based-on-timerswitch/75419/2 "2023-02-19T13:25:02Z")

</div>

I would do this by using a node-red-simple-gate to block or allow messages through, and a node-red-contrib-cron-plus node to drive it open/closed. Or if the timer requirements are very simple then just a couple of Inject nodes.

---

<div class="post-metadata">

**Author:** ![AndKe](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andke/32/73023_2.png) [@AndKe](https://discourse.nodered.org/u/AndKe)\
**Post date:** [19 February 2023 14:30 UTC](https://discourse.nodered.org/t/timerswitch-how-to-stop-forward-other-message-based-on-timerswitch/75419/3 "2023-02-19T14:30:10Z")

</div>

> [@Colin](#):
>
> node-red-simple-gate

Thank you.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [5 March 2023 14:30 UTC](https://discourse.nodered.org/t/timerswitch-how-to-stop-forward-other-message-based-on-timerswitch/75419/4 "2023-03-05T14:30:29Z")

</div>

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