node-red-contrib-power-saver 3.6.1 → 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 (107) 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 +18 -10
  5. package/docs/.vuepress/public/ads.txt +1 -0
  6. package/docs/README.md +4 -4
  7. package/docs/changelog/README.md +59 -1
  8. package/docs/contribute/README.md +8 -3
  9. package/docs/examples/README.md +2 -0
  10. package/docs/examples/example-grid-tariff-capacity-flow.json +1142 -0
  11. package/docs/examples/example-grid-tariff-capacity-part.md +988 -107
  12. package/docs/faq/README.md +1 -1
  13. package/docs/faq/best-save-viewer.md +1 -1
  14. package/docs/guide/README.md +20 -5
  15. package/docs/images/best-save-config.png +0 -0
  16. package/docs/images/combine-two-lowest-price.png +0 -0
  17. package/docs/images/example-capacity-flow.png +0 -0
  18. package/docs/images/fixed-schedule-config.png +0 -0
  19. package/docs/images/global-context-window.png +0 -0
  20. package/docs/images/lowest-price-config.png +0 -0
  21. package/docs/images/node-ps-schedule-merger.png +0 -0
  22. package/docs/images/node-ps-strategy-fixed-schedule.png +0 -0
  23. package/docs/images/ps-strategy-fixed-schedule-example.png +0 -0
  24. package/docs/images/schedule-merger-config.png +0 -0
  25. package/docs/images/schedule-merger-example-1.png +0 -0
  26. package/docs/images/vipps-plakat.png +0 -0
  27. package/docs/images/vipps-qr.png +0 -0
  28. package/docs/images/vipps-smiling-rgb-orange-pos.png +0 -0
  29. package/docs/nodes/README.md +12 -6
  30. package/docs/nodes/dynamic-commands.md +79 -0
  31. package/docs/nodes/dynamic-config.md +76 -0
  32. package/docs/nodes/ps-elvia-add-tariff.md +4 -0
  33. package/docs/nodes/ps-general-add-tariff.md +10 -0
  34. package/docs/nodes/ps-receive-price.md +2 -1
  35. package/docs/nodes/ps-schedule-merger.md +227 -0
  36. package/docs/nodes/ps-strategy-best-save.md +46 -110
  37. package/docs/nodes/ps-strategy-fixed-schedule.md +101 -0
  38. package/docs/nodes/ps-strategy-heat-capacitor.md +6 -1
  39. package/docs/nodes/ps-strategy-lowest-price.md +51 -112
  40. package/package.json +5 -2
  41. package/src/elvia/elvia-add-tariff.html +1 -2
  42. package/src/elvia/elvia-add-tariff.js +1 -3
  43. package/src/elvia/elvia-api.js +9 -0
  44. package/src/elvia/elvia-tariff.html +1 -1
  45. package/src/general-add-tariff.html +14 -8
  46. package/src/general-add-tariff.js +0 -1
  47. package/src/handle-input.js +94 -106
  48. package/src/handle-output.js +109 -0
  49. package/src/receive-price-functions.js +3 -3
  50. package/src/schedule-merger-functions.js +98 -0
  51. package/src/schedule-merger.html +135 -0
  52. package/src/schedule-merger.js +108 -0
  53. package/src/strategy-best-save.html +38 -1
  54. package/src/strategy-best-save.js +17 -63
  55. package/src/strategy-fixed-schedule.html +339 -0
  56. package/src/strategy-fixed-schedule.js +84 -0
  57. package/src/strategy-functions.js +35 -0
  58. package/src/strategy-lowest-price.html +76 -38
  59. package/src/strategy-lowest-price.js +16 -35
  60. package/src/utils.js +75 -2
  61. package/test/commands-input-best-save.test.js +142 -0
  62. package/test/commands-input-lowest-price.test.js +149 -0
  63. package/test/commands-input-schedule-merger.test.js +128 -0
  64. package/test/data/best-save-overlap-result.json +5 -1
  65. package/test/data/best-save-result.json +4 -0
  66. package/test/data/commands-result-best-save.json +383 -0
  67. package/test/data/commands-result-lowest-price.json +340 -0
  68. package/test/data/fixed-schedule-result.json +353 -0
  69. package/test/data/lowest-price-result-cont-max-fail.json +5 -1
  70. package/test/data/lowest-price-result-cont-max.json +3 -1
  71. package/test/data/lowest-price-result-cont.json +8 -1
  72. package/test/data/lowest-price-result-missing-end.json +8 -3
  73. package/test/data/lowest-price-result-neg-cont.json +27 -0
  74. package/test/data/lowest-price-result-neg-split.json +23 -0
  75. package/test/data/lowest-price-result-split-allday.json +3 -1
  76. package/test/data/lowest-price-result-split-allday10.json +1 -0
  77. package/test/data/lowest-price-result-split-max.json +3 -1
  78. package/test/data/lowest-price-result-split.json +3 -1
  79. package/test/data/merge-schedule-data.js +238 -0
  80. package/test/data/negative-prices.json +197 -0
  81. package/test/data/nordpool-event-prices.json +96 -480
  82. package/test/data/nordpool-zero-prices.json +90 -0
  83. package/test/data/reconfigResult.js +1 -0
  84. package/test/data/result.js +1 -0
  85. package/test/data/tibber-result-end-0-24h.json +12 -2
  86. package/test/data/tibber-result-end-0.json +12 -2
  87. package/test/data/tibber-result.json +1 -0
  88. package/test/receive-price.test.js +22 -0
  89. package/test/schedule-merger-functions.test.js +101 -0
  90. package/test/schedule-merger-test-utils.js +27 -0
  91. package/test/schedule-merger.test.js +130 -0
  92. package/test/send-config-input.test.js +45 -2
  93. package/test/strategy-best-save-test-utils.js +1 -1
  94. package/test/strategy-best-save.test.js +45 -0
  95. package/test/strategy-fixed-schedule.test.js +117 -0
  96. package/test/strategy-heat-capacitor.test.js +1 -1
  97. package/test/strategy-lowest-price-functions.test.js +1 -1
  98. package/test/strategy-lowest-price-test-utils.js +31 -0
  99. package/test/strategy-lowest-price.test.js +55 -45
  100. package/test/test-utils.js +43 -36
  101. package/test/utils.test.js +13 -0
  102. package/docs/images/node-power-saver.png +0 -0
  103. package/docs/nodes/power-saver.md +0 -23
  104. package/src/power-saver.html +0 -116
  105. package/src/power-saver.js +0 -260
  106. package/test/commands-input.test.js +0 -47
  107. package/test/power-saver.test.js +0 -189
