# How to trigger node injecting specific date

**URL:** <https://discourse.nodered.org/t/how-to-trigger-node-injecting-specific-date/8393>\
**Category:** General\
**Created:** [26 February 2019 06:52 UTC](https://discourse.nodered.org/t/how-to-trigger-node-injecting-specific-date/8393 "2019-02-26T06:52:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![msanchezt](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/msanchezt/32/6324_2.png) [@msanchezt](https://discourse.nodered.org/u/msanchezt)\
**Post date:** [26 February 2019 06:52 UTC](https://discourse.nodered.org/t/how-to-trigger-node-injecting-specific-date/8393/1 "2019-02-26T06:52:37Z")

</div>

Hi all, I have NodeRed connected with Home Assistant.

I would like to trigger an action (set\_cover\_position to specific value) 30 minutes before the sun rises.

I was thinking in getting this value from "sun.sun" entity:  
`data.event.new_state.attributes.next_rising`

And triggering the set\_cover\_position service if current dates matches that with an offset of 30 minutes, but I really don’t know how to put the pieces together to implement this flow.

Anyone can guide me in the correct direction? Thanks a lot!

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [26 February 2019 07:57 UTC](https://discourse.nodered.org/t/how-to-trigger-node-injecting-specific-date/8393/2 "2019-02-26T07:57:34Z")

</div>

one way is to have one trigger that is for the date  
and the other which is the sunrise use a join node. when the join gets both messages a message gets passed

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [26 February 2019 09:18 UTC](https://discourse.nodered.org/t/how-to-trigger-node-injecting-specific-date/8393/3 "2019-02-26T09:18:03Z")

</div>

or use something like the node-red-node-timeswitch node that will inject a 0 or 1 depending if between the hours you set (including sunrise with an offset). Then an RBE node to ensure you only get one transition (from 0 to 1 and 1 to 0)...

---

<div class="post-metadata">

**Author:** ![cflurin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cflurin/32/29_2.png) [@cflurin](https://discourse.nodered.org/u/cflurin)\
**Post date:** [26 February 2019 10:13 UTC](https://discourse.nodered.org/t/how-to-trigger-node-injecting-specific-date/8393/4 "2019-02-26T10:13:51Z")

</div>

Or use the schedex node:

![schedex-sunrise](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/2/2953ea5cc07d1ee1cfff85c5d621827ed1a14e64.png)

```auto
[{"id":"d9e2660b.bfbab8","type":"schedex","z":"7c6a9ec3.f1512","name":"","suspended":false,"lat":"51","lon":"-1.5","ontime":"sunrise","ontopic":"","onpayload":"on","onoffset":"-30","onrandomoffset":0,"offtime":"","offtopic":"","offpayload":"","offoffset":0,"offrandomoffset":0,"mon":true,"tue":true,"wed":true,"thu":true,"fri":true,"sat":true,"sun":true,"x":210,"y":700,"wires":[["50390619.ee4298"]]},{"id":"50390619.ee4298","type":"debug","z":"7c6a9ec3.f1512","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":390,"y":700,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![msanchezt](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/msanchezt/32/6324_2.png) [@msanchezt](https://discourse.nodered.org/u/msanchezt)\
**Post date:** [27 February 2019 07:46 UTC](https://discourse.nodered.org/t/how-to-trigger-node-injecting-specific-date/8393/5 "2019-02-27T07:46:10Z")

</div>

That is exactly the solution I was looking for, except for I wanted to base my automation on "sun.sun" entity from Home Assistant (not sure where is schedex getting the sun rising/setting data by latitude/longitude from).

But will use your solution as it's very easy to implement, thanks a lot.

---

<div class="post-metadata">

**Author:** ![cflurin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cflurin/32/29_2.png) [@cflurin](https://discourse.nodered.org/u/cflurin)\
**Post date:** [27 February 2019 08:10 UTC](https://discourse.nodered.org/t/how-to-trigger-node-injecting-specific-date/8393/6 "2019-02-27T08:10:04Z")

</div>

> [@msanchezt](#):
>
> not sure where is schedex getting the sun rising/setting data by latitude/longitude from

From [Suncalc](https://github.com/mourner/suncalc) (almost all NR nodes use Suncalc)
