# Automatic trigger from 0 to 12

**URL:** <https://discourse.nodered.org/t/automatic-trigger-from-0-to-12/21256>\
**Category:** General\
**Created:** [4 February 2020 12:05 UTC](https://discourse.nodered.org/t/automatic-trigger-from-0-to-12/21256 "2020-02-04T12:05:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![MKaiser96](https://avatars.discourse-cdn.com/v4/letter/m/8c91f0/32.png) [@MKaiser96](https://discourse.nodered.org/u/MKaiser96)\
**Post date:** [4 February 2020 12:05 UTC](https://discourse.nodered.org/t/automatic-trigger-from-0-to-12/21256/1 "2020-02-04T12:05:51Z")

</div>

Hi,

I have a new problem. I want to automatically trigger numbers from 0 to 12 (step size 1). I want to get the forecast from the dwdweather node. 0 means the actual weather. 1 means the weather in 1 hour. And so on. So I can get the Data for the next 12 hours. For this I need the automatic trigger.

How can I solve this?

I solved this by this way, but it isn't the best way. Maybe I want to get the Data for the next 24 hours.

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

---

<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:** [4 February 2020 13:49 UTC](https://discourse.nodered.org/t/automatic-trigger-from-0-to-12/21256/2 "2020-02-04T13:49:57Z")

</div>

You could use this in a function node

```auto
for (let i = 0; i < 13; i++) {
  node.send({payload: i})
}
return null

```

---

<div class="post-metadata">

**Author:** ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)\
**Post date:** [4 February 2020 14:54 UTC](https://discourse.nodered.org/t/automatic-trigger-from-0-to-12/21256/3 "2020-02-04T14:54:45Z")

</div>

Perhaps for readability/quick reading how it works, `i <= 12` will have the same effect here as `i < 13`. Doesn’t change the functionality a thing, but sometimes it’s quicker to understand

---

<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:** [4 February 2020 15:47 UTC](https://discourse.nodered.org/t/automatic-trigger-from-0-to-12/21256/4 "2020-02-04T15:47:21Z")

</div>

> [@afelix](#):
>
> sometimes it’s quicker to understand

It's a matter of personal preference I think. I find `<` easier to grasp, but other brains may well prefer `<=`. If stepping through an array or string using the length you have to use the `<` which may be why I tend in that direction. Also if starting at zero then using `<` the number to use is the number of times you want it to go through the loop.

---

<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:** [4 April 2020 15:47 UTC](https://discourse.nodered.org/t/automatic-trigger-from-0-to-12/21256/5 "2020-04-04T15:47:22Z")

</div>

Closed on 4 April 2020 15:47 UTC

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