package/.eslintrc.js ADDED
@@ -0,0 +1,15 @@
1
+ module.exports = {
2
+ "env": {
3
+ "browser": true,
4
+ "commonjs": true,
5
+ "es2021": true
6
+ },
7
+ "extends": "eslint:recommended",
8
+ "overrides": [
9
+ ],
10
+ "parserOptions": {
11
+ "ecmaVersion": "latest"
12
+ },
13
+ "rules": {
14
+ }
15
+ }
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <div class="box">
3
- <div class="left">
3
+ <div v-if="paypal" class="left">
4
4
  <form action="https://www.paypal.com/donate" method="post" target="_blank">
5
5
  <input type="hidden" name="business" value="5K5SRZU27TAC8" />
6
6
  <input type="hidden" name="no_recurring" value="0" />
@@ -16,7 +16,7 @@
16
16
  />
17
17
  </form>
18
18
  </div>
19
- <div class="right">
19
+ <div v-if="patreon" class="center">
20
20
  <a
21
21
  class="patreonButton"
22
22
  href="https://www.patreon.com/bePatron?u=65948417"
@@ -25,15 +25,28 @@
25
25
  >Become a Patron!
26
26
  </a>
27
27
  </div>
28
+ <div v-if="vipps" class="right vipps-box">
29
+ <span>
30
+ <img src="../../images/vipps-smiling-rgb-orange-pos.png" height="30" />
31
+ </span>
32
+ <span class="vippsnummer">#781437 </span>
33
+ </div>
28
34
  </div>
29
35
  <div><br /></div>
30
36
  </template>
31
- <script setup></script>
37
+ <script setup>
38
+ const props = defineProps({
39
+ paypal: { type: Boolean, required: false, default: true },
40
+ patreon: { type: Boolean, required: false, default: true },
41
+ vipps: { type: Boolean, required: false, default: true },
42
+ });
43
+ </script>
32
44
 
33
45
  <style scoped>
34
46
  .box {
35
47
  display: flex;
36
48
  justify-content: space-evenly;
49
+ align-items: center;
37
50
  }
