hoffmation-base 3.0.0-alpha.61 → 3.0.0-alpha.63

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 (26) hide show
  1. package/lib/server/devices/IoBrokerDeviceInfo.d.ts +7 -5
  2. package/lib/server/devices/IoBrokerDeviceInfo.js +49 -47
  3. package/lib/server/devices/device-cluster.js +1 -0
  4. package/lib/server/devices/deviceType.d.ts +3 -0
  5. package/lib/server/devices/deviceType.js +3 -0
  6. package/lib/server/devices/deviceUpdater.js +11 -0
  7. package/lib/server/devices/devices.d.ts +5 -0
  8. package/lib/server/devices/devices.js +18 -8
  9. package/lib/server/devices/index.d.ts +2 -0
  10. package/lib/server/devices/index.js +2 -0
  11. package/lib/server/devices/smartGarden/index.d.ts +6 -0
  12. package/lib/server/devices/smartGarden/index.js +22 -0
  13. package/lib/server/devices/smartGarden/smartGardenDevice.d.ts +33 -0
  14. package/lib/server/devices/smartGarden/smartGardenDevice.js +98 -0
  15. package/lib/server/devices/smartGarden/smartGardenDeviceRegistrationInfo.d.ts +9 -0
  16. package/lib/server/devices/smartGarden/smartGardenDeviceRegistrationInfo.js +13 -0
  17. package/lib/server/devices/smartGarden/smartGardenMower.d.ts +35 -0
  18. package/lib/server/devices/smartGarden/smartGardenMower.js +107 -0
  19. package/lib/server/devices/smartGarden/smartGardenSensor.d.ts +43 -0
  20. package/lib/server/devices/smartGarden/smartGardenSensor.js +119 -0
  21. package/lib/server/devices/smartGarden/smartGardenService.d.ts +7 -0
  22. package/lib/server/devices/smartGarden/smartGardenService.js +52 -0
  23. package/lib/server/devices/smartGarden/smartGardenValve.d.ts +36 -0
  24. package/lib/server/devices/smartGarden/smartGardenValve.js +105 -0
  25. package/lib/tsconfig.tsbuildinfo +1 -1
  26. package/package.json +1 -1
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SmartGardenMower = void 0;
4
+ const smartGardenDevice_1 = require("./smartGardenDevice");
5
+ const deviceType_1 = require("../deviceType");
6
+ const DeviceCapability_1 = require("../DeviceCapability");
7
+ const blockAutomaticHandler_1 = require("../../services/blockAutomaticHandler");
8
+ const models_1 = require("../../../models");
9
+ const sharedFunctions_1 = require("../sharedFunctions");
10
+ const services_1 = require("../../services");
11
+ class SmartGardenMower extends smartGardenDevice_1.SmartGardenDevice {
12
+ constructor(pInfo) {
13
+ super(pInfo, deviceType_1.DeviceType.SmartGardenMower);
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._activityControlStateId = `${pInfo.fullID}.SERVICE_MOWER_${this._deviceSerial}/activity_control_i`;
23
+ this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.actuator);
24
+ this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.blockAutomatic);
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) {
37
+ this.queuedValue = null;
38
+ super.update(idSplit, state, initial, true);
39
+ if (idSplit.length < 6) {
40
+ return;
41
+ }
42
+ const folder = idSplit[4];
43
+ const stateName = idSplit[5];
44
+ if (folder.indexOf('SERVICE_MOWER') === 0) {
45
+ switch (stateName) {
46
+ case 'activity_value':
47
+ this._actuatorOn = state.val;
48
+ this.persist();
49
+ break;
50
+ }
51
+ }
52
+ }
53
+ /** @inheritDoc */
54
+ setActuator(command) {
55
+ if (this._activityControlStateId === '') {
56
+ this.log(models_1.LogLevel.Error, 'Keine Switch ID bekannt.');
57
+ return;
58
+ }
59
+ sharedFunctions_1.LampUtils.setActuator(this, command);
60
+ }
61
+ /** @inheritDoc */
62
+ persist() {
63
+ var _a;
64
+ const now = services_1.Utils.nowMS();
65
+ if (this._lastPersist + 1000 > now) {
66
+ return;
67
+ }
68
+ (_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistActuator(this);
69
+ this._lastPersist = now;
70
+ }
71
+ /** @inheritDoc */
72
+ toggleActuator(command) {
73
+ const newVal = this.queuedValue !== null ? !this.queuedValue : !this._actuatorOn;
74
+ const setStateCommand = models_1.ActuatorSetStateCommand.byActuatorAndToggleCommand(this, command);
75
+ this.setActuator(setStateCommand);
76
+ return newVal;
77
+ }
78
+ /** @inheritDoc */
79
+ writeActuatorStateToDevice(c) {
80
+ if (!c.stateValue) {
81
+ this.park();
82
+ return;
83
+ }
84
+ // TODO: Add settings for duration
85
+ this.mov(4 * 60 * 60);
86
+ }
87
+ park(pauseGardenaPlan = true) {
88
+ if (pauseGardenaPlan) {
89
+ this.log(models_1.LogLevel.Info, 'Pausing Gardena Plan');
90
+ this.setState(this._activityControlStateId, 'PARK_UNTIL_FURTHER_NOTICE', undefined, (err) => {
91
+ this.log(models_1.LogLevel.Error, `Pausing gardena mower resulted in error: ${err}`);
92
+ });
93
+ return;
94
+ }
95
+ this.log(models_1.LogLevel.Info, 'Pausing until next task');
96
+ this.setState(this._activityControlStateId, 'PARK_UNTIL_NEXT_TASK', undefined, (err) => {
97
+ this.log(models_1.LogLevel.Error, `Pausing gardena mower resulted in error: ${err}`);
98
+ });
99
+ }
100
+ mov(durationInSeconds) {
101
+ this.log(models_1.LogLevel.Info, `Start moving for ${durationInSeconds} seconds`);
102
+ this.setState(this._activityControlStateId, durationInSeconds.toString(10), undefined, (err) => {
103
+ this.log(models_1.LogLevel.Error, `Starting gardena mower resulted in error: ${err}`);
104
+ });
105
+ }
106
+ }
107
+ exports.SmartGardenMower = SmartGardenMower;
@@ -0,0 +1,43 @@
1
+ /// <reference types="node" />
2
+ import { iHumiditySensor, iTemperatureSensor } from '../baseDeviceInterfaces';
3
+ import { SmartGardenDevice } from './smartGardenDevice';
4
+ import { HumiditySensorChangeAction, TemperatureSensorChangeAction } from '../../../models';
5
+ import { IoBrokerDeviceInfo } from '../IoBrokerDeviceInfo';
6
+ export declare class SmartGardenSensor extends SmartGardenDevice implements iHumiditySensor, iTemperatureSensor {
7
+ /** @inheritDoc */
8
+ readonly persistHumiditySensorInterval: NodeJS.Timeout;
9
+ /** @inheritDoc */
10
+ readonly persistTemperatureSensorInterval: NodeJS.Timeout;
11
+ private _humidityCallbacks;
12
+ private _humidity;
13
+ private _roomTemperature;
14
+ private _temperature;
15
+ private _temperaturCallbacks;
16
+ constructor(pInfo: IoBrokerDeviceInfo);
17
+ /** @inheritDoc */
18
+ get roomTemperature(): number;
19
+ /** @inheritDoc */
20
+ set roomTemperature(value: number);
21
+ /** @inheritDoc */
22
+ get humidity(): number;
23
+ private set humidity(value);
24
+ /** @inheritDoc */
25
+ get iTemperature(): number;
26
+ /** @inheritDoc */
27
+ get sTemperature(): string;
28
+ private set temperature(value);
29
+ /** @inheritDoc */
30
+ addHumidityCallback(pCallback: (action: HumiditySensorChangeAction) => void): void;
31
+ /** @inheritDoc */
32
+ addTempChangeCallback(pCallback: (action: TemperatureSensorChangeAction) => void): void;
33
+ /** @inheritDoc */
34
+ onTemperaturChange(newTemperatur: number): void;
35
+ /** @inheritDoc */
36
+ persistHumiditySensor(): void;
37
+ /** @inheritDoc */
38
+ persistTemperaturSensor(): void;
39
+ /** @inheritDoc */
40
+ update(idSplit: string[], state: ioBroker.State, initial?: boolean): void;
41
+ /** @inheritDoc */
42
+ dispose(): void;
43
+ }
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SmartGardenSensor = void 0;
4
+ const baseDeviceInterfaces_1 = require("../baseDeviceInterfaces");
5
+ const smartGardenDevice_1 = require("./smartGardenDevice");
6
+ const models_1 = require("../../../models");
7
+ const deviceType_1 = require("../deviceType");
8
+ const DeviceCapability_1 = require("../DeviceCapability");
9
+ const services_1 = require("../../services");
10
+ class SmartGardenSensor extends smartGardenDevice_1.SmartGardenDevice {
11
+ constructor(pInfo) {
12
+ super(pInfo, deviceType_1.DeviceType.SmartGardenSensor);
13
+ /** @inheritDoc */
14
+ this.persistHumiditySensorInterval = services_1.Utils.guardedInterval(() => {
15
+ this.persistHumiditySensor();
16
+ }, 5 * 60 * 1000, this, false);
17
+ /** @inheritDoc */
18
+ this.persistTemperatureSensorInterval = services_1.Utils.guardedInterval(() => {
19
+ this.persistTemperaturSensor();
20
+ }, 5 * 60 * 1000, this, false);
21
+ this._humidityCallbacks = [];
22
+ this._humidity = baseDeviceInterfaces_1.UNDEFINED_TEMP_VALUE;
23
+ this._roomTemperature = baseDeviceInterfaces_1.UNDEFINED_TEMP_VALUE;
24
+ this._temperature = baseDeviceInterfaces_1.UNDEFINED_TEMP_VALUE;
25
+ this._temperaturCallbacks = [];
26
+ this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.humiditySensor);
27
+ this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.temperatureSensor);
28
+ }
29
+ /** @inheritDoc */
30
+ get roomTemperature() {
31
+ return this._roomTemperature;
32
+ }
33
+ /** @inheritDoc */
34
+ set roomTemperature(value) {
35
+ this._roomTemperature = value;
36
+ }
37
+ /** @inheritDoc */
38
+ get humidity() {
39
+ return this._humidity;
40
+ }
41
+ set humidity(val) {
42
+ this._humidity = val;
43
+ for (const cb of this._humidityCallbacks) {
44
+ cb(new models_1.HumiditySensorChangeAction(this, val));
45
+ }
46
+ }
47
+ /** @inheritDoc */
48
+ get iTemperature() {
49
+ return this._temperature;
50
+ }
51
+ /** @inheritDoc */
52
+ get sTemperature() {
53
+ return `${this._temperature}°C`;
54
+ }
55
+ set temperature(val) {
56
+ this._temperature = val;
57
+ for (const cb of this._temperaturCallbacks) {
58
+ cb(new models_1.TemperatureSensorChangeAction(this, val));
59
+ }
60
+ }
61
+ /** @inheritDoc */
62
+ addHumidityCallback(pCallback) {
63
+ this._humidityCallbacks.push(pCallback);
64
+ if (this._humidity > 0) {
65
+ pCallback(new models_1.HumiditySensorChangeAction(this, this._humidity));
66
+ }
67
+ }
68
+ /** @inheritDoc */
69
+ addTempChangeCallback(pCallback) {
70
+ this._temperaturCallbacks.push(pCallback);
71
+ if (this._temperature > baseDeviceInterfaces_1.UNDEFINED_TEMP_VALUE) {
72
+ pCallback(new models_1.TemperatureSensorChangeAction(this, this._temperature));
73
+ }
74
+ }
75
+ /** @inheritDoc */
76
+ onTemperaturChange(newTemperatur) {
77
+ this.roomTemperature = newTemperatur;
78
+ }
79
+ /** @inheritDoc */
80
+ persistHumiditySensor() {
81
+ var _a;
82
+ (_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistHumiditySensor(this);
83
+ }
84
+ /** @inheritDoc */
85
+ persistTemperaturSensor() {
86
+ var _a;
87
+ (_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistTemperatureSensor(this);
88
+ }
89
+ /** @inheritDoc */
90
+ update(idSplit, state, initial = false) {
91
+ super.update(idSplit, state, initial, true);
92
+ if (idSplit.length < 6) {
93
+ return;
94
+ }
95
+ const folder = idSplit[4];
96
+ const stateName = idSplit[5];
97
+ if (folder.indexOf('SERVICE_SENSOR') === 0) {
98
+ switch (stateName) {
99
+ case 'soilHumidity_value':
100
+ this.humidity = state.val;
101
+ break;
102
+ case 'soilTemperature_value':
103
+ this.temperature = state.val;
104
+ break;
105
+ }
106
+ }
107
+ }
108
+ /** @inheritDoc */
109
+ dispose() {
110
+ if (this.persistTemperatureSensorInterval) {
111
+ clearInterval(this.persistTemperatureSensorInterval);
112
+ }
113
+ if (this.persistHumiditySensorInterval) {
114
+ clearInterval(this.persistHumiditySensorInterval);
115
+ }
116
+ super.dispose();
117
+ }
118
+ }
119
+ exports.SmartGardenSensor = SmartGardenSensor;
@@ -0,0 +1,7 @@
1
+ import { deviceConfig } from '../../../models';
2
+ import { SmartGardenDeviceRegistrationInfo } from './smartGardenDeviceRegistrationInfo';
3
+ export declare class SmartGardenService {
4
+ private static readonly _registeredDevices;
5
+ static preRegisterDevice(id: string, registrationInfo: SmartGardenDeviceRegistrationInfo): void;
6
+ static processSmartGardenDevice(cDevConf: deviceConfig): void;
7
+ }
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SmartGardenService = void 0;
4
+ const models_1 = require("../../../models");
5
+ const services_1 = require("../../services");
6
+ const IoBrokerDeviceInfo_1 = require("../IoBrokerDeviceInfo");
7
+ const deviceType_1 = require("../deviceType");
8
+ const devices_1 = require("../devices");
9
+ const smartGardenSensor_1 = require("./smartGardenSensor");
10
+ const smartGardenMower_1 = require("./smartGardenMower");
11
+ const smartGardenValve_1 = require("./smartGardenValve");
12
+ class SmartGardenService {
13
+ static preRegisterDevice(id, registrationInfo) {
14
+ this._registeredDevices.set(id, registrationInfo);
15
+ }
16
+ static processSmartGardenDevice(cDevConf) {
17
+ var _a;
18
+ const devName = (_a = cDevConf.common) === null || _a === void 0 ? void 0 : _a.name;
19
+ if (!devName || typeof devName !== 'string') {
20
+ return;
21
+ }
22
+ const registrationInfo = this._registeredDevices.get(devName);
23
+ if (!registrationInfo) {
24
+ services_1.ServerLogService.writeLog(models_1.LogLevel.Error, `SmartGarden Device ${devName} not registered`);
25
+ return;
26
+ }
27
+ const ioBrokerDeviceInfo = new IoBrokerDeviceInfo_1.IoBrokerDeviceInfo(cDevConf, registrationInfo.deviceId, deviceType_1.DeviceType[registrationInfo.deviceType], registrationInfo.room, registrationInfo.roomIndex);
28
+ const fullName = `${devices_1.Devices.IDENTIFIER_SMART_GARDEN}-${ioBrokerDeviceInfo.devID}`;
29
+ if (typeof devices_1.Devices.alLDevices[fullName] !== 'undefined') {
30
+ return;
31
+ }
32
+ ioBrokerDeviceInfo.allDevicesKey = fullName;
33
+ let d;
34
+ switch (registrationInfo.deviceType) {
35
+ case deviceType_1.DeviceType.SmartGardenSensor:
36
+ d = new smartGardenSensor_1.SmartGardenSensor(ioBrokerDeviceInfo);
37
+ break;
38
+ case deviceType_1.DeviceType.SmartGardenMower:
39
+ d = new smartGardenMower_1.SmartGardenMower(ioBrokerDeviceInfo);
40
+ break;
41
+ case deviceType_1.DeviceType.SmartGardenValve:
42
+ d = new smartGardenValve_1.SmartGardenValve(ioBrokerDeviceInfo);
43
+ break;
44
+ default:
45
+ services_1.ServerLogService.writeLog(models_1.LogLevel.Warn, `No SmartGarden Device Type for ${registrationInfo.deviceType} defined`);
46
+ return;
47
+ }
48
+ devices_1.Devices.alLDevices[fullName] = d;
49
+ }
50
+ }
51
+ exports.SmartGardenService = SmartGardenService;
52
+ SmartGardenService._registeredDevices = new Map();
@@ -0,0 +1,36 @@
1
+ import { SmartGardenDevice } from './smartGardenDevice';
2
+ import { iActuator } from '../baseDeviceInterfaces';
3
+ import { ActuatorSetStateCommand, ActuatorSettings, ActuatorToggleCommand, ActuatorWriteStateToDeviceCommand, RestoreTargetAutomaticValueCommand } from '../../../models';
4
+ import { BlockAutomaticHandler } from '../../services/blockAutomaticHandler';
5
+ import { IoBrokerDeviceInfo } from '../IoBrokerDeviceInfo';
6
+ export declare class SmartGardenValve extends SmartGardenDevice 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 _durationValueStateId;
17
+ private readonly _stopAllValvesStateId;
18
+ private _actuatorOn;
19
+ constructor(pInfo: IoBrokerDeviceInfo);
20
+ /** @inheritDoc */
21
+ get actuatorOn(): boolean;
22
+ /** @inheritDoc */
23
+ restoreTargetAutomaticValue(c: RestoreTargetAutomaticValueCommand): void;
24
+ /** @inheritDoc */
25
+ update(idSplit: string[], state: ioBroker.State, initial?: boolean): void;
26
+ /** @inheritDoc */
27
+ setActuator(command: ActuatorSetStateCommand): void;
28
+ /** @inheritDoc */
29
+ persist(): void;
30
+ /** @inheritDoc */
31
+ toggleActuator(command: ActuatorToggleCommand): boolean;
32
+ /** @inheritDoc */
33
+ writeActuatorStateToDevice(c: ActuatorWriteStateToDeviceCommand): void;
34
+ private stopIrrigation;
35
+ private irrigate;
36
+ }
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SmartGardenValve = void 0;
4
+ const smartGardenDevice_1 = require("./smartGardenDevice");
5
+ const models_1 = require("../../../models");
6
+ const blockAutomaticHandler_1 = require("../../services/blockAutomaticHandler");
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
+ // TODO: Add iValve interface and DeviceCapability
12
+ class SmartGardenValve extends smartGardenDevice_1.SmartGardenDevice {
13
+ constructor(pInfo) {
14
+ super(pInfo, deviceType_1.DeviceType.SmartGardenValve);
15
+ /** @inheritDoc */
16
+ this.targetAutomaticState = false;
17
+ /** @inheritDoc */
18
+ this.settings = new models_1.ActuatorSettings();
19
+ /** @inheritDoc */
20
+ this.queuedValue = null;
21
+ this._lastPersist = 0;
22
+ this._actuatorOn = false;
23
+ this._durationValueStateId = `${pInfo.fullID}.SERVICE_VALVE_${this._deviceSerial}/duration_value`;
24
+ this._stopAllValvesStateId = `${pInfo.fullID}.SERVICE_VALVE_SET_${this._deviceSerial}/stop_all_valves_i`;
25
+ this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.actuator);
26
+ this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.blockAutomatic);
27
+ this.blockAutomationHandler = new blockAutomaticHandler_1.BlockAutomaticHandler(this.restoreTargetAutomaticValue.bind(this), this.log.bind(this));
28
+ }
29
+ /** @inheritDoc */
30
+ get actuatorOn() {
31
+ return this._actuatorOn;
32
+ }
33
+ /** @inheritDoc */
34
+ restoreTargetAutomaticValue(c) {
35
+ this.setActuator(new models_1.ActuatorSetStateCommand(c, this.targetAutomaticState));
36
+ }
37
+ /** @inheritDoc */
38
+ update(idSplit, state, initial = false) {
39
+ this.queuedValue = null;
40
+ super.update(idSplit, state, initial, true);
41
+ if (idSplit.length < 6) {
42
+ return;
43
+ }
44
+ const folder = idSplit[4];
45
+ const stateName = idSplit[5];
46
+ if (folder.indexOf('SERVICE_VALVE') === 0) {
47
+ switch (stateName) {
48
+ case 'activity_value':
49
+ this._actuatorOn = state.val !== 'CLOSED';
50
+ this.persist();
51
+ break;
52
+ }
53
+ }
54
+ }
55
+ /** @inheritDoc */
56
+ setActuator(command) {
57
+ if (this._durationValueStateId === '') {
58
+ this.log(models_1.LogLevel.Error, 'Keine Switch ID bekannt.');
59
+ return;
60
+ }
61
+ sharedFunctions_1.LampUtils.setActuator(this, command);
62
+ }
63
+ /** @inheritDoc */
64
+ persist() {
65
+ var _a;
66
+ const now = services_1.Utils.nowMS();
67
+ if (this._lastPersist + 1000 > now) {
68
+ return;
69
+ }
70
+ (_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistActuator(this);
71
+ this._lastPersist = now;
72
+ }
73
+ /** @inheritDoc */
74
+ toggleActuator(command) {
75
+ const newVal = this.queuedValue !== null ? !this.queuedValue : !this._actuatorOn;
76
+ const setStateCommand = models_1.ActuatorSetStateCommand.byActuatorAndToggleCommand(this, command);
77
+ this.setActuator(setStateCommand);
78
+ return newVal;
79
+ }
80
+ /** @inheritDoc */
81
+ writeActuatorStateToDevice(c) {
82
+ if (!c.stateValue) {
83
+ this.stopIrrigation();
84
+ return;
85
+ }
86
+ // TODO: Add settings for duration
87
+ this.irrigate(15 * 60);
88
+ }
89
+ stopIrrigation() {
90
+ this.log(models_1.LogLevel.Info, 'Stopping irrigation until next task');
91
+ this.setState(this._stopAllValvesStateId, 'STOP_UNTIL_NEXT_TASK', undefined, (err) => {
92
+ this.log(models_1.LogLevel.Error, `Stopping irrigation immediately resulted in error: ${err}`);
93
+ });
94
+ this.setState(this._durationValueStateId, 'STOP_UNTIL_NEXT_TASK', undefined, (err) => {
95
+ this.log(models_1.LogLevel.Error, `Prevent irrigation restart resulted in error: ${err}`);
96
+ });
97
+ }
98
+ irrigate(durationInSeconds) {
99
+ this.log(models_1.LogLevel.Info, `Start irrigation for ${durationInSeconds} seconds`);
100
+ this.setState(this._durationValueStateId, durationInSeconds.toString(10), undefined, (err) => {
101
+ this.log(models_1.LogLevel.Error, `Starting irrigation resulted in error: ${err}`);
102
+ });
103
+ }
104
+ }
105
+ exports.SmartGardenValve = SmartGardenValve;