node-red-contrib-power-saver 3.5.2 → 3.5.3

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.
@@ -6,6 +6,10 @@ sidebar: "auto"
6
6
 
7
7
  List the most significant changes, starting in version 1.0.9.
8
8
 
9
+ ## 3.5.3
10
+
11
+ - Fix a couple of bugs in how context is used.
12
+
9
13
  ## 3.5.2
10
14
 
11
15
  - Re-introduce the search bar, after Vuepress upgrade.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-power-saver",
3
- "version": "3.5.2",
3
+ "version": "3.5.3",
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": {
@@ -22,11 +22,15 @@ function handleStrategyInput(node, msg, doPlanning) {
22
22
  .set(["lastPlan", "lastPriceData", "lastSource"], [undefined, undefined, undefined], node.contextStorage);
23
23
  deleteSavedScheduleBefore(node, DateTime.now().plus({ days: 2 }), 100);
24
24
  }
25
+
26
+ // Store config variables in node
27
+ Object.keys(effectiveConfig).forEach((key) => (node[key] = effectiveConfig[key]));
28
+
25
29
  let { priceData, source } = getPriceData(node, msg);
26
30
  if (!priceData) {
27
31
  // Use last saved price data
28
- priceData = node.context().get("lastPriceData");
29
- source = node.context().get("lastSource");
32
+ priceData = node.context().get("lastPriceData", node.contextStorage);
33
+ source = node.context().get("lastSource", node.contextStorage);
30
34
  const message = "Using saved prices";
31
35
  node.warn(message);
32
36
  node.status({ fill: "green", shape: "ring", text: message });
@@ -39,9 +43,6 @@ function handleStrategyInput(node, msg, doPlanning) {
39
43
  }
40
44
  const planFromTime = msg.payload.time ? DateTime.fromISO(msg.payload.time) : DateTime.now();
41
45
 
42
- // Store config variables in node
43
- Object.keys(effectiveConfig).forEach((key) => (node[key] = effectiveConfig[key]));
44
-
45
46
  clearTimeout(node.schedulingTimeout);
46
47
 
47
48
  const dates = [...new Set(priceData.map((v) => DateTime.fromISO(v.start).toISODate()))];
@@ -19,7 +19,7 @@ module.exports = function (RED) {
19
19
  outputOutsidePeriod: booleanConfig(config.outputOutsidePeriod),
20
20
  contextStorage: config.contextStorage || "default",
21
21
  };
22
- node.context().set("config", originalConfig, node.contextStorage);
22
+ node.context().set("config", originalConfig, originalConfig.contextStorage);
23
23
 
24
24
  node.on("close", function () {
25
25
  clearTimeout(node.schedulingTimeout);