hoffmation-base 1.1.30 → 1.1.32

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.
Files changed (33) hide show
  1. package/lib/models/deviceSettings/tvSettings.d.ts +5 -0
  2. package/lib/models/deviceSettings/tvSettings.js +7 -0
  3. package/lib/server/devices/DeviceCapability.d.ts +1 -0
  4. package/lib/server/devices/DeviceCapability.js +1 -0
  5. package/lib/server/devices/baseDeviceInterfaces/iAcDevice.d.ts +1 -1
  6. package/lib/server/devices/baseDeviceInterfaces/iTvDevice.d.ts +8 -0
  7. package/lib/server/devices/baseDeviceInterfaces/iTvDevice.js +2 -0
  8. package/lib/server/devices/baseDeviceInterfaces/index.d.ts +1 -0
  9. package/lib/server/devices/baseDeviceInterfaces/index.js +1 -0
  10. package/lib/server/devices/device-cluster-type.d.ts +2 -1
  11. package/lib/server/devices/device-cluster-type.js +1 -0
  12. package/lib/server/devices/device-cluster.js +3 -0
  13. package/lib/server/devices/deviceType.d.ts +2 -1
  14. package/lib/server/devices/deviceType.js +1 -0
  15. package/lib/server/devices/groups/heatGroup.js +1 -1
  16. package/lib/server/devices/index.d.ts +1 -0
  17. package/lib/server/devices/index.js +1 -0
  18. package/lib/server/devices/tv/index.d.ts +2 -0
  19. package/lib/server/devices/tv/index.js +18 -0
  20. package/lib/server/devices/tv/samsungTv.d.ts +15 -0
  21. package/lib/server/devices/tv/samsungTv.js +82 -0
  22. package/lib/server/devices/tv/tvDevice.d.ts +31 -0
  23. package/lib/server/devices/tv/tvDevice.js +66 -0
  24. package/lib/server/devices/tv/tvDeviceType.d.ts +4 -0
  25. package/lib/server/devices/tv/tvDeviceType.js +8 -0
  26. package/lib/server/services/ac/ac-device.d.ts +2 -2
  27. package/lib/server/services/ac/ac-device.js +5 -6
  28. package/lib/server/services/ac/daikin-service.js +3 -3
  29. package/lib/server/services/ac/own-daikin-device.d.ts +4 -1
  30. package/lib/server/services/ac/own-daikin-device.js +26 -4
  31. package/lib/server/services/api/api-service.js +1 -3
  32. package/lib/tsconfig.tsbuildinfo +1 -1
  33. package/package.json +7 -2
@@ -0,0 +1,5 @@
1
+ import { DeviceSettings } from './deviceSettings';
2
+ import { Daytime } from '../daytime';
3
+ export declare class TvSettings extends DeviceSettings {
4
+ automaticTurnOff: Daytime | undefined;
5
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TvSettings = void 0;
4
+ const deviceSettings_1 = require("./deviceSettings");
5
+ class TvSettings extends deviceSettings_1.DeviceSettings {
6
+ }
7
+ exports.TvSettings = TvSettings;
@@ -16,6 +16,7 @@ export declare enum DeviceCapability {
16
16
  speaker = 14,
17
17
  handleSensor = 15,
18
18
  batteryDriven = 16,
19
+ tv = 17,
19
20
  bluetoothDetector = 101,
20
21
  trackableDevice = 102
21
22
  }
@@ -20,6 +20,7 @@ var DeviceCapability;
20
20
  DeviceCapability[DeviceCapability["speaker"] = 14] = "speaker";
21
21
  DeviceCapability[DeviceCapability["handleSensor"] = 15] = "handleSensor";
22
22
  DeviceCapability[DeviceCapability["batteryDriven"] = 16] = "batteryDriven";
23
+ DeviceCapability[DeviceCapability["tv"] = 17] = "tv";
23
24
  DeviceCapability[DeviceCapability["bluetoothDetector"] = 101] = "bluetoothDetector";
24
25
  DeviceCapability[DeviceCapability["trackableDevice"] = 102] = "trackableDevice";
25
26
  })(DeviceCapability = exports.DeviceCapability || (exports.DeviceCapability = {}));
