node-red-contrib-power-saver 5.0.0-beta.0 → 5.0.0-beta.1

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.
@@ -7,7 +7,14 @@ sidebarDepth: 1
7
7
 
8
8
  List the most significant changes.
9
9
 
10
- ## 5.0.0
10
+ ## 5.0.0 beta.1
11
+
12
+ - Fix bug `dataDayBefore.minutes is not iterable`
13
+ - Update example for Lovelace Visualization. That example also has a function node that reduces the number of entries in the minutes array, that can be useful other places too.
14
+
15
+ Please note that if you have nodes using the hours array on output 3, you need to change those to use the minutes array.
16
+
17
+ ## 5.0.0 beta.0
11
18
 
12
19
  ::: danger BREAKING CHANGE
13
20
  This is a breaking change.
@@ -2,7 +2,7 @@
2
2
 
3
3
  The source of this example is made by Kim Storøy, and Otto Paulsen has written the documentation and made some changes to the files.
4
4
 
5
- ![Lovelace image](./lovelace.jpg)
5
+ ![Lovelace image](./lovelace.png)
6
6
 
7
7
  ## Introduction
8
8
 
@@ -30,7 +30,7 @@ apex_config:
30
30
  yaxis:
31
31
  - id: price
32
32
  show: true
33
- decimalsInFloat: 1
33
+ decimalsInFloat: 2
34
34
  floating: false
35
35
  forceNiceScale: true
36
36
  extend_to: end
@@ -52,15 +52,15 @@ series:
52
52
  extend_to: now
53
53
  name: Pris
54
54
  type: area
55
- curve: smooth
55
+ curve: stepline
56
56
  color: tomato
57
57
  show:
58
58
  legend_value: false
59
59
  data_generator: |
