@haydendonald/node-red-contrib-hass-stuff 1.3.1 → 1.4.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.
@@ -9,6 +9,7 @@
9
9
  defaults: {
10
10
  name: { value: "" },
11
11
  connectionsConfigNode: { value: '', type: "connections-config-node", required: true },
12
+ priceEntityId: { value: "", required: true },
12
13
  chargeRate: { value: 0.0, required: true, validate: RED.validators.number() },
13
14
  peakRate: { value: 0.0, required: true, validate: RED.validators.number() },
14
15
  offPeakRate: { value: 0.0, required: true, validate: RED.validators.number() },
@@ -34,6 +35,11 @@
34
35
  <label for="node-input-connectionsConfigNode">Config</label>
35
36
  <input type="text" id="node-input-connectionsConfigNode" />
36
37
  </div>
38
+ <div class="form-row">
39
+ <p>The entity ID for the price for example input_number.ev_charging_price</p>
40
+ <label for="node-input-priceEntityId">Price Entity ID</label>
41
+ <input type="text" id="node-input-priceEntityId" />
42
+ </div>
37
43
  <div class="form-row">
38
44
  <p>The charge rate in KW</p>
39
45
  <label for="node-input-chargeRate">Charge Rate</label>
@@ -10,6 +10,10 @@ module.exports = function EVChargingPriceNode(RED) {
10
10
  self.error("Connections config node is required");
11
11
  hasValidationError = true;
12
12
  }
13
+ if (!config.priceEntityId) {
14
+ self.error("Price entity ID is required");
15
+ hasValidationError = true;
16
+ }
13
17
  if (!config.chargingEntityId) {
14
18
  self.error("Charging entity ID is required");
15
19
  hasValidationError = true;
@@ -47,8 +51,12 @@ module.exports = function EVChargingPriceNode(RED) {
47
51
  let startedChargingAtHomeState;
48
52
  let startedChargingAt;
49
53
  let finishedChargingAt;
50
- //Set the price sensor
51
- let setPrice;
54
+ //Set the price value
55
+ function setPrice(value) {
56
+ connectionsConfigNode.sendHASSAction("input_number.set_value", {
57
+ entity_id: [config.priceEntityId]
58
+ }, { value });
59
+ }
52
60
  RED.nodes.createNode(this, config);
53
61
  (0, baseNode_1.assignBaseNode)(this);
54
62
  const connectionsConfigNode = RED.nodes.getNode(config.connectionsConfigNode);
@@ -66,6 +74,8 @@ module.exports = function EVChargingPriceNode(RED) {
66
74
  });
67
75
  // Get the current state of the home
68
76
  connectionsConfigNode.getHASSEntityState(config.homeEntityId, (payload, data) => { homeState = data.data.state; });
77
+ //Get the current state of the price
78
+ connectionsConfigNode.getHASSEntityState(config.priceEntityId, (payload, data) => { priceState = data.data.state; });
69
79
  //Add a boolean to keep track if the charger started while at home
70
80
  connectionsConfigNode.addHASSInputBoolean({
71
81
  friendlyName: `${self.name} - Started Charging at Home`,
@@ -78,18 +88,6 @@ module.exports = function EVChargingPriceNode(RED) {
78
88
  startedChargingAtHomeState = state;
79
89
  }
80
90
  });
81
- //Add our sensor to track the cost
82
- setPrice = connectionsConfigNode.addHASSSensor({
83
- friendlyName: `${self.name} - Price`,
84
- id: (0, utility_1.getEntityId)("sensor", `${self.name}_price`),
85
- defaultState: 0.0,
86
- creationCallback: (state) => {
87
- priceState = state;
88
- },
89
- changedCallback: (state) => {
90
- priceState = state;
91
- }
92
- });
93
91
  //Add a button to reset the price
94
92
  connectionsConfigNode.addHASSButton({
95
93
  friendlyName: `${self.name} - Reset Price`,
@@ -119,6 +117,10 @@ module.exports = function EVChargingPriceNode(RED) {
119
117
  handle();
120
118
  break;
121
119
  }
120
+ case config.priceEntityId: {
121
+ priceState = newState.state;
122
+ break;
123
+ }
122
124
  }
123
125
  };
124
126
  function sendNotification(title, message) {
@@ -7,6 +7,7 @@
7
7
  groupEntityId: { value: "", required: true, default: "light.example" },
8
8
  nightModeEntityId: { value: "", required: false, default: "input_boolean.example" },
9
9
  entitiesOffAtNight: { value: "", required: false, default: "light.example1,light.example2" },
10
+ continuousAdaptive: { value: true, required: false },
10
11
  concentrateSettings: { value: "", required: true, default: "concentrate 100" },
11
12
  readSettings: { value: "", required: true, default: "read 100" },
12
13
  relaxSettings: { value: "", required: true, default: "relax 100" },
@@ -47,6 +48,11 @@
47
48
  <p>Comma-separated list of entities to turn off during night mode. Empty to disable</p>
48
49
  <input type="text" id="node-config-input-entitiesOffAtNight" />
49
50
  </div>
51
+ <div class="form-row">
52
+ <label style="font-weight: bold;" for="node-config-input-continuousAdaptive">Continuously Send Adaptive Colours</label>
53
+ <p>If enabled, adaptive scenes will be resent every 5 minutes, if disabled will only send when a change is required</p>
54
+ <input type="checkbox" id="node-config-input-continuousAdaptive" style="display: inline-block; width: auto; vertical-align: top;">
55
+ </div>
50
56
  <div class="form-row">
51
57
  <hr>
52
58
  <h2>Scene definitions</h2>
@@ -379,7 +379,7 @@ module.exports = function LightControlConfigNode(RED) {
379
379
  const runAdaptiveInterval = () => {
380
380
  clearTimeout(adaptiveInterval);
381
381
  if (currentSceneState == "Adaptive") {
382
- run(300, false, true);
382
+ run(300, false, config.continuousAdaptive);
383
383
  }
384
384
  //Reschedule
385
385
  adaptiveInterval = setTimeout(runAdaptiveInterval, 300000);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haydendonald/node-red-contrib-hass-stuff",
3
- "version": "1.3.1",
3
+ "version": "1.4.0",
4
4
  "description": "A collection of stuff I use on my Node Red + Home Assistant server. This could be of use for others, i don't know..",
5
5
  "devDependencies": {
6
6
  "@types/node": "^18.14.0",