@haydendonald/node-red-contrib-hass-stuff 1.4.0 → 1.5.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,7 +9,6 @@
|
|
|
9
9
|
defaults: {
|
|
10
10
|
name: { value: "" },
|
|
11
11
|
connectionsConfigNode: { value: '', type: "connections-config-node", required: true },
|
|
12
|
-
priceEntityId: { value: "", required: true },
|
|
13
12
|
chargeRate: { value: 0.0, required: true, validate: RED.validators.number() },
|
|
14
13
|
peakRate: { value: 0.0, required: true, validate: RED.validators.number() },
|
|
15
14
|
offPeakRate: { value: 0.0, required: true, validate: RED.validators.number() },
|
|
@@ -35,11 +34,6 @@
|
|
|
35
34
|
<label for="node-input-connectionsConfigNode">Config</label>
|
|
36
35
|
<input type="text" id="node-input-connectionsConfigNode" />
|
|
37
36
|
</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>
|
|
43
37
|
<div class="form-row">
|
|
44
38
|
<p>The charge rate in KW</p>
|
|
45
39
|
<label for="node-input-chargeRate">Charge Rate</label>
|
|
@@ -10,10 +10,6 @@ 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
|
-
}
|
|
17
13
|
if (!config.chargingEntityId) {
|
|
18
14
|
self.error("Charging entity ID is required");
|
|
19
15
|
hasValidationError = true;
|
|
@@ -51,12 +47,8 @@ module.exports = function EVChargingPriceNode(RED) {
|
|
|
51
47
|
let startedChargingAtHomeState;
|
|
52
48
|
let startedChargingAt;
|
|
53
49
|
let finishedChargingAt;
|
|
54
|
-
//Set the price
|
|
55
|
-
|
|
56
|
-
connectionsConfigNode.sendHASSAction("input_number.set_value", {
|
|
57
|
-
entity_id: [config.priceEntityId]
|
|
58
|
-
}, { value });
|
|
59
|
-
}
|
|
50
|
+
//Set the price sensor
|
|
51
|
+
let setPrice;
|
|
60
52
|
RED.nodes.createNode(this, config);
|
|
61
53
|
(0, baseNode_1.assignBaseNode)(this);
|
|
62
54
|
const connectionsConfigNode = RED.nodes.getNode(config.connectionsConfigNode);
|
|
@@ -74,8 +66,6 @@ module.exports = function EVChargingPriceNode(RED) {
|
|
|
74
66
|
});
|
|
75
67
|
// Get the current state of the home
|
|
76
68
|
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; });
|
|
79
69
|
//Add a boolean to keep track if the charger started while at home
|
|
80
70
|
connectionsConfigNode.addHASSInputBoolean({
|
|
81
71
|
friendlyName: `${self.name} - Started Charging at Home`,
|
|
@@ -88,6 +78,18 @@ module.exports = function EVChargingPriceNode(RED) {
|
|
|
88
78
|
startedChargingAtHomeState = state;
|
|
89
79
|
}
|
|
90
80
|
});
|
|
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
|
+
});
|
|
91
93
|
//Add a button to reset the price
|
|
92
94
|
connectionsConfigNode.addHASSButton({
|
|
93
95
|
friendlyName: `${self.name} - Reset Price`,
|
|
@@ -117,10 +119,6 @@ module.exports = function EVChargingPriceNode(RED) {
|
|
|
117
119
|
handle();
|
|
118
120
|
break;
|
|
119
121
|
}
|
|
120
|
-
case config.priceEntityId: {
|
|
121
|
-
priceState = newState.state;
|
|
122
|
-
break;
|
|
123
|
-
}
|
|
124
122
|
}
|
|
125
123
|
};
|
|
126
124
|
function sendNotification(title, message) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haydendonald/node-red-contrib-hass-stuff",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.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",
|