node-red-contrib-power-saver 3.6.2 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/.eslintrc.js +15 -0
  2. package/docs/.vuepress/components/DonateButtons.vue +26 -3
  3. package/docs/.vuepress/components/VippsPlakat.vue +20 -0
  4. package/docs/.vuepress/config.js +17 -10
  5. package/docs/.vuepress/public/ads.txt +1 -0
  6. package/docs/README.md +4 -4
  7. package/docs/changelog/README.md +55 -1
  8. package/docs/contribute/README.md +8 -3
  9. package/docs/examples/example-grid-tariff-capacity-flow.json +23 -7
  10. package/docs/examples/example-grid-tariff-capacity-part.md +657 -22
  11. package/docs/faq/README.md +1 -1
  12. package/docs/faq/best-save-viewer.md +1 -1
  13. package/docs/guide/README.md +20 -5
  14. package/docs/images/best-save-config.png +0 -0
  15. package/docs/images/combine-two-lowest-price.png +0 -0
  16. package/docs/images/fixed-schedule-config.png +0 -0
  17. package/docs/images/global-context-window.png +0 -0
  18. package/docs/images/lowest-price-config.png +0 -0
  19. package/docs/images/node-ps-schedule-merger.png +0 -0
  20. package/docs/images/node-ps-strategy-fixed-schedule.png +0 -0
  21. package/docs/images/ps-strategy-fixed-schedule-example.png +0 -0
  22. package/docs/images/schedule-merger-config.png +0 -0
  23. package/docs/images/schedule-merger-example-1.png +0 -0
  24. package/docs/images/vipps-plakat.png +0 -0
  25. package/docs/images/vipps-qr.png +0 -0
  26. package/docs/images/vipps-smiling-rgb-orange-pos.png +0 -0
  27. package/docs/nodes/README.md +12 -6
  28. package/docs/nodes/dynamic-commands.md +79 -0
  29. package/docs/nodes/dynamic-config.md +76 -0
  30. package/docs/nodes/ps-elvia-add-tariff.md +4 -0
  31. package/docs/nodes/ps-general-add-tariff.md +10 -0
  32. package/docs/nodes/ps-receive-price.md +2 -1
  33. package/docs/nodes/ps-schedule-merger.md +227 -0
  34. package/docs/nodes/ps-strategy-best-save.md +46 -110
  35. package/docs/nodes/ps-strategy-fixed-schedule.md +101 -0
  36. package/docs/nodes/ps-strategy-heat-capacitor.md +6 -1
  37. package/docs/nodes/ps-strategy-lowest-price.md +51 -112
  38. package/package.json +5 -2
  39. package/src/elvia/elvia-add-tariff.html +1 -2
  40. package/src/elvia/elvia-add-tariff.js +0 -1
  41. package/src/elvia/elvia-api.js +6 -0
  42. package/src/elvia/elvia-tariff.html +1 -1
  43. package/src/general-add-tariff.html +14 -8
  44. package/src/general-add-tariff.js +0 -1
  45. package/src/handle-input.js +94 -106
  46. package/src/handle-output.js +109 -0
  47. package/src/receive-price-functions.js +3 -3
  48. package/src/schedule-merger-functions.js +98 -0
  49. package/src/schedule-merger.html +135 -0
  50. package/src/schedule-merger.js +108 -0
  51. package/src/strategy-best-save.html +38 -1
  52. package/src/strategy-best-save.js +17 -63
  53. package/src/strategy-fixed-schedule.html +339 -0
  54. package/src/strategy-fixed-schedule.js +84 -0
  55. package/src/strategy-functions.js +35 -0
  56. package/src/strategy-lowest-price.html +76 -38
  57. package/src/strategy-lowest-price.js +16 -35
  58. package/src/utils.js +75 -2
  59. package/test/commands-input-best-save.test.js +142 -0
  60. package/test/commands-input-lowest-price.test.js +149 -0
  61. package/test/commands-input-schedule-merger.test.js +128 -0
  62. package/test/data/best-save-overlap-result.json +5 -1
  63. package/test/data/best-save-result.json +4 -0
  64. package/test/data/commands-result-best-save.json +383 -0
  65. package/test/data/commands-result-lowest-price.json +340 -0
  66. package/test/data/fixed-schedule-result.json +353 -0
  67. package/test/data/lowest-price-result-cont-max-fail.json +5 -1
  68. package/test/data/lowest-price-result-cont-max.json +3 -1
  69. package/test/data/lowest-price-result-cont.json +8 -1
  70. package/test/data/lowest-price-result-missing-end.json +8 -3
  71. package/test/data/lowest-price-result-neg-cont.json +27 -0
  72. package/test/data/lowest-price-result-neg-split.json +23 -0
  73. package/test/data/lowest-price-result-split-allday.json +3 -1
  74. package/test/data/lowest-price-result-split-allday10.json +1 -0
  75. package/test/data/lowest-price-result-split-max.json +3 -1
  76. package/test/data/lowest-price-result-split.json +3 -1
  77. package/test/data/merge-schedule-data.js +238 -0
  78. package/test/data/negative-prices.json +197 -0
  79. package/test/data/nordpool-event-prices.json +96 -480
  80. package/test/data/nordpool-zero-prices.json +90 -0
  81. package/test/data/reconfigResult.js +1 -0
  82. package/test/data/result.js +1 -0
  83. package/test/data/tibber-result-end-0-24h.json +12 -2
  84. package/test/data/tibber-result-end-0.json +12 -2
  85. package/test/data/tibber-result.json +1 -0
  86. package/test/receive-price.test.js +22 -0
  87. package/test/schedule-merger-functions.test.js +101 -0
  88. package/test/schedule-merger-test-utils.js +27 -0
  89. package/test/schedule-merger.test.js +130 -0
  90. package/test/send-config-input.test.js +45 -2
  91. package/test/strategy-best-save-test-utils.js +1 -1
  92. package/test/strategy-best-save.test.js +45 -0
  93. package/test/strategy-fixed-schedule.test.js +117 -0
  94. package/test/strategy-heat-capacitor.test.js +1 -1
  95. package/test/strategy-lowest-price-functions.test.js +1 -1
  96. package/test/strategy-lowest-price-test-utils.js +31 -0
  97. package/test/strategy-lowest-price.test.js +55 -45
  98. package/test/test-utils.js +43 -36
  99. package/test/utils.test.js +13 -0
  100. package/docs/images/node-power-saver.png +0 -0
  101. package/docs/nodes/power-saver.md +0 -23
  102. package/src/power-saver.html +0 -116
  103. package/src/power-saver.js +0 -260
  104. package/test/commands-input.test.js +0 -47
  105. package/test/power-saver.test.js +0 -189