@@ -9,7 +9,7 @@ export interface iAcDevice extends iBaseDevice {
9
9
  * Disable automatic Turn-On for given amount of ms and turn off immediately.
10
10
  * @param {number} timeout
11
11
  */
12
- deactivateAutomaticTurnOn(timeout: number): void;
12
+ deactivateAutomaticChange(timeout: number): void;
13
13
  onTemperaturChange(newTemperatur: number): void;
14
14
  setDesiredMode(mode: AcMode, writeToDevice: boolean): void;
15
15
  turnOn(): void;
@@ -0,0 +1,8 @@
1
+ import { iRoomDevice } from './iRoomDevice';
2
+ export interface iTvDevice extends iRoomDevice {
3
+ readonly on: boolean;
4
+ turnOn(): void;
5
+ turnOff(): void;
6
+ volumeUp(): void;
7
+ volumeDown(): void;
8
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -15,4 +15,5 @@ export * from './iRoomDevice';
15
15
  export * from './iShutter';
16
16
  export * from './iSpeaker';
17
17
  export * from './iTemperatureSensor';
18
+ export * from './iTvDevice';
18
19
  export * from './iVibrationSensor';
@@ -31,4 +31,5 @@ __exportStar(require("./iRoomDevice"), exports);
31
31
  __exportStar(require("./iShutter"), exports);
32
32
  __exportStar(require("./iSpeaker"), exports);
33
33
  __exportStar(require("./iTemperatureSensor"), exports);
34
+ __exportStar(require("./iTvDevice"), exports);
34
35
  __exportStar(require("./iVibrationSensor"), exports);
@@ -17,5 +17,6 @@ export declare enum DeviceClusterType {
17
17
  TemperaturSensor = 16,
18
18
  HumiditySensor = 17,
19
19
  Ac = 18,
20
- WLED = 19
20
+ WLED = 19,
21
+ Tv = 20
21
22
  }
@@ -22,4 +22,5 @@ var DeviceClusterType;
22
22
  DeviceClusterType[DeviceClusterType["HumiditySensor"] = 17] = "HumiditySensor";
23
23
  DeviceClusterType[DeviceClusterType["Ac"] = 18] = "Ac";
24
24
  DeviceClusterType[DeviceClusterType["WLED"] = 19] = "WLED";
25
+ DeviceClusterType[DeviceClusterType["Tv"] = 20] = "Tv";
25
26
  })(DeviceClusterType = exports.DeviceClusterType || (exports.DeviceClusterType = {}));
@@ -29,6 +29,9 @@ class DeviceCluster {
29
29
  case deviceType_1.DeviceType.Sonos:
30
30
  clusterTypes.push(device_cluster_type_1.DeviceClusterType.Speaker);
31
31
  break;
32
+ case deviceType_1.DeviceType.SamsungTv:
33
+ clusterTypes.push(device_cluster_type_1.DeviceClusterType.Tv);
34
+ break;
32
35
  case deviceType_1.DeviceType.HmIpLampe:
33
36
  case deviceType_1.DeviceType.ZigbeeIlluDimmer:
34
37
  case deviceType_1.DeviceType.ZigbeeIlluLampe:
@@ -37,5 +37,6 @@ export declare enum DeviceType {
37
37
  Daikin = 2001,
38
38
  Sonos = 3001,
39
39
  Espresense = 4001,
40
- TrackableDevice = 4002
40
+ TrackableDevice = 4002,
41
+ SamsungTv = 5001
41
42
  }
@@ -42,4 +42,5 @@ var DeviceType;
42
42
  DeviceType[DeviceType["Sonos"] = 3001] = "Sonos";
43
43
  DeviceType[DeviceType["Espresense"] = 4001] = "Espresense";
44
44
  DeviceType[DeviceType["TrackableDevice"] = 4002] = "TrackableDevice";
45
+ DeviceType[DeviceType["SamsungTv"] = 5001] = "SamsungTv";
45
46
  })(DeviceType = exports.DeviceType || (exports.DeviceType = {}));
