eufy-security-client 2.2.2 → 2.3.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 (50) hide show
  1. package/README.md +26 -0
  2. package/build/eufysecurity.d.ts +6 -0
  3. package/build/eufysecurity.js +72 -6
  4. package/build/eufysecurity.js.map +1 -1
  5. package/build/http/api.js +76 -37
  6. package/build/http/api.js.map +1 -1
  7. package/build/http/const.d.ts +3 -0
  8. package/build/http/const.js +8546 -0
  9. package/build/http/const.js.map +1 -0
  10. package/build/http/device.d.ts +2 -1
  11. package/build/http/device.js +108 -43
  12. package/build/http/device.js.map +1 -1
  13. package/build/http/error.d.ts +12 -0
  14. package/build/http/error.js +33 -1
  15. package/build/http/error.js.map +1 -1
  16. package/build/http/interfaces.d.ts +8 -2
  17. package/build/http/parameter.js +6 -1
  18. package/build/http/parameter.js.map +1 -1
  19. package/build/http/station.d.ts +2 -0
  20. package/build/http/station.js +252 -10
  21. package/build/http/station.js.map +1 -1
  22. package/build/http/types.d.ts +40 -4
  23. package/build/http/types.js +319 -48
  24. package/build/http/types.js.map +1 -1
  25. package/build/http/utils.d.ts +1 -1
  26. package/build/http/utils.js +42 -3045
  27. package/build/http/utils.js.map +1 -1
  28. package/build/interfaces.d.ts +7 -0
  29. package/build/mqtt/service.js +26 -3
  30. package/build/mqtt/service.js.map +1 -1
  31. package/build/p2p/session.d.ts +3 -0
  32. package/build/p2p/session.js +54 -21
  33. package/build/p2p/session.js.map +1 -1
  34. package/build/p2p/types.d.ts +1 -0
  35. package/build/p2p/types.js +1 -0
  36. package/build/p2p/types.js.map +1 -1
  37. package/build/p2p/utils.d.ts +2 -1
  38. package/build/p2p/utils.js +47 -9
  39. package/build/p2p/utils.js.map +1 -1
  40. package/build/push/client.js +26 -3
  41. package/build/push/client.js.map +1 -1
  42. package/build/push/parser.js +24 -1
  43. package/build/push/parser.js.map +1 -1
  44. package/build/push/service.js +32 -3
  45. package/build/push/service.js.map +1 -1
  46. package/build/push/utils.js +24 -1
  47. package/build/push/utils.js.map +1 -1
  48. package/build/utils.js +24 -1
  49. package/build/utils.js.map +1 -1
  50. package/package.json +7 -6