@@ -47,4 +47,4 @@ Another alternative is to reduce the minimum saving from 0.05 to 0.001. Then the
47
47
 
48
48
  ## Can we get Legionella bacteria when turning off the water heater?
49
49
 
50
- Many people ask if there is a danger that legionella bacteria will grow and become dangerous when the temperature of the water heater is lowered. As long as the water is heated to at least 65 °C every day, or at least every week, the risk of infection is not considered significant, according to the norwegian [FHI](https://www.fhi.no/nettpub/legionellaveilederen/).
50
+ Be aware that the norwegian [FHI](https://www.fhi.no/nettpub/legionellaveilederen/) recommends that the temperature in the water heater is at least 70°C to avoid growth of legionella. At this temperature, legionalla bacteria die quickly.
@@ -55,7 +55,7 @@ If the number is black, it could be used, but only if all other criteria are sat
55
55
 
56
56
  ## Something seems wrong
57
57
 
58
- The tool is not using the same code as the node, so in case there is a bg in the node (or in the tool) the numbers may not match.
58
+ The tool is not using the same code as the node, so in case there is a bug in the node (or in the tool) the numbers may not match.
59
59
 
60
60
  <hr/>
61
61
 
@@ -9,7 +9,7 @@ sidebar: "auto"
9
9
  This is a collection of nodes for the popular [Node-RED](https://nodered.org/) that you can use to save money on variable electricity prices. Node-RED is a widely used low-code programming tool that can be used together with many smart home solutions to create automations.
10
10
 
11
11
  The solution can be used to control switches or other entities in a smart home system, and for example turn on when the price is low, and turn off when the price is high.
12
- There are different ways to calculate what hours to turn on and off, and these are implemented as **strategies nodes**. Each strategy node can be configured to fit different purposes.
12
+ There are different ways to calculate what hours to turn on and off, and these are implemented as **strategy nodes**. Each strategy node can be configured to fit different purposes.
13
13
 
14
14
  The strategies need price data to work. These can be received from different sources, for example Tibber, Nord Pool or custom sources.
15
15
 
@@ -41,7 +41,7 @@ May also be installed via npm:
41
41
 
42
42
  `npm install node-red-contrib-power-saver`
43
43
 
44
- Make sure that you upgrade now and then to get the latest version. See [changelog](CHANGELOG) for changes.
44
+ Make sure that you upgrade now and then to get the latest version. See [changelog](../changelog/README.md) for changes.
45
45
 
46
46
  ### Get price data
47
47
 
@@ -175,9 +175,9 @@ Use the outputs to control switches, thermostats or other entities to control yo
175
175
 
176
176
  The following os valid for the Best Save and Lowest Price strategies:
177
177
 
178
- **Output 1** is used to turn on. A payload with value `true` is sent every time turning on is scheduled.
178
+ **Output 1** is used to turn on. A payload with value `true` (or another configured value) is sent every time turning on is scheduled.
179
179
 
180
- **Output 2** is used to turn off. A payload with value `false` is sent every time turning off is scheduled.
180
+ **Output 2** is used to turn off. A payload with value `false` (or another configured value) is sent every time turning off is scheduled.
181
181
 
182
182
  Example using Home Assistant:
183
183
 
@@ -198,14 +198,29 @@ There are many ways you can use the output:
198
198
 
199
199
  For users of Magic Mirror and Tibber, the `ps-best-save` node can send its schedule to the MMM-Tibber module. See more details in the `ps-best-save` node documentation.
200
200
 
201
+ ### Combine schedules
202
+
203
+ With the Schedule Merger node, you can combine multiple schedules in order to get more control of the result.
204
+ You can combine the schedule output from Best Save or Lowest Price nodes using logical `OR`or `AND` algorithms.
205
+ Here is an example:
206
+
207
+ ![Schedule Merger Example](../images/schedule-merger-example-1.png)
208
+
209
+ In this example, the result of two Lowest Price nodes and one Best Save node are combined in a Schedule Merger node, resulting in one schedule. The output from the Schedule Merger node is used to control a switch.
210
+
211
+ Se the [Schedule Merger](../nodes/ps-schedule-merger.md) node for more details.
212
+
201
213
  ### More information
202
214
 
203
215
  There are more details and more information in the documentation for each [node](/nodes/) and in the [examples](/examples/).
204
216
 
205
217
  ## Migration from v2
206
218
 
207
- The `Power Saver` node from v2 is still here, and it is working exactly as before. However, it will not be further maintained, so you should replace it. You may directly replace the `Power Saver` node by two of the new nodes:
219
+ The `Power Saver` node from v2 has been removed and must be replaced.
220
+ You may directly replace the `Power Saver` node by two of the new nodes (`ps-receive-price` and `ps-strategy-best-save`):
208
221
 
209
222
  ![Migrate Power Saver](../images/migrate-best-save.png)
210
223
 
211
224
  See more details in the [documentation for the `ps-strategy-best-save`](../nodes/ps-strategy-best-save.md) node.
225
+
226
+ <VippsPlakat/>
Binary file
Binary file
Binary file
Binary file
@@ -2,12 +2,6 @@
2
2
 
3
3
  Here is an overview of the nodes, and links to detailed descriptions for eah of them.
4
4
 
5
- ## [Power Saver](./power-saver) <Badge type="warning" text="deprecated" vertical="middle" />
6
-
7
- ![Power Saver node](../images/node-power-saver.png)
8
-
9
- The old node from version 2 is still working, but should be replaced.
10
-
11
5
  ## Strategy nodes
12
6
 
13
7
  These are the nodes used to calculate and control saving.
@@ -30,6 +24,12 @@ Strategy to find the x hours with lowest price in a given period each day.
30
24
 
31
25
  A strategy for moving consumption from expensive to cheap periods utilizing climate entities and trading principles.
32
26
 
27
+ ### [ps-strategy-fixed-schedule](./ps-strategy-fixed-schedule)
28
+
29
+ ![ps-strategy-fixed-schedule](../images/node-ps-strategy-fixed-schedule.png)
30
+
31
+ A strategy for setting a fixed daily or weekly schedule.
32
+
33
33
  ## Utility nodes
34
34
 
35
35
  ### [ps-receive-price](./ps-receive-price)
@@ -38,6 +38,12 @@ A strategy for moving consumption from expensive to cheap periods utilizing clim
38
38
 
39
39
  Node to convert different types of input data to the format used by the strategy nodes.
40
40
 
41
+ ### [ps-schedule-merger](./ps-schedule-merger)
42
+
43
+ ![ps-schedule-merger](../images/node-ps-schedule-merger.png)
44
+
45
+ Node to combine multiple schedules into one schedule.
46
+
41
47
  ## Grid tariff nodes
42
48
 
43
49
  ### [ps-general-add-tariff](./ps-general-add-tariff)
@@ -0,0 +1,79 @@
1
+ # Dynamic commands
2
+
3
+ You can dynamically send some commands to the node via its input, by using a `commands` object in the payload as described below.
4
+ This applies to the following nodes:
5
+
6
+ - Best Save
7
+ - Lowest Price
8
+ - Schedule Merger
9
+
10
+ Commands can be sent together with config or price data. You can command multiple commands in one message, but then put them all in the same commands-object.
11
+
12
+ ## Commands
13
+
14
+ ### sendSchedule
15
+
16
+ You can get the schedule sent to output 3 any time by sending a message like this to the node:
17
+
18
+ ```json
19
+ "payload": {
20
+ "commands": {
21
+ "sendSchedule": true,
22
+ }
23
+ }
24
+ ```
25
+
26
+ When you do this, the current schedule is actually recalculated based on the last received data, and then sent to output 3 the same way as when it was originally planned.
27
+
28
+ ### sendOutput
29
+
30
+ You can get the node to send the current output to output 1 or 2 any time by sending a message like this to the node:
31
+
32
+ ```json
33
+ "payload": {
34
+ "commands": {
35
+ "sendOutput": true,
36
+ }
37
+ }
38
+ ```
39
+
40
+ When you do this, the current schedule is actually recalculated based on the last received data. The current output is sent to output 1 or 2.
41
+
42
+ ### reset
43
+
44
+ You can reset data the node has saved in context by sending this message:
45
+
46
+ ```json
47
+ "payload": {
48
+ "commands": {
49
+ "reset": true,
50
+ }
51
+ }
52
+ ```
53
+
54
+ When you do this, all historical data the node has saved is deleted, including the current schedule, so the result will be
55
+ that the node shows status "No price data". When new price data is received, a schedule is calculated without considering any history.
56
+
57
+ The nodes config is not deleted, as the node depends on it to work.
58
+
59
+ ::: warning
60
+ This operation cannot be undone.
61
+
62
+ However, it is normally not a big loss, as you can just feed the node with new price data and start from scratch.
63
+ :::
64
+
65
+ ### replan
66
+
67
+ By sending this command, you can have the node read the last received prices from the context storage,
68
+ and make a plan based on those prices:
69
+
70
+ ```json
71
+ "payload": {
72
+ "commands": {
73
+ "replan": true,
74
+ }
75
+ }
76
+ ```
77
+
78
+ If the context storage is `file` you can use this to create a new schedule after a restart,
79
+ instead of fetching prices again.
@@ -0,0 +1,76 @@
1
+ # Dynamic config
2
+
3
+ It is possible to change config dynamically by sending a config message to the node.
4
+ This applies to the following nodes:
5
+
6
+ - Best Save
7
+ - Lowest Price
8
+ - Heat Capacitor
9
+ - Schedule Merger
10
+
11
+ Dynamic config is sent on the input as a message with a payload containing a `config` object and optionally a `name`.
12
+ Example:
13
+
14
+ ```json
15
+ "payload": {
16
+ "name": "Best Save",
17
+ "config": {
18
+ "maxHoursToSaveInSequence": 4,
19
+ "minSaving": 0.02
20
+ }
21
+ }
22
+ ```
23
+
24
+ See documentation for each specific node for which values that can be sent.
25
+ All the variables in the config object are optional. You should send only those you want to change.
26
+
27
+ ::: tip name
28
+ If `name` is used, it must match the nodes name in order to have effect. Normally you do not use `name`.
29
+ The main intention of `name` is for the [grid capacity example](../examples/example-grid-tariff-capacity-part.md)
30
+ to be able to override a specific strategy node.
31
+ The `name` is the exact same value as you set as name in the nodes config.
32
+ :::
33
+
34
+ ## Output values
35
+
36
+ Valid values for `outputValueForOntype` and `outputValueForOfftype` are `bool`, `num` and `str` and must correspond
37
+ with the values for `outputValueForOn` and `outputValueForOff`. Also `str` values must be enclosed by quotes, for example:
38
+ `"outputValueForOn": "myvalue"`, while `num` and `bool` values shall not, for example: `"outputValueForOn": 1`.
39
+
40
+ The config sent like this will be valid until a new config is sent the same way, or until the flow is restarted. On a restart, the original config set up in the node will be used.
41
+
42
+ When a config is sent like this, and without price data, the schedule will be replanned based on the last previously received price data. If no price data has been received, no scheduling is done.
43
+
44
+ However, you can send config and price data in the same message. Then both will be used.
45
+
46
+ ## Override
47
+
48
+ It is possible to send an override message to a strategy node (Best Save or Lowest Price) and to the Schedule Merger node.
49
+ An override message looks like this:
50
+
51
+ ```json
52
+ "payload": {
53
+ "name": "Best Save",
54
+ "config": {
55
+ "override": "off"
56
+ }
57
+ }
58
+ ```
59
+
60
+ `name` is optional and is only necessary when you send the message to multiple nodes, but want it to have effect only on
61
+ nodes with the given name.
62
+
63
+ Legal values for override are:
64
+
65
+ | Value | Function |
66
+ | -------- | ---------------------------------------------------------------------------------------- |
67
+ | `"on"` | The node will only send output `on` |
68
+ | `"off"` | The node will only send output `off` |
69
+ | `"auto"` | The node will work according to the schedule. This is the standard and the default mode. |
70
+
71
+ ## Config saved in context
72
+
73
+ The nodes config is saved in the nodes context.
74
+ If dynamic config is sent as input, this replaces the saved config.
75
+ It is the config that is saved in context that is used when calculating.
76
+ When Node-RED starts or the flow is redeployed, the config defined in the node replaces the saved config and will be used when planning.
@@ -1,3 +1,7 @@
1
+ ---
2
+ prev: ./ps-general-add-tariff.md
3
+ ---
4
+
1
5
  # ps-elvia-add-tariff
2
6
 
3
7
  ![ps-elvia-add-tariff](../images/node-ps-elvia-add-tariff.png)
@@ -1,3 +1,8 @@
1
+ ---
2
+ prev: ./ps-schedule-merger.md
3
+ next: ./ps-elvia-add-tariff.md
4
+ ---
5
+
1
6
  # ps-general-add-tariff
2
7
 
3
8
  ![ps-general-add-tariff](../images/node-ps-general-add-tariff.png)
@@ -35,6 +40,11 @@ You can have from 1 to 24 periods during the day, with different values to add f
35
40
 
36
41
  For each period, select the time of the day the value is valid from, and enter the value.
37
42
 
43
+ ::: danger Price unit
44
+ Be careful to use the correct unit when entering the price here. If the price is `28 øre` enter `0.28`.
45
+ If the price is `36 cents` enter `0.36`.
46
+ :::
47
+
38
48
  ### Days
39
49
 
40
50
  Check which days the price is valid for. For the price to be added, both the time and the day must be correct.
@@ -1,5 +1,6 @@
1
1
  ---
2
- prev: ./ps-strategy-lowest-price.md
2
+ prev: ./ps-strategy-heat-capacitor.md
3
+ next: ./ps-schedule-merger.md
3
4
  ---
4
5
 
5
6
  # ps-receive-price
@@ -0,0 +1,227 @@
1
+ ---
2
+ prev: ./ps-receive-price.md
3
+ next: ./ps-general-add-tariff.md
4
+ ---
5
+
6
+ # ps-schedule-merger
7
+
8
+ ![ps-schedule-merger](../images/node-ps-schedule-merger.png)
9
+
10
+ ## Description
11
+
12
+ This node can be used to merge schedules from multiple strategy nodes, and create one resulting schedule. It can be useful for example to have multiple lowest price nodes to cover different periods of the day. Send all schedules as input to this node and get one schedule as output. It works for schedules from Lowest Price, Best Save and Fixed Schedule.
13
+
14
+ ![Schedule Merger Example](../images/schedule-merger-example-1.png)
15
+
16
+ All incoming schedules are saved, and after a timeout, a new resulting schedule is calculated based on all incoming schedules. The timeout can be configured, and should be long enough for all preceding strategy nodes to finish their calculation. Normally all strategy nodes will receive the same set of prices at the same time, and do their calculations almost simultaneously, so all strategies can send their schedules at the same time.
17
+
18
+ The schedules that are merged must be for the exact same period and have the exact same number of hours. If only one schedule is received, it is used unchanged.
19
+
20
+ ::: warning Different period
21
+ If a schedule with prices for a different period is received, all saved schedules are deleted, and not used any more.
22
+ :::
23
+
24
+ The merge can be done using one of two functions:
25
+
26
+ - OR
27
+ - AND
28
+
29
+ ### OR
30
+
31
+ For each hour, all schedules are compared. If any of them is `on`, the hour in the resulting schedule is `on`.
32
+ Only if all schedules has the hour set to `off` will the resulting schedule have the hour `off`.
33
+
34
+ ### AND
35
+
36
+ For each hour, all schedules are compared. If any of them is `off`, the hour in the resulting schedule is `off`.
37
+ Only if all schedules has the hour set to `on` will the resulting schedule have the hour `on``.
38
+
39
+ ::: tip Combine with Fixed Schedule
40
+ Use the Fixed Schedule strategy node to create a mask for a period of the day when you want to make
41
+ sure the switch is turned on or off, and then merge the schedule from the Fixed Schedule strategy with
42
+ the schedule from for example the Lowest Price node, using the Schedule Merger node.
43
+ :::
44
+
45
+ ## Configuration
46
+
47
+ ![Schedule Merger Config](../images/schedule-merger-config.png)
48
+
49
+ | Value | Description |
50
+ | ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
51
+ | Function | Merging function, either OR or AND (see above). |
52
+ | Delay | Delay in milliseconds from a schedule is received until a new schedule is calculated. Use this so all schedules can be received before a new schedule is calculated and used. |
53
+ | Output value for on | Set what value to output on output 1 in order to turn on. Default is `boolean true`. You can also select a `number`, for example `1`, or a `string`, for example `on`, or any other value. |
54
+ | Output value for off | Set what value to output on output 2 in order to turn off. Default is `boolean false`. You can also select a `number`, for example `0`, or a `string`, for example `off`, or any other value. |
55
+ | Send when rescheduling | Check this to make sure on or off output is sent immediately after rescheduling. If unchecked, the output is sent only if it has not been sent before, or is different from the current value. |
56
+ | If no schedule, send | What to do if there is no valid schedule any more (turn on or off). This value will be sent also before there is any valid schedule, or after the last hour there is price data for. |
57
+
58
+ ### Dynamic config
59
+
60
+ The following config values can be changed dynamically:
61
+
62
+ | Name | Description |
63
+ | ---------------------------------- | -------------------------------------------------------- |
64
+ | `logicFunction` | Legal values: `"OR"`, `"AND"` |
65
+ | `schedulingDelay` | Number (milliseconds), example: `2000` |
66
+ | `outputIfNoSchedule` | Legal values: `true`, `false` |
67
+ | `sendCurrentValueWhenRescheduling` | Legal values: `true`, `false` |
68
+ | `outputValueForOn` | See description in [Dynamic Config](./dynamic-config.md) |
69
+ | `outputValueForOff` | See description in [Dynamic Config](./dynamic-config.md) |
70
+ | `outputValueForOntype` | See description in [Dynamic Config](./dynamic-config.md) |
71
+ | `outputValueForOfftype` | See description in [Dynamic Config](./dynamic-config.md) |
72
+ | `override` | Legal values: `"on"`, `"off"`, `"auto"` |
73
+
74
+ See [Dynamic Config](./dynamic-config.md) for details and how to send dynamic config.
75
+
76
+ ### Dynamic commands
77
+
78
+ You can send dynamic commands to this node, for example to make it resend output.
79
+ See [Dynamic Commands](./dynamic-commands.md) for details and how to send dynamic commands.
80
+
81
+ ## Input
82
+
83
+ Input is the same as the output from the Lowest Price node and the Best Save node, but only the `hours` array is used.
84
+
85
+ You can make your own input by supplying a payload containing an hours array. Example:
86
+
87
+ ```json
88
+ {
89
+ "hours": [
90
+ {
91
+ "price": 1.2584,
92
+ "onOff": false,
93
+ "start": "2021-09-30T00:00:00.000+02:00",
94
+ "saving": 0.2034
95
+ },
96
+ {
97
+ "price": 1.055,
98
+ "onOff": true,
99
+ "start": "2021-09-30T01:00:00.000+02:00",
100
+ "saving": null
101
+ },
102
+ {
103
+ "price": 1.2054,
104
+ "onOff": true,
105
+ "start": "2021-09-30T02:00:00.000+02:00",
106
+ "saving": null
107
+ }
108
+ ]
109
+ }
110
+ ```
111
+
112
+ ## Output
113
+
114
+ There are three outputs. You use only those you need for your purpose.
115
+
116
+ ### Output 1
117
+
118
+ A payload with the value set in config, default `true`, is sent to output 1 whenever the power / switch shall be turned on.
119
+
120
+ ### Output 2
121
+
122
+ A payload with the value set in config, default `false`, is sent to output 2 whenever the power / switch shall be turned off.
123
+
124
+ ### Output 3
125
+
126
+ When valid input is received, and the schedule is recalculated (after the timeout), the resulting schedule, as well as some other information, is sent to output 3. You can use this to see the plan and verify that it meets your expectations. You can also use it to display the schedule in any way you like.
127
+
128
+ Example of output:
129
+
130
+ ```json
131
+ {
132
+ "schedule": [
133
+ { "time": "2022-10-31T00:00:00.000+01:00", "value": true, "countHours": 5 },
134
+ { "time": "2022-10-31T05:00:00.000+01:00", "value": false, "countHours": 1 },
135
+ { "time": "2022-10-31T06:00:00.000+01:00", "value": true, "countHours": 3 },
136
+ { "time": "2022-10-31T09:00:00.000+01:00", "value": false, "countHours": 2 },
137
+ { "time": "2022-10-31T11:00:00.000+01:00", "value": true, "countHours": 21 },
138
+ { "time": "2022-11-01T08:00:00.000+01:00", "value": false, "countHours": 3 },
139
+ { "time": "2022-11-01T11:00:00.000+01:00", "value": true, "countHours": 3 },
140
+ { "time": "2022-11-01T14:00:00.000+01:00", "value": false, "countHours": 3 },
141
+ { "time": "2022-11-01T17:00:00.000+01:00", "value": true, "countHours": 7 },
142
+ { "time": "2022-11-02T00:00:00.000+01:00", "value": false, "countHours": null }
143
+ ],
144
+ "hours": [
145
+ {
146
+ "start": "2022-10-31T00:00:00.000+01:00",
147
+ "onOff": true,
148
+ "sources": {
149
+ "01e61b1bc2b094e5": {
150
+ "hour": { "start": "2022-10-31T00:00:00.000+01:00", "price": 0.5197, "onOff": false, "saving": null }
151
+ },
152
+ "7c8126f3a95f9cc0": {
153
+ "hour": { "start": "2022-10-31T00:00:00.000+01:00", "price": 0.5197, "onOff": true, "saving": null }
154
+ },
155
+ "e4ded64403d92b14": {
156
+ "hour": { "start": "2022-10-31T00:00:00.000+01:00", "price": 0.5197, "onOff": false, "saving": null }
157
+ }
158
+ },
159
+ "price": 0.5197,
160
+ "saving": null
161
+ },
162
+ {
163
+ "start": "2022-10-31T01:00:00.000+01:00",
164
+ "onOff": true,
165
+ "sources": {
166
+ "01e61b1bc2b094e5": {
167
+ "hour": { "start": "2022-10-31T01:00:00.000+01:00", "price": 0.5117, "onOff": false, "saving": null }
168
+ },
169
+ "7c8126f3a95f9cc0": {
170
+ "hour": { "start": "2022-10-31T01:00:00.000+01:00", "price": 0.5117, "onOff": true, "saving": null }
171
+ },
172
+ "e4ded64403d92b14": {
173
+ "hour": { "start": "2022-10-31T01:00:00.000+01:00", "price": 0.5117, "onOff": true, "saving": null }
174
+ }
175
+ },
176
+ "price": 0.5117,
177
+ "saving": null
178
+ },
179
+ // ...
180
+ {
181
+ "start": "2022-11-01T23:00:00.000+01:00",
182
+ "onOff": true,
183
+ "sources": {
184
+ "01e61b1bc2b094e5": {
185
+ "hour": { "start": "2022-11-01T23:00:00.000+01:00", "price": 0.2233, "onOff": true, "saving": null }
186
+ },
187
+ "7c8126f3a95f9cc0": {
188
+ "hour": { "start": "2022-11-01T23:00:00.000+01:00", "price": 0.2233, "onOff": true, "saving": null }
189
+ },
190
+ "e4ded64403d92b14": {
191
+ "hour": { "start": "2022-11-01T23:00:00.000+01:00", "price": 0.2233, "onOff": false, "saving": null }
192
+ }
193
+ },
194
+ "price": 0.2233,
195
+ "saving": null
196
+ }
197
+ ],
198
+ "source": "Schedule Merger",
199
+ "config": {
200
+ "logicFunction": "OR",
201
+ "schedulingDelay": "2000",
202
+ "outputIfNoSchedule": false,
203
+ "hasChanged": false
204
+ },
205
+ "time": "2022-10-31T21:56:51.178+01:00",
206
+ "version": "4.0.0",
207
+ "strategyNodeId": "796f2d96a83aa709",
208
+ "current": true
209
+ }
210
+ ```
211
+
212
+ The `schedule` array shows every time the switch is turned on or off. The `hours` array shows values per hour containing the price (received as input), whether that hour is on or off and the start time of the hour. The `saving` value is always `null`.
213
+
214
+ ## Usage ideas
215
+
216
+ ### Multiple Lowest Price
217
+
218
+ If you want a switch to be on for example two of the cheapest hours between 00:00 and 08:00, and then the two cheapest hours between 12:00 and 20:00, you can do this by combining the schedule from two Lowest Price nodes, one for each of the mentioned periods. Merge the two using a Schedule Merger node with the `OR` function. Make sure to send `off` if no schedule for all nodes.
219
+
220
+ ### Day-filter for strategy nodes
221
+
222
+ If you have a strategy node, for example Lowest Price or Best Save, that you want to have effect only on weekdays,
223
+ make a Fixed Schedule node with all hours on, but only valid for weekdays, then merge the two of them with
224
+ the Schedule Merger function `"AND"`. Make sure the `If no schedule, send` is set to `off` so that this will be the
225
+ values for the other days.
226
+
227
+ <VippsPlakat/>