# Trigger an alarm at a certain time off day a couple of times at a certain time interval

**URL:** <https://discourse.nodered.org/t/trigger-an-alarm-at-a-certain-time-off-day-a-couple-of-times-at-a-certain-time-interval/59966>\
**Category:** General\
**Tags:** function-node\
**Created:** [17 March 2022 05:59 UTC](https://discourse.nodered.org/t/trigger-an-alarm-at-a-certain-time-off-day-a-couple-of-times-at-a-certain-time-interval/59966 "2022-03-17T05:59:59Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![SplitSecComp](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/splitseccomp/32/39802_2.png) [@SplitSecComp](https://discourse.nodered.org/u/SplitSecComp)\
**Post date:** [17 March 2022 05:59 UTC](https://discourse.nodered.org/t/trigger-an-alarm-at-a-certain-time-off-day-a-couple-of-times-at-a-certain-time-interval/59966/1 "2022-03-17T05:59:59Z")

</div>

Hi.

I need a timer to trigger an alarm at a certain time off day a couple of times at a certain time interval. i need to be able to change the time and interval with function node or a message.

I have tried ezitmer but have been unable to change the settings with a function node. Can some one send me an example on how to change the settings in ezitmer with function node.

Or alternatively if there is a better way of doing the above mentioned that will also help.

Many thanks.

---

<div class="post-metadata">

**Author:** ![kuema](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kuema/32/6542_2.png) [@kuema](https://discourse.nodered.org/u/kuema)\
**Post date:** [17 March 2022 06:05 UTC](https://discourse.nodered.org/t/trigger-an-alarm-at-a-certain-time-off-day-a-couple-of-times-at-a-certain-time-interval/59966/2 "2022-03-17T06:05:56Z")

</div>

There are several timing nodes that allow overriding the schedule via message.

Have you tried any of these?

> **[node-red-contrib-bigtimer](https://flows.nodered.org/node/node-red-contrib-bigtimer)**
>
> The ultimate Node-Red Timer with dusk, dawn (and variations inc. sunrise, sunset, moonrise and moonset), months, days, manual override, schedule pause, random or fixed offsets, special days and much more. Using STOP now turns the output off

> **[node-red-contrib-chronos](https://flows.nodered.org/node/node-red-contrib-chronos)**
>
> Time-based Node-RED scheduling, repeating, queueing, routing, filtering and manipulating nodes

---

<div class="post-metadata">

**Author:** ![SplitSecComp](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/splitseccomp/32/39802_2.png) [@SplitSecComp](https://discourse.nodered.org/u/SplitSecComp)\
**Post date:** [17 March 2022 06:19 UTC](https://discourse.nodered.org/t/trigger-an-alarm-at-a-certain-time-off-day-a-couple-of-times-at-a-certain-time-interval/59966/3 "2022-03-17T06:19:30Z")

</div>

Hi.

I understand that. My problem is not what to use but rather how to change the settings with a function node. I have been unable to get it working.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [17 March 2022 06:24 UTC](https://discourse.nodered.org/t/trigger-an-alarm-at-a-certain-time-off-day-a-couple-of-times-at-a-certain-time-interval/59966/4 "2022-03-17T06:24:31Z")

</div>

> **[node-red-contrib-cron-plus](https://flows.nodered.org/node/node-red-contrib-cron-plus)**
>
> A flexible scheduler (cron, solar events, simple dates) node for Node-RED with full dynamic control and Timezone support

You can modify the times with messages.

---

<div class="post-metadata">

**Author:** ![mikear](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@mikear](https://discourse.nodered.org/u/mikear)\
**Post date:** [17 March 2022 07:41 UTC](https://discourse.nodered.org/t/trigger-an-alarm-at-a-certain-time-off-day-a-couple-of-times-at-a-certain-time-interval/59966/5 "2022-03-17T07:41:27Z")

</div>

Hi, I had a comparable situation, had to modify and repeat an incoming topic from an rfx-lights node.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/7/6716509fab45559c97e5d791646724fb76231a60.png)

In my function node I have the following code:

```auto
signal_repeat = 5
final_switchID="AC/0x01C7238F/1"
initial_switchID="ARC/D/15"

if (msg.topic == initial_switchID) {
    msg.topic = final_switchID
    msg.iteration = 1
    return msg;
    
} else if (msg.topic == final_switchID ) {
    if (msg.iteration<=signal_repeat) {
     msg.iteration +=1
     return msg;
   }
}

```

It defines the number of repeats as a local variable and the incoming- and outgoing topic for the rfx-devices. At first entry the rfx-topic is changed to the desired rfx-topic and the output is fired. The node outputs the signal to the rfx-device and it is also fed into a delay-node (in this example 500ms). Then the messages is forwarded into the function again, where it detects that the topic does not equal the initial topic so it just increases the iteration number and fires the msg again. This is repeated until the msg.iteration is larger than the repeat variable. Then the loop ends.

I would trigger the input with a crontab node, as the trigger needs to be fired at fixed point in time.

Not sure if this is the best and most safe solution, but it works for me.

---

<div class="post-metadata">

**Author:** ![maxwellhadley](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/maxwellhadley/32/7827_2.png) [@maxwellhadley](https://discourse.nodered.org/u/maxwellhadley)\
**Post date:** [11 April 2022 13:33 UTC](https://discourse.nodered.org/t/trigger-an-alarm-at-a-certain-time-off-day-a-couple-of-times-at-a-certain-time-interval/59966/6 "2022-04-11T13:33:35Z")

</div>

Off-topic, but do you realise you can configure the rfx-lights node to repeat the command (once) after a delay, or to repeat it (indefinitely) at regular intervals?  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/5/75eedaf89e8f829614c082fde55ae5c45e209132.png)

---

<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:** [10 June 2022 13:33 UTC](https://discourse.nodered.org/t/trigger-an-alarm-at-a-certain-time-off-day-a-couple-of-times-at-a-certain-time-interval/59966/7 "2022-06-10T13:33:57Z")

</div>

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