@@ -1 +1 @@
1
- {"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/http/error.ts"],"names":[],"mappings":";;;AAAA,MAAa,oBAAqB,SAAQ,KAAK;IAC3C,YAAY,OAAgB;QACxB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAClD,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC,IAAI,CAAC;IAC1C,CAAC;CACJ;AAND,oDAMC;AAED,MAAa,6BAA8B,SAAQ,KAAK;IACpD,YAAY,OAAgB;QACxB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAClD,IAAI,CAAC,IAAI,GAAG,6BAA6B,CAAC,IAAI,CAAC;IACnD,CAAC;CACJ;AAND,sEAMC;AAED,MAAa,yBAA0B,SAAQ,KAAK;IAChD,YAAY,OAAgB;QACxB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAClD,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC,IAAI,CAAC;IAC/C,CAAC;CACJ;AAND,8DAMC;AAED,MAAa,yBAA0B,SAAQ,KAAK;IAChD,YAAY,OAAgB;QACxB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAClD,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC,IAAI,CAAC;IAC/C,CAAC;CACJ;AAND,8DAMC;AAED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AiB,SAAQ,KAAK;IAIvC,YAAY,IAAY,EAAE,OAAgB;QACtC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAClD,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC,IAAI,CAAC;IACtC,CAAC;CACJ;AAVD,4CAUC"}
@@ -9,7 +9,7 @@ import { Cipher, Voice, Invite, DeviceListResponse, StationListResponse, HouseLi
9
9
  import { Station } from "./station";
10
10
  import { CommandName, PropertyName } from "./types";
11
11
  import { TalkbackStream } from "../p2p/talkback";
12
- export declare type PropertyValue = number | boolean | string;
12
+ export type PropertyValue = number | boolean | string;
13
13
  export interface PropertyValues {
14
14
  [index: string]: PropertyValue;
15
15
  }
@@ -48,7 +48,7 @@ export interface HTTPApiRequest {
48
48
  endpoint: string;
49
49
  data?: any;
50
50
  }
51
- export declare type PropertyMetadataType = "number" | "boolean" | "string";
51
+ export type PropertyMetadataType = "number" | "boolean" | "string";
52
52
  export interface PropertyMetadataAny {
53
53
  key: number | string;
54
54
  name: PropertyName;
@@ -125,6 +125,7 @@ export interface HTTPApiEvents {
125
125
  "houses": (houses: Houses) => void;
126
126
  "connect": () => void;
127
127
  "close": () => void;
128
+ "connection error": (error: Error) => void;
128
129
  "tfa request": () => void;
129
130
  "captcha request": (id: string, captcha: string) => void;
130
131
  "auth token invalidated": () => void;
@@ -175,6 +176,11 @@ export interface DeviceEvents {
175
176
  "pet detected": (device: Device, state: boolean) => void;
176
177
  "sound detected": (device: Device, state: boolean) => void;
177
178
  "crying detected": (device: Device, state: boolean) => void;
179
+ "vehicle detected": (device: Device, state: boolean) => void;
180
+ "dog detected": (device: Device, state: boolean) => void;
181
+ "dog lick detected": (device: Device, state: boolean) => void;
182
+ "dog poop detected": (device: Device, state: boolean) => void;
183
+ "stranger person detected": (device: Device, state: boolean) => void;
178
184
  "rings": (device: Device, state: boolean) => void;
179
185
  "locked": (device: Device, state: boolean) => void;
180
186
  "open": (device: Device, state: boolean) => void;
@@ -18,7 +18,12 @@ class ParameterHelper {
18
18
  type === types_1.CommandType.ARM_DELAY_CUS3 ||
19
19
  type === types_1.CommandType.ARM_DELAY_OFF) {
20
20
  try {
21
- return JSON.parse((0, utils_1.decodeBase64)(value).toString("utf8"));
21
+ if (typeof value === "string") {
22
+ return JSON.parse((0, utils_1.decodeBase64)(value).toString("utf8"));
23
+ }
24
+ else {
25
+ return value; //return object
26
+ }
22
27
  }
23
28
  catch (error) {
24
29
  log.error(`Error readValue param ${type} `, error, type, value);
@@ -1 +1 @@
1
- {"version":3,"file":"parameter.js","sourceRoot":"","sources":["../../src/http/parameter.ts"],"names":[],"mappings":";;;AAEA,wCAA2C;AAC3C,wCAA4C;AAC5C,mCAAoC;AAEpC,MAAa,eAAe;IAEjB,MAAM,CAAC,SAAS,CAAC,IAAY,EAAE,KAAa,EAAE,GAAW;QAC5D,IAAI,KAAK,EAAE;YACP,IAAI,IAAI,KAAK,iBAAS,CAAC,WAAW;gBAC9B,IAAI,KAAK,iBAAS,CAAC,mBAAmB;gBACtC,IAAI,KAAK,mBAAW,CAAC,oCAAoC;gBACzD,IAAI,KAAK,mBAAW,CAAC,8BAA8B;gBACnD,IAAI,KAAK,mBAAW,CAAC,cAAc;gBACnC,IAAI,KAAK,mBAAW,CAAC,cAAc;gBACnC,IAAI,KAAK,mBAAW,CAAC,cAAc;gBACnC,IAAI,KAAK,mBAAW,CAAC,cAAc;gBACnC,IAAI,KAAK,mBAAW,CAAC,cAAc;gBACnC,IAAI,KAAK,mBAAW,CAAC,aAAa,EAAE;gBACpC,IAAI;oBACA,OAAO,IAAI,CAAC,KAAK,CAAC,IAAA,oBAAY,EAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;iBAC3D;gBAAC,OAAM,KAAK,EAAE;oBACX,GAAG,CAA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;SACjB;QACD,OAAO,EAAE,CAAC;IACd,CAAC;CAEJ;AA/DD,0CA+DC"}
@@ -30,6 +30,7 @@ export declare class Station extends TypedEmitter<StationEvents> {
30
30
  update(station: StationListResponse, cloudOnlyProperties?: boolean): void;
31
31
  updateProperty(name: string, value: PropertyValue): boolean;
32
32
  updateRawProperties(values: RawValues): void;
33
+ protected handlePropertyChange(metadata: PropertyMetadataAny, oldValue: PropertyValue, newValue: PropertyValue): void;
33
34
  updateRawProperty(type: number, value: string): boolean;
34
35
  protected convertRawPropertyValue(property: PropertyMetadataAny, value: string): PropertyValue;
35
36
  getPropertyMetadata(name: string): PropertyMetadataAny;
@@ -286,4 +287,5 @@ export declare class Station extends TypedEmitter<StationEvents> {
286
287
  setNotificationUnlocked(device: Device, value: boolean): Promise<void>;
287
288
  private _sendLockV12P2PCommand;
288
289
  queryAllUserId(device: Device): Promise<void>;
290
+ chimeHombase(value: number): Promise<void>;
289
291
  }
@@ -103,7 +103,7 @@ class Station extends tiny_typed_emitter_1.TypedEmitter {
103
103
  this.updateProperty(property.name, property.default);
104
104
  }
105
105
  }
106
- if (!cloudOnlyProperties) {
106
+ if (!cloudOnlyProperties && this.rawStation.params) {
107
107
  this.rawStation.params.forEach(param => {
108
108
  this.updateRawProperty(param.param_type, param.param_value);
109
109
  });
@@ -113,9 +113,21 @@ class Station extends tiny_typed_emitter_1.TypedEmitter {
113
113
  updateProperty(name, value) {
114
114
  if ((this.properties[name] !== undefined && this.properties[name] !== value)
115
115
  || this.properties[name] === undefined) {
116
+ const oldValue = this.properties[name];
116
117
  this.properties[name] = value;
117
118
  if (this.ready)
118
119
  this.emit("property changed", this, name, value);
120
+ try {
121
+ this.handlePropertyChange(this.getPropertyMetadata(name), oldValue, this.properties[name]);
122
+ }
123
+ catch (error) {
124
+ if (error instanceof error_2.InvalidPropertyError) {
125
+ this.log.error(`Invalid Property ${name} error`, error);
126
+ }
127
+ else {
128
+ this.log.error(`Property ${name} error`, error);
129
+ }
130
+ }
119
131
  return true;
120
132
  }
121
133
  return false;
@@ -126,6 +138,31 @@ class Station extends tiny_typed_emitter_1.TypedEmitter {
126
138
  this.updateRawProperty(param_type, values[param_type]);
127
139
  });
128
140
  }
141
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
142
+ handlePropertyChange(metadata, oldValue, newValue) {
143
+ if (metadata.name === types_1.PropertyName.StationCurrentMode) {
144
+ //TODO: Finish implementation!
145
+ if (newValue === types_1.AlarmMode.DISARMED) {
146
+ if (this.hasProperty(types_1.PropertyName.StationAlarmArmed)) {
147
+ this.updateProperty(types_1.PropertyName.StationAlarmArmed, false);
148
+ }
149
+ if (this.hasProperty(types_1.PropertyName.StationAlarmDelay)) {
150
+ this.updateProperty(types_1.PropertyName.StationAlarmDelay, 0);
151
+ }
152
+ if (this.hasProperty(types_1.PropertyName.StationAlarmDelayType)) {
153
+ this.updateProperty(types_1.PropertyName.StationAlarmDelayType, 0);
154
+ }
155
+ if (this.hasProperty(types_1.PropertyName.StationAlarm)) {
156
+ this.updateProperty(types_1.PropertyName.StationAlarm, false);
157
+ }
158
+ if (this.hasProperty(types_1.PropertyName.StationAlarmType)) {
159
+ this.updateProperty(types_1.PropertyName.StationAlarmType, 0);
160
+ }
161
+ } /*else if (this.hasProperty(PropertyName.StationAlarmArmed)) { //TODO: Type !== HB3 or STATION
162
+ this.updateProperty(PropertyName.StationAlarmArmed, this.isAlarmArmable(newValue as AlarmMode));
163
+ }*/
164
+ }
165
+ }
129
166
  updateRawProperty(type, value) {
130
167
  const parsedValue = parameter_1.ParameterHelper.readValue(type, value, this.log);
131
168
  if ((this.rawProperties[type] !== undefined && this.rawProperties[type] !== parsedValue)
@@ -452,12 +489,67 @@ class Station extends tiny_typed_emitter_1.TypedEmitter {
452
489
  }
453
490
  onAlarmDelay(alarmDelayEvent, alarmDelay) {
454
491
  this.emit("alarm delay event", this, alarmDelayEvent, alarmDelay);
492
+ if (this.hasProperty(types_1.PropertyName.StationAlarmDelay)) {
493
+ this.updateProperty(types_1.PropertyName.StationAlarmDelay, alarmDelay);
494
+ }
495
+ if (this.hasProperty(types_1.PropertyName.StationAlarmDelayType)) {
496
+ this.updateProperty(types_1.PropertyName.StationAlarmDelayType, alarmDelayEvent);
497
+ }
455
498
  }
456
499
  onAlarmArmed() {
457
500
  this.emit("alarm armed event", this);
501
+ if (this.hasProperty(types_1.PropertyName.StationAlarmArmDelay)) {
502
+ this.updateProperty(types_1.PropertyName.StationAlarmArmDelay, 0);
503
+ }
504
+ /*if (this.hasProperty(PropertyName.StationAlarmArmed) && this.hasProperty(PropertyName.StationCurrentMode)) {
505
+ this.updateProperty(PropertyName.StationAlarmArmed, this.isAlarmArmable(this.getPropertyValue(PropertyName.StationCurrentMode) as AlarmMode));
506
+ }*/
507
+ if (this.hasProperty(types_1.PropertyName.StationAlarmArmed)) {
508
+ this.updateProperty(types_1.PropertyName.StationAlarmArmed, true);
509
+ }
510
+ if (this.hasProperty(types_1.PropertyName.StationAlarmDelay)) {
511
+ this.updateProperty(types_1.PropertyName.StationAlarmDelay, 0);
512
+ }
513
+ if (this.hasProperty(types_1.PropertyName.StationAlarmDelayType)) {
514
+ this.updateProperty(types_1.PropertyName.StationAlarmDelayType, 0);
515
+ }
516
+ if (this.hasProperty(types_1.PropertyName.StationAlarm)) {
517
+ this.updateProperty(types_1.PropertyName.StationAlarm, false);
518
+ }
519
+ if (this.hasProperty(types_1.PropertyName.StationAlarmType)) {
520
+ this.updateProperty(types_1.PropertyName.StationAlarmType, 0);
521
+ }
458
522
  }
459
523
  onAlarmEvent(alarmEvent) {
460
524
  this.emit("alarm event", this, alarmEvent);
525
+ if (this.hasProperty(types_1.PropertyName.StationAlarmDelay)) {
526
+ this.updateProperty(types_1.PropertyName.StationAlarmDelay, 0);
527
+ }
528
+ if (this.hasProperty(types_1.PropertyName.StationAlarmDelayType)) {
529
+ this.updateProperty(types_1.PropertyName.StationAlarmDelayType, 0);
530
+ }
531
+ switch (alarmEvent) {
532
+ case types_2.AlarmEvent.DEV_STOP:
533
+ case types_2.AlarmEvent.HUB_STOP:
534
+ case types_2.AlarmEvent.HUB_STOP_BY_APP:
535
+ case types_2.AlarmEvent.HUB_STOP_BY_HAND:
536
+ case types_2.AlarmEvent.HUB_STOP_BY_KEYPAD:
537
+ if (this.hasProperty(types_1.PropertyName.StationAlarm)) {
538
+ this.updateProperty(types_1.PropertyName.StationAlarm, false);
539
+ }
540
+ if (this.hasProperty(types_1.PropertyName.StationAlarmType)) {
541
+ this.updateProperty(types_1.PropertyName.StationAlarmType, 0);
542
+ }
543
+ break;
544
+ default:
545
+ if (this.hasProperty(types_1.PropertyName.StationAlarm)) {
546
+ this.updateProperty(types_1.PropertyName.StationAlarm, true);
547
+ }
548
+ if (this.hasProperty(types_1.PropertyName.StationAlarmType)) {
549
+ this.updateProperty(types_1.PropertyName.StationAlarmType, alarmEvent);
550
+ }
551
+ break;
552
+ }
461
553
  }
462
554
  async setGuardMode(mode) {
463
555
  const propertyData = {
@@ -524,6 +616,29 @@ class Station extends tiny_typed_emitter_1.TypedEmitter {
524
616
  const armDelay = this.getArmDelay(mode);
525
617
  if (armDelay > 0) {
526
618
  this.emit("alarm arm delay event", this, armDelay);
619
+ if (this.hasProperty(types_1.PropertyName.StationAlarmArmDelay)) {
620
+ this.updateProperty(types_1.PropertyName.StationAlarmArmDelay, armDelay);
621
+ }
622
+ }
623
+ if (mode === types_1.AlarmMode.DISARMED) {
624
+ if (this.hasProperty(types_1.PropertyName.StationAlarmArmDelay)) {
625
+ this.updateProperty(types_1.PropertyName.StationAlarmArmDelay, 0);
626
+ }
627
+ if (this.hasProperty(types_1.PropertyName.StationAlarmArmed)) {
628
+ this.updateProperty(types_1.PropertyName.StationAlarmArmed, false);
629
+ }
630
+ if (this.hasProperty(types_1.PropertyName.StationAlarmDelay)) {
631
+ this.updateProperty(types_1.PropertyName.StationAlarmDelay, 0);
632
+ }
633
+ if (this.hasProperty(types_1.PropertyName.StationAlarmDelayType)) {
634
+ this.updateProperty(types_1.PropertyName.StationAlarmDelayType, 0);
635
+ }
636
+ if (this.hasProperty(types_1.PropertyName.StationAlarm)) {
637
+ this.updateProperty(types_1.PropertyName.StationAlarm, false);
638
+ }
639
+ if (this.hasProperty(types_1.PropertyName.StationAlarmType)) {
640
+ this.updateProperty(types_1.PropertyName.StationAlarmType, 0);
641
+ }
527
642
  }
528
643
  // Trigger refresh Guard Mode
529
644
  await this.getCameraInfo();
@@ -561,6 +676,42 @@ class Station extends tiny_typed_emitter_1.TypedEmitter {
561
676
  }
562
677
  return 0;
563
678
  }
679
+ /*private getGuardModeActionSetting(mode: AlarmMode): number {
680
+ //TODO: This settings are only available on the device properties...
681
+ let value = 0;
682
+ try {
683
+ switch (mode) {
684
+ case AlarmMode.HOME:
685
+ value = Number.parseInt(this.getRawProperty(CommandType.CMD_GET_HOME_ACTION));
686
+ break;
687
+ case AlarmMode.AWAY:
688
+ value = Number.parseInt(this.getRawProperty(CommandType.CMD_GET_AWAY_ACTION));
689
+ break;
690
+ case AlarmMode.CUSTOM1:
691
+ value = Number.parseInt(this.getRawProperty(CommandType.CMD_GET_CUSTOM1_ACTION));
692
+ break;
693
+ case AlarmMode.CUSTOM2:
694
+ value = Number.parseInt(this.getRawProperty(CommandType.CMD_GET_CUSTOM2_ACTION));
695
+ break;
696
+ case AlarmMode.CUSTOM3:
697
+ value = Number.parseInt(this.getRawProperty(CommandType.CMD_GET_CUSTOM3_ACTION));
698
+ break;
699
+ }
700
+ } catch (error) {
701
+ this.log.debug(`Station ${this.getSerial()} - getGuardModeActionSetting - Error`, { error: error, mode: mode });
702
+ }
703
+ return value;
704
+ }
705
+
706
+ private isAlarmArmable(mode: AlarmMode): boolean {
707
+ const action = this.getGuardModeActionSetting(mode);
708
+ if ((action & GuardModeSecuritySettingsAction.CAMERA_ALARM) == GuardModeSecuritySettingsAction.CAMERA_ALARM ||
709
+ (action & GuardModeSecuritySettingsAction.HOMEBASE_ALARM) == GuardModeSecuritySettingsAction.HOMEBASE_ALARM ||
710
+ (action & GuardModeSecuritySettingsAction.LIGHT_ALARM) == GuardModeSecuritySettingsAction.LIGHT_ALARM) {
711
+ return true;
712
+ }
713
+ return false;
714
+ }*/
564
715
  _getDeviceSerial(channel) {
565
716
  if (this.rawStation.devices)
566
717
  for (const device of this.rawStation.devices) {
@@ -890,7 +1041,7 @@ class Station extends tiny_typed_emitter_1.TypedEmitter {
890
1041
  const property = device.getPropertyMetadata(propertyData.name);
891
1042
  (0, utils_3.validValue)(property, value);
892
1043
  this.log.debug(`Sending motion detection command to station ${this.getSerial()} for device ${device.getSerial()} with value: ${value}`);
893
- if (device.isIndoorCamera() || (device.isFloodLight() && device.getDeviceType() !== types_1.DeviceType.FLOODLIGHT) || device.isFloodLightT8420X()) {
1044
+ if (device.isIndoorCamera() || (device.isFloodLight() && device.getDeviceType() !== types_1.DeviceType.FLOODLIGHT) || device.isFloodLightT8420X() || device.isWiredDoorbellT8200X()) {
894
1045
  await this.p2pSession.sendCommandWithStringPayload({
895
1046
  commandType: types_2.CommandType.CMD_DOORBELL_SET_PAYLOAD,
896
1047
  value: JSON.stringify({
@@ -1203,7 +1354,7 @@ class Station extends tiny_typed_emitter_1.TypedEmitter {
1203
1354
  property: propertyData
1204
1355
  });
1205
1356
  }
1206
- else if (device.isSoloCameras()) {
1357
+ else if (device.isSoloCameras() || device.isWiredDoorbellT8200X()) {
1207
1358
  await this.p2pSession.sendCommandWithStringPayload({
1208
1359
  commandType: types_2.CommandType.CMD_DOORBELL_SET_PAYLOAD,
1209
1360
  value: JSON.stringify({
@@ -1398,6 +1549,20 @@ class Station extends tiny_typed_emitter_1.TypedEmitter {
1398
1549
  property: propertyData
1399
1550
  });
1400
1551
  }
1552
+ else if (device.isWiredDoorbellT8200X()) {
1553
+ await this.p2pSession.sendCommandWithStringPayload({
1554
+ commandType: types_2.CommandType.CMD_DOORBELL_SET_PAYLOAD,
1555
+ value: JSON.stringify({
1556
+ "commandType": types_2.CommandType.CMD_SET_DETECT_TYPE,
1557
+ "data": {
1558
+ "value": value,
1559
+ }
1560
+ }),
1561
+ channel: device.getChannel()
1562
+ }, {
1563
+ property: propertyData
1564
+ });
1565
+ }
1401
1566
  else {
1402
1567
  throw new error_1.NotSupportedError(`This functionality is not implemented or supported by ${device.getSerial()}`);
1403
1568
  }
@@ -1646,6 +1811,20 @@ class Station extends tiny_typed_emitter_1.TypedEmitter {
1646
1811
  property: propertyData
1647
1812
  });
1648
1813
  }
1814
+ else if (device.isWiredDoorbellT8200X()) {
1815
+ await this.p2pSession.sendCommandWithStringPayload({
1816
+ commandType: types_2.CommandType.CMD_DOORBELL_SET_PAYLOAD,
1817
+ value: JSON.stringify({
1818
+ "commandType": types_2.CommandType.CMD_INDOOR_SET_RECORD_AUDIO_ENABLE,
1819
+ "data": {
1820
+ "enable": value === true ? 1 : 0,
1821
+ }
1822
+ }),
1823
+ channel: device.getChannel()
1824
+ }, {
1825
+ property: propertyData
1826
+ });
1827
+ }
1649
1828
  else if (device.isWiredDoorbell()) {
1650
1829
  await this.p2pSession.sendCommandWithStringPayload({
1651
1830
  commandType: types_2.CommandType.CMD_DOORBELL_SET_PAYLOAD,
@@ -1737,6 +1916,20 @@ class Station extends tiny_typed_emitter_1.TypedEmitter {
1737
1916
  property: propertyData
1738
1917
  });
1739
1918
  }
1919
+ else if (device.isWiredDoorbellT8200X()) {
1920
+ await this.p2pSession.sendCommandWithStringPayload({
1921
+ commandType: types_2.CommandType.CMD_DOORBELL_SET_PAYLOAD,
1922
+ value: JSON.stringify({
1923
+ "commandType": types_2.CommandType.CMD_T8200X_SET_RINGTONE_VOLUME,
1924
+ "data": {
1925
+ "status": value,
1926
+ }
1927
+ }),
1928
+ channel: device.getChannel()
1929
+ }, {
1930
+ property: propertyData
1931
+ });
1932
+ }
1740
1933
  else if (device.isWiredDoorbell()) {
1741
1934
  await this.p2pSession.sendCommandWithStringPayload({
1742
1935
  commandType: types_2.CommandType.CMD_DOORBELL_SET_PAYLOAD,
@@ -1930,6 +2123,20 @@ class Station extends tiny_typed_emitter_1.TypedEmitter {
1930
2123
  property: propertyData
1931
2124
  });
1932
2125
  }
2126
+ else if (device.isWiredDoorbellT8200X()) {
2127
+ await this.p2pSession.sendCommandWithStringPayload({
2128
+ commandType: types_2.CommandType.CMD_DOORBELL_SET_PAYLOAD,
2129
+ value: JSON.stringify({
2130
+ "commandType": types_2.CommandType.CMD_INDOOR_PUSH_NOTIFY_TYPE,
2131
+ "data": {
2132
+ "value": value,
2133
+ }
2134
+ }),
2135
+ channel: device.getChannel()
2136
+ }, {
2137
+ property: propertyData
2138
+ });
2139
+ }
1933
2140
  else if (device.isBatteryDoorbell() || device.isWiredDoorbellDual()) {
1934
2141
  await this.p2pSession.sendCommandWithStringPayload({
1935
2142
  commandType: types_2.CommandType.CMD_SET_PAYLOAD,
@@ -3152,7 +3359,7 @@ class Station extends tiny_typed_emitter_1.TypedEmitter {
3152
3359
  const property = device.getPropertyMetadata(propertyData.name);
3153
3360
  (0, utils_3.validValue)(property, value);
3154
3361
  let param_value = value === true ? 0 : 1;
3155
- if ((device.isIndoorCamera() && !device.isIndoorCamMini()) || device.isWiredDoorbell() || device.getDeviceType() === types_1.DeviceType.FLOODLIGHT_CAMERA_8422 || device.getDeviceType() === types_1.DeviceType.FLOODLIGHT_CAMERA_8424 || device.isFloodLightT8420X())
3362
+ if ((device.isIndoorCamera() && !device.isIndoorCamMini()) || (device.isWiredDoorbell() && !device.isWiredDoorbellT8200X()) || device.getDeviceType() === types_1.DeviceType.FLOODLIGHT_CAMERA_8422 || device.getDeviceType() === types_1.DeviceType.FLOODLIGHT_CAMERA_8424 || device.isFloodLightT8420X())
3156
3363
  param_value = value === true ? 1 : 0;
3157
3364
  this.log.debug(`Sending enable device command to station ${this.getSerial()} for device ${device.getSerial()} with value: ${value}`);
3158
3365
  if (device.isIndoorCamMini()) {
@@ -3290,8 +3497,8 @@ class Station extends tiny_typed_emitter_1.TypedEmitter {
3290
3497
  }
3291
3498
  this.log.debug(`Sending start livestream command to station ${this.getSerial()} for device ${device.getSerial()}`);
3292
3499
  const rsa_key = this.p2pSession.getRSAPrivateKey();
3293
- if (device.isSoloCameras() || device.getDeviceType() === types_1.DeviceType.FLOODLIGHT_CAMERA_8423) {
3294
- this.log.debug(`Using CMD_DOORBELL_SET_PAYLOAD (solo cams) for station ${this.getSerial()} (main_sw_version: ${this.getSoftwareVersion()})`);
3500
+ if (device.isSoloCameras() || device.getDeviceType() === types_1.DeviceType.FLOODLIGHT_CAMERA_8423 || device.isWiredDoorbellT8200X()) {
3501
+ this.log.debug(`Using CMD_DOORBELL_SET_PAYLOAD (1) for station ${this.getSerial()} (main_sw_version: ${this.getSoftwareVersion()})`);
3295
3502
  await this.p2pSession.sendCommandWithStringPayload({
3296
3503
  commandType: types_2.CommandType.CMD_DOORBELL_SET_PAYLOAD,
3297
3504
  value: JSON.stringify({
@@ -3308,7 +3515,7 @@ class Station extends tiny_typed_emitter_1.TypedEmitter {
3308
3515
  });
3309
3516
  }
3310
3517
  else if (device.isWiredDoorbell() || (device.isFloodLight() && device.getDeviceType() !== types_1.DeviceType.FLOODLIGHT) || device.isIndoorCamera() || (device.getSerial().startsWith("T8420") && (0, utils_1.isGreaterEqualMinVersion)("2.0.4.8", this.getSoftwareVersion()))) {
3311
- this.log.debug(`Using CMD_DOORBELL_SET_PAYLOAD for station ${this.getSerial()} (main_sw_version: ${this.getSoftwareVersion()})`);
3518
+ this.log.debug(`Using CMD_DOORBELL_SET_PAYLOAD (2) for station ${this.getSerial()} (main_sw_version: ${this.getSoftwareVersion()})`);
3312
3519
  await this.p2pSession.sendCommandWithStringPayload({
3313
3520
  commandType: types_2.CommandType.CMD_DOORBELL_SET_PAYLOAD,
3314
3521
  value: JSON.stringify({
@@ -5908,15 +6115,14 @@ class Station extends tiny_typed_emitter_1.TypedEmitter {
5908
6115
  }
5909
6116
  this.log.debug(`Sending snooze command to station ${this.getSerial()} for device ${device.getSerial()} with value: ${value}`);
5910
6117
  if (device.isDoorbell()) {
5911
- //TODO: To test if it works
5912
6118
  await this.p2pSession.sendCommandWithStringPayload({
5913
6119
  commandType: types_2.CommandType.CMD_SET_SNOOZE_MODE,
5914
6120
  value: JSON.stringify({
5915
6121
  "account_id": this.rawStation.member.admin_user_id,
5916
6122
  "snooze_time": value.snooze_time,
5917
- //"startTime": 0,
6123
+ "startTime": `${Math.trunc(new Date().getTime() / 1000)}`,
5918
6124
  "chime_onoff": value.snooze_chime !== undefined && value.snooze_chime ? 1 : 0,
5919
- "motion_onoff": value.snooze_motion !== undefined && value.snooze_motion ? 1 : 0,
6125
+ "motion_notify_onoff": value.snooze_motion !== undefined && value.snooze_motion ? 1 : 0,
5920
6126
  "homebase_onoff": value.snooze_homebase !== undefined && value.snooze_homebase ? 1 : 0,
5921
6127
  }),
5922
6128
  channel: device.getChannel()
@@ -6481,6 +6687,42 @@ class Station extends tiny_typed_emitter_1.TypedEmitter {
6481
6687
  throw new error_1.NotSupportedError(`This functionality is not implemented or supported by ${device.getSerial()}`);
6482
6688
  }
6483
6689
  }
6690
+ async chimeHombase(value) {
6691
+ const commandData = {
6692
+ name: types_1.CommandName.StationChime,
6693
+ value: value
6694
+ };
6695
+ if (!this.hasCommand(commandData.name)) {
6696
+ throw new error_1.NotSupportedError(`This functionality is not implemented or supported by ${this.getSerial()}`);
6697
+ }
6698
+ if (this.rawStation.devices !== undefined) {
6699
+ this.rawStation.devices.forEach((device) => {
6700
+ if (device_1.Device.isDoorbell(device.device_type)) {
6701
+ throw new error_1.NotSupportedError(`This functionality is only supported on stations without registered Doorbells on it (${this.getSerial()})`);
6702
+ }
6703
+ });
6704
+ }
6705
+ this.log.debug(`Sending homebase chime command to station ${this.getSerial()} with value: ${value}`);
6706
+ if (this.isStation()) {
6707
+ await this.p2pSession.sendCommandWithStringPayload({
6708
+ commandType: types_2.CommandType.CMD_SET_PAYLOAD,
6709
+ value: JSON.stringify({
6710
+ "account_id": this.rawStation.member.admin_user_id,
6711
+ "cmd": types_2.CommandType.CMD_BAT_DOORBELL_DINGDONG_R,
6712
+ "mValue3": 0,
6713
+ "payload": {
6714
+ "dingdong_ringtone": value,
6715
+ }
6716
+ }),
6717
+ channel: 0
6718
+ }, {
6719
+ command: commandData
6720
+ });
6721
+ }
6722
+ else {
6723
+ throw new error_1.NotSupportedError(`This functionality is not implemented or supported by ${this.getSerial()}`);
6724
+ }
6725
+ }
6484
6726
  }
6485
6727
  exports.Station = Station;
6486
6728
  Station.CHANNEL = 255;