eufy-security-client
Version:
Client to comunicate with Eufy-Security devices
637 lines • 258 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.UnknownDevice = exports.SmartDrop = exports.DoorbellLock = exports.Tracker = exports.SmartSafe = exports.Keypad = exports.LockKeypad = exports.Lock = exports.MotionSensor = exports.EntrySensor = exports.Sensor = exports.GarageCamera = exports.WallLightCam = exports.FloodlightCamera = exports.BatteryDoorbellCamera = exports.WiredDoorbellCamera = exports.DoorbellCamera = exports.IndoorCamera = exports.SoloCamera = exports.Camera = exports.Device = void 0;
const tiny_typed_emitter_1 = require("tiny-typed-emitter");
const types_1 = require("./types");
const parameter_1 = require("./parameter");
const types_2 = require("../p2p/types");
const utils_1 = require("./utils");
const utils_2 = require("../p2p/utils");
const types_3 = require("../push/types");
const utils_3 = require("../utils");
const error_1 = require("./error");
const error_2 = require("../error");
const logging_1 = require("../logging");
const station_1 = require("./station");
class Device extends tiny_typed_emitter_1.TypedEmitter {
api;
rawDevice;
eventTimeouts = new Map();
pictureEventTimeouts = new Map();
properties = {};
config = {};
rawProperties = {};
ready = false;
constructor(api, device, deviceConfig) {
super();
this.api = api;
this.rawDevice = device;
this.config = deviceConfig;
}
initializeState() {
this.update(this.rawDevice);
this.ready = true;
setImmediate(() => {
this.emit("ready", this);
});
}
initialize() {
this.initializeState();
}
getRawDevice() {
return this.rawDevice;
}
update(device) {
this.rawDevice = device;
const metadata = this.getPropertiesMetadata(true);
for (const property of Object.values(metadata)) {
if (this.rawDevice[property.key] !== undefined && typeof property.key === "string") {
if (property.key === "cover_path" && !this.getPropertyValue(property.name) && this.rawDevice[property.key] !== "") {
// First image initialisation if no image has been set yet and a cloud value is available
this.updateProperty(property.name, this.convertRawPropertyValue(property, (0, utils_1.getImagePath)(this.rawDevice[property.key])));
}
else {
this.updateProperty(property.name, this.convertRawPropertyValue(property, this.rawDevice[property.key]));
}
}
else if (this.properties[property.name] === undefined && property.default !== undefined && !this.ready) {
this.updateProperty(property.name, property.default);
}
}
if (this.rawDevice.params) {
this.rawDevice.params.forEach(param => {
this.updateRawProperty(param.param_type, param.param_value, "http");
});
}
logging_1.rootHTTPLogger.debug("Update device cloud properties", { deviceSN: this.getSerial(), properties: this.properties });
}
updateProperty(name, value, force = false) {
if ((this.properties[name] !== undefined && this.properties[name] !== value)
|| this.properties[name] === undefined || force) {
const oldValue = this.properties[name];
this.properties[name] = value;
this.emit("property changed", this, name, value, this.ready);
try {
this.handlePropertyChange(this.getPropertyMetadata(name, true), oldValue, this.properties[name]);
}
catch (err) {
const error = (0, error_2.ensureError)(err);
if (error instanceof error_1.InvalidPropertyError) {
logging_1.rootHTTPLogger.error(`Device update property - Invalid Property error`, { error: (0, utils_3.getError)(error), deviceSN: this.getSerial(), propertyName: name, propertyValue: value, force: force });
}
else {
logging_1.rootHTTPLogger.error(`Device update property - Property error`, { error: (0, utils_3.getError)(error), deviceSN: this.getSerial(), propertyName: name, propertyValue: value, force: force });
}
}
return true;
}
return false;
}
updateRawProperties(values) {
Object.keys(values).forEach(paramtype => {
const param_type = Number.parseInt(paramtype);
this.updateRawProperty(param_type, values[param_type].value, values[param_type].source);
});
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
handlePropertyChange(metadata, oldValue, newValue) {
try {
if ((metadata.key === types_1.ParamType.DETECT_MOTION_SENSITIVE || metadata.key === types_1.ParamType.DETECT_MODE) && this.isWiredDoorbell()) {
//TODO: Not perfectly solved, can in certain cases briefly trigger a double event where the last event is the correct one
const rawSensitivity = this.getRawProperty(types_1.ParamType.DETECT_MOTION_SENSITIVE);
const rawMode = this.getRawProperty(types_1.ParamType.DETECT_MODE);
if (rawSensitivity !== undefined && rawMode !== undefined && this.hasProperty(types_1.PropertyName.DeviceMotionDetectionSensitivity)) {
const sensitivity = Number.parseInt(rawSensitivity);
const mode = Number.parseInt(rawMode);
if (mode === 3 && sensitivity === 2) {
this.updateProperty(types_1.PropertyName.DeviceMotionDetectionSensitivity, 1);
}
else if (mode === 1 && sensitivity === 1) {
this.updateProperty(types_1.PropertyName.DeviceMotionDetectionSensitivity, 2);
}
else if (mode === 1 && sensitivity === 2) {
this.updateProperty(types_1.PropertyName.DeviceMotionDetectionSensitivity, 3);
}
else if (mode === 1 && sensitivity === 3) {
this.updateProperty(types_1.PropertyName.DeviceMotionDetectionSensitivity, 4);
}
else if (mode === 2 && sensitivity === 1) {
this.updateProperty(types_1.PropertyName.DeviceMotionDetectionSensitivity, 5);
}
}
}
else if (metadata.name === types_1.PropertyName.DeviceWifiRSSI && this.hasProperty(types_1.PropertyName.DeviceWifiSignalLevel)) {
this.updateProperty(types_1.PropertyName.DeviceWifiSignalLevel, (0, utils_1.calculateWifiSignalLevel)(this, newValue));
}
else if (metadata.name === types_1.PropertyName.DeviceCellularRSSI && this.hasProperty(types_1.PropertyName.DeviceCellularSignalLevel)) {
this.updateProperty(types_1.PropertyName.DeviceCellularSignalLevel, (0, utils_1.calculateCellularSignalLevel)(newValue));
}
}
catch (err) {
const error = (0, error_2.ensureError)(err);
logging_1.rootHTTPLogger.error(`Device handle property change - error`, { error: (0, utils_3.getError)(error), deviceSN: this.getSerial(), metadata: metadata, oldValue: oldValue, newValue: newValue });
}
}
updateRawProperty(type, value, source) {
const parsedValue = parameter_1.ParameterHelper.readValue(this.getStationSerial(), type, value, logging_1.rootHTTPLogger);
if (parsedValue !== undefined &&
((this.rawProperties[type] !== undefined && this.rawProperties[type].value !== parsedValue && (0, utils_1.isPrioritySourceType)(this.rawProperties[type].source, source)) || this.rawProperties[type] === undefined)) {
this.rawProperties[type] = {
value: parsedValue,
source: source
};
if (this.ready)
this.emit("raw property changed", this, type, this.rawProperties[type].value);
const metadata = this.getPropertiesMetadata(true);
for (const property of Object.values(metadata)) {
if (property.key === type) {
try {
this.updateProperty(property.name, this.convertRawPropertyValue(property, this.rawProperties[type].value));
}
catch (err) {
const error = (0, error_2.ensureError)(err);
if (error instanceof error_1.PropertyNotSupportedError) {
logging_1.rootHTTPLogger.debug("Device update raw property - Property not supported error", { error: (0, utils_3.getError)(error), deviceSN: this.getSerial(), type: type, value: value, source: source });
}
else {
logging_1.rootHTTPLogger.error("Device update raw property - Property error", { error: (0, utils_3.getError)(error), deviceSN: this.getSerial(), type: type, value: value, source: source });
}
}
}
}
return true;
}
return false;
}
convertRawPropertyValue(property, value) {
try {
if (property.key === types_1.ParamType.PRIVATE_MODE || property.key === types_1.ParamType.OPEN_DEVICE || property.key === types_2.CommandType.CMD_DEVS_SWITCH) {
if ((this.isIndoorCamera() && !this.isIndoorPanAndTiltCameraS350()) || (this.isWiredDoorbell() && !this.isWiredDoorbellT8200X()) || this.getDeviceType() === types_1.DeviceType.FLOODLIGHT_CAMERA_8422 || this.getDeviceType() === types_1.DeviceType.FLOODLIGHT_CAMERA_8424) {
return value !== undefined ? (value === "true" ? true : false) : false;
}
return value !== undefined ? (value === "0" ? true : false) : false;
}
else if (property.key === types_2.CommandType.CMD_BAT_DOORBELL_SET_NOTIFICATION_MODE) {
switch (property.name) {
case types_1.PropertyName.DeviceNotificationRing: {
const booleanProperty = property;
try {
return value !== undefined ? (Number.parseInt(value.notification_ring_onoff) === 1 ? true : false) : booleanProperty.default !== undefined ? booleanProperty.default : false;
}
catch (err) {
const error = (0, error_2.ensureError)(err);
logging_1.rootHTTPLogger.error("Device convert raw property - CMD_BAT_DOORBELL_SET_NOTIFICATION_MODE DeviceNotificationRing Error", { error: (0, utils_3.getError)(error), deviceSN: this.getSerial(), property: property, value: value });
return booleanProperty.default !== undefined ? booleanProperty.default : false;
}
}
case types_1.PropertyName.DeviceNotificationMotion: {
const booleanProperty = property;
try {
return value !== undefined ? (Number.parseInt(value.notification_motion_onoff) === 1 ? true : false) : booleanProperty.default !== undefined ? booleanProperty.default : false;
}
catch (err) {
const error = (0, error_2.ensureError)(err);
logging_1.rootHTTPLogger.error("Device convert raw property - CMD_BAT_DOORBELL_SET_NOTIFICATION_MODE DeviceNotificationMotion Error", { error: (0, utils_3.getError)(error), deviceSN: this.getSerial(), property: property, value: value });
return booleanProperty.default !== undefined ? booleanProperty.default : false;
}
}
case types_1.PropertyName.DeviceNotificationType: {
const numericProperty = property;
try {
return value !== undefined ? Number.parseInt(value.notification_style) : (numericProperty.default !== undefined ? numericProperty.default : (numericProperty.min !== undefined ? numericProperty.min : 0));
}
catch (err) {
const error = (0, error_2.ensureError)(err);
logging_1.rootHTTPLogger.error("Device convert raw property - CMD_BAT_DOORBELL_SET_NOTIFICATION_MODE DeviceNotificationType Error", { error: (0, utils_3.getError)(error), deviceSN: this.getSerial(), property: property, value: value });
return numericProperty.default !== undefined ? numericProperty.default : (numericProperty.min !== undefined ? numericProperty.min : 0);
}
}
}
}
else if (property.key === types_1.ParamType.DOORBELL_NOTIFICATION_OPEN) {
try {
switch (property.name) {
case types_1.PropertyName.DeviceNotificationRing:
return value !== undefined ? (Number.parseInt(value) === 3 || Number.parseInt(value) === 1 ? true : false) : false;
case types_1.PropertyName.DeviceNotificationMotion:
return value !== undefined ? (Number.parseInt(value) === 3 || Number.parseInt(value) === 2 ? true : false) : false;
}
}
catch (err) {
const error = (0, error_2.ensureError)(err);
logging_1.rootHTTPLogger.error("Device convert raw property - DOORBELL_NOTIFICATION_OPEN Error", { error: (0, utils_3.getError)(error), deviceSN: this.getSerial(), property: property, value: value });
return false;
}
}
else if (property.key === types_2.CommandType.CMD_SET_PIRSENSITIVITY) {
const numericProperty = property;
try {
if (this.getDeviceType() === types_1.DeviceType.CAMERA || this.getDeviceType() === types_1.DeviceType.CAMERA_E) {
const convertedValue = ((200 - Number.parseInt(value)) / 2) + 1;
return convertedValue;
}
else if (this.isCamera2Product()) {
let convertedValue;
switch (Number.parseInt(value)) {
case 192:
convertedValue = 1;
break;
case 118:
convertedValue = 2;
break;
case 72:
convertedValue = 3;
break;
case 46:
convertedValue = 4;
break;
case 30:
convertedValue = 5;
break;
case 20:
convertedValue = 6;
break;
case 14:
convertedValue = 7;
break;
default:
convertedValue = 4;
break;
}
return convertedValue;
}
else {
return value !== undefined ? Number.parseInt(value) : (numericProperty.default !== undefined ? numericProperty.default : (numericProperty.min !== undefined ? numericProperty.min : 0));
}
}
catch (err) {
const error = (0, error_2.ensureError)(err);
logging_1.rootHTTPLogger.error("Device convert raw property - CMD_SET_PIRSENSITIVITY Error", { error: (0, utils_3.getError)(error), deviceSN: this.getSerial(), property: property, value: value });
return numericProperty.default !== undefined ? numericProperty.default : (numericProperty.min !== undefined ? numericProperty.min : 0);
}
}
else if (property.key === types_2.CommandType.CMD_SMARTLOCK_AUTO_LOCK_SCHEDULE_STARTTIME || property.key === types_2.CommandType.CMD_SMARTLOCK_AUTO_LOCK_SCHEDULE_ENDTIME) {
const tmpBuffer = Buffer.from(value, "hex");
return `${tmpBuffer.subarray(0, 1).readInt8().toString().padStart(2, "0")}:${tmpBuffer.subarray(1).readInt8().toString().padStart(2, "0")}`;
}
else if (property.key === types_2.CommandType.CMD_DOORBELL_DUAL_RADAR_WD_DETECTION_SENSITIVITY) {
const numericProperty = property;
try {
switch (property.name) {
case types_1.PropertyName.DeviceMotionDetectionSensitivityMode:
return value !== undefined && value.model !== undefined ? value.model : (numericProperty.default !== undefined ? numericProperty.default : (numericProperty.min !== undefined ? numericProperty.min : 0));
case types_1.PropertyName.DeviceMotionDetectionSensitivityStandard:
return value !== undefined && value.model === 0 ? (0, utils_1.getDistances)(value.block_list)[0] : (numericProperty.default !== undefined ? numericProperty.default : (numericProperty.min !== undefined ? numericProperty.min : 0));
case types_1.PropertyName.DeviceMotionDetectionSensitivityAdvancedA:
return value !== undefined && value.model === 1 ? (0, utils_1.getDistances)(value.block_list)[0] : (numericProperty.default !== undefined ? numericProperty.default : (numericProperty.min !== undefined ? numericProperty.min : 0));
case types_1.PropertyName.DeviceMotionDetectionSensitivityAdvancedB:
return value !== undefined && value.model === 1 ? (0, utils_1.getDistances)(value.block_list)[1] : (numericProperty.default !== undefined ? numericProperty.default : (numericProperty.min !== undefined ? numericProperty.min : 0));
case types_1.PropertyName.DeviceMotionDetectionSensitivityAdvancedC:
return value !== undefined && value.model === 1 ? (0, utils_1.getDistances)(value.block_list)[2] : (numericProperty.default !== undefined ? numericProperty.default : (numericProperty.min !== undefined ? numericProperty.min : 0));
case types_1.PropertyName.DeviceMotionDetectionSensitivityAdvancedD:
return value !== undefined && value.model === 1 ? (0, utils_1.getDistances)(value.block_list)[3] : (numericProperty.default !== undefined ? numericProperty.default : (numericProperty.min !== undefined ? numericProperty.min : 0));
case types_1.PropertyName.DeviceMotionDetectionSensitivityAdvancedE:
return value !== undefined && value.model === 1 ? (0, utils_1.getDistances)(value.block_list)[4] : (numericProperty.default !== undefined ? numericProperty.default : (numericProperty.min !== undefined ? numericProperty.min : 0));
case types_1.PropertyName.DeviceMotionDetectionSensitivityAdvancedF:
return value !== undefined && value.model === 1 ? (0, utils_1.getDistances)(value.block_list)[5] : (numericProperty.default !== undefined ? numericProperty.default : (numericProperty.min !== undefined ? numericProperty.min : 0));
case types_1.PropertyName.DeviceMotionDetectionSensitivityAdvancedG:
return value !== undefined && value.model === 1 ? (0, utils_1.getDistances)(value.block_list)[6] : (numericProperty.default !== undefined ? numericProperty.default : (numericProperty.min !== undefined ? numericProperty.min : 0));
case types_1.PropertyName.DeviceMotionDetectionSensitivityAdvancedH:
return value !== undefined && value.model === 1 ? (0, utils_1.getDistances)(value.block_list)[7] : (numericProperty.default !== undefined ? numericProperty.default : (numericProperty.min !== undefined ? numericProperty.min : 0));
}
}
catch (err) {
const error = (0, error_2.ensureError)(err);
logging_1.rootHTTPLogger.error(`Device convert raw property - CMD_DOORBELL_DUAL_RADAR_WD_DETECTION_SENSITIVITY ${property.name} Error`, { error: (0, utils_3.getError)(error), deviceSN: this.getSerial(), property: property, value: value });
return numericProperty.default !== undefined ? numericProperty.default : (numericProperty.min !== undefined ? numericProperty.min : 0);
}
}
else if (property.key === types_2.CommandType.CMD_DOORBELL_DUAL_RADAR_WD_AUTO_RESPONSE) {
switch (property.name) {
case types_1.PropertyName.DeviceLoiteringCustomResponseTimeFrom: {
const stringProperty = property;
try {
return (value?.setting?.length !== undefined && value?.setting?.length > 0 && value?.setting[0]?.start_hour !== undefined && value?.setting[0]?.start_min !== undefined) ? `${value?.setting[0]?.start_hour?.padStart(2, "0")}:${value?.setting[0]?.start_min?.padStart(2, "0")}` : stringProperty.default !== undefined ? stringProperty.default : "";
}
catch (err) {
const error = (0, error_2.ensureError)(err);
logging_1.rootHTTPLogger.error("Device convert raw property - CMD_DOORBELL_DUAL_RADAR_WD_AUTO_RESPONSE DeviceLoiteringCustomResponseTimeFrom Error", { error: (0, utils_3.getError)(error), deviceSN: this.getSerial(), property: property, value: value });
return stringProperty.default !== undefined ? stringProperty.default : "";
}
}
case types_1.PropertyName.DeviceLoiteringCustomResponseTimeTo: {
const stringProperty = property;
try {
return (value?.setting?.length !== undefined && value?.setting?.length > 0 && value?.setting[0]?.end_hour !== undefined && value?.setting[0]?.end_min !== undefined) ? `${value?.setting[0]?.end_hour?.padStart(2, "0")}:${value?.setting[0]?.end_min?.padStart(2, "0")}` : stringProperty.default !== undefined ? stringProperty.default : "";
}
catch (err) {
const error = (0, error_2.ensureError)(err);
logging_1.rootHTTPLogger.error("Device convert raw property - CMD_DOORBELL_DUAL_RADAR_WD_AUTO_RESPONSE DeviceLoiteringCustomResponseTimeTo Error", { error: (0, utils_3.getError)(error), deviceSN: this.getSerial(), property: property, value: value });
return stringProperty.default !== undefined ? stringProperty.default : "";
}
}
case types_1.PropertyName.DeviceLoiteringCustomResponsePhoneNotification: {
const booleanProperty = property;
try {
return value?.setting[0]?.push_notify === 1 ? true : booleanProperty.default !== undefined ? booleanProperty.default : false;
}
catch (err) {
const error = (0, error_2.ensureError)(err);
logging_1.rootHTTPLogger.error("Device convert raw property - CMD_DOORBELL_DUAL_RADAR_WD_AUTO_RESPONSE DeviceLoiteringCustomResponsePhoneNotification Error", { error: (0, utils_3.getError)(error), deviceSN: this.getSerial(), property: property, value: value });
return booleanProperty.default !== undefined ? booleanProperty.default : false;
}
}
case types_1.PropertyName.DeviceLoiteringCustomResponseHomeBaseNotification: {
const booleanProperty = property;
try {
return value?.setting[0]?.homebase_alert === 1 ? true : booleanProperty.default !== undefined ? booleanProperty.default : false;
}
catch (err) {
const error = (0, error_2.ensureError)(err);
logging_1.rootHTTPLogger.error("Device convert raw property - CMD_DOORBELL_DUAL_RADAR_WD_AUTO_RESPONSE DeviceLoiteringCustomResponseHomeBaseNotification Error", { error: (0, utils_3.getError)(error), deviceSN: this.getSerial(), property: property, value: value });
return booleanProperty.default !== undefined ? booleanProperty.default : false;
}
}
case types_1.PropertyName.DeviceLoiteringCustomResponseAutoVoiceResponse: {
const booleanProperty = property;
try {
return value?.setting[0]?.auto_voice_resp === 1 ? true : booleanProperty.default !== undefined ? booleanProperty.default : false;
}
catch (err) {
const error = (0, error_2.ensureError)(err);
logging_1.rootHTTPLogger.error("Device convert raw property - CMD_DOORBELL_DUAL_RADAR_WD_AUTO_RESPONSE DeviceLoiteringCustomResponseAutoVoiceResponse Error", { error: (0, utils_3.getError)(error), deviceSN: this.getSerial(), property: property, value: value });
return booleanProperty.default !== undefined ? booleanProperty.default : false;
}
}
case types_1.PropertyName.DeviceLoiteringCustomResponseAutoVoiceResponseVoice: {
const numericProperty = property;
try {
return (value?.setting?.length !== undefined && value?.setting?.length > 0 && value?.setting[0]?.auto_voice_id !== undefined) ? value?.setting[0]?.auto_voice_id : numericProperty.default !== undefined ? numericProperty.default : (numericProperty.min !== undefined ? numericProperty.min : 0);
}
catch (err) {
const error = (0, error_2.ensureError)(err);
logging_1.rootHTTPLogger.error("Device convert raw property - CMD_DOORBELL_DUAL_RADAR_WD_AUTO_RESPONSE DeviceLoiteringCustomResponseAutoVoiceResponseVoice Error", { error: (0, utils_3.getError)(error), deviceSN: this.getSerial(), property: property, value: value });
return numericProperty.default !== undefined ? numericProperty.default : (numericProperty.min !== undefined ? numericProperty.min : 0);
}
}
}
}
else if (property.key === types_2.CommandType.CMD_DOORBELL_DUAL_DELIVERY_GUARD_SWITCH) {
const booleanProperty = property;
try {
return value !== undefined && value.ai_bottom_switch !== undefined ? value.ai_bottom_switch === 1024 : (booleanProperty.default !== undefined ? booleanProperty.default : false);
}
catch (err) {
const error = (0, error_2.ensureError)(err);
logging_1.rootHTTPLogger.error("Device convert raw property - CMD_DOORBELL_DUAL_DELIVERY_GUARD_SWITCH Error", { error: (0, utils_3.getError)(error), deviceSN: this.getSerial(), property: property, value: value });
return booleanProperty.default !== undefined ? booleanProperty.default : false;
}
}
else if (property.key === types_2.CommandType.CMD_DOORBELL_DUAL_PACKAGE_STRAND_TIME) {
const stringProperty = property;
try {
return (value?.start_h !== undefined && value?.start_m !== undefined) ? `${value?.start_h?.toString().padStart(2, "0")}:${value?.start_m?.toString().padStart(2, "0")}` : stringProperty.default !== undefined ? stringProperty.default : "";
}
catch (err) {
const error = (0, error_2.ensureError)(err);
logging_1.rootHTTPLogger.error("Device convert raw property - CMD_DOORBELL_DUAL_PACKAGE_STRAND_TIME Error", { error: (0, utils_3.getError)(error), deviceSN: this.getSerial(), property: property, value: value });
return stringProperty.default !== undefined ? stringProperty.default : "";
}
}
else if (property.key === types_2.CommandType.CMD_DOORBELL_DUAL_RING_AUTO_RESPONSE) {
switch (property.name) {
case types_1.PropertyName.DeviceRingAutoResponse: {
const booleanProperty = property;
try {
return value?.setting[0]?.active === 1 ? true : booleanProperty.default !== undefined ? booleanProperty.default : false;
}
catch (err) {
const error = (0, error_2.ensureError)(err);
logging_1.rootHTTPLogger.error("Device convert raw property - CMD_DOORBELL_DUAL_RING_AUTO_RESPONSE DeviceRingAutoResponse Error", { error: (0, utils_3.getError)(error), deviceSN: this.getSerial(), property: property, value: value });
return booleanProperty.default !== undefined ? booleanProperty.default : false;
}
}
case types_1.PropertyName.DeviceRingAutoResponseVoiceResponse: {
const booleanProperty = property;
try {
return value?.setting[0]?.active === 1 ? true : booleanProperty.default !== undefined ? booleanProperty.default : false;
}
catch (err) {
const error = (0, error_2.ensureError)(err);
logging_1.rootHTTPLogger.error("Device convert raw property - CMD_DOORBELL_DUAL_RING_AUTO_RESPONSE DeviceRingAutoResponseVoiceResponse Error", { error: (0, utils_3.getError)(error), deviceSN: this.getSerial(), property: property, value: value });
return booleanProperty.default !== undefined ? booleanProperty.default : false;
}
}
case types_1.PropertyName.DeviceRingAutoResponseTimeFrom: {
const stringProperty = property;
try {
return (value?.setting?.length !== undefined && value?.setting?.length > 0 && value?.setting[0]?.start_hour !== undefined && value?.setting[0]?.start_min !== undefined) ? `${value?.setting[0]?.start_hour?.padStart(2, "0")}:${value?.setting[0]?.start_min?.padStart(2, "0")}` : stringProperty.default !== undefined ? stringProperty.default : "";
}
catch (err) {
const error = (0, error_2.ensureError)(err);
logging_1.rootHTTPLogger.error("Device convert raw property - CMD_DOORBELL_DUAL_RING_AUTO_RESPONSE DeviceRingAutoResponseTimeFrom Error", { error: (0, utils_3.getError)(error), deviceSN: this.getSerial(), property: property, value: value });
return stringProperty.default !== undefined ? stringProperty.default : "";
}
}
case types_1.PropertyName.DeviceRingAutoResponseTimeTo: {
const stringProperty = property;
try {
return (value?.setting?.length !== undefined && value?.setting?.length > 0 && value?.setting[0]?.end_hour !== undefined && value?.setting[0]?.end_min !== undefined) ? `${value?.setting[0]?.end_hour?.padStart(2, "0")}:${value?.setting[0]?.end_min?.padStart(2, "0")}` : stringProperty.default !== undefined ? stringProperty.default : "";
}
catch (err) {
const error = (0, error_2.ensureError)(err);
logging_1.rootHTTPLogger.error("Device convert raw property - CMD_DOORBELL_DUAL_RING_AUTO_RESPONSE DeviceRingAutoResponseTimeTo Error", { error: (0, utils_3.getError)(error), deviceSN: this.getSerial(), property: property, value: value });
return stringProperty.default !== undefined ? stringProperty.default : "";
}
}
case types_1.PropertyName.DeviceRingAutoResponseVoiceResponseVoice: {
const numericProperty = property;
try {
return (value?.setting?.length !== undefined && value?.setting?.length > 0 && value?.setting[0]?.auto_voice_id !== undefined) ? value?.setting[0]?.auto_voice_id : numericProperty.default !== undefined ? numericProperty.default : (numericProperty.min !== undefined ? numericProperty.min : 0);
}
catch (err) {
const error = (0, error_2.ensureError)(err);
logging_1.rootHTTPLogger.error("Device convert raw property - CMD_DOORBELL_DUAL_RING_AUTO_RESPONSE DeviceRingAutoResponseVoiceResponseVoice Error", { error: (0, utils_3.getError)(error), deviceSN: this.getSerial(), property: property, value: value });
return numericProperty.default !== undefined ? numericProperty.default : (numericProperty.min !== undefined ? numericProperty.min : 0);
}
}
}
}
else if (property.key === types_2.CommandType.CMD_DOORBELL_DUAL_PACKAGE_GUARD_TIME) {
switch (property.name) {
case types_1.PropertyName.DeviceDeliveryGuardPackageGuardingActivatedTimeFrom: {
const stringProperty = property;
try {
return (value?.start_h !== undefined && value?.start_m !== undefined) ? `${value?.start_h?.toString().padStart(2, "0")}:${value?.start_m?.toString().padStart(2, "0")}` : stringProperty.default !== undefined ? stringProperty.default : "";
}
catch (err) {
const error = (0, error_2.ensureError)(err);
logging_1.rootHTTPLogger.error("Device convert raw property - CMD_DOORBELL_DUAL_PACKAGE_GUARD_TIME DeviceDeliveryGuardPackageGuardingActivatedTimeFrom Error", { error: (0, utils_3.getError)(error), deviceSN: this.getSerial(), property: property, value: value });
return stringProperty.default !== undefined ? stringProperty.default : "";
}
}
case types_1.PropertyName.DeviceDeliveryGuardPackageGuardingActivatedTimeTo: {
const stringProperty = property;
try {
return (value?.end_h !== undefined && value?.end_m !== undefined) ? `${value?.end_h?.toString().padStart(2, "0")}:${value?.end_m?.toString().padStart(2, "0")}` : stringProperty.default !== undefined ? stringProperty.default : "";
}
catch (err) {
const error = (0, error_2.ensureError)(err);
logging_1.rootHTTPLogger.error("Device convert raw property - CMD_DOORBELL_DUAL_PACKAGE_GUARD_TIME DeviceDeliveryGuardPackageGuardingActivatedTimeTo Error", { error: (0, utils_3.getError)(error), deviceSN: this.getSerial(), property: property, value: value });
return stringProperty.default !== undefined ? stringProperty.default : "";
}
}
}
}
else if (property.key === types_2.CommandType.CMD_DOORBELL_DUAL_RADAR_WD_DISTANCE) {
const numericProperty = property;
try {
return value !== undefined && value.radar_wd_distance !== undefined ? value.radar_wd_distance : (numericProperty.default !== undefined ? numericProperty.default : (numericProperty.min !== undefined ? numericProperty.min : 0));
}
catch (err) {
const error = (0, error_2.ensureError)(err);
logging_1.rootHTTPLogger.error("Device convert raw property - CMD_DOORBELL_DUAL_RADAR_WD_DISTANCE Error", { error: (0, utils_3.getError)(error), deviceSN: this.getSerial(), property: property, value: value });
return numericProperty.default !== undefined ? numericProperty.default : (numericProperty.min !== undefined ? numericProperty.min : 0);
}
}
else if (property.key === types_2.CommandType.CMD_DOORBELL_DUAL_RADAR_WD_TIME) {
const numericProperty = property;
try {
return value !== undefined && value.radar_wd_time !== undefined ? value.radar_wd_time : (numericProperty.default !== undefined ? numericProperty.default : (numericProperty.min !== undefined ? numericProperty.min : 0));
}
catch (err) {
const error = (0, error_2.ensureError)(err);
logging_1.rootHTTPLogger.error("Device convert raw property - CMD_DOORBELL_DUAL_RADAR_WD_TIME Error", { error: (0, utils_3.getError)(error), deviceSN: this.getSerial(), property: property, value: value });
return numericProperty.default !== undefined ? numericProperty.default : (numericProperty.min !== undefined ? numericProperty.min : 0);
}
}
else if (property.key === types_2.CommandType.CMD_DOORBELL_DUAL_PACKAGE_GUARD_VOICE) {
const numericProperty = property;
try {
return value !== undefined && value.auto_voice_id !== undefined ? value.auto_voice_id : (numericProperty.default !== undefined ? numericProperty.default : (numericProperty.min !== undefined ? numericProperty.min : 0));
}
catch (err) {
const error = (0, error_2.ensureError)(err);
logging_1.rootHTTPLogger.error("Device convert raw property - CMD_DOORBELL_DUAL_PACKAGE_GUARD_VOICE Error", { error: (0, utils_3.getError)(error), deviceSN: this.getSerial(), property: property, value: value });
return numericProperty.default !== undefined ? numericProperty.default : (numericProperty.min !== undefined ? numericProperty.min : 0);
}
}
else if (property.key === types_2.CommandType.CMD_MOTION_SET_LEAVING_REACTIONS) {
switch (property.name) {
case types_1.PropertyName.DeviceLeavingReactionStartTime: {
const stringProperty = property;
try {
return (value !== undefined && value.start_hour !== undefined && value.start_min !== undefined) ? `${value.start_hour.padStart(2, "0")}:${value.start_min.padStart(2, "0")}` : stringProperty.default !== undefined ? stringProperty.default : "";
}
catch (err) {
const error = (0, error_2.ensureError)(err);
logging_1.rootHTTPLogger.error("Device convert raw property - CMD_MOTION_SET_LEAVING_REACTIONS DeviceLeavingReactionStartTime Error", { error: (0, utils_3.getError)(error), deviceSN: this.getSerial(), property: property, value: value });
return stringProperty.default !== undefined ? stringProperty.default : "";
}
}
case types_1.PropertyName.DeviceLeavingReactionEndTime: {
const stringProperty = property;
try {
return (value !== undefined && value.end_hour !== undefined && value.end_min !== undefined) ? `${value.end_hour.padStart(2, "0")}:${value.end_min.padStart(2, "0")}` : stringProperty.default !== undefined ? stringProperty.default : "";
}
catch (err) {
const error = (0, error_2.ensureError)(err);
logging_1.rootHTTPLogger.error("Device convert raw property - CMD_MOTION_SET_LEAVING_REACTIONS DeviceLeavingReactionEndTime Error", { error: (0, utils_3.getError)(error), deviceSN: this.getSerial(), property: property, value: value });
return stringProperty.default !== undefined ? stringProperty.default : "";
}
}
case types_1.PropertyName.DeviceLeavingReactionNotification: {
const booleanProperty = property;
try {
return value !== undefined && value.push_notify === 1 ? true : booleanProperty.default !== undefined ? booleanProperty.default : false;
}
catch (err) {
const error = (0, error_2.ensureError)(err);
logging_1.rootHTTPLogger.error("Device convert raw property - CMD_MOTION_SET_LEAVING_REACTIONS DeviceLeavingReactionNotification Error", { error: (0, utils_3.getError)(error), deviceSN: this.getSerial(), property: property, value: value });
return booleanProperty.default !== undefined ? booleanProperty.default : false;
}
}
}
}
else if (property.key === types_2.CommandType.CMD_SET_SNOOZE_MODE) {
switch (property.name) {
case types_1.PropertyName.DeviceSnooze: {
const booleanProperty = property;
try {
return value !== undefined && value.snooze_time !== undefined && value.snooze_time !== "" && Number.parseInt(value.snooze_time) !== 0 ? true : booleanProperty.default !== undefined ? booleanProperty.default : false;
}
catch (err) {
const error = (0, error_2.ensureError)(err);
logging_1.rootHTTPLogger.error("Device convert raw property - CMD_SET_SNOOZE_MODE DeviceSnooze Error", { error: (0, utils_3.getError)(error), deviceSN: this.getSerial(), property: property, value: value });
return booleanProperty.default !== undefined ? booleanProperty.default : false;
}
}
case types_1.PropertyName.DeviceSnoozeTime: {
const numericProperty = property;
try {
return value !== undefined && value.snooze_time !== undefined && value.snooze_time !== "" ? Number.parseInt(value.snooze_time) : (numericProperty.default !== undefined ? numericProperty.default : (numericProperty.min !== undefined ? numericProperty.min : 0));
}
catch (err) {
const error = (0, error_2.ensureError)(err);
logging_1.rootHTTPLogger.error("Device convert raw property - CMD_SET_SNOOZE_MODE DeviceSnoozeTime Error", { error: (0, utils_3.getError)(error), deviceSN: this.getSerial(), property: property, value: value });
return numericProperty.default !== undefined ? numericProperty.default : (numericProperty.min !== undefined ? numericProperty.min : 0);
}
}
case types_1.PropertyName.DeviceSnoozeStartTime: {
const numericProperty = property;
try {
return value !== undefined && value.startTime !== undefined ? Number.parseInt(value.startTime) : (numericProperty.default !== undefined ? numericProperty.default : (numericProperty.min !== undefined ? numericProperty.min : 0));
}
catch (err) {
const error = (0, error_2.ensureError)(err);
logging_1.rootHTTPLogger.error("Device convert raw property - CMD_SET_SNOOZE_MODE DeviceSnoozeTime Error", { error: (0, utils_3.getError)(error), deviceSN: this.getSerial(), property: property, value: value });
return numericProperty.default !== undefined ? numericProperty.default : (numericProperty.min !== undefined ? numericProperty.min : 0);
}
}
case types_1.PropertyName.DeviceSnoozeHomebase: {
const booleanProperty = property;
try {
return value !== undefined && value.homebase_onoff !== undefined ? (value.homebase_onoff === 1 ? true : false) : (booleanProperty.default !== undefined ? booleanProperty.default : false);
}
catch (err) {
const error = (0, error_2.ensureError)(err);
logging_1.rootHTTPLogger.error("Device convert raw property - CMD_SET_SNOOZE_MODE DeviceSnoozeHomebase Error", { error: (0, utils_3.getError)(error), deviceSN: this.getSerial(), property: property, value: value });
return booleanProperty.default !== undefined ? booleanProperty.default : false;
}
}
case types_1.PropertyName.DeviceSnoozeMotion: {
const booleanProperty = property;
try {
return value !== undefined && value.motion_notify_onoff !== undefined ? (value.motion_notify_onoff === 1 ? true : false) : (booleanProperty.default !== undefined ? booleanProperty.default : false);
}
catch (err) {
const error = (0, error_2.ensureError)(err);
logging_1.rootHTTPLogger.error("Device convert raw property - CMD_SET_SNOOZE_MODE DeviceSnoozeMotion Error", { error: (0, utils_3.getError)(error), deviceSN: this.getSerial(), property: property, value: value });
return booleanProperty.default !== undefined ? booleanProperty.default : false;
}
}
case types_1.PropertyName.DeviceSnoozeChime: {
const booleanProperty = property;
try {
return value !== undefined && value.chime_onoff !== undefined ? (value.chime_onoff === 1 ? true : false) : (booleanProperty.default !== undefined ? booleanProperty.default : false);
}
catch (err) {
const error = (0, error_2.ensureError)(err);
logging_1.rootHTTPLogger.error("Device convert raw property - CMD_SET_SNOOZE_MODE DeviceSnoozeChime Error", { error: (0, utils_3.getError)(error), deviceSN: this.getSerial(), property: property, value: value });
return booleanProperty.default !== undefined ? booleanProperty.default : false;
}
}
}
}
else if ((property.name === types_1.PropertyName.DeviceMotionDetectionTypeHuman ||
property.name === types_1.PropertyName.DeviceMotionDetectionTypeHumanRecognition ||
property.name === types_1.PropertyName.DeviceMotionDetectionTypePet ||
property.name === types_1.PropertyName.DeviceMotionDetectionTypeVehicle ||
property.name === types_1.PropertyName.DeviceMotionDetectionTypeAllOtherMotions) && this.getStationSerial().startsWith("T8030")) {
const booleanProperty = property;
try {
return (0, utils_1.isHB3DetectionModeEnabled)(Number.parseInt(value), property.name === types_1.PropertyName.DeviceMotionDetectionTypeHuman ? types_1.HB3DetectionTypes.HUMAN_DETECTION : property.name === types_1.PropertyName.DeviceMotionDetectionTypeHumanRecognition ? types_1.HB3DetectionTypes.HUMAN_RECOGNITION : property.name === types_1.PropertyName.DeviceMotionDetectionTypePet ? types_1.HB3DetectionTypes.PET_DETECTION : property.name === types_1.PropertyName.DeviceMotionDetectionTypeVehicle ? types_1.HB3DetectionTypes.VEHICLE_DETECTION : types_1.HB3DetectionTypes.ALL_OTHER_MOTION);
}
catch (err) {
const error = (0, error_2.ensureError)(err);
logging_1.rootHTTPLogger.error("Device convert raw property - HB3 motion detection type Error", { error: (0, utils_3.getError)(error), deviceSN: this.getSerial