@haydendonald/node-red-contrib-hass-stuff 1.1.0 → 1.1.2

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.
@@ -251,7 +251,6 @@ module.exports = function ConnectionsConfigNode(RED) {
251
251
  }
252
252
  const previousState = entities.length == 1 ? entities[0].state : undefined;
253
253
  self.addHASSEntity(entityId, data(options.state || previousState), options.creationCallback ? (response) => {
254
- console.log(response);
255
254
  options.creationCallback(response.payload.state, response);
256
255
  } : undefined);
257
256
  });
@@ -114,7 +114,6 @@ module.exports = function EVChargingPriceNode(RED) {
114
114
  finishedChargingAt = undefined;
115
115
  }
116
116
  else {
117
- startedChargingAt = oldState.last_changed;
118
117
  finishedChargingAt = newState.last_changed;
119
118
  }
120
119
  handle();
@@ -155,7 +154,7 @@ module.exports = function EVChargingPriceNode(RED) {
155
154
  // Split charging period at hour boundaries for accurate rate calculation
156
155
  let timeInPeakMs = 0;
157
156
  let timeInOffPeakMs = 0;
158
- let currentTime = new Date();
157
+ let currentTime = new Date(startDate);
159
158
  while (currentTime < endDate) {
160
159
  // Find the next hour boundary or end of charging period
161
160
  const nextHourBoundary = new Date(currentTime);
@@ -171,6 +171,22 @@ module.exports = function LightControlConfigNode(RED) {
171
171
  });
172
172
  }
173
173
  });
174
+ //Add our toggle scene
175
+ connectionsConfigNode.addHASSScene({
176
+ friendlyName: `${self.name} - Toggle`,
177
+ id: (0, utility_1.getEntityId)("scene", `${self.name}_toggle`),
178
+ creationCallback: (response) => { },
179
+ activatedCallback: (serviceData) => {
180
+ if (currentState.state == "off") {
181
+ runLights(serviceData.transition || 1, true);
182
+ }
183
+ else {
184
+ connectionsConfigNode.sendHASSAction("light.turn_off", { entity_id: [config.groupEntityId] }, {
185
+ transition: serviceData.transition || 1
186
+ });
187
+ }
188
+ }
189
+ });
174
190
  //Add our select to keep track of what scene we are running
175
191
  connectionsConfigNode.addHASSSelect({
176
192
  friendlyName: `${self.name} - Current Scene`,
@@ -210,7 +226,7 @@ module.exports = function LightControlConfigNode(RED) {
210
226
  this.msgReceived = function (msg, senderIds) { };
211
227
  const activateScene = (scene, transitionSec, turnLightsOn, entitiesOn, entitiesOff) => {
212
228
  //If the lights are off and we are not to turn the lights on don't do anything
213
- if (turnLightsOn == false && currentState == "off") {
229
+ if (turnLightsOn == false && currentState.state == "off") {
214
230
  return;
215
231
  }
216
232
  //Is not a scene preset scene if we have a entity id
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haydendonald/node-red-contrib-hass-stuff",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
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",