homebridge-tasmota-control 1.7.12-beta.0 → 1.7.13

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "Tasmota Control",
3
3
  "name": "homebridge-tasmota-control",
4
- "version": "1.7.12-beta.0",
4
+ "version": "1.7.13",
5
5
  "description": "Homebridge plugin to control Tasmota flashed devices.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
@@ -7,7 +7,7 @@ class ImpulseGenerator extends EventEmitter {
7
7
  this.timers = [];
8
8
  }
9
9
 
10
- async state(state, timers = []) {
10
+ async state(state, timers = [], runOnStart = true) {
11
11
  // Stop current timers before new start
12
12
  if (this.timersState && state) {
13
13
  await this.state(false);
@@ -19,7 +19,7 @@ class ImpulseGenerator extends EventEmitter {
19
19
  for (const { name, sampling } of timers) {
20
20
  if (!name || !sampling) continue;
21
21
 
22
- this.emit(name);
22
+ if (runOnStart) this.emit(name);
23
23
 
24
24
  const interval = setInterval(() => {
25
25
  this.emit(name);
package/src/lights.js CHANGED
@@ -57,12 +57,12 @@ class Lights extends EventEmitter {
57
57
  if (this.enableDebugMode) this.emit('debug', `Requesting status`);
58
58
  try {
59
59
  //power status
60
- const powerStatusData = await this.axiosInstance(ApiCommands.PowerStatus);
60
+ const powerStatusData = await this.client(ApiCommands.PowerStatus);
61
61
  const powerStatus = powerStatusData.data ?? {};
62
62
  if (this.enableDebugMode) this.emit('debug', `Power status: ${JSON.stringify(powerStatus, null, 2)}`);
63
63
 
64
64
  //sensor status
65
- const sensorStatusData = await this.axiosInstance(ApiCommands.Status);
65
+ const sensorStatusData = await this.client(ApiCommands.Status);
66
66
  const sensorStatus = sensorStatusData.data ?? {};
67
67
  if (this.enableDebugMode) this.emit('debug', `Sensors status: ${JSON.stringify(sensorStatus, null, 2)}`);
68
68
 
@@ -208,7 +208,7 @@ class Lights extends EventEmitter {
208
208
  const powerOff = this.lights.length === 1 ? ApiCommands.PowerOff : `${ApiCommands.Power}${relayNr}${ApiCommands.Off}`;
209
209
  state = state ? powerOn : powerOff;
210
210
 
211
- await this.axiosInstance.get(state);
211
+ await this.client.get(state);
212
212
  if (!this.disableLogInfo) this.emit('info', `${friendlyName}, set state: ${state ? 'ON' : 'OFF'}`);
213
213
  } catch (error) {
214
214
  this.emit('warn', `${friendlyName}, set state error: ${error}`);
@@ -223,7 +223,7 @@ class Lights extends EventEmitter {
223
223
  .onSet(async (value) => {
224
224
  try {
225
225
  const brightness = ['', `${ApiCommands.Dimmer}${value}`, `${ApiCommands.HSBBrightness}${value}`][this.lights[i].brightnessType]; //0..100
226
- await this.axiosInstance.get(brightness);
226
+ await this.client.get(brightness);
227
227
  if (!this.disableLogInfo) this.emit('info', `${friendlyName}, set brightness: ${value} %`);
228
228
  } catch (error) {
229
229
  this.emit('warn', `set brightness error: ${error}`);
@@ -240,7 +240,7 @@ class Lights extends EventEmitter {
240
240
  try {
241
241
  value = await this.functions.scaleValue(value, 140, 500, 153, 500);
242
242
  const colorTemperature = `${ApiCommands.ColorTemperature}${value}`; //153..500
243
- await this.axiosInstance.get(colorTemperature);
243
+ await this.client.get(colorTemperature);
244
244
  if (!this.disableLogInfo) this.emit('info', `${friendlyName}, set color temperatur: ${value}`);
245
245
  } catch (error) {
246
246
  this.emit('warn', `set color temperatur error: ${error}`);
@@ -256,7 +256,7 @@ class Lights extends EventEmitter {
256
256
  .onSet(async (value) => {
257
257
  try {
258
258
  const hue = `${ApiCommands.HSBHue}${value}`; //0..360
259
- await this.axiosInstance.get(hue);
259
+ await this.client.get(hue);
260
260
  if (!this.disableLogInfo) this.emit('info', `${friendlyName}, set hue: ${value}`);
261
261
  } catch (error) {
262
262
  this.emit('warn', `set hue error: ${error}`);
@@ -272,7 +272,7 @@ class Lights extends EventEmitter {
272
272
  .onSet(async (value) => {
273
273
  try {
274
274
  const saturation = `${ApiCommands.HSBSaturation}${value}`; //0..100
275
- await this.axiosInstance.get(saturation);
275
+ await this.client.get(saturation);
276
276
  if (!this.disableLogInfo) this.emit('info', `set saturation: ${value}`);
277
277
  } catch (error) {
278
278
  this.emit('warn', `set saturation error: ${error}`);