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.
Files changed (97) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/LICENSE +20 -0
  3. package/PUBLISHING.md +80 -0
  4. package/README.md +233 -0
  5. package/SUPPORTED_DEVICES.md +206 -0
  6. package/config.schema.json +131 -0
  7. package/dist/cloud/api/TuyaHACloudAPI.js +286 -0
  8. package/dist/cloud/api/TuyaHASharingMQ.js +114 -0
  9. package/dist/cloud/device/TuyaDevice.js +50 -0
  10. package/dist/cloud/device/TuyaHADeviceManager.js +355 -0
  11. package/dist/index.js +7 -0
  12. package/dist/platform.js +397 -0
  13. package/dist/settings.js +18 -0
  14. package/dist/shared/AccessoryFactory.js +276 -0
  15. package/dist/shared/accessories/AccessoryFactory.js +305 -0
  16. package/dist/shared/accessories/AirConditionerAccessory.js +307 -0
  17. package/dist/shared/accessories/AirPurifierAccessory.js +90 -0
  18. package/dist/shared/accessories/AirQualitySensorAccessory.js +30 -0
  19. package/dist/shared/accessories/BaseAccessory.js +406 -0
  20. package/dist/shared/accessories/BlindsAccessory.js +199 -0
  21. package/dist/shared/accessories/CameraAccessory.js +121 -0
  22. package/dist/shared/accessories/CarbonDioxideSensorAccessory.js +52 -0
  23. package/dist/shared/accessories/CarbonMonoxideSensorAccessory.js +52 -0
  24. package/dist/shared/accessories/ContactSensorAccessory.js +30 -0
  25. package/dist/shared/accessories/DehumidifierAccessory.js +68 -0
  26. package/dist/shared/accessories/DiffuserAccessory.js +55 -0
  27. package/dist/shared/accessories/DimmerAccessory.js +94 -0
  28. package/dist/shared/accessories/DoorbellAccessory.js +91 -0
  29. package/dist/shared/accessories/ExtractionHoodAccessory.js +120 -0
  30. package/dist/shared/accessories/FanAccessory.js +129 -0
  31. package/dist/shared/accessories/GarageDoorAccessory.js +69 -0
  32. package/dist/shared/accessories/HeaterAccessory.js +102 -0
  33. package/dist/shared/accessories/HeaterAccessory_old.js +96 -0
  34. package/dist/shared/accessories/HumanPresenceSensorAccessory.js +20 -0
  35. package/dist/shared/accessories/HumidifierAccessory.js +137 -0
  36. package/dist/shared/accessories/IRAirConditionerAccessory.js +278 -0
  37. package/dist/shared/accessories/IRControlHubAccessory.js +49 -0
  38. package/dist/shared/accessories/IRControlHubSubAccessory.js +52 -0
  39. package/dist/shared/accessories/IRGenericAccessory.js +49 -0
  40. package/dist/shared/accessories/LeakSensorAccessory.js +36 -0
  41. package/dist/shared/accessories/LightAccessory.js +36 -0
  42. package/dist/shared/accessories/LightSensorAccessory.js +32 -0
  43. package/dist/shared/accessories/LocationWeatherAccessory.js +72 -0
  44. package/dist/shared/accessories/LockAccessory.js +56 -0
  45. package/dist/shared/accessories/MotionSensorAccessory.js +20 -0
  46. package/dist/shared/accessories/OutletAccessory.js +23 -0
  47. package/dist/shared/accessories/PetFeederAccessory.js +139 -0
  48. package/dist/shared/accessories/SceneAccessory.js +32 -0
  49. package/dist/shared/accessories/SceneSwitchAccessory.js +44 -0
  50. package/dist/shared/accessories/SecuritySystemAccessory.js +30 -0
  51. package/dist/shared/accessories/SmokeSensorAccessory.js +35 -0
  52. package/dist/shared/accessories/SwitchAccessory.js +148 -0
  53. package/dist/shared/accessories/TemperatureHumiditySensorAccessory.js +24 -0
  54. package/dist/shared/accessories/ThermostatAccessory.js +192 -0
  55. package/dist/shared/accessories/TowerRackAccessory.js +157 -0
  56. package/dist/shared/accessories/ValveAccessory.js +45 -0
  57. package/dist/shared/accessories/VibrationSensorAccessory.js +46 -0
  58. package/dist/shared/accessories/WeatherStationAccessory.js +58 -0
  59. package/dist/shared/accessories/WetBulbGlobeTemperatureAccessory.js +23 -0
  60. package/dist/shared/accessories/WhiteNoiseLightAccessory.js +59 -0
  61. package/dist/shared/accessories/WindowAccessory.js +14 -0
  62. package/dist/shared/accessories/WindowCoveringAccessory.js +156 -0
  63. package/dist/shared/accessories/WirelessSwitchAccessory.js +42 -0
  64. package/dist/shared/accessories/characteristic/Active.js +22 -0
  65. package/dist/shared/accessories/characteristic/AirQuality.js +74 -0
  66. package/dist/shared/accessories/characteristic/CurrentRelativeHumidity.js +23 -0
  67. package/dist/shared/accessories/characteristic/CurrentTemperature.js +23 -0
  68. package/dist/shared/accessories/characteristic/CurrentWeather.js +49 -0
  69. package/dist/shared/accessories/characteristic/CurrentWeatherByOpenMeteo.js +49 -0
  70. package/dist/shared/accessories/characteristic/CurrentWetBulbGlobeTemperature.js +48 -0
  71. package/dist/shared/accessories/characteristic/EnergyUsage.js +98 -0
  72. package/dist/shared/accessories/characteristic/Light.js +268 -0
  73. package/dist/shared/accessories/characteristic/LightSensor.js +23 -0
  74. package/dist/shared/accessories/characteristic/LockPhysicalControls.js +21 -0
  75. package/dist/shared/accessories/characteristic/MotionDetected.js +22 -0
  76. package/dist/shared/accessories/characteristic/Name.js +15 -0
  77. package/dist/shared/accessories/characteristic/OccupancyDetected.js +19 -0
  78. package/dist/shared/accessories/characteristic/On.js +25 -0
  79. package/dist/shared/accessories/characteristic/OutletInUse.js +14 -0
  80. package/dist/shared/accessories/characteristic/ProgrammableSwitchEvent.js +89 -0
  81. package/dist/shared/accessories/characteristic/RelativeHumidityDehumidifierThreshold.js +28 -0
  82. package/dist/shared/accessories/characteristic/RotationSpeed.js +78 -0
  83. package/dist/shared/accessories/characteristic/SecuritySystemState.js +74 -0
  84. package/dist/shared/accessories/characteristic/SwingMode.js +21 -0
  85. package/dist/shared/accessories/characteristic/TargetTemperature.js +29 -0
  86. package/dist/shared/accessories/characteristic/TemperatureDisplayUnits.js +25 -0
  87. package/dist/shared/util/ConfigHash.js +79 -0
  88. package/dist/shared/util/FfmpegStreamingProcess.js +126 -0
  89. package/dist/shared/util/InfraredTool.js +392 -0
  90. package/dist/shared/util/Logger.js +42 -0
  91. package/dist/shared/util/TuyaRecordingDelegate.js +22 -0
  92. package/dist/shared/util/TuyaStreamDelegate.js +329 -0
  93. package/dist/shared/util/color.js +23 -0
  94. package/dist/shared/util/util.js +135 -0
  95. package/homebridge-ui/public/index.html +329 -0
  96. package/homebridge-ui/server.js +224 -0
  97. package/package.json +61 -0