38
51
  left {
39
52
  flex: 1 1 auto;
@@ -83,4 +96,14 @@ right {
83
96
  text-decoration: none;
84
97
  cursor: pointer;
85
98
  }
99
+
100
+ .vipps-box {
101
+ display: flex;
102
+ align-items: flex-start;
103
+ }
104
+
105
+ .vippsnummer {
106
+ font-size: 1.3rem;
107
+ margin-left: 10px;
108
+ }
86
109
  </style>
@@ -0,0 +1,20 @@
1
+ <template>
2
+ <div class="box">
3
+ <div class="vipps-plakat">
4
+ <img src="../../images/vipps-plakat.png" />
5
+ </div>
6
+ </div>
7
+ </template>
8
+ <script setup></script>
9
+ <style scoped>
10
+ .box {
11
+ display: flex;
12
+ justify-content: space-evenly;
13
+ align-items: center;
14
+ }
15
+
16
+ .vipps-plakat {
17
+ display: flex;
18
+ align-items: flex-start;
19
+ }
20
+ </style>
@@ -4,7 +4,7 @@ const navbar = require("./navbar");
4
4
  module.exports = {
5
5
  lang: "en-US",
6
6
  title: "Power Saver",
7
- description: "A Node-RED note to save money on hourly changing power prices",
7
+ description: "A Node-RED node collection to save money on hourly changing power prices",
8
8
  base: "/",
9
9
  themeConfig: {
10
10
  contributors: false,
@@ -16,19 +16,16 @@ module.exports = {
16
16
  {
17
17
  text: "Nodes",
18
18
  children: [
19
- { text: "Power Saver", link: "/nodes/power-saver.md" },
20
19
  {
21
20
  text: "Strategy nodes",
22
21
  children: [
23
22
  "/nodes/ps-strategy-best-save.md",
24
23
  "/nodes/ps-strategy-lowest-price.md",
25
- {
26
- text: "ps-strategy-heat-capacitor",
27
- link: "/nodes/ps-strategy-heat-capacitor.md",
28
- },
24
+ "/nodes/ps-strategy-heat-capacitor.md",
25
+ "/nodes/ps-strategy-fixed-schedule.md",
29
26
  ],
30
27
  },
31
- { text: "Utility nodes", children: ["/nodes/ps-receive-price.md"] },
28
+ { text: "Utility nodes", children: ["/nodes/ps-receive-price.md", "/nodes/ps-schedule-merger.md"] },
32
29
  {
33
30
  text: "Grid tariff nodes",
34
31
  children: ["/nodes/ps-general-add-tariff.md", "/nodes/ps-elvia-add-tariff.md"],
@@ -36,8 +33,8 @@ module.exports = {
36
33
  ],
37
34
  },
38
35
  {
39
- text: "Data format",
40
- children: ["/nodes/strategy-input.md"],
36
+ text: "Node features",
37
+ children: ["/nodes/strategy-input.md", "/nodes/dynamic-config.md", "/nodes/dynamic-commands.md"],
41
38
  },
42
39
  ],
43
40
  "/examples/": [
@@ -50,6 +47,7 @@ module.exports = {
50
47
  "/examples/example-heat-capacitor.md",
51
48
  "/examples/example-cascade-temperature-control.md",
52
49
  "/examples/example-visualize-on-off/example-visualize-on-off.md",
50
+ "/examples/example-grid-tariff-capacity-part.md",
53
51
  ],
54
52
  },
55
53
  ],
@@ -58,7 +56,17 @@ module.exports = {
58
56
  "/changelog/": [{ text: "Changelog", children: ["/changelog/README.md"] }],
59
57
  },
60
58
  },
61
- head: [["link", { rel: "shortcut icon", type: "image/x-icon", href: "euro.png" }]],
59
+ head: [
60
+ ["link", { rel: "shortcut icon", type: "image/x-icon", href: "euro.png" }],
61
+ [
62
+ "script",
63
+ {
64
+ async: true,
65
+ crossorigin: "anonymous",
66
+ src: "https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-9857859182772006",
67
+ },
68
+ ],
69
+ ],
62
70
  plugins: [
63
71
  [
64
72
  "@vuepress/register-components",
@@ -0,0 +1 @@
1
+ google.com, pub-9857859182772006, DIRECT, f08c47fec0942fa0
package/docs/README.md CHANGED
@@ -17,10 +17,10 @@ actions:
17
17
  features:
18
18
  - title: Automatic scheduling
19
19
  details: Automatically calculate best plan and send signal to turn on and off.
20
- - title: Best Save Strategy
21
- details: Postpone power consumption when there is most to save, perfect for the water heater.
22
- - title: Lowest Price Strategy
23
- details: Turn on power when the prices are the lowest, perfect for smart charging or heating.
20
+ - title: Multiple strategies
21
+ details: Different strategies for different purposes. See Best Save, Lowest Price and Heat Capacitor.
22
+ - title: Grid Capacity Optimization
23
+ details: Automatically turn off consumption to avoid breaking capacity limits.
24
24
  - title: Add variable grid tariff
25
25
  details: Automatically add values that varies on fixed hours, or use API to get grid tariff from Elvia.
26
26
  - title: Perfect with Home Assistant
@@ -1,10 +1,68 @@
1
1
  ---
2
2
  sidebar: "auto"
3
+ sidebarDepth: 1
3
4
  ---
4
5
 
5
6
  # Change Log
6
7
 
7
- List the most significant changes, starting in version 1.0.9.
8
+ List the most significant changes.
9
+
10
+ ## 4.0.0
11
+
12
+ This is a major rewrite of some of the central code, in order to lay ground for further development and maintenance.
13
+ There are a couple of new nodes that open for many interesting use cases.
14
+ A rewrite like this may lead to changes in behavior, intended or not.
15
+ There are some breaking changes, but most users should not be affected by them.
16
+
17
+ ### New features
18
+
19
+ - New node `ps-schedule-merger` or `Schedule Merger`, used to merge schedules from multiple Best Save and/or Lowest Price nodes,
20
+ as well as the new Fixed Schedule node.
21
+ - New strategy node `ps-strategy-fixed-schedule` or `Fixed Schedule`, to set a fixed daily or weekly schedule.
22
+ The main purpose of this node is to function as a mask for other strategies when merged using the Schedule Merger,
23
+ but it can also be used alone.
24
+ - For Best Save and Lowest Price you now can configure the output value, sent on output 1 and 2 to turn on or off.
25
+ Default is true/false as before, but you can configure to send for example 1 and 0, or "on" and "off", or any
26
+ other number or string values.
27
+ - The config output on Best Save and Lowest Price (as well as the new Schedule Merger) has a new attribute: `hasChanged`.
28
+ It is set to `true` if the config just was changed by a config input message.
29
+ - You can now donate using Vipps :-)
30
+
31
+ ### Breaking changes
32
+
33
+ - The old Power Saver node has been removed, as it has been deprecated for a long time.
34
+ - The `sentOnCommand` output has been removed.
35
+ - Some bug-fixes may be regarded as breaking.
36
+ - There may be some changes to what data that is stored in the context.
37
+
38
+ ### Bug fixes
39
+
40
+ - Fix so the `If no schedule, send` config works as one should expect for the end of the schedule.
41
+ If the last scheduled switch is different from this setting, a switch to the
42
+ value set by this setting will be scheduled on the first hour after the whole schedule, normally at midnight.
43
+ The `countHours` value for this schedule will be `null`, as it is impossible to say how many hours it will last for.
44
+ - Fixed also so `If no schedule, send` works if the schedule only exists for the future. Then this value is used until the
45
+ time for the first scheduled value is reached.
46
+ - Fixed Best Save and Lowest Price so when rescheduling, for example if prices are received,
47
+ and `Send when rescheduling` is not checked,
48
+ output to output 1 or output 2 is only sent if it has not been sent before,
49
+ or if it is changed by the new schedule. This is to avoid sending output when not
50
+ necessary, that is if there is no change. Of course, if the `Send when rescheduling` is checked,
51
+ output is sent anyway.
52
+
53
+ NB! If for some reason a switch did not catch the last output, this may lead to it not being switched
54
+ until the next scheduled switch. If you get trouble with that, you can always enforce switch output
55
+ by sending the [`sendOutput` command](../nodes/dynamic-commands.html#sendoutput).
56
+
57
+ - Fix price receiver so it works when price is 0.
58
+ - Fixed bug in Lowest Price and Best Save for 0 prices.
59
+ - Improved error handling for Elvia Add Tariff.
60
+
61
+ <VippsPlakat/>
62
+
63
+ ## 3.6.2
64
+
65
+ - Fix bug in Elvia API causing Node-RED to crash when the API key was wrong. Not it shows status `Unauthorized` and survive.
8
66
 
9
67
  ## 3.6.1
10
68
 
@@ -6,11 +6,16 @@ sidebar: "auto"
6
6
 
7
7
  ## Donate
8
8
 
9
- Developing software is time consuming. This solution has taken the better part of all my free time for about 3 quarters of a year. Getting something back would make it easier to also spend future time on this.
9
+ Developing software is time consuming. This solution has taken the better part of all my free time for a couple of years now. Getting something back would make it easier to also spend future time on this.
10
10
 
11
- I am trying out Patreon and PayPals "Donate" to see if it is possible to get something back for the work I do. The software is open source, and you can use it for free, but if you feel it has value, you can support the development by donating or becoming a patron, paying a fee of your choice.
11
+ <VippsPlakat/>
12
12
 
13
- <DonateButtons></DonateButtons>
13
+ The software is open source, and you can use it for free, but if you feel it has value, you can support the development by donating or becoming a patron, paying a fee of your choice.
14
+
15
+ <br/>
16
+ <br/>
17
+
18
+ <DonateButtons/>
14
19
 
15
20
  ## Code
16
21
 
@@ -12,6 +12,8 @@
12
12
 
13
13
  [Visualize on/off, price and consumption in Lovelace](example-visualize-on-off/example-visualize-on-off)
14
14
 
15
+ [Capacity part of grid tariff](./example-grid-tariff-capacity-part)
16
+
15
17
  ## User provided examples
16
18
 
17
19
  [Output schedule to a sensor entity](./example-next-schedule-entity.md) (by Stefan)