# Trigger one hour before sunset

**URL:** <https://discourse.nodered.org/t/trigger-one-hour-before-sunset/7411>\
**Category:** General\
**Created:** [30 January 2019 22:55 UTC](https://discourse.nodered.org/t/trigger-one-hour-before-sunset/7411 "2019-01-30T22:55:21Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![rogersmj](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/rogersmj/32/712_2.png) [@rogersmj](https://discourse.nodered.org/u/rogersmj)\
**Post date:** [30 January 2019 22:55 UTC](https://discourse.nodered.org/t/trigger-one-hour-before-sunset/7411/1 "2019-01-30T22:55:21Z")

</div>

I'm trying to figure out how to have something trigger one hour before sunset. I've found Bigtimer, but it's not respecting the offset when I use "Sunset" as the trigger time. I haven't found very detailed documentation on it, everything just points back to the [blog post](https://tech.scargill.net/big-timer/) which isn't really comprehensive.

Here's how I have it setup:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/f/fa58193b1c4ca99606c6de8535df948e4bc89f84.png)

I have tested the offset by manually setting an "On Time", then using a negative On Offset (just like shown here), and it triggers just when I expect it to.

But when the On Time is set to Sunset, it seems to ignore the On Offset and just fires right at Sunset. Is there another way to do this?

---

<div class="post-metadata">

**Author:** ![craigcurtin](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@craigcurtin](https://discourse.nodered.org/u/craigcurtin)\
**Post date:** [31 January 2019 02:39 UTC](https://discourse.nodered.org/t/trigger-one-hour-before-sunset/7411/2 "2019-01-31T02:39:46Z")

</div>

YOur best bet would be to ask Peter Scargill on the blog you have referenced. He is very responsive and will point you in the right direction

regards

Craig

---

<div class="post-metadata">

**Author:** ![rgerrans](https://avatars.discourse-cdn.com/v4/letter/r/2bfe46/32.png) [@rgerrans](https://discourse.nodered.org/u/rgerrans)\
**Post date:** [31 January 2019 05:04 UTC](https://discourse.nodered.org/t/trigger-one-hour-before-sunset/7411/3 "2019-01-31T05:04:07Z")

</div>

Maybe try clearing out some of the extra fields. Here is mine which works:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/2/2ddbcea02e55e4edb5ea649bfeab0cf9f5a0d9c3.png)

You might want to setup a separate node with just Sunset and verify the off time's are same/different. I have 2 nodes below with the Evening set for Sunset and the Early Evening set 30 minutes prior (above). You can see the 30 minutes difference in the time when they will turn back on below:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/c/c9ab2816572606b5db2a71278814426df5577171.png)

---

<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:** [31 January 2019 10:21 UTC](https://discourse.nodered.org/t/trigger-one-hour-before-sunset/7411/4 "2019-01-31T10:21:17Z")

</div>

> [@rogersmj](#):
>
> But when the On Time is set to Sunset, it seems to ignore the On Offset and just fires right at Sunset. Is there another way to do this?

Another option would be to use the `node-red-contrib-schedex`

---

<div class="post-metadata">

**Author:** ![Anita](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@Anita](https://discourse.nodered.org/u/Anita)\
**Post date:** [31 January 2019 16:20 UTC](https://discourse.nodered.org/t/trigger-one-hour-before-sunset/7411/5 "2019-01-31T16:20:22Z")

</div>

[rogersmj](https://discourse.nodered.org/u/rogersmj),  
As [craigcurtin](https://discourse.nodered.org/u/craigcurtin) mentioned, contacting Peter is the best option.

If you like to go for a workaround,

 ![flow](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/2/2c40263292ec7554d088e731cfc50b09db6ee870.png) , this flow could work. 😐

-anita

---

<div class="post-metadata">

**Author:** ![rogersmj](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/rogersmj/32/712_2.png) [@rogersmj](https://discourse.nodered.org/u/rogersmj)\
**Post date:** [5 February 2019 01:46 UTC](https://discourse.nodered.org/t/trigger-one-hour-before-sunset/7411/6 "2019-02-05T01:46:32Z")

</div>

Thanks all, I'll try posting on that blog.

> [@rgerrans](#):
>
> Maybe try clearing out some of the extra fields. Here is mine which works:

Haha, I kept adding those other fields in an attempt to get it to work.

Weirdly, I can't set the on/off time 2 fields to empty, like you have. I have to choose something -- it's defaulted to 00:00. But I don't think that would make a difference here, and it's not firing at midnight.

> [@rgerrans](#):
>
> You might want to setup a separate node with just Sunset and verify the off time's are same/different.

OK I'm trying that out, but my coordinates are correct and it's firing _exactly_ at sunset right now.

---

<div class="post-metadata">

**Author:** ![rgerrans](https://avatars.discourse-cdn.com/v4/letter/r/2bfe46/32.png) [@rgerrans](https://discourse.nodered.org/u/rgerrans)\
**Post date:** [5 February 2019 04:44 UTC](https://discourse.nodered.org/t/trigger-one-hour-before-sunset/7411/7 "2019-02-05T04:44:28Z")

</div>

> [@rogersmj](#):
>
> Weirdly, I can't set the on/off time 2 fields to empty, like you have. I have to choose something -- it's defaulted to 00:00. But I don't think that would make a difference here, and it's not firing at midnight.

That's because I deployed mine long before he added the 2nd on/off time. From looking at it I suspect if the 2nd times are equal it doesn't deploy.

> [@rogersmj](#):
>
> OK I'm trying that out, but my coordinates are correct and it's firing _exactly_ at sunset right now.

Have you tried with a hard coded time? I just did a quick test of deploying a new node, using the default lat/long, setting it to an exact time in the near future, deployed, verified the time until on, then added a negative offset, deployed, and verified the time had decreased by the appropriate amount.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/a/a20b076a477ee2d4e4cf65254dd7a4e451761006.png)

Maybe also make sure your system time is set correctly on your server.

---

<div class="post-metadata">

**Author:** ![keithdw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/keithdw/32/16927_2.png) [@keithdw](https://discourse.nodered.org/u/keithdw)\
**Post date:** [11 February 2020 00:11 UTC](https://discourse.nodered.org/t/trigger-one-hour-before-sunset/7411/8 "2020-02-11T00:11:47Z")

</div>

Looking forward to a solution as I am experiencing the same issue.

---

<div class="post-metadata">

**Author:** ![janhatton](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/janhatton/32/39564_2.png) [@janhatton](https://discourse.nodered.org/u/janhatton)\
**Post date:** [31 March 2021 16:10 UTC](https://discourse.nodered.org/t/trigger-one-hour-before-sunset/7411/9 "2021-03-31T16:10:44Z")

</div>

Hi, I was having the same problem. My issue was that I was entering the offset in hours rather than minutes, so entering the number 2 rather than 120, which made practically no difference. If you look under the node when you deploy you will see the time range so you can verify the trigger points are changing when you adjust the offset without having to wait.  
Oh and remember to Deploy.