@@ -0,0 +1,192 @@
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 CurrentTemperature_1 = require("./characteristic/CurrentTemperature");
9
+ const TemperatureDisplayUnits_1 = require("./characteristic/TemperatureDisplayUnits");
10
+ const SCHEMA_CODE = {
11
+ ON: ['switch'],
12
+ CURRENT_MODE: ['work_state', 'mode'],
13
+ TARGET_MODE: ['mode'],
14
+ CURRENT_TEMP: ['temp_current', 'temp_set'],
15
+ TARGET_TEMP: ['temp_set'],
16
+ TEMP_UNIT_CONVERT: ['temp_unit_convert', 'c_f'],
17
+ };
18
+ class ThermostatAccessory extends BaseAccessory_1.default {
19
+ requiredSchema() {
20
+ return [SCHEMA_CODE.CURRENT_TEMP, SCHEMA_CODE.TARGET_TEMP];
21
+ }
22
+ configureServices() {
23
+ this.configureCurrentState();
24
+ this.configureTargetState();
25
+ (0, CurrentTemperature_1.configureCurrentTemperature)(this, this.mainService(), this.getSchema(...SCHEMA_CODE.CURRENT_TEMP));
26
+ this.configureTargetTemp();
27
+ (0, TemperatureDisplayUnits_1.configureTempDisplayUnits)(this, this.mainService(), this.getSchema(...SCHEMA_CODE.TEMP_UNIT_CONVERT));
28
+ }
29
+ mainService() {
30
+ return this.accessory.getService(this.Service.Thermostat)
31
+ || this.accessory.addService(this.Service.Thermostat);
32
+ }
33
+ configureCurrentState() {
34
+ const { OFF, HEAT, COOL } = this.Characteristic.CurrentHeatingCoolingState;
35
+ this.mainService().getCharacteristic(this.Characteristic.CurrentHeatingCoolingState)
36
+ .onGet(() => {
37
+ const on = this.getStatus('switch');
38
+ if (on && on.value === false) {
39
+ return OFF;
40
+ }
41
+ const schema = this.getSchema(...SCHEMA_CODE.CURRENT_MODE);
42
+ if (!schema) {
43
+ // If don't support mode, compare current and target temp.
44
+ const currentSchema = this.getSchema(...SCHEMA_CODE.CURRENT_TEMP);
45
+ const targetSchema = this.getSchema(...SCHEMA_CODE.TARGET_TEMP);
46
+ if (!currentSchema || !targetSchema) {
47
+ return OFF;
48
+ }
49
+ const current = this.getStatus(currentSchema.code);
50
+ const target = this.getStatus(targetSchema.code);
51
+ if (target.value > current.value) {
52
+ return HEAT;
53
+ }
54
+ else if (target.value < current.value) {
55
+ return COOL;
56
+ }
57
+ else {
58
+ return OFF;
59
+ }
60
+ }
61
+ const status = this.getStatus(schema.code);
62
+ if (status.value === 'hot' || status.value === 'opened' || status.value === 'heating') {
63
+ return HEAT;
64
+ }
65
+ else if (status.value === 'cold' ||
66
+ status.value === 'eco' ||
67
+ status.value === 'idle' ||
68
+ status.value === 'window_opened') {
69
+ return COOL;
70
+ }
71
+ // Don't know how to display unsupported work mode.
72
+ return OFF;
73
+ });
74
+ }
75
+ configureTargetState() {
76
+ const { OFF, HEAT, COOL, AUTO } = this.Characteristic.TargetHeatingCoolingState;
77
+ const validValues = [AUTO];
78
+ // Thermostat valve may not support 'Power Off'
79
+ if (this.getStatus('switch')) {
80
+ validValues.push(OFF);
81
+ }
82
+ const schema = this.getSchema(...SCHEMA_CODE.TARGET_MODE);
83
+ const property = schema?.property;
84
+ if (property) {
85
+ if (property.range.includes('hot')) {
86
+ validValues.push(HEAT);
87
+ }
88
+ if (property.range.includes('cold') || property.range.includes('eco')) {
89
+ validValues.push(COOL);
90
+ }
91
+ }
92
+ this.mainService().getCharacteristic(this.Characteristic.TargetHeatingCoolingState)
93
+ .onGet(() => {
94
+ const on = this.getStatus('switch');
95
+ if (on && on.value === false) {
96
+ return OFF;
97
+ }
98
+ if (!schema) {
99
+ // If don't support mode, display auto.
100
+ return AUTO;
101
+ }
102
+ const status = this.getStatus(schema.code);
103
+ if (status.value === 'hot') {
104
+ return HEAT;
105
+ }
106
+ else if (status.value === 'cold' || status.value === 'eco') {
107
+ return COOL;
108
+ }
109
+ else if (status.value === 'auto' || status.value === 'temp_auto') {
110
+ return AUTO;
111
+ }
112
+ // Don't know how to display unsupported mode.
113
+ return AUTO;
114
+ })
115
+ .onSet(async (value) => {
116
+ const commands = [];
117
+ // Thermostat valve may not support 'Power Off'
118
+ const on = this.getStatus('switch');
119
+ if (on) {
120
+ if (value === OFF) {
121
+ commands.push({
122
+ code: 'switch',
123
+ value: false,
124
+ });
125
+ }
126
+ else if (on.value === false) {
127
+ commands.push({
128
+ code: 'switch',
129
+ value: true,
130
+ });
131
+ }
132
+ }
133
+ if (schema) {
134
+ if ((value === HEAT) && property.range.includes('hot')) {
135
+ commands.push({ code: schema.code, value: 'hot' });
136
+ }
137
+ else if (value === COOL) {
138
+ if (property.range.includes('eco')) {
139
+ commands.push({ code: schema.code, value: 'eco' });
140
+ }
141
+ else if (property.range.includes('cold')) {
142
+ commands.push({ code: schema.code, value: 'cold' });
143
+ }
144
+ }
145
+ else if ((value === AUTO) && property.range.includes('auto')) {
146
+ commands.push({ code: schema.code, value: 'auto' });
147
+ }
148
+ }
149
+ if (commands.length !== 0) {
150
+ await this.sendCommands(commands);
151
+ }
152
+ })
153
+ .setProps({ validValues });
154
+ }
155
+ // FIXME: For some reason, a limit is being imposed on the target temperature.
156
+ // Request to those who have the actual product: Please investigate whether ./characteristic/TargetTemperature can be used.
157
+ configureTargetTemp() {
158
+ const schema = this.getSchema(...SCHEMA_CODE.TARGET_TEMP);
159
+ if (!schema) {
160
+ this.log.warn('TargetTemperature not supported.');
161
+ return;
162
+ }
163
+ const property = schema.property;
164
+ let multiple = Math.pow(10, property.scale);
165
+ let props = {
166
+ minValue: Math.max(10, property.min / multiple),
167
+ maxValue: Math.min(38, property.max / multiple),
168
+ minStep: Math.max(0.1, property.step / multiple),
169
+ };
170
+ if (props.maxValue <= props.minValue) {
171
+ this.log.warn('Invalid schema: %o, props will be reset to the default value.', schema);
172
+ multiple = 1;
173
+ props = { minValue: 10, maxValue: 38, minStep: 1 };
174
+ }
175
+ this.log.debug('Set props for TargetTemperature:', props);
176
+ this.mainService().getCharacteristic(this.Characteristic.TargetTemperature)
177
+ .onGet(() => {
178
+ const status = this.getStatus(schema.code);
179
+ const temp = status.value / multiple;
180
+ return (0, util_1.limit)(temp, props.minValue, props.maxValue);
181
+ })
182
+ .onSet(async (value) => {
183
+ await this.sendCommands([{
184
+ code: schema.code,
185
+ value: value * multiple,
186
+ }]);
187
+ })
188
+ .setProps(props);
189
+ }
190
+ }
191
+ exports.default = ThermostatAccessory;
192
+ //# sourceMappingURL=ThermostatAccessory.js.map
@@ -0,0 +1,157 @@
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 CurrentTemperature_1 = require("./characteristic/CurrentTemperature");
8
+ const TargetTemperature_1 = require("./characteristic/TargetTemperature");
9
+ const TemperatureDisplayUnits_1 = require("./characteristic/TemperatureDisplayUnits");
10
+ const SCHEMA_CODE = {
11
+ ON: ['switch'],
12
+ TARGET_TEMP: ['temp_set'],
13
+ TARGET_MODE: ['mode'],
14
+ TEMP_UNIT_CONVERT: ['temp_unit_convert', 'c_f'],
15
+ CURRENT_TEMP: ['temp_current', 'temp_set'],
16
+ CURRENT_MODE: ['work_state', 'mode'],
17
+ };
18
+ class TowelRackAccessory extends BaseAccessory_1.default {
19
+ requiredSchema() {
20
+ return [SCHEMA_CODE.CURRENT_TEMP, SCHEMA_CODE.TARGET_TEMP];
21
+ }
22
+ configureServices() {
23
+ this.configureCurrentState();
24
+ this.configureTargetState();
25
+ (0, CurrentTemperature_1.configureCurrentTemperature)(this, this.mainService(), this.getSchema(...SCHEMA_CODE.CURRENT_TEMP));
26
+ (0, TargetTemperature_1.configureTargetTemperature)(this, this.mainService(), this.getSchema(...SCHEMA_CODE.TARGET_TEMP));
27
+ (0, TemperatureDisplayUnits_1.configureTempDisplayUnits)(this, this.mainService(), this.getSchema(...SCHEMA_CODE.TEMP_UNIT_CONVERT));
28
+ }
29
+ mainService() {
30
+ return this.accessory.getService(this.Service.Thermostat)
31
+ || this.accessory.addService(this.Service.Thermostat);
32
+ }
33
+ configureCurrentState() {
34
+ const { OFF, HEAT, COOL } = this.Characteristic.CurrentHeatingCoolingState;
35
+ this.mainService().getCharacteristic(this.Characteristic.CurrentHeatingCoolingState)
36
+ .onGet(() => {
37
+ const on = this.getStatus('switch');
38
+ if (on && on.value === false) {
39
+ return OFF;
40
+ }
41
+ const schema = this.getSchema(...SCHEMA_CODE.CURRENT_MODE);
42
+ if (!schema) {
43
+ // If don't support mode, compare current and target temp.
44
+ const currentSchema = this.getSchema(...SCHEMA_CODE.CURRENT_TEMP);
45
+ const targetSchema = this.getSchema(...SCHEMA_CODE.TARGET_TEMP);
46
+ if (!currentSchema || !targetSchema) {
47
+ return OFF;
48
+ }
49
+ const current = this.getStatus(currentSchema.code);
50
+ const target = this.getStatus(targetSchema.code);
51
+ if (target.value > current.value) {
52
+ return HEAT;
53
+ }
54
+ else if (target.value < current.value) {
55
+ return COOL;
56
+ }
57
+ else {
58
+ return OFF;
59
+ }
60
+ }
61
+ const status = this.getStatus(schema.code);
62
+ if (status.value === 'hot' || status.value === 'opened' || status.value === 'heating') {
63
+ return HEAT;
64
+ }
65
+ else if (status.value === 'cold' ||
66
+ status.value === 'eco' ||
67
+ status.value === 'idle' ||
68
+ status.value === 'window_opened') {
69
+ return COOL;
70
+ }
71
+ // Don't know how to display unsupported work mode.
72
+ return OFF;
73
+ });
74
+ }
75
+ configureTargetState() {
76
+ const { OFF, HEAT, COOL, AUTO } = this.Characteristic.TargetHeatingCoolingState;
77
+ const validValues = [AUTO];
78
+ // Thermostat valve may not support 'Power Off'
79
+ if (this.getStatus('switch')) {
80
+ validValues.push(OFF);
81
+ }
82
+ const schema = this.getSchema(...SCHEMA_CODE.TARGET_MODE);
83
+ const property = schema?.property;
84
+ if (property) {
85
+ if (property.range.includes('hot')) {
86
+ validValues.push(HEAT);
87
+ }
88
+ if (property.range.includes('cold') || property.range.includes('eco')) {
89
+ validValues.push(COOL);
90
+ }
91
+ }
92
+ this.mainService().getCharacteristic(this.Characteristic.TargetHeatingCoolingState)
93
+ .onGet(() => {
94
+ const on = this.getStatus('switch');
95
+ if (on && on.value === false) {
96
+ return OFF;
97
+ }
98
+ if (!schema) {
99
+ // If don't support mode, display auto.
100
+ return AUTO;
101
+ }
102
+ const status = this.getStatus(schema.code);
103
+ if (status.value === 'hot') {
104
+ return HEAT;
105
+ }
106
+ else if (status.value === 'cold' || status.value === 'eco') {
107
+ return COOL;
108
+ }
109
+ else if (status.value === 'auto' || status.value === 'temp_auto') {
110
+ return AUTO;
111
+ }
112
+ // Don't know how to display unsupported mode.
113
+ return AUTO;
114
+ })
115
+ .onSet(async (value) => {
116
+ const commands = [];
117
+ // Thermostat valve may not support 'Power Off'
118
+ const on = this.getStatus('switch');
119
+ if (on) {
120
+ if (value === OFF) {
121
+ commands.push({
122
+ code: 'switch',
123
+ value: false,
124
+ });
125
+ }
126
+ else if (on.value === false) {
127
+ commands.push({
128
+ code: 'switch',
129
+ value: true,
130
+ });
131
+ }
132
+ }
133
+ if (schema) {
134
+ if ((value === HEAT) && property.range.includes('hot')) {
135
+ commands.push({ code: schema.code, value: 'hot' });
136
+ }
137
+ else if (value === COOL) {
138
+ if (property.range.includes('eco')) {
139
+ commands.push({ code: schema.code, value: 'eco' });
140
+ }
141
+ else if (property.range.includes('cold')) {
142
+ commands.push({ code: schema.code, value: 'cold' });
143
+ }
144
+ }
145
+ else if ((value === AUTO) && property.range.includes('auto')) {
146
+ commands.push({ code: schema.code, value: 'auto' });
147
+ }
148
+ }
149
+ if (commands.length !== 0) {
150
+ await this.sendCommands(commands);
151
+ }
152
+ })
153
+ .setProps({ validValues });
154
+ }
155
+ }
156
+ exports.default = TowelRackAccessory;
157
+ //# sourceMappingURL=TowerRackAccessory.js.map
@@ -0,0 +1,45 @@
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 Name_1 = require("./characteristic/Name");
10
+ const SCHEMA_CODE = {
11
+ ON: ['switch', 'switch_1'],
12
+ };
13
+ class ValveAccessory extends BaseAccessory_1.default {
14
+ requiredSchema() {
15
+ return [SCHEMA_CODE.ON];
16
+ }
17
+ configureServices() {
18
+ const oldService = this.accessory.getService(this.Service.Valve);
19
+ if (oldService && oldService?.subtype === undefined) {
20
+ this.platform.log.warn('Remove old service:', oldService.UUID);
21
+ this.accessory.removeService(oldService);
22
+ }
23
+ const schema = SCHEMA_CODE.ON.map(code => this.getSchema(code))
24
+ .filter((s) => !!s && s.type === TuyaDevice_1.TuyaDeviceSchemaType.Boolean);
25
+ for (const _schema of schema) {
26
+ const name = (schema.length === 1) ? this.device.name : _schema.code;
27
+ this.configureValve(_schema, name);
28
+ }
29
+ }
30
+ configureValve(schema, name) {
31
+ const service = this.accessory.getService(schema.code)
32
+ || this.accessory.addService(this.Service.Valve, name, schema.code);
33
+ (0, Name_1.configureName)(this, service, name);
34
+ service.setCharacteristic(this.Characteristic.ValveType, this.Characteristic.ValveType.IRRIGATION);
35
+ const { NOT_IN_USE, IN_USE } = this.Characteristic.InUse;
36
+ service.getCharacteristic(this.Characteristic.InUse)
37
+ .onGet(() => {
38
+ const status = this.getStatus(schema.code);
39
+ return status.value ? IN_USE : NOT_IN_USE;
40
+ });
41
+ (0, Active_1.configureActive)(this, service, schema);
42
+ }
43
+ }
44
+ exports.default = ValveAccessory;
45
+ //# sourceMappingURL=ValveAccessory.js.map
@@ -0,0 +1,46 @@
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
+ STATE: ['shock_state'],
9
+ };
10
+ class VibrationSensorAccessory extends BaseAccessory_1.default {
11
+ requiredSchema() {
12
+ return [SCHEMA_CODE.STATE];
13
+ }
14
+ configureServices() {
15
+ this.getMotionService().setCharacteristic(this.Characteristic.MotionDetected, false);
16
+ }
17
+ getMotionService() {
18
+ return this.accessory.getService(this.Service.MotionSensor)
19
+ || this.accessory.addService(this.Service.MotionSensor);
20
+ }
21
+ async onDeviceStatusUpdate(status) {
22
+ super.onDeviceStatusUpdate(status);
23
+ const motionSchema = this.getSchema(...SCHEMA_CODE.STATE);
24
+ const motionStatus = status.find(_status => _status.code === motionSchema.code);
25
+ if (motionStatus) {
26
+ this.onMotionDetected(motionStatus);
27
+ }
28
+ }
29
+ onMotionDetected(status) {
30
+ if (!this.initialized) {
31
+ return;
32
+ }
33
+ if (status.value !== 'vibration' && status.value !== 'drop') {
34
+ return;
35
+ }
36
+ this.log.info('Motion event:', status.value);
37
+ const characteristic = this.getMotionService().getCharacteristic(this.Characteristic.MotionDetected);
38
+ characteristic.updateValue(true);
39
+ if (this.timer) {
40
+ clearTimeout(this.timer);
41
+ }
42
+ this.timer = setTimeout(() => characteristic.updateValue(false), 3 * 1000);
43
+ }
44
+ }
45
+ exports.default = VibrationSensorAccessory;
46
+ //# sourceMappingURL=VibrationSensorAccessory.js.map
@@ -0,0 +1,58 @@
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
+ class TemperatureHumiditySensorAccessory extends BaseAccessory_1.default {
8
+ configureServices() {
9
+ const { temperatureSchemas, humiditySchemas } = this.getDynamicSchemaCodes();
10
+ temperatureSchemas.forEach((schema, index) => {
11
+ const serviceName = `Temperature Sensor ${index + 1}`;
12
+ const serviceSubtype = `temperature_sensor_${index + 1}`;
13
+ const service = this.accessory.getServiceById(this.Service.TemperatureSensor, serviceSubtype) ||
14
+ this.accessory.addService(this.Service.TemperatureSensor, serviceName, serviceSubtype);
15
+ service
16
+ .getCharacteristic(this.Characteristic.CurrentTemperature)
17
+ .onGet(() => {
18
+ const status = this.getStatus(schema.code);
19
+ if (status) {
20
+ const property = this.getSchema(schema.code)?.property;
21
+ const multiple = Math.pow(10, property.scale || 0);
22
+ return Math.min(Math.max(status.value / multiple, -100), 100);
23
+ }
24
+ return 0; // Default value if no status is found
25
+ });
26
+ });
27
+ humiditySchemas.forEach((schema, index) => {
28
+ const serviceName = `Humidity Sensor ${index + 1}`;
29
+ const serviceSubtype = `humidity_sensor_${index + 1}`;
30
+ const service = this.accessory.getServiceById(this.Service.HumiditySensor, serviceSubtype) ||
31
+ this.accessory.addService(this.Service.HumiditySensor, serviceName, serviceSubtype);
32
+ service
33
+ .getCharacteristic(this.Characteristic.CurrentRelativeHumidity)
34
+ .onGet(() => {
35
+ const status = this.getStatus(schema.code);
36
+ if (status) {
37
+ return status.value;
38
+ }
39
+ return 0; // Default value if no status is found
40
+ });
41
+ });
42
+ }
43
+ getDynamicSchemaCodes() {
44
+ const temperatureSchemas = [];
45
+ const humiditySchemas = [];
46
+ this.device.schema.forEach((schema) => {
47
+ if (schema.code.includes('ToutCh')) {
48
+ temperatureSchemas.push(schema);
49
+ }
50
+ else if (schema.code.includes('HoutCh')) {
51
+ humiditySchemas.push(schema);
52
+ }
53
+ });
54
+ return { temperatureSchemas, humiditySchemas };
55
+ }
56
+ }
57
+ exports.default = TemperatureHumiditySensorAccessory;
58
+ //# sourceMappingURL=WeatherStationAccessory.js.map
@@ -0,0 +1,23 @@
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 TemperatureHumiditySensorAccessory_1 = __importDefault(require("./TemperatureHumiditySensorAccessory"));
8
+ const CurrentWetBulbGlobeTemperature_1 = require("./characteristic/CurrentWetBulbGlobeTemperature");
9
+ const SCHEMA_CODE = {
10
+ CURRENT_TEMP: ['va_temperature', 'temp_value'],
11
+ CURRENT_HUMIDITY: ['va_humidity', 'humidity_value'],
12
+ };
13
+ class WetBulbGlobeTemperatureAccessory extends BaseAccessory_1.default {
14
+ requiredSchema() {
15
+ return [SCHEMA_CODE.CURRENT_TEMP, SCHEMA_CODE.CURRENT_HUMIDITY];
16
+ }
17
+ configureServices() {
18
+ const helperAcessory = new TemperatureHumiditySensorAccessory_1.default(this.platform, this.accessory);
19
+ (0, CurrentWetBulbGlobeTemperature_1.configureCurrentWetBulbGlobeTemperature)(helperAcessory);
20
+ }
21
+ }
22
+ exports.default = WetBulbGlobeTemperatureAccessory;
23
+ //# sourceMappingURL=WetBulbGlobeTemperatureAccessory.js.map
@@ -0,0 +1,59 @@
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 On_1 = require("./characteristic/On");
8
+ const Light_1 = require("./characteristic/Light");
9
+ const SCHEMA_CODE = {
10
+ LIGHT_ON: ['switch_led'],
11
+ LIGHT_COLOR: ['colour_data'],
12
+ MUSIC_ON: ['switch_music'],
13
+ };
14
+ class WhiteNoiseLightAccessory extends BaseAccessory_1.default {
15
+ requiredSchema() {
16
+ return [SCHEMA_CODE.LIGHT_ON, SCHEMA_CODE.MUSIC_ON];
17
+ }
18
+ configureServices() {
19
+ // Light
20
+ if (this.lightServiceType() === this.Service.Lightbulb) {
21
+ (0, Light_1.configureLight)(this, this.lightService(), this.getSchema(...SCHEMA_CODE.LIGHT_ON), undefined, undefined, this.lightColorSchema(), undefined);
22
+ }
23
+ else if (this.lightServiceType() === this.Service.Switch) {
24
+ (0, On_1.configureOn)(this, undefined, this.getSchema(...SCHEMA_CODE.LIGHT_ON));
25
+ const unusedService = this.accessory.getService(this.Service.Lightbulb);
26
+ unusedService && this.accessory.removeService(unusedService);
27
+ }
28
+ // White Noise
29
+ (0, On_1.configureOn)(this, undefined, this.getSchema(...SCHEMA_CODE.MUSIC_ON));
30
+ }
31
+ lightColorSchema() {
32
+ const colorSchema = this.getSchema(...SCHEMA_CODE.LIGHT_COLOR);
33
+ if (!colorSchema) {
34
+ return;
35
+ }
36
+ const { h, s, v } = (colorSchema.property || {});
37
+ if (!h || !s || !v) {
38
+ // Set sensible defaults for missing properties
39
+ colorSchema.property = {
40
+ h: { min: 0, scale: 0, unit: '', max: 360, step: 1 },
41
+ s: { min: 0, scale: 0, unit: '', max: 1000, step: 1 },
42
+ v: { min: 0, scale: 0, unit: '', max: 1000, step: 1 },
43
+ };
44
+ }
45
+ return colorSchema;
46
+ }
47
+ lightServiceType() {
48
+ if (this.lightColorSchema()) {
49
+ return this.Service.Lightbulb;
50
+ }
51
+ return this.Service.Switch;
52
+ }
53
+ lightService() {
54
+ return (this.accessory.getService(this.Service.Lightbulb) ||
55
+ this.accessory.addService(this.Service.Lightbulb));
56
+ }
57
+ }
58
+ exports.default = WhiteNoiseLightAccessory;
59
+ //# sourceMappingURL=WhiteNoiseLightAccessory.js.map
@@ -0,0 +1,14 @@
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 WindowCoveringAccessory_1 = __importDefault(require("./WindowCoveringAccessory"));
7
+ class WindowAccessory extends WindowCoveringAccessory_1.default {
8
+ mainService() {
9
+ return this.accessory.getService(this.Service.Window)
10
+ || this.accessory.addService(this.Service.Window);
11
+ }
12
+ }
13
+ exports.default = WindowAccessory;
14
+ //# sourceMappingURL=WindowAccessory.js.map