# Managing schedule of mutually exclusive scenes

**URL:** <https://discourse.nodered.org/t/managing-schedule-of-mutually-exclusive-scenes/39024>\
**Category:** General\
**Created:** [12 January 2021 20:59 UTC](https://discourse.nodered.org/t/managing-schedule-of-mutually-exclusive-scenes/39024 "2021-01-12T20:59:12Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![robcos](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/robcos/32/35278_2.png) [@robcos](https://discourse.nodered.org/u/robcos)\
**Post date:** [12 January 2021 20:59 UTC](https://discourse.nodered.org/t/managing-schedule-of-mutually-exclusive-scenes/39024/1 "2021-01-12T20:59:12Z")

</div>

Say that I have 2 _scenes_, morning and evening and I want different nodes to trigger every x minutes. For the sake of the example, the Night node triggers every 5 minutes during the morning and the Evening node triggers ever 5 minutes during the evening. No nodes should trigger in the afternoon.

One way of dealing with it is with a set of timers that trigger at the beginning and end of the morning and another that triggers at the beginning and end of the night. BigTimer does this however it is very cumbersome, especially if I have more than 2 scenes and if a scene ends at the same time that another scene starts.

Ideally I want something like [node-red-contrib-light-scheduler (node) - Node-RED](https://flows.nodered.org/node/node-red-contrib-light-scheduler) which allows me to set a schedule. This particular contrib however does not tell me the "name" of the scene so I can't distinguish between the morning and the evening without looking at the time.

Does anyone have any suggestions on how to do it nicely?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [12 January 2021 21:09 UTC](https://discourse.nodered.org/t/managing-schedule-of-mutually-exclusive-scenes/39024/2 "2021-01-12T21:09:55Z")

</div>

[Node-red-contrib-cron-plus](https://flows.nodered.org/node/node-red-contrib-cron-plus) can do everything you need. It has lots of built in examples (ctrl+I --\> examples)

A lot of folks are scared off by the Cron syntax but this node has a helper & extensive tool tips.

You can use one or multiple nodes. Each node can have 0, 1 or more schedules. You can set the topic and payload that is sent to anything you want.

And everything can be automated by input control messages. These are all documented in the built in help.

---

<div class="post-metadata">

**Author:** ![robcos](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/robcos/32/35278_2.png) [@robcos](https://discourse.nodered.org/u/robcos)\
**Post date:** [20 January 2021 17:20 UTC](https://discourse.nodered.org/t/managing-schedule-of-mutually-exclusive-scenes/39024/3 "2021-01-20T17:20:24Z")

</div>

I've given it a try but I'm not sure it does what I want (I am quite familiar with the cron syntax) in a simpler way than with BigTimer.  
What I want to be able to do is stuff like  
10:00 -\> 12:00 : Send "Morning" every minute  
12:00 -\> 16:37 : Send "Afternoon" every minute  
16:37 -\> 20:00 : Send "Afternoon" every minute

am I missing something?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [20 January 2021 17:50 UTC](https://discourse.nodered.org/t/managing-schedule-of-mutually-exclusive-scenes/39024/4 "2021-01-20T17:50:52Z")

</div>

do you really want to send a string of "Morning" every minute between 10:00 ~ 12:00?

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

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [20 January 2021 18:14 UTC](https://discourse.nodered.org/t/managing-schedule-of-mutually-exclusive-scenes/39024/5 "2021-01-20T18:14:52Z")

</div>

Alternatively, if you didnt mean fixed times (and want actual solar state from location coordinates) then you can simply poll the CRON node every minute & ask for solar state...

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

```auto
[{"id":"4a271714.8ef808","type":"cronplus","z":"a2d1264d.2189b8","name":"","outputField":"payload","timeZone":"","persistDynamic":false,"commandResponseMsgOutput":"output1","outputs":1,"options":[],"x":1700,"y":120,"wires":[["f741509.947aeb","3c05b2a6.a43e1e"]]},{"id":"560a940b.49825c","type":"cronplus","z":"a2d1264d.2189b8","name":"every-minute","outputField":"payload","timeZone":"","persistDynamic":false,"commandResponseMsgOutput":"output1","outputs":1,"options":[{"name":"min","topic":"describe","payloadType":"json","payload":"{\"command\":\"describe\",\"expressionType\":\"solar\",\"solarType\":\"all\",\"solarEvents\":\"sunrise,sunset\",\"location\":\"51.5024701136258 0.011844635009765625\"}","expressionType":"cron","expression":"0 * * * * *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"}],"x":1490,"y":120,"wires":[["4a271714.8ef808"]]},{"id":"8e87e155.6e8e5","type":"debug","z":"a2d1264d.2189b8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload.state","statusType":"msg","x":1870,"y":200,"wires":[]},{"id":"f741509.947aeb","type":"function","z":"a2d1264d.2189b8","name":"morning? afternoon? night?","func":"var solarState = msg.payload.result.solarState;\nmsg.payload = { };\nif(solarState.day && solarState.direction == \"fall\") {\n msg.payload.state = \"afternoon\";\n} else if (solarState.eveningTwilight) {\n msg.payload.state = \"evening\";\n} else if (solarState.night) {\n msg.payload.state = \"night\";\n} else {\n msg.payload.state = \"morning\";\n}\nmsg.payload.details = solarState;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1540,"y":200,"wires":[["8e87e155.6e8e5"]]},{"id":"3c05b2a6.a43e1e","type":"debug","z":"a2d1264d.2189b8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1850,"y":120,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![robcos](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/robcos/32/35278_2.png) [@robcos](https://discourse.nodered.org/u/robcos)\
**Post date:** [20 January 2021 19:54 UTC](https://discourse.nodered.org/t/managing-schedule-of-mutually-exclusive-scenes/39024/6 "2021-01-20T19:54:17Z")

</div>

I was just making an example - I don't actually care about the mornings. I just want to be able to get the state of multiple, non overlapping events, in an easy way.

Unfortunately Cron doesn't have syntax to express non full hours intervals. Eh. 10:30 to 11:16

Imagine a UI like a thermostat but with multiple values.

 ![Screenshot_20210120-195341.png](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/7/4762cba76a053f1596f077c24e7d500b9e88e08a.png)

---

<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:** [20 January 2021 20:01 UTC](https://discourse.nodered.org/t/managing-schedule-of-mutually-exclusive-scenes/39024/7 "2021-01-20T20:01:54Z")

</div>

The simple [node-red-node-timeswitch (node) - Node-RED](https://flows.nodered.org/node/node-red-node-timeswitch) does that - I has a per minute output as well as "on the event" output. Only one timer per node instance though.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [20 January 2021 20:07 UTC](https://discourse.nodered.org/t/managing-schedule-of-mutually-exclusive-scenes/39024/8 "2021-01-20T20:07:04Z")

</div>

> [@robcos](#):
>
> Unfortunately Cron doesn't have syntax to express non full hours intervals. Eh. 10:30 to 11:16

No, it doesnt but you can add multiple schedules (either statically or dynamically via a dashboard forexample)

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

* * *

Any how, there isnt much you cant do with cron-plus (sometimes more with the addition of another node like a switch or function to act as a filter or a change to store state etc) but I hope at least I have demonstrated some possibilities.

Feel free to take or leave it 🙂

---

<div class="post-metadata">

**Author:** ![fellinga](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fellinga/32/30631_2.png) [@fellinga](https://discourse.nodered.org/u/fellinga)\
**Post date:** [20 January 2021 22:42 UTC](https://discourse.nodered.org/t/managing-schedule-of-mutually-exclusive-scenes/39024/9 "2021-01-20T22:42:05Z")

</div>

> [@robcos](#):
>
> Imagine a UI like a thermostat but with multiple values.

If you are using the node-red-dashboard then also have a look at: [node-red-contrib-ui-time-scheduler](https://discourse.nodered.org/t/announce-node-red-contrib-ui-time-scheduler/36288).

---

<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:** [21 March 2021 22:42 UTC](https://discourse.nodered.org/t/managing-schedule-of-mutually-exclusive-scenes/39024/10 "2021-03-21T22:42:09Z")

</div>

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