@@ -134,7 +134,7 @@ class HeatGroup extends base_group_1.BaseGroup {
134
134
  continue;
135
135
  }
136
136
  if (force) {
137
- dev.deactivateAutomaticTurnOn(60 * 60 * 1000);
137
+ dev.deactivateAutomaticChange(60 * 60 * 1000);
138
138
  continue;
139
139
  }
140
140
  dev.turnOff();
@@ -17,4 +17,5 @@ export * from './Griffe';
17
17
  export * from './Heizgruppen';
18
18
  export * from './iDeviceUpdater';
19
19
  export * from './IoBrokerBaseDevice';
20
+ export * from './tv';
20
21
  export * from './wledDevice';
@@ -33,4 +33,5 @@ __exportStar(require("./Griffe"), exports);
33
33
  __exportStar(require("./Heizgruppen"), exports);
34
34
  __exportStar(require("./iDeviceUpdater"), exports);
35
35
  __exportStar(require("./IoBrokerBaseDevice"), exports);
36
+ __exportStar(require("./tv"), exports);
36
37
  __exportStar(require("./wledDevice"), exports);
@@ -0,0 +1,2 @@
1
+ export * from './tvDevice';
2
+ export * from './tvDeviceType';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./tvDevice"), exports);
18
+ __exportStar(require("./tvDeviceType"), exports);
@@ -0,0 +1,15 @@
1
+ import { TvDevice } from './tvDevice';
2
+ import { DeviceType } from '../deviceType';
3
+ export declare class SamsungTv extends TvDevice {
4
+ deviceType: DeviceType;
5
+ private _device;
6
+ constructor(name: string, roomName: string, ip: string, mac: string, token: string);
7
+ private _on;
8
+ get on(): boolean;
9
+ automaticCheck(): void;
10
+ turnOff(): void;
11
+ turnOn(): void;
12
+ volumeDown(): void;
13
+ volumeUp(): void;
14
+ private sendKey;
15
+ }
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.SamsungTv = void 0;
27
+ const tvDevice_1 = require("./tvDevice");
28
+ const deviceType_1 = require("../deviceType");
29
+ const tvDeviceType_1 = require("./tvDeviceType");
30
+ const samsung_tv_control_1 = __importStar(require("samsung-tv-control"));
31
+ const models_1 = require("../../../models");
32
+ class SamsungTv extends tvDevice_1.TvDevice {
33
+ constructor(name, roomName, ip, mac, token) {
34
+ super(name, roomName, ip, tvDeviceType_1.TvDeviceType.Samsung);
35
+ this.deviceType = deviceType_1.DeviceType.SamsungTv;
36
+ this._on = false;
37
+ this._device = new samsung_tv_control_1.default({
38
+ debug: false,
39
+ ip: ip,
40
+ mac: mac,
41
+ nameApp: 'hoffmation',
42
+ port: 8001,
43
+ token: token,
44
+ });
45
+ }
46
+ get on() {
47
+ return this._on;
48
+ }
49
+ automaticCheck() {
50
+ this._device
51
+ .isAvailable()
52
+ .then((available) => {
53
+ this._on = available;
54
+ })
55
+ .catch((reason) => {
56
+ this.log(models_1.LogLevel.Warn, `Available check failed ${reason}`);
57
+ })
58
+ .finally(() => {
59
+ super.automaticCheck();
60
+ });
61
+ }
62
+ turnOff() {
63
+ this.sendKey(samsung_tv_control_1.KEYS.KEY_POWER);
64
+ }
65
+ turnOn() {
66
+ void this._device.turnOn();
67
+ }
68
+ volumeDown() {
69
+ this.sendKey(samsung_tv_control_1.KEYS.KEY_VOLDOWN);
70
+ }
71
+ volumeUp() {
72
+ this.sendKey(samsung_tv_control_1.KEYS.KEY_VOLUP);
73
+ }
74
+ sendKey(key) {
75
+ this._device.sendKey(key, (err, _res) => {
76
+ if (err) {
77
+ this.log(models_1.LogLevel.Warn, `SendKeyFailed: ${err}`);
78
+ }
79
+ });
80
+ }
81
+ }
82
+ exports.SamsungTv = SamsungTv;
@@ -0,0 +1,31 @@
1
+ import { DeviceInfo, DeviceType } from '../../devices';
2
+ import { LogLevel, RoomBase } from '../../../models';
3
+ import { iTvDevice } from '../baseDeviceInterfaces';
4
+ import { TvSettings } from '../../../models/deviceSettings/tvSettings';
5
+ import { DeviceCapability } from '../DeviceCapability';
6
+ import { LogDebugType } from '../../services';
7
+ import { TvDeviceType } from './tvDeviceType';
8
+ export declare abstract class TvDevice implements iTvDevice {
9
+ ip: string;
10
+ tvDeviceType: TvDeviceType;
11
+ tvSettings: TvSettings;
12
+ room: RoomBase | undefined;
13
+ deviceCapabilities: DeviceCapability[];
14
+ protected constructor(name: string, roomName: string, ip: string, tvDeviceType: TvDeviceType);
15
+ protected _info: DeviceInfo;
16
+ get info(): DeviceInfo;
17
+ set info(info: DeviceInfo);
18
+ abstract get deviceType(): DeviceType;
19
+ get name(): string;
20
+ get id(): string;
21
+ abstract get on(): boolean;
22
+ abstract volumeDown(): void;
23
+ abstract volumeUp(): void;
24
+ abstract turnOn(): void;
25
+ abstract turnOff(): void;
26
+ turnOffDueToMissingEnergy(): void;
27
+ log(level: LogLevel, message: string, debugType?: LogDebugType): void;
28
+ automaticCheck(): void;
29
+ persistDeviceInfo(): void;
30
+ toJSON(): Partial<TvDevice>;
31
+ }
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.TvDevice = void 0;
7
+ const devices_1 = require("../../devices");
8
+ const lodash_1 = __importDefault(require("lodash"));
9
+ const tvSettings_1 = require("../../../models/deviceSettings/tvSettings");
10
+ const DeviceCapability_1 = require("../DeviceCapability");
11
+ const services_1 = require("../../services");
12
+ class TvDevice {
13
+ constructor(name, roomName, ip, tvDeviceType) {
14
+ this.ip = ip;
15
+ this.tvDeviceType = tvDeviceType;
16
+ this.tvSettings = new tvSettings_1.TvSettings();
17
+ this.deviceCapabilities = [DeviceCapability_1.DeviceCapability.tv];
18
+ this._info = new devices_1.DeviceInfo();
19
+ this._info.fullName = `TV ${name}`;
20
+ this._info.customName = `${roomName} ${name}`;
21
+ this._info.room = roomName;
22
+ this._info.allDevicesKey = `tv-${roomName}-${name}`;
23
+ services_1.Utils.guardedInterval(this.automaticCheck, 60000, this, false);
24
+ }
25
+ get info() {
26
+ return this._info;
27
+ }
28
+ set info(info) {
29
+ this._info = info;
30
+ }
31
+ get name() {
32
+ return this.info.customName;
33
+ }
34
+ get id() {
35
+ var _a;
36
+ return (_a = this.info.allDevicesKey) !== null && _a !== void 0 ? _a : `ac-${this.info.room}-${this.info.customName}`;
37
+ }
38
+ turnOffDueToMissingEnergy() {
39
+ this.turnOff();
40
+ }
41
+ log(level, message, debugType = services_1.LogDebugType.None) {
42
+ var _a, _b;
43
+ services_1.ServerLogService.writeLog(level, `${this.name}: ${message}`, {
44
+ debugType: debugType,
45
+ room: (_b = (_a = this.room) === null || _a === void 0 ? void 0 : _a.roomName) !== null && _b !== void 0 ? _b : '',
46
+ deviceId: this.name,
47
+ deviceName: this.name,
48
+ });
49
+ }
50
+ automaticCheck() {
51
+ // TODO: Implement automatic turn off
52
+ }
53
+ persistDeviceInfo() {
54
+ services_1.Utils.guardedTimeout(() => {
55
+ var _a;
56
+ (_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.addDevice(this);
57
+ }, 5000, this);
58
+ }
59
+ toJSON() {
60
+ // eslint-disable-next-line
61
+ const result = lodash_1.default.omit(this, ['room']);
62
+ result['on'] = this.on;
63
+ return services_1.Utils.jsonFilter(result);
64
+ }
65
+ }
66
+ exports.TvDevice = TvDevice;
@@ -0,0 +1,4 @@
1
+ export declare enum TvDeviceType {
2
+ Unknown = 0,
3
+ Samsung = 1
4
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TvDeviceType = void 0;
4
+ var TvDeviceType;
5
+ (function (TvDeviceType) {
6
+ TvDeviceType[TvDeviceType["Unknown"] = 0] = "Unknown";
7
+ TvDeviceType[TvDeviceType["Samsung"] = 1] = "Samsung";
8
+ })(TvDeviceType = exports.TvDeviceType || (exports.TvDeviceType = {}));
@@ -33,7 +33,7 @@ export declare abstract class AcDevice implements iExcessEnergyConsumer, iRoomDe
33
33
  * Disable automatic Turn-On for given amount of ms and turn off immediately.
34
34
  * @param {number} timeout
35
35
  */
36
- deactivateAutomaticTurnOn(timeout?: number): void;
36
+ deactivateAutomaticChange(timeout?: number): void;
37
37
  abstract setDesiredMode(mode: AcMode, writeToDevice: boolean): void;
38
38
  abstract turnOn(): void;
39
39
  onTemperaturChange(newTemperatur: number): void;
@@ -43,7 +43,7 @@ export declare abstract class AcDevice implements iExcessEnergyConsumer, iRoomDe
43
43
  turnOffDueToMissingEnergy(): void;
44
44
  log(level: LogLevel, message: string, debugType?: LogDebugType): void;
45
45
  wasActivatedByExcessEnergy(): boolean;
46
- private automaticCheck;
46
+ protected automaticCheck(): void;
47
47
  persistDeviceInfo(): void;
48
48
  toJSON(): Partial<AcDevice>;
49
49
  }
@@ -30,7 +30,7 @@ class AcDevice {
30
30
  this._info.customName = `${roomName} ${name}`;
31
31
  this._info.room = roomName;
32
32
  this._info.allDevicesKey = `ac-${roomName}-${name}`;
33
- utils_1.Utils.guardedInterval(this.automaticCheck, 60000, this, true);
33
+ utils_1.Utils.guardedInterval(this.automaticCheck, 5 * 60 * 1000, this, true);
34
34
  utils_1.Utils.guardedInterval(this.persist, 15 * 60 * 1000, this, true);
35
35
  this.persistDeviceInfo();
36
36
  }
@@ -78,13 +78,13 @@ class AcDevice {
78
78
  const acOn = this.on;
79
79
  let threshold = acOn ? 0 : 1;
80
80
  let desiredMode = ac_mode_1.AcMode.Off;
81
- if ((_b = (_a = devices_1.Devices.energymanager) === null || _a === void 0 ? void 0 : _a.excessEnergy) !== null && _b !== void 0 ? _b : 0 > 1000) {
81
+ if ((_b = (_a = devices_1.Devices.energymanager) === null || _a === void 0 ? void 0 : _a.excessEnergy) !== null && _b !== void 0 ? _b : 0 > (acOn ? 200 : 1000)) {
82
82
  // As there is plenty of energy to spare we plan to overshoot the target by 1 degree
83
83
  threshold = -1;
84
84
  }
85
85
  const coolUntil = this.acSettings.stopCoolingTemperatur + threshold;
86
86
  const heatUntil = this.acSettings.stopHeatingTemperatur - threshold;
87
- if (temp > coolUntil && settings_service_1.SettingsService.heatMode !== config_1.HeatingMode.Winter) {
87
+ if (temp > coolUntil && settings_service_1.SettingsService.heatMode === config_1.HeatingMode.Sommer) {
88
88
  desiredMode = ac_mode_1.AcMode.Cooling;
89
89
  }
90
90
  else if (temp < heatUntil && this.acSettings.heatingAllowed && settings_service_1.SettingsService.heatMode !== config_1.HeatingMode.Sommer) {
@@ -99,9 +99,8 @@ class AcDevice {
99
99
  * Disable automatic Turn-On for given amount of ms and turn off immediately.
100
100
  * @param {number} timeout
101
101
  */
102
- deactivateAutomaticTurnOn(timeout = 60 * 60 * 1000) {
102
+ deactivateAutomaticChange(timeout = 60 * 60 * 1000) {
103
103
  this._blockAutomaticTurnOnMS = utils_1.Utils.nowMS() + timeout;
104
- this.turnOff();
105
104
  }
106
105
  onTemperaturChange(newTemperatur) {
107
106
  this.roomTemperatur = newTemperatur;
@@ -139,7 +138,7 @@ class AcDevice {
139
138
  automaticCheck() {
140
139
  var _a;
141
140
  const desiredMode = this.calculateDesiredMode();
142
- if (this.on === (desiredMode !== ac_mode_1.AcMode.Off)) {
141
+ if (utils_1.Utils.nowMS() < this._blockAutomaticTurnOnMS || this.on === (desiredMode !== ac_mode_1.AcMode.Off)) {
143
142
  // Device already in desired state --> do nothing
144
143
  return;
145
144
  }
@@ -77,12 +77,12 @@ class DaikinService {
77
77
  if (on) {
78
78
  dev.turnOn();
79
79
  }
80
- else if (force) {
81
- dev.deactivateAutomaticTurnOn(180 * 60 * 1000);
82
- }
83
80
  else {
84
81
  dev.turnOff();
85
82
  }
83
+ if (force) {
84
+ dev.deactivateAutomaticChange(180 * 60 * 1000);
85
+ }
86
86
  }
87
87
  }
88
88
  static async reconnect(name, ip) {
@@ -8,15 +8,18 @@ export declare class OwnDaikinDevice extends AcDevice {
8
8
  desiredHum: number | 'AUTO';
9
9
  desiredMode: number;
10
10
  deviceType: DeviceType;
11
+ private _on;
11
12
  constructor(name: string, roomName: string, ip: string, device: DaikinAC | undefined);
12
13
  private _device;
13
14
  get device(): DaikinAC | undefined;
14
- set device(device: DaikinAC | undefined);
15
15
  get on(): boolean;
16
+ set device(device: DaikinAC | undefined);
16
17
  setDesiredMode(mode: AcMode, writeToDevice?: boolean): void;
17
18
  turnOn(): void;
18
19
  turnOff(): void;
20
+ protected automaticCheck(): void;
19
21
  private setDesiredInfo;
22
+ private updateInfo;
20
23
  private handleDeviceUnreach;
21
24
  private handleParamNg;
22
25
  }
@@ -19,12 +19,16 @@ class OwnDaikinDevice extends ac_device_1.AcDevice {
19
19
  this.desiredHum = 'AUTO';
20
20
  this.desiredMode = daikin_controller_1.Mode.COLD;
21
21
  this.deviceType = devices_1.DeviceType.Daikin;
22
+ this._on = false;
22
23
  this.energyConsumerSettings.priority = 50;
23
24
  this._device = device;
24
25
  }
25
26
  get device() {
26
27
  return this._device;
27
28
  }
29
+ get on() {
30
+ return this._on;
31
+ }
28
32
  set device(device) {
29
33
  var _a;
30
34
  this._device = device;
@@ -36,10 +40,7 @@ class OwnDaikinDevice extends ac_device_1.AcDevice {
36
40
  log_service_1.ServerLogService.writeLog(models_1.LogLevel.Debug, `${this.name}_RequestLogger: ${data}`);
37
41
  });
38
42
  }
39
- }
40
- get on() {
41
- var _a, _b, _c;
42
- return (_c = (_b = (_a = this._device) === null || _a === void 0 ? void 0 : _a.currentACControlInfo) === null || _b === void 0 ? void 0 : _b.power) !== null && _c !== void 0 ? _c : false;
43
+ this.updateInfo();
43
44
  }
44
45
  setDesiredMode(mode, writeToDevice = true) {
45
46
  let newMode = -1;
@@ -71,6 +72,12 @@ class OwnDaikinDevice extends ac_device_1.AcDevice {
71
72
  this.desiredState = daikin_controller_1.Power.OFF;
72
73
  this.setDesiredInfo();
73
74
  }
75
+ automaticCheck() {
76
+ // First Load Device Info, then perform check
77
+ this.updateInfo().then((_on) => {
78
+ super.automaticCheck();
79
+ });
80
+ }
74
81
  setDesiredInfo(retry = false) {
75
82
  var _a;
76
83
  let targetTemp = this.desiredTemp;
@@ -87,6 +94,7 @@ class OwnDaikinDevice extends ac_device_1.AcDevice {
87
94
  targetTemperature: targetTemp,
88
95
  };
89
96
  (_a = this.device) === null || _a === void 0 ? void 0 : _a.setACControlInfo(changeObject, (err, res) => {
97
+ var _a;
90
98
  if (err !== null) {
91
99
  log_service_1.ServerLogService.writeLog(models_1.LogLevel.Warn, `Setting Ac Info for ${this.name} failed: ${err} `);
92
100
  if (err.message.includes('EHOSTUNREACH') && !retry) {
@@ -101,6 +109,7 @@ class OwnDaikinDevice extends ac_device_1.AcDevice {
101
109
  else if (res) {
102
110
  this.log(models_1.LogLevel.Info, `Changing Ac ${this.name} Settings was successful`);
103
111
  this.log(models_1.LogLevel.Debug, `Device Info ${JSON.stringify(res)}`, log_service_1.LogDebugType.DaikinSuccessfullControlInfo);
112
+ this._on = (_a = res.power) !== null && _a !== void 0 ? _a : this.desiredState;
104
113
  this.persist();
105
114
  }
106
115
  else {
@@ -108,6 +117,19 @@ class OwnDaikinDevice extends ac_device_1.AcDevice {
108
117
  }
109
118
  });
110
119
  }
120
+ updateInfo() {
121
+ return new Promise((res) => {
122
+ var _a;
123
+ (_a = this.device) === null || _a === void 0 ? void 0 : _a.getACControlInfo((_err, response) => {
124
+ var _a;
125
+ if (response) {
126
+ this.log(models_1.LogLevel.Trace, `Getting Ac ${this.name} info was successful`);
127
+ this._on = (_a = response.power) !== null && _a !== void 0 ? _a : this.desiredState;
128
+ }
129
+ res(this._on);
130
+ });
131
+ });
132
+ }
111
133
  handleDeviceUnreach() {
112
134
  this.log(models_1.LogLevel.Warn, `Detected EHOSTUNREACH for ${this.name}(${this.ip}), will try reconecting`);
113
135
  daikin_service_1.DaikinService.reconnect(this.name, this.ip).then((device) => {
@@ -59,9 +59,7 @@ class API {
59
59
  if (desiredState) {
60
60
  d.turnOn();
61
61
  }
62
- else {
63
- d.deactivateAutomaticTurnOn(60 * 60 * 1000);
64
- }
62
+ d.deactivateAutomaticChange(60 * 60 * 1000);
65
63
  return true;
66
64
  }
67
65
  /**