60
- return entity.attributes.hours.map((entry) => {
60
+ return entity.attributes.minutes.map((entry) => {
61
61
  return [new Date(entry.start), entry.price];
62
62
  });
63
- - entity: sensor.accumulated_consumption_current_hour_xxxx
63
+ - entity: sensor.accumulated_consumption_current_hour_xxx
64
64
  yaxis_id: usage
65
65
  type: column
66
66
  name: Forbruk
@@ -68,13 +68,14 @@ series:
68
68
  func: max
69
69
  show:
70
70
  legend_value: false
71
+ curve: smooth
71
72
  - entity: sensor.powersaver
72
73
  data_generator: |
73
- return entity.attributes.hours.map((entry) => {
74
+ return entity.attributes.minutes.map((entry) => {
74
75
  return [new Date(entry.start), entry.onOff];
75
76
  });
76
77
  yaxis_id: powersaver
77
- name: ' '
78
+ name: " "
78
79
  type: area
79
80
  color: rgb(0, 255, 0)
80
81
  opacity: 0.2
@@ -1,88 +1,74 @@
1
1
  [
2
2
  {
3
- "id": "eab799518168f5a3",
4
- "type": "ha-entity",
3
+ "id": "a6c0472f7981fad2",
4
+ "type": "function",
5
5
  "z": "d938c47f.3398f8",
6
- "name": "Info fra PS til HA",
7
- "server": "ec4a12a1.b2be9",
8
- "version": 2,
9
- "debugenabled": false,
6
+ "name": "Reduce minutes count",
7
+ "func": "const minutes = []\nlet previousHour = \"\"\nlet previousSaving = null\nmsg.payload.minutes.forEach(m => {\n const hour = m.start.substring(0, 13)\n if (hour !== previousHour || m.saving !== previousSaving) {\n minutes.push(m)\n previousHour = hour\n previousSaving = m.saving\n }\n})\n\nmsg.payload.minutes = minutes\nmsg.payload.hours = minutes\n\nreturn msg;",
10
8
  "outputs": 1,
11
- "entityType": "sensor",
12
- "config": [
13
- {
14
- "property": "name",
15
- "value": "Powersaver"
16
- },
17
- {
18
- "property": "device_class",
19
- "value": ""
20
- },
21
- {
22
- "property": "icon",
23
- "value": ""
24
- },
25
- {
26
- "property": "unit_of_measurement",
27
- "value": ""
28
- },
29
- {
30
- "property": "state_class",
31
- "value": ""
32
- },
33
- {
34
- "property": "last_reset",
35
- "value": ""
36
- }
37
- ],
38
- "state": "payload",
39
- "stateType": "str",
40
- "attributes": [
41
- {
42
- "property": "Schedule",
43
- "value": "payload.schedule",
44
- "valueType": "msg"
45
- },
46
- {
47
- "property": "Hours",
48
- "value": "payload.hours",
49
- "valueType": "msg"
50
- },
51
- {
52
- "property": "Control",
53
- "value": "payload.hours[0].onOff",
54
- "valueType": "str"
55
- },
56
- {
57
- "property": "Current",
58
- "value": "payload.current",
59
- "valueType": "str"
60
- }
61
- ],
62
- "resend": true,
63
- "outputLocation": "payload",
64
- "outputLocationType": "none",
65
- "inputOverride": "allow",
66
- "outputOnStateChange": false,
67
- "outputPayload": "",
68
- "outputPayloadType": "str",
69
- "x": 830,
70
- "y": 630,
71
- "wires": [[]]
9
+ "timeout": 0,
10
+ "noerr": 0,
11
+ "initialize": "",
12
+ "finalize": "",
13
+ "libs": [],
14
+ "x": 640,
15
+ "y": 640,
16
+ "wires": [["cad33a63f66ef72e"]]
72
17
  },
73
18
  {
74
19
  "id": "cad33a63f66ef72e",
75
20
  "type": "function",
76
21
  "z": "d938c47f.3398f8",
77
22
  "name": "Convert true/false to 1/0",
78
- "func": "msg.payload.hours.forEach(h => h.onOff = h.onOff ? \"1\" : \"0\")\nreturn msg;",
23
+ "func": "msg.payload.minutes.forEach(h => h.onOff = h.onOff ? \"1\" : \"0\")\nreturn msg;",
79
24
  "outputs": 1,
25
+ "timeout": "",
80
26
  "noerr": 0,
81
27
  "initialize": "",
82
28
  "finalize": "",
83
29
  "libs": [],
84
- "x": 550,
85
- "y": 630,
86
- "wires": [["eab799518168f5a3", "37a23d88cfc668f2"]]
30
+ "x": 880,
31
+ "y": 640,
32
+ "wires": [["4e2452b33c54d90b"]]
33
+ },
34
+ {
35
+ "id": "4e2452b33c54d90b",
36
+ "type": "ha-sensor",
37
+ "z": "d938c47f.3398f8",
38
+ "name": "Info fra PS til HA",
39
+ "entityConfig": "eab799518168f5a3",
40
+ "version": 0,
41
+ "state": "payload",
42
+ "stateType": "str",
43
+ "attributes": [
44
+ { "property": "Schedule", "value": "payload.schedule", "valueType": "msg" },
45
+ { "property": "Hours", "value": "payload.hours", "valueType": "msg" },
46
+ { "property": "Control", "value": "payload.minutes[0].onOff", "valueType": "str" },
47
+ { "property": "Current", "value": "payload.current", "valueType": "str" },
48
+ { "property": "Minutes", "value": "payload.minutes", "valueType": "msg" }
49
+ ],
50
+ "inputOverride": "allow",
51
+ "outputProperties": [],
52
+ "x": 1100,
53
+ "y": 640,
54
+ "wires": [[]]
55
+ },
56
+ {
57
+ "id": "eab799518168f5a3",
58
+ "type": "ha-entity-config",
59
+ "server": "ec4a12a1.b2be9",
60
+ "deviceConfig": "",
61
+ "name": "sensor config for Info fra PS til HA",
62
+ "version": 6,
63
+ "entityType": "sensor",
64
+ "haConfig": [
65
+ { "property": "name", "value": "Powersaver" },
66
+ { "property": "device_class", "value": "" },
67
+ { "property": "icon", "value": "" },
68
+ { "property": "unit_of_measurement", "value": "" },
69
+ { "property": "state_class", "value": "" },
70
+ { "property": "last_reset", "value": "" }
71
+ ],
72
+ "resend": true
87
73
  }
88
74
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-power-saver",
3
- "version": "5.0.0-beta.0",
3
+ "version": "5.0.0-beta.1",
4
4
  "description": "A module for Node-RED that you can use to turn on and off a switch based on power prices",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/utils.js CHANGED
@@ -105,6 +105,9 @@ function loadDayData(node, date) {
105
105
  schedule: [],
106
106
  minutes: [],
107
107
  };
108
+ if(!res.minutes) {
109
+ res.minutes = []
110
+ }
108
111
  return res;
109
112
  }
110
113