# Best way for emulating time of use electricity rates?

**URL:** <https://discourse.nodered.org/t/best-way-for-emulating-time-of-use-electricity-rates/46062>\
**Category:** General\
**Created:** [22 May 2021 00:49 UTC](https://discourse.nodered.org/t/best-way-for-emulating-time-of-use-electricity-rates/46062 "2021-05-22T00:49:31Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![poldim](https://avatars.discourse-cdn.com/v4/letter/p/aca169/32.png) [@poldim](https://discourse.nodered.org/u/poldim)\
**Post date:** [22 May 2021 00:49 UTC](https://discourse.nodered.org/t/best-way-for-emulating-time-of-use-electricity-rates/46062/1 "2021-05-22T00:49:31Z")

</div>

I'm trying to set a variable in home assistant of which electricity rate I'm currently on. My utility has 3 different rates (peak, partial peak, and off peak) which vary based on day of the week (weekday vs weekend) and season of the year. Additionally, holidays are entirely off-peak.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/8/e83544a984ed89ae1750825499fef2c24955e3a3.png)

I imagine it can be done with a function block, but as I'm not a programmer, I'd like to try to do it with existing blocks and maybe some extra ones that can be installed on the pallet.

My thoughts are to have several inject nodes that fire at the appropriate change times. First I want to check if its a holiday, then check season, day of week, and time and finally send an output with the correct rate.

Does anyone have any recommendations where to begin?

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [22 May 2021 07:23 UTC](https://discourse.nodered.org/t/best-way-for-emulating-time-of-use-electricity-rates/46062/2 "2021-05-22T07:23:10Z")

</div>

Hi @poldim,

Some time ago I have created a custom node to create time-based profiles. One of my use cases was to generate a TOU profile. However that node has - like many of my other nodes - never seen the daylight yet...

Perhaps I can adapt it to fit your needs, because this is something I will also need myself in the near future. But _ **I hope that others can jump in to give us some ideas** _, because I assume there are many ways that we can implement this.

We could do it e.g. via _ **cron expressions** _, but there might be better ways to do it? Because it would be nice if we could configure this node dynamically from a user interface.

So please let the ideas come!!!! I will do the development part, since I have already a nearly finished node...

Bart

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [22 May 2021 08:22 UTC](https://discourse.nodered.org/t/best-way-for-emulating-time-of-use-electricity-rates/46062/3 "2021-05-22T08:22:45Z")

</div>

Btw perhaps for your use-case it id enough to use e.g. the following node from @Steve-Mcl :

> **[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

Not sure if that can help you. But if that is the case, I will continue with my time-profile node separate from this discussion...

---

<div class="post-metadata">

**Author:** ![poldim](https://avatars.discourse-cdn.com/v4/letter/p/aca169/32.png) [@poldim](https://discourse.nodered.org/u/poldim)\
**Post date:** [22 May 2021 20:12 UTC](https://discourse.nodered.org/t/best-way-for-emulating-time-of-use-electricity-rates/46062/4 "2021-05-22T20:12:36Z")

</div>

I didn't think about using cron, but this is a great great, thanks Bart!

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [22 May 2021 20:46 UTC](https://discourse.nodered.org/t/best-way-for-emulating-time-of-use-electricity-rates/46062/5 "2021-05-22T20:46:39Z")

</div>

Dmitriy,  
You are welcome!  
It would be nice if you could share the result of your experiment here, so we can all learn from it.  
And of course if you are stuck, don't hesitate to come back here.  
Although I haven't used the magnificent cron-plus node myself, others might jump in ...  
Good luck!  
Bart

---

<div class="post-metadata">

**Author:** ![greengolfer](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/greengolfer/32/28276_2.png) [@greengolfer](https://discourse.nodered.org/u/greengolfer)\
**Post date:** [23 May 2021 15:26 UTC](https://discourse.nodered.org/t/best-way-for-emulating-time-of-use-electricity-rates/46062/6 "2021-05-23T15:26:13Z")

</div>

Here is one solution using a combination of the excellent [cron-plus](https://flows.nodered.org/node/node-red-contrib-cron-plus) node, [holiday](https://flows.nodered.org/node/node-red-contrib-holiday) node and [within-time](https://flows.nodered.org/node/node-red-contrib-sun-position) node.  
As always with NR there are multiple ways to obtain the desired outcome.  
You can adjust the frequency of cron-plus.  
I put the result into a global variable.

```auto
[{"id":"14a5ab56.0b4225","type":"cronplus","z":"89990f99.a6d4e","name":"E6 - TOU","outputField":"payload","timeZone":"","persistDynamic":false,"commandResponseMsgOutput":"output1","outputs":1,"options":[{"name":"schedule1","topic":"summer","payloadType":"str","payload":"weekday","expressionType":"cron","expression":"0 */5 * * JUN-SEP MON-FRI","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"},{"name":"schedule2","topic":"winter","payloadType":"str","payload":"weekday","expressionType":"cron","expression":"0 */5 * * OCT-MAY MON-FRI","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"},{"name":"schedule3","topic":"summer","payloadType":"str","payload":"weekend","expressionType":"cron","expression":"0 */5 * * JUN-SEP SAT-SUN","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"},{"name":"schedule4","topic":"winter","payloadType":"str","payload":"weekend","expressionType":"cron","expression":"0 */5 * * OCT-MAY SAT-SUN","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"}],"x":280,"y":2960,"wires":[["70fff7d5.b829d8"]]},{"id":"70fff7d5.b829d8","type":"holiday","z":"89990f99.a6d4e","name":"USA - Louisiana - New-Orleans","country":"US","state":"la","region":"no","languages":"English","typePublic":true,"typeBank":true,"typeSchool":true,"typeObservance":false,"typeOptional":false,"weekend":"","x":510,"y":2960,"wires":[["c33bd6ec.6f5fe8"],["bdbaafd.70ecb5"]]},{"id":"c33bd6ec.6f5fe8","type":"change","z":"89990f99.a6d4e","name":"Off","rules":[{"t":"set","p":"period","pt":"global","to":"off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":2940,"wires":[[]]},{"id":"bdbaafd.70ecb5","type":"switch","z":"89990f99.a6d4e","name":"Day ?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"weekend","vt":"str"},{"t":"eq","v":"weekday","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":730,"y":2980,"wires":[["8a60c235.b69b8"],["a0a834bd.956e98"]]},{"id":"8a60c235.b69b8","type":"switch","z":"89990f99.a6d4e","name":"Season ?","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"winter","vt":"str"},{"t":"eq","v":"summer","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":880,"y":2980,"wires":[["5cfc94a9.99c6ac"],["53749e56.e637e"]]},{"id":"5cfc94a9.99c6ac","type":"change","z":"89990f99.a6d4e","name":"Off","rules":[{"t":"set","p":"period","pt":"global","to":"off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1030,"y":2960,"wires":[[]]},{"id":"53749e56.e637e","type":"within-time-switch","z":"89990f99.a6d4e","name":"17-20","nameInt":"","positionConfig":"e2e4f670.cd19a8","startTime":"17:00","startTimeType":"entered","startOffset":0,"startOffsetType":"none","startOffsetMultiplier":60000,"endTime":"20:00","endTimeType":"entered","endOffset":0,"endOffsetType":"none","endOffsetMultiplier":60000,"timeRestrictions":0,"timeRestrictionsType":"none","timeDays":"*","timeOnlyOddDays":false,"timeOnlyEvenDays":false,"timeMonths":"*","timedatestart":"","timedateend":"","propertyStart":"","propertyStartType":"none","propertyStartCompare":"true","propertyStartThreshold":"","propertyStartThresholdType":"num","startTimeAlt":"","startTimeAltType":"entered","startOffsetAlt":0,"startOffsetAltType":"none","startOffsetAltMultiplier":60000,"propertyEnd":"","propertyEndType":"none","propertyEndCompare":"true","propertyEndThreshold":"","propertyEndThresholdType":"num","endTimeAlt":"","endTimeAltType":"entered","endOffsetAlt":0,"endOffsetAltType":"none","endOffsetAltMultiplier":60000,"tsCompare":"0","x":1030,"y":3020,"wires":[["2ae7df87.8bd6c"],["f0188b13.27d378"]]},{"id":"2ae7df87.8bd6c","type":"change","z":"89990f99.a6d4e","name":"Partial","rules":[{"t":"set","p":"period","pt":"global","to":"partial","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1190,"y":3000,"wires":[[]]},{"id":"f0188b13.27d378","type":"change","z":"89990f99.a6d4e","name":"Off","rules":[{"t":"set","p":"period","pt":"global","to":"off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1190,"y":3040,"wires":[[]]},{"id":"a0a834bd.956e98","type":"switch","z":"89990f99.a6d4e","name":"Season ?","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"winter","vt":"str"},{"t":"eq","v":"summer","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":880,"y":3060,"wires":[["53749e56.e637e"],["ed2dc379.a41d3"]]},{"id":"ed2dc379.a41d3","type":"within-time-switch","z":"89990f99.a6d4e","name":"12-15","nameInt":"","positionConfig":"e2e4f670.cd19a8","startTime":"12:00","startTimeType":"entered","startOffset":0,"startOffsetType":"none","startOffsetMultiplier":60000,"endTime":"15:00","endTimeType":"entered","endOffset":0,"endOffsetType":"none","endOffsetMultiplier":60000,"timeRestrictions":0,"timeRestrictionsType":"none","timeDays":"*","timeOnlyOddDays":false,"timeOnlyEvenDays":false,"timeMonths":"*","timedatestart":"","timedateend":"","propertyStart":"","propertyStartType":"none","propertyStartCompare":"true","propertyStartThreshold":"","propertyStartThresholdType":"num","startTimeAlt":"","startTimeAltType":"entered","startOffsetAlt":0,"startOffsetAltType":"none","startOffsetAltMultiplier":60000,"propertyEnd":"","propertyEndType":"none","propertyEndCompare":"true","propertyEndThreshold":"","propertyEndThresholdType":"num","endTimeAlt":"","endTimeAltType":"entered","endOffsetAlt":0,"endOffsetAltType":"none","endOffsetAltMultiplier":60000,"tsCompare":"0","x":1030,"y":3100,"wires":[["c70a9588.5c1918"],["7e064587.d0567c"]]},{"id":"7e064587.d0567c","type":"within-time-switch","z":"89990f99.a6d4e","name":"15 - 20","nameInt":"","positionConfig":"e2e4f670.cd19a8","startTime":"15:00","startTimeType":"entered","startOffset":0,"startOffsetType":"none","startOffsetMultiplier":60000,"endTime":"20:00","endTimeType":"entered","endOffset":0,"endOffsetType":"none","endOffsetMultiplier":60000,"timeRestrictions":0,"timeRestrictionsType":"none","timeDays":"*","timeOnlyOddDays":false,"timeOnlyEvenDays":false,"timeMonths":"*","timedatestart":"","timedateend":"","propertyStart":"","propertyStartType":"none","propertyStartCompare":"true","propertyStartThreshold":"","propertyStartThresholdType":"num","startTimeAlt":"","startTimeAltType":"entered","startOffsetAlt":0,"startOffsetAltType":"none","startOffsetAltMultiplier":60000,"propertyEnd":"","propertyEndType":"none","propertyEndCompare":"true","propertyEndThreshold":"","propertyEndThresholdType":"num","endTimeAlt":"","endTimeAltType":"entered","endOffsetAlt":0,"endOffsetAltType":"none","endOffsetAltMultiplier":60000,"tsCompare":"0","x":1200,"y":3120,"wires":[["d526882b.7882a8"],["8ffbc27c.b97b7"]]},{"id":"8ffbc27c.b97b7","type":"within-time-switch","z":"89990f99.a6d4e","name":"20 - 22","nameInt":"","positionConfig":"e2e4f670.cd19a8","startTime":"20:00","startTimeType":"entered","startOffset":0,"startOffsetType":"none","startOffsetMultiplier":60000,"endTime":"22:00","endTimeType":"entered","endOffset":0,"endOffsetType":"none","endOffsetMultiplier":60000,"timeRestrictions":0,"timeRestrictionsType":"none","timeDays":"*","timeOnlyOddDays":false,"timeOnlyEvenDays":false,"timeMonths":"*","timedatestart":"","timedateend":"","propertyStart":"","propertyStartType":"none","propertyStartCompare":"true","propertyStartThreshold":"","propertyStartThresholdType":"num","startTimeAlt":"","startTimeAltType":"entered","startOffsetAlt":0,"startOffsetAltType":"none","startOffsetAltMultiplier":60000,"propertyEnd":"","propertyEndType":"none","propertyEndCompare":"true","propertyEndThreshold":"","propertyEndThresholdType":"num","endTimeAlt":"","endTimeAltType":"entered","endOffsetAlt":0,"endOffsetAltType":"none","endOffsetAltMultiplier":60000,"tsCompare":"0","x":1360,"y":3140,"wires":[["4c181e4d.8c1ca"],["9a81aebf.ae421"]]},{"id":"c70a9588.5c1918","type":"change","z":"89990f99.a6d4e","name":"Partial","rules":[{"t":"set","p":"period","pt":"global","to":"partial","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1190,"y":3080,"wires":[[]]},{"id":"d526882b.7882a8","type":"change","z":"89990f99.a6d4e","name":"Peak","rules":[{"t":"set","p":"period","pt":"global","to":"peak","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1350,"y":3100,"wires":[[]]},{"id":"4c181e4d.8c1ca","type":"change","z":"89990f99.a6d4e","name":"Partial","rules":[{"t":"set","p":"period","pt":"global","to":"partial","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1510,"y":3120,"wires":[[]]},{"id":"9a81aebf.ae421","type":"change","z":"89990f99.a6d4e","name":"Off","rules":[{"t":"set","p":"period","pt":"global","to":"off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1510,"y":3160,"wires":[[]]},{"id":"e2e4f670.cd19a8","type":"position-config","name":"NewOrleans","isValide":"true","longitude":"0","latitude":"0","angleType":"deg","timeZoneOffset":"99","timeZoneDST":"0","stateTimeFormat":"3","stateDateFormat":"12"}]

```

It looks like this:

 ![Screenshot 2021-05-23 at 18.30.03](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/b/1b733a0799000f7d28ffb65c74ff931b8717d833.png)

---

<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:** [24 May 2021 01:07 UTC](https://discourse.nodered.org/t/best-way-for-emulating-time-of-use-electricity-rates/46062/7 "2021-05-24T01:07:27Z")

</div>

I am working on exactly this at the moment as well.

We have a similar tarriff structure at the moment with something like

Summer  
M-F 7AM-4PM - Shoulder  
M-F 4PM-9PM - Peak  
M-F 9PM-7AM - Off Peak

And similar structure for the other seasons, with variations for weekends etc

The best structure i have come up with at the moment is a MultiLevel/Dimensional Array

[MonthNumber][DayofWeek][HourofDay][ApplicableTarriff]

So you would using standard nodes - be very easily able to say

MonthNumber=5  
DayOfweek=Mon  
HourOfDay=11  
ApplicableTarriff=AutumnShoulder

And then have a simple lookup table for how ever many tarriff types you have

You could then use an number of nodes (moment is the one i intend to use) to generate a lookup to the Array by doing a function to do somethhing like

(Pseudo Code)

Inject node- Timestamp -\> MomentNode \> ouput Month, DayOfWeek, Hour  
CurrentTarriff = Output of Moment node

You could then just run this every minute to output a Global variable as to what the current tarrif was and you would then look up the table with all the tarriff values toget the appropriate number

I should have something finished by the end of the week on this

Craig

---

<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:** [24 May 2021 15:19 UTC](https://discourse.nodered.org/t/best-way-for-emulating-time-of-use-electricity-rates/46062/8 "2021-05-24T15:19:07Z")

</div>

I should add here - that i found this idea better in terms of maintenance of the schedules (over doing it in something like CronPlus etc) as it should be easy to define the tables and have them initialised at each restart etc, somethink like

//Summer 1 Nov to 31 Mar  
SummerMonths = [1,2,3,11,12];

// Summer Peak 2pm - 8pm M-F  
// Peak Times (hours)  
SummerPeakHours = [14,15,16,17,18,19];  
SummerPeakDays=[Mon,Tue,Wed,Thu,Fri]

// Summer Shoulder 7AM - 2PM M-F, 8PM - 10PM, M-F, 7AM - 10PM, S-S  
SummerShoulderHours = [7,8,9,10,11,12,13,20,21];  
SummerShoulderDays=[Mon,Tue,Wed,Thu,Fri,Sat,Sun]

etc etc

Craig

---

<div class="post-metadata">

**Author:** ![greengolfer](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/greengolfer/32/28276_2.png) [@greengolfer](https://discourse.nodered.org/u/greengolfer)\
**Post date:** [24 May 2021 17:30 UTC](https://discourse.nodered.org/t/best-way-for-emulating-time-of-use-electricity-rates/46062/9 "2021-05-24T17:30:06Z")

</div>

As I said, many ways to do this. Function is clearly an option. However, the initial request was:

> [@poldim](#):
>
> I imagine it can be done with a function block, but as I'm not a programmer, I'd like to try to do it with existing blocks and maybe some extra ones that can be installed on the pallet.

Hence, the solution above.

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [24 May 2021 19:25 UTC](https://discourse.nodered.org/t/best-way-for-emulating-time-of-use-electricity-rates/46062/10 "2021-05-24T19:25:55Z")

</div>

Interesting two see two different approaches for the same problem. While the solution from @greengolfer is indeed closer that what the OP has asked, the solution from @craigcurtin might be useful info for my custom time-profile node...  
So please keep posting!

---

<div class="post-metadata">

**Author:** ![greengolfer](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/greengolfer/32/28276_2.png) [@greengolfer](https://discourse.nodered.org/u/greengolfer)\
**Post date:** [25 May 2021 06:26 UTC](https://discourse.nodered.org/t/best-way-for-emulating-time-of-use-electricity-rates/46062/11 "2021-05-25T06:26:53Z")

</div>

Challenge accepted 🙂

Here is another way without cron-plus. Maybe easier to "see" the periods:

 ![Screenshot 2021-05-25 at 09.47.27](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/8/e81245fc75efd409338e05b2b6ae7cbc8bafd1e9.png)

```auto
[{"id":"90982777.aae5b8","type":"inject","z":"89990f99.a6d4e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"120","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":230,"y":3200,"wires":[["24dae5a5.035aba"]]},{"id":"24dae5a5.035aba","type":"holiday","z":"89990f99.a6d4e","name":"USA - Louisiana - New-Orleans","country":"US","state":"la","region":"no","languages":"English","typePublic":true,"typeBank":true,"typeSchool":true,"typeObservance":false,"typeOptional":false,"weekend":"","x":490,"y":3200,"wires":[["6586584d.c6ab68"],["3c92cb0f.03cde4","ef941cc.2516be","229fbc7d.d9b054","c448faa4.011218","aec1c907.84ff88"]]},{"id":"6586584d.c6ab68","type":"change","z":"89990f99.a6d4e","name":"Off","rules":[{"t":"set","p":"period","pt":"global","to":"off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":750,"y":3200,"wires":[[]]},{"id":"3c92cb0f.03cde4","type":"within-time-switch","z":"89990f99.a6d4e","name":"Weekday - Summer - 15/20","nameInt":"","positionConfig":"e2e4f670.cd19a8","startTime":"15:00","startTimeType":"entered","startOffset":0,"startOffsetType":"none","startOffsetMultiplier":60000,"endTime":"20:00","endTimeType":"entered","endOffset":0,"endOffsetType":"none","endOffsetMultiplier":60000,"timeRestrictions":0,"timeRestrictionsType":"none","timeDays":"1,2,3,4,5","timeOnlyOddDays":false,"timeOnlyEvenDays":false,"timeMonths":"4,5,6,7","timedatestart":"","timedateend":"","propertyStart":"","propertyStartType":"none","propertyStartCompare":"true","propertyStartThreshold":"","propertyStartThresholdType":"num","startTimeAlt":"","startTimeAltType":"entered","startOffsetAlt":0,"startOffsetAltType":"none","startOffsetAltMultiplier":60000,"propertyEnd":"","propertyEndType":"none","propertyEndCompare":"true","propertyEndThreshold":"","propertyEndThresholdType":"num","endTimeAlt":"","endTimeAltType":"entered","endOffsetAlt":0,"endOffsetAltType":"none","endOffsetAltMultiplier":60000,"tsCompare":"0","x":820,"y":3300,"wires":[["1a691c1b.ceddb4"],["c77f2f26.4b669"]]},{"id":"1a691c1b.ceddb4","type":"change","z":"89990f99.a6d4e","name":"Peak","rules":[{"t":"set","p":"period","pt":"global","to":"peak","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1050,"y":3300,"wires":[[]]},{"id":"ef941cc.2516be","type":"within-time-switch","z":"89990f99.a6d4e","name":"Weekday - Summer - 12/15","nameInt":"","positionConfig":"e2e4f670.cd19a8","startTime":"12:00","startTimeType":"entered","startOffset":0,"startOffsetType":"none","startOffsetMultiplier":60000,"endTime":"15:00","endTimeType":"entered","endOffset":0,"endOffsetType":"none","endOffsetMultiplier":60000,"timeRestrictions":0,"timeRestrictionsType":"none","timeDays":"1,2,3,4,5","timeOnlyOddDays":false,"timeOnlyEvenDays":false,"timeMonths":"4,5,6,7","timedatestart":"","timedateend":"","propertyStart":"","propertyStartType":"none","propertyStartCompare":"true","propertyStartThreshold":"","propertyStartThresholdType":"num","startTimeAlt":"","startTimeAltType":"entered","startOffsetAlt":0,"startOffsetAltType":"none","startOffsetAltMultiplier":60000,"propertyEnd":"","propertyEndType":"none","propertyEndCompare":"true","propertyEndThreshold":"","propertyEndThresholdType":"num","endTimeAlt":"","endTimeAltType":"entered","endOffsetAlt":0,"endOffsetAltType":"none","endOffsetAltMultiplier":60000,"tsCompare":"0","x":820,"y":3260,"wires":[["73c35883.4119d8"],["c77f2f26.4b669"]]},{"id":"73c35883.4119d8","type":"change","z":"89990f99.a6d4e","name":"Partial","rules":[{"t":"set","p":"period","pt":"global","to":"partial","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1050,"y":3260,"wires":[[]]},{"id":"229fbc7d.d9b054","type":"within-time-switch","z":"89990f99.a6d4e","name":"Weekday - Summer - 20/22","nameInt":"","positionConfig":"e2e4f670.cd19a8","startTime":"20:00","startTimeType":"entered","startOffset":0,"startOffsetType":"none","startOffsetMultiplier":60000,"endTime":"22:00","endTimeType":"entered","endOffset":0,"endOffsetType":"none","endOffsetMultiplier":60000,"timeRestrictions":0,"timeRestrictionsType":"none","timeDays":"1,2,3,4,5","timeOnlyOddDays":false,"timeOnlyEvenDays":false,"timeMonths":"4,5,6,7","timedatestart":"","timedateend":"","propertyStart":"","propertyStartType":"none","propertyStartCompare":"true","propertyStartThreshold":"","propertyStartThresholdType":"num","startTimeAlt":"","startTimeAltType":"entered","startOffsetAlt":0,"startOffsetAltType":"none","startOffsetAltMultiplier":60000,"propertyEnd":"","propertyEndType":"none","propertyEndCompare":"true","propertyEndThreshold":"","propertyEndThresholdType":"num","endTimeAlt":"","endTimeAltType":"entered","endOffsetAlt":0,"endOffsetAltType":"none","endOffsetAltMultiplier":60000,"tsCompare":"0","x":820,"y":3340,"wires":[["ceb085ef.cb1888"],["c77f2f26.4b669"]]},{"id":"ceb085ef.cb1888","type":"change","z":"89990f99.a6d4e","name":"Partial","rules":[{"t":"set","p":"period","pt":"global","to":"partial","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1050,"y":3340,"wires":[[]]},{"id":"aec1c907.84ff88","type":"within-time-switch","z":"89990f99.a6d4e","name":"Weekday - Winter - 17/20","nameInt":"","positionConfig":"e2e4f670.cd19a8","startTime":"17:00","startTimeType":"entered","startOffset":0,"startOffsetType":"none","startOffsetMultiplier":60000,"endTime":"20:00","endTimeType":"entered","endOffset":0,"endOffsetType":"none","endOffsetMultiplier":60000,"timeRestrictions":0,"timeRestrictionsType":"none","timeDays":"1,2,3,4,5","timeOnlyOddDays":false,"timeOnlyEvenDays":false,"timeMonths":"0,1,2,3,8,9,10,11","timedatestart":"","timedateend":"","propertyStart":"","propertyStartType":"none","propertyStartCompare":"true","propertyStartThreshold":"","propertyStartThresholdType":"num","startTimeAlt":"","startTimeAltType":"entered","startOffsetAlt":0,"startOffsetAltType":"none","startOffsetAltMultiplier":60000,"propertyEnd":"","propertyEndType":"none","propertyEndCompare":"true","propertyEndThreshold":"","propertyEndThresholdType":"num","endTimeAlt":"","endTimeAltType":"entered","endOffsetAlt":0,"endOffsetAltType":"none","endOffsetAltMultiplier":60000,"tsCompare":"0","x":810,"y":3420,"wires":[["aba501a1.a40ce"],["c77f2f26.4b669"]]},{"id":"aba501a1.a40ce","type":"change","z":"89990f99.a6d4e","name":"Partial","rules":[{"t":"set","p":"period","pt":"global","to":"partial","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1050,"y":3420,"wires":[[]]},{"id":"c448faa4.011218","type":"within-time-switch","z":"89990f99.a6d4e","name":"Weekend- Summer - 17/20","nameInt":"","positionConfig":"e2e4f670.cd19a8","startTime":"17:00","startTimeType":"entered","startOffset":0,"startOffsetType":"none","startOffsetMultiplier":60000,"endTime":"20:00","endTimeType":"entered","endOffset":0,"endOffsetType":"none","endOffsetMultiplier":60000,"timeRestrictions":0,"timeRestrictionsType":"none","timeDays":"6,0","timeOnlyOddDays":false,"timeOnlyEvenDays":false,"timeMonths":"4,5,6,7","timedatestart":"","timedateend":"","propertyStart":"","propertyStartType":"none","propertyStartCompare":"true","propertyStartThreshold":"","propertyStartThresholdType":"num","startTimeAlt":"","startTimeAltType":"entered","startOffsetAlt":0,"startOffsetAltType":"none","startOffsetAltMultiplier":60000,"propertyEnd":"","propertyEndType":"none","propertyEndCompare":"true","propertyEndThreshold":"","propertyEndThresholdType":"num","endTimeAlt":"","endTimeAltType":"entered","endOffsetAlt":0,"endOffsetAltType":"none","endOffsetAltMultiplier":60000,"tsCompare":"0","x":820,"y":3380,"wires":[["a2483d8e.b16dc"],["c77f2f26.4b669"]]},{"id":"a2483d8e.b16dc","type":"change","z":"89990f99.a6d4e","name":"Partial","rules":[{"t":"set","p":"period","pt":"global","to":"partial","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1050,"y":3380,"wires":[[]]},{"id":"c77f2f26.4b669","type":"change","z":"89990f99.a6d4e","name":"Off","rules":[{"t":"set","p":"period","pt":"global","to":"off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1050,"y":3480,"wires":[[]]},{"id":"e2e4f670.cd19a8","type":"position-config","name":"NewOrleans","isValide":"true","longitude":"0","latitude":"0","angleType":"deg","timeZoneOffset":"99","timeZoneDST":"0","stateTimeFormat":"3","stateDateFormat":"12"}]

```

EDIT: One node was wrong in the initial post

---

<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:** [25 May 2021 07:24 UTC](https://discourse.nodered.org/t/best-way-for-emulating-time-of-use-electricity-rates/46062/12 "2021-05-25T07:24:02Z")

</div>

Wow that does look nice - i am going to put some time into that tonight and look for pros and cons against my first approach

Craig

---

<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:** [25 May 2021 22:02 UTC](https://discourse.nodered.org/t/best-way-for-emulating-time-of-use-electricity-rates/46062/13 "2021-05-25T22:02:02Z")

</div>

OK started on this last night for an hour or so - there are going to be a LOT of time windows with the Time between tests

But it looks like it might be doable and it is self documenting so worth pursuing - will finish it up today and see what it looks like and then post it up for comment

Craig

---

<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:** [26 May 2021 04:23 UTC](https://discourse.nodered.org/t/best-way-for-emulating-time-of-use-electricity-rates/46062/14 "2021-05-26T04:23:35Z")

</div>

OK well here is what the flow looks like

It could be a lot smaller and neater if done in a couple of function nodes with Arrays - but i think this format lends itself well to ongoing maintenance and support - i am happy with this and will use it for my solution for the next 6 months or so and see how it goes.

```auto
[{"id":"90982777.aae5b8","type":"inject","z":"55cbc3dd.d02e2c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"60","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":130,"y":80,"wires":[["24dae5a5.035aba"]]},{"id":"6586584d.c6ab68","type":"change","z":"55cbc3dd.d02e2c","name":"Public-Holiday","rules":[{"t":"set","p":"period","pt":"global","to":"Public-Holiday","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":680,"y":80,"wires":[[]]},{"id":"3c92cb0f.03cde4","type":"within-time-switch","z":"55cbc3dd.d02e2c","name":"Summer Week Day - Shoulder - Day","nameInt":"","positionConfig":"e2e4f670.cd19a8","startTime":"7:00","startTimeType":"entered","startOffset":0,"startOffsetType":"none","startOffsetMultiplier":60000,"endTime":"13:59","endTimeType":"entered","endOffset":0,"endOffsetType":"none","endOffsetMultiplier":60000,"timeDays":"1,2,3,4,5","timeOnlyOddDays":false,"timeOnlyEvenDays":false,"timeMonths":"0,1,2,10,11","timedatestart":"","timedateend":"","propertyStart":"","propertyStartType":"none","propertyStartCompare":"true","propertyStartThreshold":"","propertyStartThresholdType":"num","startTimeAlt":"","startTimeAltType":"entered","startOffsetAlt":0,"startOffsetAltType":"none","startOffsetAltMultiplier":60000,"propertyEnd":"","propertyEndType":"none","propertyEndCompare":"true","propertyEndThreshold":"","propertyEndThresholdType":"num","endTimeAlt":"","endTimeAltType":"entered","endOffsetAlt":0,"endOffsetAltType":"none","endOffsetAltMultiplier":60000,"tsCompare":"0","x":750,"y":180,"wires":[["85b5ac01.2f6ea"],[]]},{"id":"1a691c1b.ceddb4","type":"change","z":"55cbc3dd.d02e2c","name":"Peak","rules":[{"t":"set","p":"period","pt":"global","to":"peak","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1250,"y":220,"wires":[[]]},{"id":"ef941cc.2516be","type":"within-time-switch","z":"55cbc3dd.d02e2c","name":"Summer Week Day - Peak","nameInt":"","positionConfig":"e2e4f670.cd19a8","startTime":"14:00","startTimeType":"entered","startOffset":0,"startOffsetType":"none","startOffsetMultiplier":60000,"endTime":"19:59","endTimeType":"entered","endOffset":0,"endOffsetType":"none","endOffsetMultiplier":60000,"timeDays":"1,2,3,4,5","timeOnlyOddDays":false,"timeOnlyEvenDays":false,"timeMonths":"0,1,2,10,11","timedatestart":"","timedateend":"","propertyStart":"","propertyStartType":"none","propertyStartCompare":"true","propertyStartThreshold":"","propertyStartThresholdType":"num","startTimeAlt":"","startTimeAltType":"entered","startOffsetAlt":0,"startOffsetAltType":"none","startOffsetAltMultiplier":60000,"propertyEnd":"","propertyEndType":"none","propertyEndCompare":"true","propertyEndThreshold":"","propertyEndThresholdType":"num","endTimeAlt":"","endTimeAltType":"entered","endOffsetAlt":0,"endOffsetAltType":"none","endOffsetAltMultiplier":60000,"tsCompare":"0","x":720,"y":120,"wires":[["dbb15981.573258"],[]]},{"id":"73c35883.4119d8","type":"change","z":"55cbc3dd.d02e2c","name":"Shoulder","rules":[{"t":"set","p":"period","pt":"global","to":"Shoulder","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1220,"y":400,"wires":[[]]},{"id":"c448faa4.011218","type":"within-time-switch","z":"55cbc3dd.d02e2c","name":"Winter - WeekDay - Peak","nameInt":"","positionConfig":"e2e4f670.cd19a8","startTime":"17:00","startTimeType":"entered","startOffset":0,"startOffsetType":"none","startOffsetMultiplier":60000,"endTime":"20:59","endTimeType":"entered","endOffset":0,"endOffsetType":"none","endOffsetMultiplier":60000,"timeDays":"1,2,3,4,5","timeOnlyOddDays":false,"timeOnlyEvenDays":false,"timeMonths":"5,6,7","timedatestart":"","timedateend":"","propertyStart":"","propertyStartType":"none","propertyStartCompare":"true","propertyStartThreshold":"","propertyStartThresholdType":"num","startTimeAlt":"","startTimeAltType":"entered","startOffsetAlt":0,"startOffsetAltType":"none","startOffsetAltMultiplier":60000,"propertyEnd":"","propertyEndType":"none","propertyEndCompare":"true","propertyEndThreshold":"","propertyEndThresholdType":"num","endTimeAlt":"","endTimeAltType":"entered","endOffsetAlt":0,"endOffsetAltType":"none","endOffsetAltMultiplier":60000,"tsCompare":"0","x":710,"y":300,"wires":[["51ec1af9.dda374"],[]]},{"id":"c77f2f26.4b669","type":"change","z":"55cbc3dd.d02e2c","name":"Off-Peak","rules":[{"t":"set","p":"period","pt":"global","to":"Off-Peak","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1220,"y":520,"wires":[[]]},{"id":"24dae5a5.035aba","type":"holiday","z":"55cbc3dd.d02e2c","name":"Australia - Sydney","country":"AU","state":"NSW","region":"no","languages":"English","typePublic":true,"typeBank":true,"typeSchool":false,"typeObservance":false,"typeOptional":false,"weekend":"","x":350,"y":80,"wires":[["6586584d.c6ab68"],["3c92cb0f.03cde4","ef941cc.2516be","c448faa4.011218","617b5e5a.a6fc9","c73605d4.0723e8","da878d00.88c38","49f66093.939c3","a49a1ba7.dd9ed8","7cae7413.2818fc"]]},{"id":"617b5e5a.a6fc9","type":"within-time-switch","z":"55cbc3dd.d02e2c","name":"Summer Week Day - Shoulder - Night","nameInt":"","positionConfig":"e2e4f670.cd19a8","startTime":"20:00","startTimeType":"entered","startOffset":0,"startOffsetType":"none","startOffsetMultiplier":60000,"endTime":"21:59","endTimeType":"entered","endOffset":0,"endOffsetType":"none","endOffsetMultiplier":60000,"timeDays":"1,2,3,4,5","timeOnlyOddDays":false,"timeOnlyEvenDays":false,"timeMonths":"0,1,2,10,11","timedatestart":"","timedateend":"","propertyStart":"","propertyStartType":"none","propertyStartCompare":"true","propertyStartThreshold":"","propertyStartThresholdType":"num","startTimeAlt":"","startTimeAltType":"entered","startOffsetAlt":0,"startOffsetAltType":"none","startOffsetAltMultiplier":60000,"propertyEnd":"","propertyEndType":"none","propertyEndCompare":"true","propertyEndThreshold":"","propertyEndThresholdType":"num","endTimeAlt":"","endTimeAltType":"entered","endOffsetAlt":0,"endOffsetAltType":"none","endOffsetAltMultiplier":60000,"tsCompare":"0","x":750,"y":240,"wires":[["85b5ac01.2f6ea"],[]]},{"id":"a49a1ba7.dd9ed8","type":"within-time-switch","z":"55cbc3dd.d02e2c","name":"All Seasons - Off Peak","nameInt":"","positionConfig":"e2e4f670.cd19a8","startTime":"22:00","startTimeType":"entered","startOffset":0,"startOffsetType":"none","startOffsetMultiplier":60000,"endTime":"6:59","endTimeType":"entered","endOffset":0,"endOffsetType":"none","endOffsetMultiplier":60000,"timeDays":"*","timeOnlyOddDays":false,"timeOnlyEvenDays":false,"timeMonths":"*","timedatestart":"","timedateend":"","propertyStart":"","propertyStartType":"none","propertyStartCompare":"true","propertyStartThreshold":"","propertyStartThresholdType":"num","startTimeAlt":"","startTimeAltType":"entered","startOffsetAlt":0,"startOffsetAltType":"none","startOffsetAltMultiplier":60000,"propertyEnd":"","propertyEndType":"none","propertyEndCompare":"true","propertyEndThreshold":"","propertyEndThresholdType":"num","endTimeAlt":"","endTimeAltType":"entered","endOffsetAlt":0,"endOffsetAltType":"none","endOffsetAltMultiplier":60000,"tsCompare":"0","x":700,"y":540,"wires":[["c77f2f26.4b669"],[]]},{"id":"7cae7413.2818fc","type":"within-time-switch","z":"55cbc3dd.d02e2c","name":"All Seasons - Weekend Shoulder","nameInt":"","positionConfig":"e2e4f670.cd19a8","startTime":"7:00","startTimeType":"entered","startOffset":0,"startOffsetType":"none","startOffsetMultiplier":60000,"endTime":"21:59","endTimeType":"entered","endOffset":0,"endOffsetType":"none","endOffsetMultiplier":60000,"timeDays":"6,0","timeOnlyOddDays":false,"timeOnlyEvenDays":false,"timeMonths":"*","timedatestart":"","timedateend":"","propertyStart":"","propertyStartType":"none","propertyStartCompare":"true","propertyStartThreshold":"","propertyStartThresholdType":"num","startTimeAlt":"","startTimeAltType":"entered","startOffsetAlt":0,"startOffsetAltType":"none","startOffsetAltMultiplier":60000,"propertyEnd":"","propertyEndType":"none","propertyEndCompare":"true","propertyEndThreshold":"","propertyEndThresholdType":"num","endTimeAlt":"","endTimeAltType":"entered","endOffsetAlt":0,"endOffsetAltType":"none","endOffsetAltMultiplier":60000,"tsCompare":"0","x":740,"y":600,"wires":[["d33e1f06.be522"],[]]},{"id":"c73605d4.0723e8","type":"within-time-switch","z":"55cbc3dd.d02e2c","name":"Winter - WeekDay - Shoulder - Day","nameInt":"","positionConfig":"e2e4f670.cd19a8","startTime":"7:00","startTimeType":"entered","startOffset":0,"startOffsetType":"none","startOffsetMultiplier":60000,"endTime":"16:59","endTimeType":"entered","endOffset":0,"endOffsetType":"none","endOffsetMultiplier":60000,"timeDays":"1,2,3,4,5","timeOnlyOddDays":false,"timeOnlyEvenDays":false,"timeMonths":"5,6,7","timedatestart":"","timedateend":"","propertyStart":"","propertyStartType":"none","propertyStartCompare":"true","propertyStartThreshold":"","propertyStartThresholdType":"num","startTimeAlt":"","startTimeAltType":"entered","startOffsetAlt":0,"startOffsetAltType":"none","startOffsetAltMultiplier":60000,"propertyEnd":"","propertyEndType":"none","propertyEndCompare":"true","propertyEndThreshold":"","propertyEndThresholdType":"num","endTimeAlt":"","endTimeAltType":"entered","endOffsetAlt":0,"endOffsetAltType":"none","endOffsetAltMultiplier":60000,"tsCompare":"0","x":740,"y":360,"wires":[["95ab6011.772ef"],[]]},{"id":"da878d00.88c38","type":"within-time-switch","z":"55cbc3dd.d02e2c","name":"Winter - WeekDay - Shoulder - Night","nameInt":"","positionConfig":"e2e4f670.cd19a8","startTime":"21:00","startTimeType":"entered","startOffset":0,"startOffsetType":"none","startOffsetMultiplier":60000,"endTime":"21:59","endTimeType":"entered","endOffset":0,"endOffsetType":"none","endOffsetMultiplier":60000,"timeDays":"1,2,3,4,5","timeOnlyOddDays":false,"timeOnlyEvenDays":false,"timeMonths":"5,6,7","timedatestart":"","timedateend":"","propertyStart":"","propertyStartType":"none","propertyStartCompare":"true","propertyStartThreshold":"","propertyStartThresholdType":"num","startTimeAlt":"","startTimeAltType":"entered","startOffsetAlt":0,"startOffsetAltType":"none","startOffsetAltMultiplier":60000,"propertyEnd":"","propertyEndType":"none","propertyEndCompare":"true","propertyEndThreshold":"","propertyEndThresholdType":"num","endTimeAlt":"","endTimeAltType":"entered","endOffsetAlt":0,"endOffsetAltType":"none","endOffsetAltMultiplier":60000,"tsCompare":"0","x":750,"y":420,"wires":[["95ab6011.772ef"],[]]},{"id":"49f66093.939c3","type":"within-time-switch","z":"55cbc3dd.d02e2c","name":"Autumn/Spring - WeekDay - Shoulder ","nameInt":"","positionConfig":"e2e4f670.cd19a8","startTime":"7:00","startTimeType":"entered","startOffset":0,"startOffsetType":"none","startOffsetMultiplier":60000,"endTime":"21:59","endTimeType":"entered","endOffset":0,"endOffsetType":"none","endOffsetMultiplier":60000,"timeDays":"1,2,3,4,5","timeOnlyOddDays":false,"timeOnlyEvenDays":false,"timeMonths":"3,4,8,9","timedatestart":"","timedateend":"","propertyStart":"","propertyStartType":"none","propertyStartCompare":"true","propertyStartThreshold":"","propertyStartThresholdType":"num","startTimeAlt":"","startTimeAltType":"entered","startOffsetAlt":0,"startOffsetAltType":"none","startOffsetAltMultiplier":60000,"propertyEnd":"","propertyEndType":"none","propertyEndCompare":"true","propertyEndThreshold":"","propertyEndThresholdType":"num","endTimeAlt":"","endTimeAltType":"entered","endOffsetAlt":0,"endOffsetAltType":"none","endOffsetAltMultiplier":60000,"tsCompare":"0","x":750,"y":480,"wires":[["95ab6011.772ef","3adba0f9.631d8"],[]]},{"id":"49704715.a12e58","type":"link in","z":"55cbc3dd.d02e2c","name":"Peak In","links":["dbb15981.573258","51ec1af9.dda374"],"x":1115,"y":220,"wires":[["1a691c1b.ceddb4"]]},{"id":"dbb15981.573258","type":"link out","z":"55cbc3dd.d02e2c","name":"Peak Out","links":["49704715.a12e58"],"x":975,"y":140,"wires":[]},{"id":"51ec1af9.dda374","type":"link out","z":"55cbc3dd.d02e2c","name":"Peak Out","links":["49704715.a12e58"],"x":975,"y":300,"wires":[]},{"id":"85b5ac01.2f6ea","type":"link out","z":"55cbc3dd.d02e2c","name":"Shoulder Out","links":["d09fc92a.bc4a88"],"x":965,"y":220,"wires":[]},{"id":"d09fc92a.bc4a88","type":"link in","z":"55cbc3dd.d02e2c","name":"Shoulder In","links":["85b5ac01.2f6ea","95ab6011.772ef","d33e1f06.be522"],"x":1115,"y":380,"wires":[["73c35883.4119d8"]]},{"id":"95ab6011.772ef","type":"link out","z":"55cbc3dd.d02e2c","name":"Shoulder Out","links":["d09fc92a.bc4a88"],"x":975,"y":380,"wires":[]},{"id":"d33e1f06.be522","type":"link out","z":"55cbc3dd.d02e2c","name":"Shoulder Out","links":["d09fc92a.bc4a88"],"x":995,"y":600,"wires":[]},{"id":"3adba0f9.631d8","type":"debug","z":"55cbc3dd.d02e2c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1060,"y":460,"wires":[]},{"id":"e2e4f670.cd19a8","type":"position-config","name":"Sydney - Castle Cove","isValide":"true","longitude":"0","latitude":"0","angleType":"deg","timeZoneOffset":"99","timeZoneDST":"0","stateTimeFormat":"3","stateDateFormat":"12"}]

```

Thanks for the hint and the initial flow to get me moving in this direction @greengolfer

Craig

---

<div class="post-metadata">

**Author:** ![Urs-Eppenberger](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/urs-eppenberger/32/28_2.png) [@Urs-Eppenberger](https://discourse.nodered.org/u/Urs-Eppenberger)\
**Post date:** [27 May 2021 05:56 UTC](https://discourse.nodered.org/t/best-way-for-emulating-time-of-use-electricity-rates/46062/15 "2021-05-27T05:56:19Z")

</div>

Thanks to everyone for their contributions on this topic. I follow it closely, because I plan to control the charging of my Tesla with node-red. A number of the ingredients are already in place, like reading the available solar power via modbus, and the Tesla API node. The topic here gives me another one, great.

To learn from your example I copied your flow. There seem to be a number of nodes missing on my side. Would you please give me a hint on what nodes I need to install, in order to be able to test your flow?

---

<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:** [27 May 2021 06:42 UTC](https://discourse.nodered.org/t/best-way-for-emulating-time-of-use-electricity-rates/46062/16 "2021-05-27T06:42:19Z")

</div>

Sorry Yes

node-red-contrib-sunposition - gives you the within-time node which is the main one  
Also node-red-contrib-holiday - gives the one node at the top for world wide public holidays

Not sure you would need any others

Craig

---

<div class="post-metadata">

**Author:** ![poldim](https://avatars.discourse-cdn.com/v4/letter/p/aca169/32.png) [@poldim](https://discourse.nodered.org/u/poldim)\
**Post date:** [13 June 2021 01:11 UTC](https://discourse.nodered.org/t/best-way-for-emulating-time-of-use-electricity-rates/46062/17 "2021-06-13T01:11:23Z")

</div>

So I ended up with multiple solutions just to see what would be easier than the others. And then to top it off, I challenged myself to figure out how to do with a function node even though my 6-year-old cousin can out code me.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/4/54610b7446b6d64e53d916a8e892fd8acf313243.png)

I have a Rainforest gateway that's supposed to get the data over zigbee from the meter. So my initial through was to use that to trigger the tier changes. While my NR flow works, the gateway pulls worthless data that's not remotely close to accurate.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/3/c36235b831a2b07e2373417fac77bddeee5a4156.png)  
Next was using Big Timer nodes to schedule the time times. This actually works surprisingly well. If anyone hasn't used Big Timer, I highly recommend it.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/c/9c8ba77f84989177f6d9c057f0d8f95ab70926b6.png)  
Finally was my funciton block attempt. This uses three individual function blocks which progressively narrow down to a specific TOU rate. The flow is triggered by a cron plus node that is also very handy (also recommend anyone to try this working with times/schedules).

I'm currently running my function block flow to test it to, but honestly, I might go back to the Big Timer as I like how it displays the upcoming time for each of it's (or remaining time if it's active).

---

<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:** [13 June 2021 04:26 UTC](https://discourse.nodered.org/t/best-way-for-emulating-time-of-use-electricity-rates/46062/18 "2021-06-13T04:26:21Z")

</div>

Hey well done hanging in there on this one

I have been happily using the one i posted up earlier and it works well.

Would be interested in seeing the stuff you have done with Peters Bigtimer if you could post up the flow ?

Craig

---

<div class="post-metadata">

**Author:** ![poldim](https://avatars.discourse-cdn.com/v4/letter/p/aca169/32.png) [@poldim](https://discourse.nodered.org/u/poldim)\
**Post date:** [16 June 2021 16:20 UTC](https://discourse.nodered.org/t/best-way-for-emulating-time-of-use-electricity-rates/46062/19 "2021-06-16T16:20:20Z")

</div>

Sure thing:

```auto
[{"id":"c882e7b1.5e1708","type":"bigtimer","z":"22471325.87950c","outtopic":"","outpayload1":"","outpayload2":"","name":"Summer, Peak","comment":"6/1-9/30, 3 PM - 8 PM, Mon-Fri","lat":"37.79461","lon":"-122.43763","starttime":"900","endtime":"1200","starttime2":0,"endtime2":0,"startoff":0,"endoff":0,"startoff2":0,"endoff2":0,"offs":0,"outtext1":"on","outtext2":"off","timeout":1440,"sun":false,"mon":true,"tue":true,"wed":true,"thu":true,"fri":true,"sat":false,"jan":false,"feb":false,"mar":false,"apr":false,"may":true,"jun":true,"jul":true,"aug":true,"sep":true,"oct":true,"nov":false,"dec":false,"day1":0,"month1":0,"day2":0,"month2":0,"day3":0,"month3":0,"day4":0,"month4":0,"day5":0,"month5":0,"day6":0,"month6":0,"day7":0,"month7":0,"day8":0,"month8":0,"day9":0,"month9":0,"day10":0,"month10":0,"day11":0,"month11":0,"day12":0,"month12":0,"d1":0,"w1":0,"d2":0,"w2":0,"d3":0,"w3":0,"d4":0,"w4":0,"d5":0,"w5":0,"d6":0,"w6":0,"xday1":0,"xmonth1":0,"xday2":0,"xmonth2":0,"xday3":0,"xmonth3":0,"xday4":0,"xmonth4":0,"xday5":0,"xmonth5":0,"xday6":0,"xmonth6":0,"xd1":0,"xw1":0,"xd2":0,"xw2":0,"xd3":0,"xw3":0,"xd4":0,"xw4":0,"xd5":0,"xw5":0,"xd6":0,"xw6":0,"suspend":false,"random":false,"randon1":false,"randoff1":false,"randon2":false,"randoff2":false,"repeat":true,"atstart":true,"odd":false,"even":false,"x":4160,"y":1050,"wires":[[],[],["393244eb.bf586c"]]},{"id":"84ccc004.5a2c6","type":"api-call-service","z":"22471325.87950c","name":"Partial Peak (RED)","server":"c75798f0.9eb148","version":3,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.dining_room_switch_status_led","data":"{\"effect\":\"Pulse RED\"}","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":4780,"y":1200,"wires":[[]]},{"id":"393244eb.bf586c","type":"switch","z":"22471325.87950c","d":true,"name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":4520,"y":1250,"wires":[["84ccc004.5a2c6","4b1b0ea7.4d1f3"],["7d1e70a3.6edeb","9b0102e0.045aa"]]},{"id":"1bd1ad4d.431cf3","type":"bigtimer","z":"22471325.87950c","outtopic":"","outpayload1":"","outpayload2":"","name":"Summer, Partial Peak","comment":"6/1-9/30, 12 AM - 3 PM, Mon-Fri","lat":"37.79461","lon":"-122.43763","starttime":"720","endtime":"900","starttime2":0,"endtime2":0,"startoff":0,"endoff":0,"startoff2":0,"endoff2":0,"offs":0,"outtext1":"on","outtext2":"off","timeout":1440,"sun":false,"mon":true,"tue":true,"wed":true,"thu":true,"fri":true,"sat":false,"jan":false,"feb":false,"mar":false,"apr":false,"may":true,"jun":true,"jul":true,"aug":true,"sep":true,"oct":true,"nov":false,"dec":false,"day1":0,"month1":0,"day2":0,"month2":0,"day3":0,"month3":0,"day4":0,"month4":0,"day5":0,"month5":0,"day6":0,"month6":0,"day7":0,"month7":0,"day8":0,"month8":0,"day9":0,"month9":0,"day10":0,"month10":0,"day11":0,"month11":0,"day12":0,"month12":0,"d1":0,"w1":0,"d2":0,"w2":0,"d3":0,"w3":0,"d4":0,"w4":0,"d5":0,"w5":0,"d6":0,"w6":0,"xday1":0,"xmonth1":0,"xday2":0,"xmonth2":0,"xday3":0,"xmonth3":0,"xday4":0,"xmonth4":0,"xday5":0,"xmonth5":0,"xday6":0,"xmonth6":0,"xd1":0,"xw1":0,"xd2":0,"xw2":0,"xd3":0,"xw3":0,"xd4":0,"xw4":0,"xd5":0,"xw5":0,"xd6":0,"xw6":0,"suspend":false,"random":false,"randon1":false,"randoff1":false,"randon2":false,"randoff2":false,"repeat":true,"atstart":true,"odd":false,"even":false,"x":4180,"y":1170,"wires":[[],[],["ae08cb1a.285ec8"]]},{"id":"ae08cb1a.285ec8","type":"switch","z":"22471325.87950c","d":true,"name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":4520,"y":1360,"wires":[["4d16e365.f00ddc"],["7d1e70a3.6edeb"]]},{"id":"5180c5c9.6271ec","type":"bigtimer","z":"22471325.87950c","outtopic":"","outpayload1":"","outpayload2":"","name":"Summer, Partial Peak","comment":"6/1-9/30, 8-10 PM, Mon-Fri","lat":"37.79461","lon":"-122.43763","starttime":"1200","endtime":"1320","starttime2":0,"endtime2":0,"startoff":0,"endoff":0,"startoff2":0,"endoff2":0,"offs":0,"outtext1":"on","outtext2":"off","timeout":1440,"sun":false,"mon":true,"tue":true,"wed":true,"thu":true,"fri":true,"sat":false,"jan":false,"feb":false,"mar":false,"apr":false,"may":true,"jun":true,"jul":true,"aug":true,"sep":true,"oct":true,"nov":false,"dec":false,"day1":0,"month1":0,"day2":0,"month2":0,"day3":0,"month3":0,"day4":0,"month4":0,"day5":0,"month5":0,"day6":0,"month6":0,"day7":0,"month7":0,"day8":0,"month8":0,"day9":0,"month9":0,"day10":0,"month10":0,"day11":0,"month11":0,"day12":0,"month12":0,"d1":0,"w1":0,"d2":0,"w2":0,"d3":0,"w3":0,"d4":0,"w4":0,"d5":0,"w5":0,"d6":0,"w6":0,"xday1":0,"xmonth1":0,"xday2":0,"xmonth2":0,"xday3":0,"xmonth3":0,"xday4":0,"xmonth4":0,"xday5":0,"xmonth5":0,"xday6":0,"xmonth6":0,"xd1":0,"xw1":0,"xd2":0,"xw2":0,"xd3":0,"xw3":0,"xd4":0,"xw4":0,"xd5":0,"xw5":0,"xd6":0,"xw6":0,"suspend":false,"random":false,"randon1":false,"randoff1":false,"randon2":false,"randoff2":false,"repeat":true,"atstart":true,"odd":false,"even":false,"x":4180,"y":1290,"wires":[[],[],["ae08cb1a.285ec8"]]},{"id":"4d16e365.f00ddc","type":"api-call-service","z":"22471325.87950c","name":"Partial Peak (YELLOW)","server":"c75798f0.9eb148","version":3,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.dining_room_switch_status_led","data":"{\"effect\":\"Pulse YELLOW\"}","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":4790,"y":1310,"wires":[[]]},{"id":"74db62d1.25b8dc","type":"bigtimer","z":"22471325.87950c","outtopic":"","outpayload1":"","outpayload2":"","name":"Summer, Partial Peak, Weekends","comment":"6/1-9/30, 5-8 PM, Sat-Sun","lat":"37.79461","lon":"-122.43763","starttime":"1020","endtime":"1200","starttime2":0,"endtime2":0,"startoff":0,"endoff":0,"startoff2":0,"endoff2":0,"offs":0,"outtext1":"on","outtext2":"off","timeout":1440,"sun":true,"mon":false,"tue":false,"wed":false,"thu":false,"fri":false,"sat":true,"jan":false,"feb":false,"mar":false,"apr":false,"may":true,"jun":true,"jul":true,"aug":true,"sep":true,"oct":true,"nov":false,"dec":false,"day1":0,"month1":0,"day2":0,"month2":0,"day3":0,"month3":0,"day4":0,"month4":0,"day5":0,"month5":0,"day6":0,"month6":0,"day7":0,"month7":0,"day8":0,"month8":0,"day9":0,"month9":0,"day10":0,"month10":0,"day11":0,"month11":0,"day12":0,"month12":0,"d1":0,"w1":0,"d2":0,"w2":0,"d3":0,"w3":0,"d4":0,"w4":0,"d5":0,"w5":0,"d6":0,"w6":0,"xday1":0,"xmonth1":0,"xday2":0,"xmonth2":0,"xday3":0,"xmonth3":0,"xday4":0,"xmonth4":0,"xday5":0,"xmonth5":0,"xday6":0,"xmonth6":0,"xd1":0,"xw1":0,"xd2":0,"xw2":0,"xd3":0,"xw3":0,"xd4":0,"xw4":0,"xd5":0,"xw5":0,"xd6":0,"xw6":0,"suspend":false,"random":false,"randon1":false,"randoff1":false,"randon2":false,"randoff2":false,"repeat":true,"atstart":true,"odd":false,"even":false,"x":4220,"y":1400,"wires":[[],[],["ae08cb1a.285ec8"]]},{"id":"58b0fac3.a21e14","type":"bigtimer","z":"22471325.87950c","outtopic":"","outpayload1":"","outpayload2":"","name":"Winter, Partial Peak","comment":"10/1-5/31, 5-8 PM, Mon-Fri","lat":"37.79461","lon":"-122.43763","starttime":"1020","endtime":"1200","starttime2":0,"endtime2":0,"startoff":0,"endoff":0,"startoff2":0,"endoff2":0,"offs":0,"outtext1":"on","outtext2":"off","timeout":1440,"sun":false,"mon":true,"tue":true,"wed":true,"thu":true,"fri":true,"sat":false,"jan":true,"feb":true,"mar":true,"apr":true,"may":true,"jun":false,"jul":false,"aug":false,"sep":false,"oct":true,"nov":true,"dec":true,"day1":0,"month1":0,"day2":0,"month2":0,"day3":0,"month3":0,"day4":0,"month4":0,"day5":0,"month5":0,"day6":0,"month6":0,"day7":0,"month7":0,"day8":0,"month8":0,"day9":0,"month9":0,"day10":0,"month10":0,"day11":0,"month11":0,"day12":0,"month12":0,"d1":0,"w1":0,"d2":0,"w2":0,"d3":0,"w3":0,"d4":0,"w4":0,"d5":0,"w5":0,"d6":0,"w6":0,"xday1":0,"xmonth1":0,"xday2":0,"xmonth2":0,"xday3":0,"xmonth3":0,"xday4":0,"xmonth4":0,"xday5":0,"xmonth5":0,"xday6":0,"xmonth6":0,"xd1":0,"xw1":0,"xd2":0,"xw2":0,"xd3":0,"xw3":0,"xd4":0,"xw4":0,"xd5":0,"xw5":0,"xd6":0,"xw6":0,"suspend":false,"random":false,"randon1":false,"randoff1":false,"randon2":false,"randoff2":false,"repeat":true,"atstart":true,"odd":false,"even":false,"x":4170,"y":1510,"wires":[[],[],["ae08cb1a.285ec8"]]},{"id":"7d1e70a3.6edeb","type":"api-call-service","z":"22471325.87950c","name":"Off","server":"c75798f0.9eb148","version":3,"debugenabled":false,"service_domain":"light","service":"turn_off","entityId":"light.dining_room_switch_status_led","data":"","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":4740,"y":1460,"wires":[[]]},{"id":"4b1b0ea7.4d1f3","type":"link out","z":"22471325.87950c","name":"Power in peak tier","links":["6f9b3e4f.934d6"],"x":4705,"y":1160,"wires":[]},{"id":"9b0102e0.045aa","type":"link out","z":"22471325.87950c","name":"Power out of peak tier","links":["114efbb3.dc5854"],"x":4705,"y":1420,"wires":[]},{"id":"aaa7d4a2.06e1d8","type":"inject","z":"22471325.87950c","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"auto","payloadType":"str","x":3800,"y":1150,"wires":[["a782c45b.b0a618"]]},{"id":"48915e37.47d65","type":"inject","z":"22471325.87950c","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"off","payloadType":"str","x":3800,"y":1270,"wires":[["f730e5a5.45c928"]]},{"id":"1dd109aa.b516b6","type":"inject","z":"22471325.87950c","name":"auto","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"auto","payloadType":"str","x":3950,"y":1090,"wires":[["c882e7b1.5e1708"]]},{"id":"41d1fbbc.1227d4","type":"inject","z":"22471325.87950c","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"off","payloadType":"str","x":3950,"y":1050,"wires":[["c882e7b1.5e1708"]]},{"id":"30e5ecda.997bc4","type":"inject","z":"22471325.87950c","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"on","payloadType":"str","x":3950,"y":1010,"wires":[["c882e7b1.5e1708"]]},{"id":"7adb7d6a.c12994","type":"comment","z":"22471325.87950c","name":"Schedule via Big Timer","info":"# # Peak\n# # 5/1-10/31, 1 PM - 7 PM, Mon-Fri\n\n# # Partial Peak\n# # 5/1-10/31, 10 AM - 1 PM, Mon-Fri\n# # 5/1-10/31, 7-9 PM, Mon-Fri\n# # 5/1-10/31, 5-8 PM, Sat-Sun\n# # 11/1-4/30, 5-8 PM, Mon-Fri","x":3700,"y":930,"wires":[]},{"id":"a782c45b.b0a618","type":"trigger-state","z":"22471325.87950c","name":"TOU is ON, send AUTO","server":"c75798f0.9eb148","version":0,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"switch.dining_room_switch_utility_tou_notification","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"targetType":"this_entity","targetValue":"","propertyType":"previous_state","comparatorType":"is_not","comparatorValueDatatype":"str","comparatorValue":"off","propertyValue":"old_state.state"},{"targetType":"this_entity","targetValue":"","propertyType":"current_state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"off","propertyValue":"new_state.state"}],"outputs":3,"customoutputs":[{"messageType":"payload","messageValue":"off","messageValueType":"json","comparatorPropertyType":"always","comparatorType":"is","comparatorValue":"","comparatorValueDataType":"str","comparatorPropertyValue":""}],"outputinitially":false,"state_type":"str","x":3860,"y":1200,"wires":[[],[],["c882e7b1.5e1708","1bd1ad4d.431cf3","5180c5c9.6271ec","74db62d1.25b8dc","58b0fac3.a21e14"]]},{"id":"f730e5a5.45c928","type":"trigger-state","z":"22471325.87950c","name":"TOU is OFF, send OFF","server":"c75798f0.9eb148","version":0,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"switch.dining_room_switch_utility_tou_notification","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"targetType":"this_entity","targetValue":"","propertyType":"previous_state","comparatorType":"is_not","comparatorValueDatatype":"str","comparatorValue":"on","propertyValue":"old_state.state"},{"targetType":"this_entity","targetValue":"","propertyType":"current_state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"on","propertyValue":"new_state.state"}],"outputs":3,"customoutputs":[{"messageType":"payload","messageValue":"auto","messageValueType":"json","comparatorPropertyType":"always","comparatorType":"is","comparatorValue":"","comparatorValueDataType":"str","comparatorPropertyValue":""}],"outputinitially":false,"state_type":"str","x":3870,"y":1320,"wires":[[],[],["c882e7b1.5e1708","1bd1ad4d.431cf3","5180c5c9.6271ec","74db62d1.25b8dc","58b0fac3.a21e14"]]},{"id":"c75798f0.9eb148","type":"server","name":"Home Assistant Synology","version":1,"legacy":false,"addon":false,"rejectUnauthorizedCerts":false,"ha_boolean":"y|yes|true|on|ON|home|open","connectionDelay":true,"cacheJson":true}]

```

---

<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:** [16 June 2021 22:55 UTC](https://discourse.nodered.org/t/best-way-for-emulating-time-of-use-electricity-rates/46062/20 "2021-06-16T22:55:51Z")

</div>

Hey looks good - i know Peter Scargill gives a lot of love to this node so i might swing across to using it

thanks for the heads up on it

Craig

[Next page](https://discourse.nodered.org/t/best-way-for-emulating-time-of-use-electricity-rates/46062.md?page=2)
