hoffmation-base 3.2.1-alpha.4 → 3.2.1-alpha.6

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.
@@ -5,7 +5,7 @@ const baseAction_1 = require("./baseAction");
5
5
  const enums_1 = require("../enums");
6
6
  class ActuatorChangeAction extends baseAction_1.BaseAction {
7
7
  constructor(device) {
8
- super(undefined, `New Actuator state (${device.actuatorOn}) received`);
8
+ super(enums_1.CommandSource.Automatic, `New Actuator state (${device.actuatorOn}) received`);
9
9
  /** @inheritDoc */
10
10
  this.type = enums_1.CommandType.ActuatorChangeAction;
11
11
  this.actuatorOn = device.actuatorOn;
@@ -1,5 +1,6 @@
1
1
  import { BaseCommand } from '../command';
2
+ import { CommandSource } from '../enums';
2
3
  export declare abstract class BaseAction extends BaseCommand {
3
- protected constructor(source?: BaseAction, reason?: string);
4
+ protected constructor(source: BaseAction | CommandSource, reason?: string);
4
5
  get logMessage(): string;
5
6
  }
@@ -2,10 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BaseAction = void 0;
4
4
  const command_1 = require("../command");
5
- const enums_1 = require("../enums");
6
5
  class BaseAction extends command_1.BaseCommand {
7
6
  constructor(source, reason) {
8
- super(source !== null && source !== void 0 ? source : enums_1.CommandSource.Automatic, reason);
7
+ super(source, reason);
9
8
  }
10
9
  get logMessage() {
11
10
  return this.reasonTrace;
@@ -5,7 +5,7 @@ const baseAction_1 = require("./baseAction");
5
5
  const enums_1 = require("../enums");
6
6
  class BatteryLevelChangeAction extends baseAction_1.BaseAction {
7
7
  constructor(device) {
8
- super(undefined, `New Battery Level (${device.batteryLevel}%) received`);
8
+ super(enums_1.CommandSource.Automatic, `New Battery Level (${device.batteryLevel}%) received`);
9
9
  /** @inheritDoc */
10
10
  this.type = enums_1.CommandType.BatteryManagerLevelChangeAction;
11
11
  this.newLevel = device.batteryLevel;
@@ -5,7 +5,7 @@ const baseAction_1 = require("./baseAction");
5
5
  const enums_1 = require("../enums");
6
6
  class HandleChangeAction extends baseAction_1.BaseAction {
7
7
  constructor(handle) {
8
- super(undefined, `${handle.customName} ${handle.position === enums_1.WindowPosition.closed ? 'opened' : 'closed'}`);
8
+ super(enums_1.CommandSource.Automatic, `${handle.customName} ${handle.position === enums_1.WindowPosition.closed ? 'opened' : 'closed'}`);
9
9
  /** @inheritDoc */
10
10
  this.type = enums_1.CommandType.HandleChangedAction;
11
11
  this.handle = handle;
@@ -5,7 +5,7 @@ const baseAction_1 = require("./baseAction");
5
5
  const enums_1 = require("../enums");
6
6
  class HumiditySensorChangeAction extends baseAction_1.BaseAction {
7
7
  constructor(sensor, newHumidity) {
8
- super(undefined, `${sensor.customName} detected ${newHumidity} humidity`);
8
+ super(enums_1.CommandSource.Automatic, `${sensor.customName} detected ${newHumidity} humidity`);
9
9
  /** @inheritDoc */
10
10
  this.type = enums_1.CommandType.HumiditySensorChangeAction;
11
11
  this.newHumidity = newHumidity;
@@ -5,7 +5,7 @@ const baseAction_1 = require("./baseAction");
5
5
  const enums_1 = require("../enums");
6
6
  class MotionSensorAction extends baseAction_1.BaseAction {
7
7
  constructor(sensor) {
8
- super(undefined, `${sensor.customName} ${sensor.movementDetected ? 'detected' : 'cleared'} motion`);
8
+ super(enums_1.CommandSource.Automatic, `${sensor.customName} ${sensor.movementDetected ? 'detected' : 'cleared'} motion`);
9
9
  /** @inheritDoc */
10
10
  this.type = enums_1.CommandType.MotionSensorAction;
11
11
  this.motionDetected = sensor.movementDetected;
@@ -1,7 +1,7 @@
1
1
  import { BaseAction } from './baseAction';
2
- import { CommandType } from '../enums';
2
+ import { CommandSource, CommandType } from '../enums';
3
3
  export declare class PresenceGroupAnyMovementAction extends BaseAction {
4
4
  /** @inheritDoc */
5
5
  type: CommandType;
6
- constructor(source?: BaseAction, reason?: string);
6
+ constructor(source: BaseAction | CommandSource, reason?: string);
7
7
  }
@@ -1,7 +1,7 @@
1
1
  import { BaseAction } from './baseAction';
2
- import { CommandType } from '../enums';
2
+ import { CommandSource, CommandType } from '../enums';
3
3
  export declare class PresenceGroupFirstEnterAction extends BaseAction {
4
4
  /** @inheritDoc */
5
5
  type: CommandType;
6
- constructor(source?: BaseAction, reason?: string);
6
+ constructor(source: BaseAction | CommandSource, reason?: string);
7
7
  }
@@ -1,7 +1,7 @@
1
- import { CommandType } from '../enums';
1
+ import { CommandSource, CommandType } from '../enums';
2
2
  import { BaseAction } from './baseAction';
3
3
  export declare class PresenceGroupLastLeftAction extends BaseAction {
4
4
  /** @inheritDoc */
5
5
  type: CommandType;
6
- constructor(source?: BaseAction, reason?: string);
6
+ constructor(source: BaseAction | CommandSource, reason?: string);
7
7
  }
@@ -5,7 +5,7 @@ const baseAction_1 = require("./baseAction");
5
5
  const enums_1 = require("../enums");
6
6
  class ShutterPositionChangedAction extends baseAction_1.BaseAction {
7
7
  constructor(shutter, newPosition) {
8
- super(undefined, `${shutter.customName} changed position to ${newPosition}`);
8
+ super(enums_1.CommandSource.Automatic, `${shutter.customName} changed position to ${newPosition}`);
9
9
  this.newPosition = newPosition;
10
10
  /** @inheritDoc */
11
11
  this.type = enums_1.CommandType.ShutterPositionChangedAction;
@@ -5,7 +5,7 @@ const baseAction_1 = require("./baseAction");
5
5
  const enums_1 = require("../enums");
6
6
  class TemperatureSensorChangeAction extends baseAction_1.BaseAction {
7
7
  constructor(sensor, newTemperature) {
8
- super(undefined, `${sensor.customName} detected ${newTemperature} °C`);
8
+ super(enums_1.CommandSource.Automatic, `${sensor.customName} detected ${newTemperature} °C`);
9
9
  /** @inheritDoc */
10
10
  this.type = enums_1.CommandType.TemperatureSensorChangeAction;
11
11
  this.newTemperature = newTemperature;
@@ -61,13 +61,13 @@ class BaseCommand {
61
61
  }
62
62
  get reasonTrace() {
63
63
  let ownPart = `${this.type}`;
64
- if (this.reason !== undefined) {
64
+ if (this.reason) {
65
65
  ownPart += `("${this.reason}")`;
66
66
  }
67
67
  if (this.ignoreReason !== undefined) {
68
68
  ownPart += ` ignored due to: "${this.ignoreReason}"`;
69
69
  }
70
- if (typeof this.source === 'object') {
70
+ if (this.source instanceof BaseCommand) {
71
71
  return `${this.source.reasonTrace} -> ${ownPart}`;
72
72
  }
73
73
  return `CommandType("${enums_1.CommandSource[this.source]}") stack => ${ownPart}`;
@@ -1,10 +1,14 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.BaseDevice = void 0;
4
7
  const enums_1 = require("../enums");
5
8
  const utils_1 = require("../utils");
6
9
  const logging_1 = require("../logging");
7
10
  const services_1 = require("../services");
11
+ const lodash_1 = __importDefault(require("lodash"));
8
12
  class BaseDevice {
9
13
  constructor(_info, deviceType) {
10
14
  this._info = _info;
@@ -86,6 +90,9 @@ class BaseDevice {
86
90
  }
87
91
  /** @inheritDoc */
88
92
  toJSON() {
93
+ // eslint-disable-next-line
94
+ const returnValue = lodash_1.default.omit(this, 'lastCommands');
95
+ returnValue['lastCommands'] = this.lastCommands.readAmount(this.lastCommands.maximumSize);
89
96
  return utils_1.Utils.jsonFilter(this, this.jsonOmitKeys);
90
97
  }
91
98
  }
@@ -115,7 +115,6 @@ class LampUtils {
115
115
  device.targetAutomaticState = c.on;
116
116
  }
117
117
  if (LampUtils.canActuatorChangeBeSkipped(device, c)) {
118
- device.logCommand(c, 'Actuator change can be skipped');
119
118
  return;
120
119
  }
121
120
  device.queuedValue = c.on;