homebridge-tuya-without-developer-account 1.0.0
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/CHANGELOG.md +10 -0
- package/LICENSE +20 -0
- package/PUBLISHING.md +80 -0
- package/README.md +233 -0
- package/SUPPORTED_DEVICES.md +206 -0
- package/config.schema.json +131 -0
- package/dist/cloud/api/TuyaHACloudAPI.js +286 -0
- package/dist/cloud/api/TuyaHASharingMQ.js +114 -0
- package/dist/cloud/device/TuyaDevice.js +50 -0
- package/dist/cloud/device/TuyaHADeviceManager.js +355 -0
- package/dist/index.js +7 -0
- package/dist/platform.js +397 -0
- package/dist/settings.js +18 -0
- package/dist/shared/AccessoryFactory.js +276 -0
- package/dist/shared/accessories/AccessoryFactory.js +305 -0
- package/dist/shared/accessories/AirConditionerAccessory.js +307 -0
- package/dist/shared/accessories/AirPurifierAccessory.js +90 -0
- package/dist/shared/accessories/AirQualitySensorAccessory.js +30 -0
- package/dist/shared/accessories/BaseAccessory.js +406 -0
- package/dist/shared/accessories/BlindsAccessory.js +199 -0
- package/dist/shared/accessories/CameraAccessory.js +121 -0
- package/dist/shared/accessories/CarbonDioxideSensorAccessory.js +52 -0
- package/dist/shared/accessories/CarbonMonoxideSensorAccessory.js +52 -0
- package/dist/shared/accessories/ContactSensorAccessory.js +30 -0
- package/dist/shared/accessories/DehumidifierAccessory.js +68 -0
- package/dist/shared/accessories/DiffuserAccessory.js +55 -0
- package/dist/shared/accessories/DimmerAccessory.js +94 -0
- package/dist/shared/accessories/DoorbellAccessory.js +91 -0
- package/dist/shared/accessories/ExtractionHoodAccessory.js +120 -0
- package/dist/shared/accessories/FanAccessory.js +129 -0
- package/dist/shared/accessories/GarageDoorAccessory.js +69 -0
- package/dist/shared/accessories/HeaterAccessory.js +102 -0
- package/dist/shared/accessories/HeaterAccessory_old.js +96 -0
- package/dist/shared/accessories/HumanPresenceSensorAccessory.js +20 -0
- package/dist/shared/accessories/HumidifierAccessory.js +137 -0
- package/dist/shared/accessories/IRAirConditionerAccessory.js +278 -0
- package/dist/shared/accessories/IRControlHubAccessory.js +49 -0
- package/dist/shared/accessories/IRControlHubSubAccessory.js +52 -0
- package/dist/shared/accessories/IRGenericAccessory.js +49 -0
- package/dist/shared/accessories/LeakSensorAccessory.js +36 -0
- package/dist/shared/accessories/LightAccessory.js +36 -0
- package/dist/shared/accessories/LightSensorAccessory.js +32 -0
- package/dist/shared/accessories/LocationWeatherAccessory.js +72 -0
- package/dist/shared/accessories/LockAccessory.js +56 -0
- package/dist/shared/accessories/MotionSensorAccessory.js +20 -0
- package/dist/shared/accessories/OutletAccessory.js +23 -0
- package/dist/shared/accessories/PetFeederAccessory.js +139 -0
- package/dist/shared/accessories/SceneAccessory.js +32 -0
- package/dist/shared/accessories/SceneSwitchAccessory.js +44 -0
- package/dist/shared/accessories/SecuritySystemAccessory.js +30 -0
- package/dist/shared/accessories/SmokeSensorAccessory.js +35 -0
- package/dist/shared/accessories/SwitchAccessory.js +148 -0
- package/dist/shared/accessories/TemperatureHumiditySensorAccessory.js +24 -0
- package/dist/shared/accessories/ThermostatAccessory.js +192 -0
- package/dist/shared/accessories/TowerRackAccessory.js +157 -0
- package/dist/shared/accessories/ValveAccessory.js +45 -0
- package/dist/shared/accessories/VibrationSensorAccessory.js +46 -0
- package/dist/shared/accessories/WeatherStationAccessory.js +58 -0
- package/dist/shared/accessories/WetBulbGlobeTemperatureAccessory.js +23 -0
- package/dist/shared/accessories/WhiteNoiseLightAccessory.js +59 -0
- package/dist/shared/accessories/WindowAccessory.js +14 -0
- package/dist/shared/accessories/WindowCoveringAccessory.js +156 -0
- package/dist/shared/accessories/WirelessSwitchAccessory.js +42 -0
- package/dist/shared/accessories/characteristic/Active.js +22 -0
- package/dist/shared/accessories/characteristic/AirQuality.js +74 -0
- package/dist/shared/accessories/characteristic/CurrentRelativeHumidity.js +23 -0
- package/dist/shared/accessories/characteristic/CurrentTemperature.js +23 -0
- package/dist/shared/accessories/characteristic/CurrentWeather.js +49 -0
- package/dist/shared/accessories/characteristic/CurrentWeatherByOpenMeteo.js +49 -0
- package/dist/shared/accessories/characteristic/CurrentWetBulbGlobeTemperature.js +48 -0
- package/dist/shared/accessories/characteristic/EnergyUsage.js +98 -0
- package/dist/shared/accessories/characteristic/Light.js +268 -0
- package/dist/shared/accessories/characteristic/LightSensor.js +23 -0
- package/dist/shared/accessories/characteristic/LockPhysicalControls.js +21 -0
- package/dist/shared/accessories/characteristic/MotionDetected.js +22 -0
- package/dist/shared/accessories/characteristic/Name.js +15 -0
- package/dist/shared/accessories/characteristic/OccupancyDetected.js +19 -0
- package/dist/shared/accessories/characteristic/On.js +25 -0
- package/dist/shared/accessories/characteristic/OutletInUse.js +14 -0
- package/dist/shared/accessories/characteristic/ProgrammableSwitchEvent.js +89 -0
- package/dist/shared/accessories/characteristic/RelativeHumidityDehumidifierThreshold.js +28 -0
- package/dist/shared/accessories/characteristic/RotationSpeed.js +78 -0
- package/dist/shared/accessories/characteristic/SecuritySystemState.js +74 -0
- package/dist/shared/accessories/characteristic/SwingMode.js +21 -0
- package/dist/shared/accessories/characteristic/TargetTemperature.js +29 -0
- package/dist/shared/accessories/characteristic/TemperatureDisplayUnits.js +25 -0
- package/dist/shared/util/ConfigHash.js +79 -0
- package/dist/shared/util/FfmpegStreamingProcess.js +126 -0
- package/dist/shared/util/InfraredTool.js +392 -0
- package/dist/shared/util/Logger.js +42 -0
- package/dist/shared/util/TuyaRecordingDelegate.js +22 -0
- package/dist/shared/util/TuyaStreamDelegate.js +329 -0
- package/dist/shared/util/color.js +23 -0
- package/dist/shared/util/util.js +135 -0
- package/homebridge-ui/public/index.html +329 -0
- package/homebridge-ui/server.js +224 -0
- package/package.json +61 -0
|
@@ -0,0 +1,120 @@
|
|
|
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
|
+
const TuyaDevice_1 = require("../../cloud/device/TuyaDevice");
|
|
7
|
+
const BaseAccessory_1 = __importDefault(require("./BaseAccessory"));
|
|
8
|
+
const Active_1 = require("./characteristic/Active");
|
|
9
|
+
const LockPhysicalControls_1 = require("./characteristic/LockPhysicalControls");
|
|
10
|
+
const RotationSpeed_1 = require("./characteristic/RotationSpeed");
|
|
11
|
+
const Light_1 = require("./characteristic/Light");
|
|
12
|
+
const On_1 = require("./characteristic/On");
|
|
13
|
+
const SCHEMA_CODE = {
|
|
14
|
+
ACTIVE: ['switch'],
|
|
15
|
+
MODE: ['mode'],
|
|
16
|
+
LOCK: ['lock'],
|
|
17
|
+
SPEED: ['speed'],
|
|
18
|
+
SPEED_LEVEL: ['fan_speed_enum', 'speed'],
|
|
19
|
+
AIR_QUALITY: ['air_quality', 'pm25'],
|
|
20
|
+
PM2_5: ['pm25'],
|
|
21
|
+
VOC: ['tvoc'],
|
|
22
|
+
LIGHT_ON: ['light', 'switch_led'],
|
|
23
|
+
LIGHT_MODE: ['work_mode'],
|
|
24
|
+
LIGHT_BRIGHT: ['bright_value', 'bright_value_v2'],
|
|
25
|
+
LIGHT_TEMP: ['temp_value', 'temp_value_v2'],
|
|
26
|
+
LIGHT_COLOR: ['colour_data'],
|
|
27
|
+
};
|
|
28
|
+
class ExtractionHoodAccessory extends BaseAccessory_1.default {
|
|
29
|
+
requiredSchema() {
|
|
30
|
+
return [SCHEMA_CODE.ACTIVE];
|
|
31
|
+
}
|
|
32
|
+
configureServices() {
|
|
33
|
+
(0, Active_1.configureActive)(this, this.mainService(), this.getSchema(...SCHEMA_CODE.ACTIVE));
|
|
34
|
+
this.configureCurrentState();
|
|
35
|
+
this.configureTargetState();
|
|
36
|
+
(0, LockPhysicalControls_1.configureLockPhysicalControls)(this, this.mainService(), this.getSchema(...SCHEMA_CODE.LOCK));
|
|
37
|
+
if (this.getFanSpeedSchema()) {
|
|
38
|
+
(0, RotationSpeed_1.configureRotationSpeed)(this, this.mainService(), this.getFanSpeedSchema());
|
|
39
|
+
}
|
|
40
|
+
else if (this.getFanSpeedLevelSchema()) {
|
|
41
|
+
(0, RotationSpeed_1.configureRotationSpeedLevel)(this, this.mainService(), this.getFanSpeedLevelSchema());
|
|
42
|
+
}
|
|
43
|
+
// Light
|
|
44
|
+
if (this.getSchema(...SCHEMA_CODE.LIGHT_ON)) {
|
|
45
|
+
if (this.lightServiceType() === this.Service.Lightbulb) {
|
|
46
|
+
(0, Light_1.configureLight)(this, this.lightService(), this.getSchema(...SCHEMA_CODE.LIGHT_ON), this.getSchema(...SCHEMA_CODE.LIGHT_BRIGHT), this.getSchema(...SCHEMA_CODE.LIGHT_TEMP), this.getSchema(...SCHEMA_CODE.LIGHT_COLOR), this.getSchema(...SCHEMA_CODE.LIGHT_MODE));
|
|
47
|
+
}
|
|
48
|
+
else if (this.lightServiceType() === this.Service.Switch) {
|
|
49
|
+
(0, On_1.configureOn)(this, undefined, this.getSchema(...SCHEMA_CODE.LIGHT_ON));
|
|
50
|
+
const unusedService = this.accessory.getService(this.Service.Lightbulb);
|
|
51
|
+
if (unusedService) {
|
|
52
|
+
this.accessory.removeService(unusedService);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
mainService() {
|
|
58
|
+
return this.accessory.getService(this.Service.AirPurifier)
|
|
59
|
+
|| this.accessory.addService(this.Service.AirPurifier);
|
|
60
|
+
}
|
|
61
|
+
getFanSpeedSchema() {
|
|
62
|
+
const schema = this.getSchema(...SCHEMA_CODE.SPEED);
|
|
63
|
+
if (schema && schema.type === TuyaDevice_1.TuyaDeviceSchemaType.Integer) {
|
|
64
|
+
return schema;
|
|
65
|
+
}
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
getFanSpeedLevelSchema() {
|
|
69
|
+
const schema = this.getSchema(...SCHEMA_CODE.SPEED_LEVEL);
|
|
70
|
+
if (schema && schema.type === TuyaDevice_1.TuyaDeviceSchemaType.Enum) {
|
|
71
|
+
return schema;
|
|
72
|
+
}
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
75
|
+
configureCurrentState() {
|
|
76
|
+
const schema = this.getSchema(...SCHEMA_CODE.ACTIVE);
|
|
77
|
+
if (!schema) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const { INACTIVE, PURIFYING_AIR } = this.Characteristic.CurrentAirPurifierState;
|
|
81
|
+
this.mainService().getCharacteristic(this.Characteristic.CurrentAirPurifierState)
|
|
82
|
+
.onGet(() => {
|
|
83
|
+
const status = this.getStatus(schema.code);
|
|
84
|
+
return status.value ? PURIFYING_AIR : INACTIVE;
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
configureTargetState() {
|
|
88
|
+
const schema = this.getSchema(...SCHEMA_CODE.MODE);
|
|
89
|
+
if (!schema) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const { MANUAL, AUTO } = this.Characteristic.TargetAirPurifierState;
|
|
93
|
+
this.mainService().getCharacteristic(this.Characteristic.TargetAirPurifierState)
|
|
94
|
+
.onGet(() => {
|
|
95
|
+
const status = this.getStatus(schema.code);
|
|
96
|
+
return (status.value === 'auto') ? AUTO : MANUAL;
|
|
97
|
+
})
|
|
98
|
+
.onSet(async (value) => {
|
|
99
|
+
await this.sendCommands([{
|
|
100
|
+
code: schema.code,
|
|
101
|
+
value: (value === AUTO) ? 'auto' : 'manual',
|
|
102
|
+
}], true);
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
lightServiceType() {
|
|
106
|
+
if (this.getSchema(...SCHEMA_CODE.LIGHT_BRIGHT)
|
|
107
|
+
|| this.getSchema(...SCHEMA_CODE.LIGHT_TEMP)
|
|
108
|
+
|| this.getSchema(...SCHEMA_CODE.LIGHT_COLOR)
|
|
109
|
+
|| this.getSchema(...SCHEMA_CODE.LIGHT_MODE)) {
|
|
110
|
+
return this.Service.Lightbulb;
|
|
111
|
+
}
|
|
112
|
+
return this.Service.Switch;
|
|
113
|
+
}
|
|
114
|
+
lightService() {
|
|
115
|
+
return this.accessory.getService(this.Service.Lightbulb)
|
|
116
|
+
|| this.accessory.addService(this.Service.Lightbulb);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
exports.default = ExtractionHoodAccessory;
|
|
120
|
+
//# sourceMappingURL=ExtractionHoodAccessory.js.map
|
|
@@ -0,0 +1,129 @@
|
|
|
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
|
+
const TuyaDevice_1 = require("../../cloud/device/TuyaDevice");
|
|
7
|
+
const BaseAccessory_1 = __importDefault(require("./BaseAccessory"));
|
|
8
|
+
const Active_1 = require("./characteristic/Active");
|
|
9
|
+
const Light_1 = require("./characteristic/Light");
|
|
10
|
+
const LockPhysicalControls_1 = require("./characteristic/LockPhysicalControls");
|
|
11
|
+
const On_1 = require("./characteristic/On");
|
|
12
|
+
const RotationSpeed_1 = require("./characteristic/RotationSpeed");
|
|
13
|
+
const SwingMode_1 = require("./characteristic/SwingMode");
|
|
14
|
+
const SCHEMA_CODE = {
|
|
15
|
+
FAN_ON: ['switch_fan', 'fan_switch', 'switch'],
|
|
16
|
+
FAN_DIRECTION: ['fan_direction'],
|
|
17
|
+
FAN_SPEED: ['fan_speed', 'fan_speed_percent'],
|
|
18
|
+
FAN_SPEED_LEVEL: ['fan_speed_enum', 'fan_speed'],
|
|
19
|
+
FAN_LOCK: ['child_lock'],
|
|
20
|
+
FAN_SWING: ['switch_horizontal', 'switch_vertical'],
|
|
21
|
+
LIGHT_ON: ['light', 'switch_led'],
|
|
22
|
+
LIGHT_MODE: ['work_mode'],
|
|
23
|
+
LIGHT_BRIGHT: ['bright_value', 'bright_value_v2'],
|
|
24
|
+
LIGHT_TEMP: ['temp_value', 'temp_value_v2'],
|
|
25
|
+
LIGHT_COLOR: ['colour_data'],
|
|
26
|
+
};
|
|
27
|
+
class FanAccessory extends BaseAccessory_1.default {
|
|
28
|
+
requiredSchema() {
|
|
29
|
+
return [SCHEMA_CODE.FAN_ON];
|
|
30
|
+
}
|
|
31
|
+
configureServices() {
|
|
32
|
+
if (this.fanServiceType() === this.Service.Fan) {
|
|
33
|
+
const unusedService = this.accessory.getService(this.Service.Fanv2);
|
|
34
|
+
if (unusedService) {
|
|
35
|
+
this.accessory.removeService(unusedService);
|
|
36
|
+
}
|
|
37
|
+
(0, On_1.configureOn)(this, this.fanService(), this.getSchema(...SCHEMA_CODE.FAN_ON));
|
|
38
|
+
}
|
|
39
|
+
else if (this.fanServiceType() === this.Service.Fanv2) {
|
|
40
|
+
const unusedService = this.accessory.getService(this.Service.Fan);
|
|
41
|
+
if (unusedService) {
|
|
42
|
+
this.accessory.removeService(unusedService);
|
|
43
|
+
}
|
|
44
|
+
(0, Active_1.configureActive)(this, this.fanService(), this.getSchema(...SCHEMA_CODE.FAN_ON));
|
|
45
|
+
(0, LockPhysicalControls_1.configureLockPhysicalControls)(this, this.fanService(), this.getSchema(...SCHEMA_CODE.FAN_LOCK));
|
|
46
|
+
(0, SwingMode_1.configureSwingMode)(this, this.fanService(), this.getSchema(...SCHEMA_CODE.FAN_SWING));
|
|
47
|
+
}
|
|
48
|
+
// Common Characteristics
|
|
49
|
+
if (this.getFanSpeedSchema()) {
|
|
50
|
+
(0, RotationSpeed_1.configureRotationSpeed)(this, this.fanService(), this.getFanSpeedSchema());
|
|
51
|
+
}
|
|
52
|
+
else if (this.getFanSpeedLevelSchema()) {
|
|
53
|
+
(0, RotationSpeed_1.configureRotationSpeedLevel)(this, this.fanService(), this.getFanSpeedLevelSchema());
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
(0, RotationSpeed_1.configureRotationSpeedOn)(this, this.fanService(), this.getSchema(...SCHEMA_CODE.FAN_ON));
|
|
57
|
+
}
|
|
58
|
+
this.configureRotationDirection();
|
|
59
|
+
// Light
|
|
60
|
+
if (this.getSchema(...SCHEMA_CODE.LIGHT_ON)) {
|
|
61
|
+
if (this.lightServiceType() === this.Service.Lightbulb) {
|
|
62
|
+
(0, Light_1.configureLight)(this, this.lightService(), this.getSchema(...SCHEMA_CODE.LIGHT_ON), this.getSchema(...SCHEMA_CODE.LIGHT_BRIGHT), this.getSchema(...SCHEMA_CODE.LIGHT_TEMP), this.getSchema(...SCHEMA_CODE.LIGHT_COLOR), this.getSchema(...SCHEMA_CODE.LIGHT_MODE));
|
|
63
|
+
}
|
|
64
|
+
else if (this.lightServiceType() === this.Service.Switch) {
|
|
65
|
+
(0, On_1.configureOn)(this, undefined, this.getSchema(...SCHEMA_CODE.LIGHT_ON));
|
|
66
|
+
const unusedService = this.accessory.getService(this.Service.Lightbulb);
|
|
67
|
+
if (unusedService) {
|
|
68
|
+
this.accessory.removeService(unusedService);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
fanServiceType() {
|
|
74
|
+
if (this.getSchema(...SCHEMA_CODE.FAN_LOCK)
|
|
75
|
+
|| this.getSchema(...SCHEMA_CODE.FAN_SWING)) {
|
|
76
|
+
return this.Service.Fanv2;
|
|
77
|
+
}
|
|
78
|
+
return this.Service.Fan;
|
|
79
|
+
}
|
|
80
|
+
fanService() {
|
|
81
|
+
const serviceType = this.fanServiceType();
|
|
82
|
+
return this.accessory.getService(serviceType)
|
|
83
|
+
|| this.accessory.addService(serviceType);
|
|
84
|
+
}
|
|
85
|
+
lightServiceType() {
|
|
86
|
+
if (this.getSchema(...SCHEMA_CODE.LIGHT_BRIGHT)
|
|
87
|
+
|| this.getSchema(...SCHEMA_CODE.LIGHT_TEMP)
|
|
88
|
+
|| this.getSchema(...SCHEMA_CODE.LIGHT_COLOR)
|
|
89
|
+
|| this.getSchema(...SCHEMA_CODE.LIGHT_MODE)) {
|
|
90
|
+
return this.Service.Lightbulb;
|
|
91
|
+
}
|
|
92
|
+
return this.Service.Switch;
|
|
93
|
+
}
|
|
94
|
+
lightService() {
|
|
95
|
+
return this.accessory.getService(this.Service.Lightbulb)
|
|
96
|
+
|| this.accessory.addService(this.Service.Lightbulb);
|
|
97
|
+
}
|
|
98
|
+
getFanSpeedSchema() {
|
|
99
|
+
const schema = this.getSchema(...SCHEMA_CODE.FAN_SPEED);
|
|
100
|
+
if (schema && schema.type === TuyaDevice_1.TuyaDeviceSchemaType.Integer) {
|
|
101
|
+
return schema;
|
|
102
|
+
}
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
105
|
+
getFanSpeedLevelSchema() {
|
|
106
|
+
const schema = this.getSchema(...SCHEMA_CODE.FAN_SPEED_LEVEL);
|
|
107
|
+
if (schema && schema.type === TuyaDevice_1.TuyaDeviceSchemaType.Enum) {
|
|
108
|
+
return schema;
|
|
109
|
+
}
|
|
110
|
+
return undefined;
|
|
111
|
+
}
|
|
112
|
+
configureRotationDirection() {
|
|
113
|
+
const schema = this.getSchema(...SCHEMA_CODE.FAN_DIRECTION);
|
|
114
|
+
if (!schema) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
const { CLOCKWISE, COUNTER_CLOCKWISE } = this.Characteristic.RotationDirection;
|
|
118
|
+
this.fanService().getCharacteristic(this.Characteristic.RotationDirection)
|
|
119
|
+
.onGet(() => {
|
|
120
|
+
const status = this.getStatus(schema.code);
|
|
121
|
+
return (status.value !== 'reverse') ? CLOCKWISE : COUNTER_CLOCKWISE;
|
|
122
|
+
})
|
|
123
|
+
.onSet(async (value) => {
|
|
124
|
+
await this.sendCommands([{ code: schema.code, value: (value === CLOCKWISE) ? 'forward' : 'reverse' }]);
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
exports.default = FanAccessory;
|
|
129
|
+
//# sourceMappingURL=FanAccessory.js.map
|
|
@@ -0,0 +1,69 @@
|
|
|
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
|
+
const BaseAccessory_1 = __importDefault(require("./BaseAccessory"));
|
|
7
|
+
const SCHEMA_CODE = {
|
|
8
|
+
CURRENT_DOOR_STATE: ['doorcontact_state'],
|
|
9
|
+
TARGET_DOOR_STATE: ['switch_1'],
|
|
10
|
+
};
|
|
11
|
+
class GarageDoorAccessory extends BaseAccessory_1.default {
|
|
12
|
+
requiredSchema() {
|
|
13
|
+
return [SCHEMA_CODE.TARGET_DOOR_STATE];
|
|
14
|
+
}
|
|
15
|
+
configureServices() {
|
|
16
|
+
this.configureCurrentDoorState();
|
|
17
|
+
this.configureTargetDoorState();
|
|
18
|
+
}
|
|
19
|
+
mainService() {
|
|
20
|
+
return this.accessory.getService(this.Service.GarageDoorOpener)
|
|
21
|
+
|| this.accessory.addService(this.Service.GarageDoorOpener);
|
|
22
|
+
}
|
|
23
|
+
configureCurrentDoorState() {
|
|
24
|
+
const { OPEN, CLOSED, OPENING, CLOSING, STOPPED } = this.Characteristic.CurrentDoorState;
|
|
25
|
+
this.mainService().getCharacteristic(this.Characteristic.CurrentDoorState)
|
|
26
|
+
.onGet(() => {
|
|
27
|
+
const currentSchema = this.getSchema(...SCHEMA_CODE.CURRENT_DOOR_STATE);
|
|
28
|
+
const targetSchema = this.getSchema(...SCHEMA_CODE.TARGET_DOOR_STATE);
|
|
29
|
+
if (!currentSchema || !targetSchema) {
|
|
30
|
+
return STOPPED;
|
|
31
|
+
}
|
|
32
|
+
const currentStatus = this.getStatus(currentSchema.code);
|
|
33
|
+
const targetStatus = this.getStatus(targetSchema.code);
|
|
34
|
+
if (currentStatus.value === true && targetStatus.value === true) {
|
|
35
|
+
return OPEN;
|
|
36
|
+
}
|
|
37
|
+
else if (currentStatus.value === false && targetStatus.value === false) {
|
|
38
|
+
return CLOSED;
|
|
39
|
+
}
|
|
40
|
+
else if (currentStatus.value === false && targetStatus.value === true) {
|
|
41
|
+
return OPENING;
|
|
42
|
+
}
|
|
43
|
+
else if (currentStatus.value === true && targetStatus.value === false) {
|
|
44
|
+
return CLOSING;
|
|
45
|
+
}
|
|
46
|
+
return STOPPED;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
configureTargetDoorState() {
|
|
50
|
+
const schema = this.getSchema(...SCHEMA_CODE.TARGET_DOOR_STATE);
|
|
51
|
+
if (!schema) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const { OPEN, CLOSED } = this.Characteristic.TargetDoorState;
|
|
55
|
+
this.mainService().getCharacteristic(this.Characteristic.TargetDoorState)
|
|
56
|
+
.onGet(() => {
|
|
57
|
+
const status = this.getStatus(schema.code);
|
|
58
|
+
return status.value ? OPEN : CLOSED;
|
|
59
|
+
})
|
|
60
|
+
.onSet(async (value) => {
|
|
61
|
+
await this.sendCommands([{
|
|
62
|
+
code: schema.code,
|
|
63
|
+
value: (value === OPEN) ? true : false,
|
|
64
|
+
}]);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.default = GarageDoorAccessory;
|
|
69
|
+
//# sourceMappingURL=GarageDoorAccessory.js.map
|
|
@@ -0,0 +1,102 @@
|
|
|
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
|
+
const util_1 = require("../util/util");
|
|
7
|
+
const BaseAccessory_1 = __importDefault(require("./BaseAccessory"));
|
|
8
|
+
const Active_1 = require("./characteristic/Active");
|
|
9
|
+
const CurrentTemperature_1 = require("./characteristic/CurrentTemperature");
|
|
10
|
+
const LockPhysicalControls_1 = require("./characteristic/LockPhysicalControls");
|
|
11
|
+
const SwingMode_1 = require("./characteristic/SwingMode");
|
|
12
|
+
const TemperatureDisplayUnits_1 = require("./characteristic/TemperatureDisplayUnits");
|
|
13
|
+
const SCHEMA_CODE = {
|
|
14
|
+
ACTIVE: ['switch'],
|
|
15
|
+
WORK_STATE: ['work_state', 'mode'],
|
|
16
|
+
CURRENT_TEMP: ['temp_current'],
|
|
17
|
+
TARGET_TEMP: ['temp_set'],
|
|
18
|
+
LOCK: ['lock'],
|
|
19
|
+
SWING: ['shake'],
|
|
20
|
+
TEMP_UNIT_CONVERT: ['temp_unit_convert', 'c_f'],
|
|
21
|
+
};
|
|
22
|
+
const STATE_CODE = {
|
|
23
|
+
HEATING: ['heating', 'High'],
|
|
24
|
+
IDLE: ['warming', 'Low'],
|
|
25
|
+
};
|
|
26
|
+
class HeaterAccessory extends BaseAccessory_1.default {
|
|
27
|
+
requiredSchema() {
|
|
28
|
+
return [SCHEMA_CODE.ACTIVE];
|
|
29
|
+
}
|
|
30
|
+
configureServices() {
|
|
31
|
+
(0, Active_1.configureActive)(this, this.mainService(), this.getSchema(...SCHEMA_CODE.ACTIVE));
|
|
32
|
+
this.configureCurrentState();
|
|
33
|
+
this.configureTargetState();
|
|
34
|
+
(0, CurrentTemperature_1.configureCurrentTemperature)(this, this.mainService(), this.getSchema(...SCHEMA_CODE.CURRENT_TEMP));
|
|
35
|
+
(0, LockPhysicalControls_1.configureLockPhysicalControls)(this, this.mainService(), this.getSchema(...SCHEMA_CODE.LOCK));
|
|
36
|
+
(0, SwingMode_1.configureSwingMode)(this, this.mainService(), this.getSchema(...SCHEMA_CODE.SWING));
|
|
37
|
+
this.configureHeatingThresholdTemp();
|
|
38
|
+
(0, TemperatureDisplayUnits_1.configureTempDisplayUnits)(this, this.mainService(), this.getSchema(...SCHEMA_CODE.TEMP_UNIT_CONVERT));
|
|
39
|
+
}
|
|
40
|
+
mainService() {
|
|
41
|
+
return this.accessory.getService(this.Service.HeaterCooler)
|
|
42
|
+
|| this.accessory.addService(this.Service.HeaterCooler);
|
|
43
|
+
}
|
|
44
|
+
configureCurrentState() {
|
|
45
|
+
const schema = this.getSchema(...SCHEMA_CODE.WORK_STATE);
|
|
46
|
+
const { ACTIVE: ON, INACTIVE: OFF } = this.Characteristic.Active;
|
|
47
|
+
const { INACTIVE, IDLE, HEATING } = this.Characteristic.CurrentHeaterCoolerState;
|
|
48
|
+
this.mainService().getCharacteristic(this.Characteristic.CurrentHeaterCoolerState)
|
|
49
|
+
.onGet(() => {
|
|
50
|
+
if (!schema) {
|
|
51
|
+
return INACTIVE;
|
|
52
|
+
}
|
|
53
|
+
if (this.mainService().getCharacteristic(this.Characteristic.Active).value === OFF) {
|
|
54
|
+
return INACTIVE;
|
|
55
|
+
}
|
|
56
|
+
const status = this.getStatus(schema.code);
|
|
57
|
+
if (STATE_CODE.HEATING.includes(status.value)) {
|
|
58
|
+
return HEATING;
|
|
59
|
+
}
|
|
60
|
+
else if (STATE_CODE.IDLE.includes(status.value)) {
|
|
61
|
+
return IDLE;
|
|
62
|
+
}
|
|
63
|
+
return INACTIVE;
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
configureTargetState() {
|
|
67
|
+
const { AUTO, HEAT, COOL } = this.Characteristic.TargetHeaterCoolerState;
|
|
68
|
+
const validValues = [HEAT];
|
|
69
|
+
this.mainService().getCharacteristic(this.Characteristic.TargetHeaterCoolerState)
|
|
70
|
+
.onGet(() => {
|
|
71
|
+
// Since setting the mode to AUTO prevents temperature adjustments in the iPhone Home app, the default mode will be set to HEAT.
|
|
72
|
+
return HEAT;
|
|
73
|
+
})
|
|
74
|
+
.onSet(async (value) => {
|
|
75
|
+
// TODO
|
|
76
|
+
this.log.debug('configureTargetState set:' + value);
|
|
77
|
+
})
|
|
78
|
+
.setProps({ validValues });
|
|
79
|
+
}
|
|
80
|
+
configureHeatingThresholdTemp() {
|
|
81
|
+
const schema = this.getSchema(...SCHEMA_CODE.TARGET_TEMP);
|
|
82
|
+
if (!schema) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const property = schema.property;
|
|
86
|
+
const props = (0, util_1.toHapProperty)(property);
|
|
87
|
+
const multiple = Math.pow(10, property['scale'] || 0);
|
|
88
|
+
this.log.debug('Set props for HeatingThresholdTemperature:', props);
|
|
89
|
+
this.mainService().getCharacteristic(this.Characteristic.HeatingThresholdTemperature)
|
|
90
|
+
.onGet(() => {
|
|
91
|
+
const status = this.getStatus(schema.code);
|
|
92
|
+
const temp = status.value / multiple;
|
|
93
|
+
return (0, util_1.limit)(temp, props['minValue'], props['maxValue']);
|
|
94
|
+
})
|
|
95
|
+
.onSet(async (value) => {
|
|
96
|
+
await this.sendCommands([{ code: schema.code, value: value * multiple }]);
|
|
97
|
+
})
|
|
98
|
+
.setProps(props);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
exports.default = HeaterAccessory;
|
|
102
|
+
//# sourceMappingURL=HeaterAccessory.js.map
|
|
@@ -0,0 +1,96 @@
|
|
|
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
|
+
const util_1 = require("../util/util");
|
|
7
|
+
const BaseAccessory_1 = __importDefault(require("./BaseAccessory"));
|
|
8
|
+
const Active_1 = require("./characteristic/Active");
|
|
9
|
+
const CurrentTemperature_1 = require("./characteristic/CurrentTemperature");
|
|
10
|
+
const LockPhysicalControls_1 = require("./characteristic/LockPhysicalControls");
|
|
11
|
+
const SwingMode_1 = require("./characteristic/SwingMode");
|
|
12
|
+
const TemperatureDisplayUnits_1 = require("./characteristic/TemperatureDisplayUnits");
|
|
13
|
+
const SCHEMA_CODE = {
|
|
14
|
+
ACTIVE: ['switch'],
|
|
15
|
+
WORK_STATE: ['work_state'],
|
|
16
|
+
CURRENT_TEMP: ['temp_current'],
|
|
17
|
+
TARGET_TEMP: ['temp_set'],
|
|
18
|
+
LOCK: ['lock'],
|
|
19
|
+
SWING: ['shake'],
|
|
20
|
+
TEMP_UNIT_CONVERT: ['temp_unit_convert', 'c_f'],
|
|
21
|
+
};
|
|
22
|
+
class HeaterAccessory_old extends BaseAccessory_1.default {
|
|
23
|
+
requiredSchema() {
|
|
24
|
+
return [SCHEMA_CODE.ACTIVE];
|
|
25
|
+
}
|
|
26
|
+
configureServices() {
|
|
27
|
+
(0, Active_1.configureActive)(this, this.mainService(), this.getSchema(...SCHEMA_CODE.ACTIVE));
|
|
28
|
+
this.configureCurrentState();
|
|
29
|
+
this.configureTargetState();
|
|
30
|
+
(0, CurrentTemperature_1.configureCurrentTemperature)(this, this.mainService(), this.getSchema(...SCHEMA_CODE.CURRENT_TEMP));
|
|
31
|
+
(0, LockPhysicalControls_1.configureLockPhysicalControls)(this, this.mainService(), this.getSchema(...SCHEMA_CODE.LOCK));
|
|
32
|
+
(0, SwingMode_1.configureSwingMode)(this, this.mainService(), this.getSchema(...SCHEMA_CODE.SWING));
|
|
33
|
+
this.configureHeatingThreshouldTemp();
|
|
34
|
+
(0, TemperatureDisplayUnits_1.configureTempDisplayUnits)(this, this.mainService(), this.getSchema(...SCHEMA_CODE.TEMP_UNIT_CONVERT));
|
|
35
|
+
}
|
|
36
|
+
mainService() {
|
|
37
|
+
return this.accessory.getService(this.Service.HeaterCooler)
|
|
38
|
+
|| this.accessory.addService(this.Service.HeaterCooler);
|
|
39
|
+
}
|
|
40
|
+
configureCurrentState() {
|
|
41
|
+
const schema = this.getSchema(...SCHEMA_CODE.WORK_STATE);
|
|
42
|
+
const { INACTIVE, IDLE, HEATING } = this.Characteristic.CurrentHeaterCoolerState;
|
|
43
|
+
this.mainService().getCharacteristic(this.Characteristic.CurrentHeaterCoolerState)
|
|
44
|
+
.onGet(() => {
|
|
45
|
+
if (!schema) {
|
|
46
|
+
return IDLE;
|
|
47
|
+
}
|
|
48
|
+
const status = this.getStatus(schema.code);
|
|
49
|
+
if (status.value === 'heating') {
|
|
50
|
+
return HEATING;
|
|
51
|
+
}
|
|
52
|
+
else if (status.value === 'warming') {
|
|
53
|
+
return IDLE;
|
|
54
|
+
}
|
|
55
|
+
return INACTIVE;
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
configureTargetState() {
|
|
59
|
+
const { AUTO, HEAT, COOL } = this.Characteristic.TargetHeaterCoolerState;
|
|
60
|
+
const validValues = [AUTO];
|
|
61
|
+
this.mainService().getCharacteristic(this.Characteristic.TargetHeaterCoolerState)
|
|
62
|
+
.onGet(() => {
|
|
63
|
+
return AUTO;
|
|
64
|
+
})
|
|
65
|
+
.onSet(async (value) => {
|
|
66
|
+
// TODO
|
|
67
|
+
})
|
|
68
|
+
.setProps({ validValues });
|
|
69
|
+
}
|
|
70
|
+
configureHeatingThreshouldTemp() {
|
|
71
|
+
const schema = this.getSchema(...SCHEMA_CODE.TARGET_TEMP);
|
|
72
|
+
if (!schema) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const property = schema.property;
|
|
76
|
+
const multiple = property ? Math.pow(10, property.scale) : 1;
|
|
77
|
+
const props = {
|
|
78
|
+
minValue: property.min / multiple,
|
|
79
|
+
maxValue: property.max / multiple,
|
|
80
|
+
minStep: Math.max(0.1, property.step / multiple),
|
|
81
|
+
};
|
|
82
|
+
this.log.debug('Set props for HeatingThresholdTemperature:', props);
|
|
83
|
+
this.mainService().getCharacteristic(this.Characteristic.HeatingThresholdTemperature)
|
|
84
|
+
.onGet(() => {
|
|
85
|
+
const status = this.getStatus(schema.code);
|
|
86
|
+
const temp = status.value / multiple;
|
|
87
|
+
return (0, util_1.limit)(temp, props.minValue, props.maxValue);
|
|
88
|
+
})
|
|
89
|
+
.onSet(async (value) => {
|
|
90
|
+
await this.sendCommands([{ code: schema.code, value: value * multiple }]);
|
|
91
|
+
})
|
|
92
|
+
.setProps(props);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
exports.default = HeaterAccessory_old;
|
|
96
|
+
//# sourceMappingURL=HeaterAccessory_old.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
const BaseAccessory_1 = __importDefault(require("./BaseAccessory"));
|
|
7
|
+
const OccupancyDetected_1 = require("./characteristic/OccupancyDetected");
|
|
8
|
+
const SCHEMA_CODE = {
|
|
9
|
+
PRESENCE: ['presence_state'],
|
|
10
|
+
};
|
|
11
|
+
class HumanPresenceSensorAccessory extends BaseAccessory_1.default {
|
|
12
|
+
requiredSchema() {
|
|
13
|
+
return [SCHEMA_CODE.PRESENCE];
|
|
14
|
+
}
|
|
15
|
+
configureServices() {
|
|
16
|
+
(0, OccupancyDetected_1.configureOccupancyDetected)(this, undefined, this.getSchema(...SCHEMA_CODE.PRESENCE));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.default = HumanPresenceSensorAccessory;
|
|
20
|
+
//# sourceMappingURL=HumanPresenceSensorAccessory.js.map
|
|
@@ -0,0 +1,137 @@
|
|
|
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
|
+
const util_1 = require("../util/util");
|
|
7
|
+
const BaseAccessory_1 = __importDefault(require("./BaseAccessory"));
|
|
8
|
+
const Active_1 = require("./characteristic/Active");
|
|
9
|
+
const CurrentTemperature_1 = require("./characteristic/CurrentTemperature");
|
|
10
|
+
const CurrentRelativeHumidity_1 = require("./characteristic/CurrentRelativeHumidity");
|
|
11
|
+
const Light_1 = require("./characteristic/Light");
|
|
12
|
+
const SCHEMA_CODE = {
|
|
13
|
+
ACTIVE: ['switch'],
|
|
14
|
+
CURRENT_HUMIDITY: ['humidity_current'],
|
|
15
|
+
TARGET_HUMIDITY: ['humidity_set'],
|
|
16
|
+
CURRENT_TEMP: ['temp_current'],
|
|
17
|
+
LIGHT_ON: ['switch_led'],
|
|
18
|
+
LIGHT_MODE: ['work_mode'],
|
|
19
|
+
LIGHT_BRIGHT: ['bright_value', 'bright_value_v2'],
|
|
20
|
+
LIGHT_COLOR: ['colour_data', 'colour_data_hsv'],
|
|
21
|
+
};
|
|
22
|
+
class HumidifierAccessory extends BaseAccessory_1.default {
|
|
23
|
+
requiredSchema() {
|
|
24
|
+
return [SCHEMA_CODE.ACTIVE];
|
|
25
|
+
}
|
|
26
|
+
configureServices() {
|
|
27
|
+
// Required Characteristics
|
|
28
|
+
(0, Active_1.configureActive)(this, this.mainService(), this.getSchema(...SCHEMA_CODE.ACTIVE));
|
|
29
|
+
this.configureCurrentState();
|
|
30
|
+
this.configureTargetState();
|
|
31
|
+
(0, CurrentRelativeHumidity_1.configureCurrentRelativeHumidity)(this, this.mainService(), this.getSchema(...SCHEMA_CODE.CURRENT_HUMIDITY));
|
|
32
|
+
// Optional Characteristics
|
|
33
|
+
this.configureRelativeHumidityHumidifierThreshold();
|
|
34
|
+
this.configureRotationSpeed();
|
|
35
|
+
// Other
|
|
36
|
+
(0, CurrentTemperature_1.configureCurrentTemperature)(this, undefined, this.getSchema(...SCHEMA_CODE.CURRENT_TEMP));
|
|
37
|
+
(0, Light_1.configureLight)(this, undefined, this.getSchema(...SCHEMA_CODE.LIGHT_ON), this.getSchema(...SCHEMA_CODE.LIGHT_BRIGHT), undefined, this.getSchema(...SCHEMA_CODE.LIGHT_COLOR), this.getSchema(...SCHEMA_CODE.LIGHT_MODE));
|
|
38
|
+
}
|
|
39
|
+
mainService() {
|
|
40
|
+
return this.accessory.getService(this.Service.HumidifierDehumidifier)
|
|
41
|
+
|| this.accessory.addService(this.Service.HumidifierDehumidifier);
|
|
42
|
+
}
|
|
43
|
+
configureTargetState() {
|
|
44
|
+
const { HUMIDIFIER } = this.Characteristic.TargetHumidifierDehumidifierState;
|
|
45
|
+
const validValues = [HUMIDIFIER];
|
|
46
|
+
this.mainService().getCharacteristic(this.Characteristic.TargetHumidifierDehumidifierState)
|
|
47
|
+
.onGet(() => {
|
|
48
|
+
return HUMIDIFIER;
|
|
49
|
+
}).setProps({ validValues });
|
|
50
|
+
}
|
|
51
|
+
configureCurrentState() {
|
|
52
|
+
const schema = this.getSchema(...SCHEMA_CODE.ACTIVE);
|
|
53
|
+
if (!schema) {
|
|
54
|
+
this.log.warn('CurrentHumidifierDehumidifierState not supported.');
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const { INACTIVE, HUMIDIFYING } = this.Characteristic.CurrentHumidifierDehumidifierState;
|
|
58
|
+
this.mainService().getCharacteristic(this.Characteristic.CurrentHumidifierDehumidifierState)
|
|
59
|
+
.onGet(() => {
|
|
60
|
+
const status = this.getStatus(schema.code);
|
|
61
|
+
return status?.value ? HUMIDIFYING : INACTIVE;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
configureRelativeHumidityHumidifierThreshold() {
|
|
65
|
+
const schema = this.getSchema(...SCHEMA_CODE.TARGET_HUMIDITY);
|
|
66
|
+
if (!schema) {
|
|
67
|
+
this.log.warn('Humidity setting is not supported.');
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const property = schema.property;
|
|
71
|
+
const multiple = Math.pow(10, property ? property.scale : 0);
|
|
72
|
+
const props = {
|
|
73
|
+
minValue: 0,
|
|
74
|
+
maxValue: 100,
|
|
75
|
+
minStep: Math.max(1, property.step / multiple),
|
|
76
|
+
};
|
|
77
|
+
this.log.debug('Set props for RelativeHumidityHumidifierThreshold:', props);
|
|
78
|
+
this.mainService().getCharacteristic(this.Characteristic.RelativeHumidityHumidifierThreshold)
|
|
79
|
+
.onGet(() => {
|
|
80
|
+
const status = this.getStatus(schema.code);
|
|
81
|
+
return (0, util_1.limit)(status.value / multiple, 0, 100);
|
|
82
|
+
})
|
|
83
|
+
.onSet(async (value) => {
|
|
84
|
+
const humidity_set = (0, util_1.limit)(value * multiple, property.min, property.max);
|
|
85
|
+
await this.sendCommands([{ code: schema.code, value: humidity_set }]);
|
|
86
|
+
// also set spray mode to humidity
|
|
87
|
+
await this.setSprayModeToHumidity();
|
|
88
|
+
}).setProps(props);
|
|
89
|
+
}
|
|
90
|
+
configureRotationSpeed() {
|
|
91
|
+
const schema = this.getSchema('mode');
|
|
92
|
+
if (!schema) {
|
|
93
|
+
this.log.warn('Mode setting is not supported.');
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
const unusedService = this.accessory.getService(this.Service.Fan);
|
|
97
|
+
if (unusedService) {
|
|
98
|
+
this.accessory.removeService(unusedService);
|
|
99
|
+
}
|
|
100
|
+
this.mainService().getCharacteristic(this.Characteristic.RotationSpeed)
|
|
101
|
+
.onGet(() => {
|
|
102
|
+
const status = this.getStatus(schema.code);
|
|
103
|
+
let v = 3;
|
|
104
|
+
switch (status.value) {
|
|
105
|
+
case 'small':
|
|
106
|
+
v = 1;
|
|
107
|
+
break;
|
|
108
|
+
case 'middle':
|
|
109
|
+
v = 2;
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
return (0, util_1.remap)(v, 0, 3, 0, 100);
|
|
113
|
+
}).onSet(async (value) => {
|
|
114
|
+
value = Math.round((0, util_1.remap)(value, 0, 100, 0, 3));
|
|
115
|
+
let mode = 'small';
|
|
116
|
+
switch (value) {
|
|
117
|
+
case 2:
|
|
118
|
+
mode = 'middle';
|
|
119
|
+
break;
|
|
120
|
+
case 3:
|
|
121
|
+
mode = 'large';
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
await this.sendCommands([{ code: schema.code, value: mode }]);
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
async setSprayModeToHumidity() {
|
|
128
|
+
const schema = this.getSchema('spray_mode');
|
|
129
|
+
if (!schema) {
|
|
130
|
+
this.log.debug('Spray mode not supported.');
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
await this.sendCommands([{ code: schema.code, value: 'humidity' }]);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
exports.default = HumidifierAccessory;
|
|
137
|
+
//# sourceMappingURL=HumidifierAccessory.js.map
|