hoffmation-base 3.0.0-alpha.52 → 3.0.0-alpha.54

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.
@@ -34,6 +34,7 @@ class DeviceCluster {
34
34
  break;
35
35
  case deviceType_1.DeviceType.Camera:
36
36
  clusterTypes.push(device_cluster_type_1.DeviceClusterType.Camera);
37
+ clusterTypes.push(device_cluster_type_1.DeviceClusterType.MotionDetection);
37
38
  break;
38
39
  case deviceType_1.DeviceType.HmIpLampe:
39
40
  case deviceType_1.DeviceType.ZigbeeIlluDimmer:
@@ -76,6 +77,7 @@ class DeviceCluster {
76
77
  clusterTypes.push(device_cluster_type_1.DeviceClusterType.MotionDetection);
77
78
  break;
78
79
  case deviceType_1.DeviceType.ZigbeeIkeaSteckdose:
80
+ case deviceType_1.DeviceType.ZigbeeBlitzShp:
79
81
  clusterTypes.push(device_cluster_type_1.DeviceClusterType.Outlets);
80
82
  break;
81
83
  case deviceType_1.DeviceType.ZigbeeIlluLedRGBCCT:
@@ -93,9 +95,6 @@ class DeviceCluster {
93
95
  case deviceType_1.DeviceType.ZigbeeAquaraWater:
94
96
  clusterTypes.push(device_cluster_type_1.DeviceClusterType.WaterDetectors);
95
97
  break;
96
- case deviceType_1.DeviceType.ZigbeeBlitzShp:
97
- clusterTypes.push(device_cluster_type_1.DeviceClusterType.Outlets);
98
- break;
99
98
  case deviceType_1.DeviceType.WledDevice:
100
99
  clusterTypes.push(device_cluster_type_1.DeviceClusterType.WLED);
101
100
  break;
@@ -105,6 +104,7 @@ class DeviceCluster {
105
104
  case deviceType_1.DeviceType.HmIpHeizung: // Setting/Controlling via HM-Ip Heizgruppe
106
105
  case deviceType_1.DeviceType.unknown:
107
106
  case deviceType_1.DeviceType.HmIpAccessPoint: // You can't really do stuff with it.
107
+ case deviceType_1.DeviceType.ShellyActuator: // Dependent on use case
108
108
  break;
109
109
  }
110
110
  for (const type of clusterTypes) {
@@ -41,6 +41,7 @@ export declare enum DeviceType {
41
41
  JsEnergyManager = 301,
42
42
  RoomScene = 401,
43
43
  ShellyTrv = 402,
44
+ ShellyActuator = 403,
44
45
  TuyaGarageDoorOpener = 501,
45
46
  WledDevice = 1001,
46
47
  GoveeLed = 1002,
@@ -45,6 +45,7 @@ var DeviceType;
45
45
  DeviceType[DeviceType["JsEnergyManager"] = 301] = "JsEnergyManager";
46
46
  DeviceType[DeviceType["RoomScene"] = 401] = "RoomScene";
47
47
  DeviceType[DeviceType["ShellyTrv"] = 402] = "ShellyTrv";
48
+ DeviceType[DeviceType["ShellyActuator"] = 403] = "ShellyActuator";
48
49
  DeviceType[DeviceType["TuyaGarageDoorOpener"] = 501] = "TuyaGarageDoorOpener";
49
50
  DeviceType[DeviceType["WledDevice"] = 1001] = "WledDevice";
50
51
  DeviceType[DeviceType["GoveeLed"] = 1002] = "GoveeLed";
@@ -12,6 +12,7 @@ const wledDevice_1 = require("./wledDevice");
12
12
  const DeviceCapability_1 = require("./DeviceCapability");
13
13
  const shelly_1 = require("./shelly");
14
14
  const tuya_1 = require("./tuya");
15
+ const shellyActuator_1 = require("./shelly/shellyActuator");
15
16
  class Devices {
16
17
  constructor(pDeviceData, pRoomImportEnforcer, config) {
17
18
  var _a;
@@ -104,6 +105,9 @@ class Devices {
104
105
  case 'Trv':
105
106
  d = new shelly_1.ShellyTrv(shellyInfo);
106
107
  break;
108
+ case 'Actuator':
109
+ d = new shellyActuator_1.ShellyActuator(shellyInfo);
110
+ break;
107
111
  default:
108
112
  services_1.ServerLogService.writeLog(models_1.LogLevel.Warn, `No shelly Device Type for ${shellyInfo.deviceType} defined`);
109
113
  d = new shelly_1.ShellyDevice(shellyInfo, deviceType_1.DeviceType.unknown);
@@ -0,0 +1,33 @@
1
+ import { ShellyDevice } from './shellyDevice';
2
+ import { iActuator } from '../baseDeviceInterfaces';
3
+ import { BlockAutomaticHandler } from '../../services/blockAutomaticHandler';
4
+ import { ActuatorSetStateCommand, ActuatorSettings, ActuatorToggleCommand, ActuatorWriteStateToDeviceCommand, RestoreTargetAutomaticValueCommand } from '../../../models';
5
+ import { IoBrokerDeviceInfo } from '../IoBrokerDeviceInfo';
6
+ export declare class ShellyActuator extends ShellyDevice implements iActuator {
7
+ /** @inheritDoc */
8
+ readonly blockAutomationHandler: BlockAutomaticHandler;
9
+ /** @inheritDoc */
10
+ targetAutomaticState: boolean;
11
+ /** @inheritDoc */
12
+ settings: ActuatorSettings;
13
+ /** @inheritDoc */
14
+ queuedValue: boolean | null;
15
+ private _lastPersist;
16
+ private readonly _actuatorOnStateId;
17
+ private _actuatorOn;
18
+ constructor(pInfo: IoBrokerDeviceInfo);
19
+ /** @inheritDoc */
20
+ get actuatorOn(): boolean;
21
+ /** @inheritDoc */
22
+ restoreTargetAutomaticValue(c: RestoreTargetAutomaticValueCommand): void;
23
+ /** @inheritDoc */
24
+ update(idSplit: string[], state: ioBroker.State, initial?: boolean, handledByChildObject?: boolean): void;
25
+ /** @inheritDoc */
26
+ setActuator(command: ActuatorSetStateCommand): void;
27
+ /** @inheritDoc */
28
+ persist(): void;
29
+ /** @inheritDoc */
30
+ toggleActuator(command: ActuatorToggleCommand): boolean;
31
+ /** @inheritDoc */
32
+ writeActuatorStateToDevice(c: ActuatorWriteStateToDeviceCommand): void;
33
+ }
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ShellyActuator = void 0;
4
+ const shellyDevice_1 = require("./shellyDevice");
5
+ const blockAutomaticHandler_1 = require("../../services/blockAutomaticHandler");
6
+ const models_1 = require("../../../models");
7
+ const deviceType_1 = require("../deviceType");
8
+ const DeviceCapability_1 = require("../DeviceCapability");
9
+ const sharedFunctions_1 = require("../sharedFunctions");
10
+ const services_1 = require("../../services");
11
+ class ShellyActuator extends shellyDevice_1.ShellyDevice {
12
+ constructor(pInfo) {
13
+ super(pInfo, deviceType_1.DeviceType.ShellyActuator);
14
+ /** @inheritDoc */
15
+ this.targetAutomaticState = false;
16
+ /** @inheritDoc */
17
+ this.settings = new models_1.ActuatorSettings();
18
+ /** @inheritDoc */
19
+ this.queuedValue = null;
20
+ this._lastPersist = 0;
21
+ this._actuatorOn = false;
22
+ this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.actuator);
23
+ this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.blockAutomatic);
24
+ this._actuatorOnStateId = `${this.info.fullID}.Relay0.Switch`;
25
+ this.blockAutomationHandler = new blockAutomaticHandler_1.BlockAutomaticHandler(this.restoreTargetAutomaticValue.bind(this), this.log.bind(this));
26
+ }
27
+ /** @inheritDoc */
28
+ get actuatorOn() {
29
+ return this._actuatorOn;
30
+ }
31
+ /** @inheritDoc */
32
+ restoreTargetAutomaticValue(c) {
33
+ this.setActuator(new models_1.ActuatorSetStateCommand(c, this.targetAutomaticState));
34
+ }
35
+ /** @inheritDoc */
36
+ update(idSplit, state, initial = false, handledByChildObject = false) {
37
+ if (!handledByChildObject) {
38
+ this.log(models_1.LogLevel.DeepTrace, `Aktuator Update: ID: ${idSplit.join('.')} JSON: ${JSON.stringify(state)}`);
39
+ }
40
+ this.queuedValue = null;
41
+ super.update(idSplit, state, initial, true);
42
+ if (idSplit[3] === 'Relay0') {
43
+ if (idSplit[4] === 'Switch') {
44
+ this._actuatorOn = state.val;
45
+ if (!initial) {
46
+ this.persist();
47
+ }
48
+ }
49
+ }
50
+ }
51
+ /** @inheritDoc */
52
+ setActuator(command) {
53
+ if (this._actuatorOnStateId === '') {
54
+ this.log(models_1.LogLevel.Error, 'Keine Switch ID bekannt.');
55
+ return;
56
+ }
57
+ sharedFunctions_1.LampUtils.setActuator(this, command);
58
+ }
59
+ /** @inheritDoc */
60
+ persist() {
61
+ var _a;
62
+ const now = services_1.Utils.nowMS();
63
+ if (this._lastPersist + 1000 > now) {
64
+ return;
65
+ }
66
+ (_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistActuator(this);
67
+ this._lastPersist = now;
68
+ }
69
+ /** @inheritDoc */
70
+ toggleActuator(command) {
71
+ const newVal = this.queuedValue !== null ? !this.queuedValue : !this._actuatorOn;
72
+ const setStateCommand = models_1.ActuatorSetStateCommand.byActuatorAndToggleCommand(this, command);
73
+ this.setActuator(setStateCommand);
74
+ return newVal;
75
+ }
76
+ /** @inheritDoc */
77
+ writeActuatorStateToDevice(c) {
78
+ this.log(models_1.LogLevel.Debug, c.logMessage, services_1.LogDebugType.SetActuator);
79
+ this.setState(this._actuatorOnStateId, c.stateValue, undefined, (err) => {
80
+ this.log(models_1.LogLevel.Error, `Lampe schalten ergab Fehler: ${err}`);
81
+ });
82
+ }
83
+ }
84
+ exports.ShellyActuator = ShellyActuator;
@@ -14,6 +14,7 @@ const DeviceCapability_1 = require("../../devices/DeviceCapability");
14
14
  const settings_service_1 = require("../settings-service");
15
15
  const config_1 = require("../../config");
16
16
  const blockAutomaticHandler_1 = require("../blockAutomaticHandler");
17
+ const weather_1 = require("../weather");
17
18
  class AcDevice {
18
19
  /**
19
20
  * Whether the AC is allowed to cool (depends on the season
@@ -27,6 +28,12 @@ class AcDevice {
27
28
  if (this.settings.noCoolingOnMovement && ((_b = (_a = this.room) === null || _a === void 0 ? void 0 : _a.PraesenzGroup) === null || _b === void 0 ? void 0 : _b.anyPresent())) {
28
29
  return false;
29
30
  }
31
+ if (weather_1.WeatherService.active &&
32
+ weather_1.WeatherService.todayMaxTemp < 22 && // TODO: Make this value configurable
33
+ weather_1.WeatherService.todayMaxTemp !== devices_1.UNDEFINED_TEMP_VALUE) {
34
+ // As it is quite cold outside there is no need to cool
35
+ return false;
36
+ }
30
37
  return true;
31
38
  }
32
39
  /**
@@ -26,6 +26,7 @@ export declare class WeatherService {
26
26
  private static longitude;
27
27
  private static appID?;
28
28
  static addWeatherUpdateCb(name: string, cb: () => void): void;
29
+ static get todayMaxTemp(): number;
29
30
  static initialize(config: iWeatherSettings): void;
30
31
  static update(): void;
31
32
  static stopInterval(): void;
@@ -11,10 +11,15 @@ const utils_1 = require("../utils");
11
11
  const log_service_1 = require("../log-service");
12
12
  const suncalc_1 = __importDefault(require("suncalc"));
13
13
  const time_callback_service_1 = require("../time-callback-service");
14
+ const devices_1 = require("../../devices");
14
15
  class WeatherService {
15
16
  static addWeatherUpdateCb(name, cb) {
16
17
  this._dataUpdateCbs[name] = cb;
17
18
  }
19
+ static get todayMaxTemp() {
20
+ var _a, _b, _c;
21
+ return (_c = (_b = (_a = WeatherService.lastResponse) === null || _a === void 0 ? void 0 : _a.daily[0]) === null || _b === void 0 ? void 0 : _b.temp.max) !== null && _c !== void 0 ? _c : devices_1.UNDEFINED_TEMP_VALUE;
22
+ }
18
23
  static initialize(config) {
19
24
  this.active = true;
20
25
  this.longitude = config.longitude;