Skip to content

Commit

Permalink
Merge pull request #544 from homebridge-eufy-security/lenoxys/issue543
Browse files Browse the repository at this point in the history
[Bug]: Inconsistencies in Applying Display Settings for Enabled, Motion, and Light Buttons  Fixes #543
  • Loading branch information
lenoxys authored Apr 17, 2024
2 parents 0d22598 + a454185 commit 3aaf19e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { NgFor } from '@angular/common';

interface ButtonConfig {
name: string;
button: string;
description: string;
value: boolean;
propertyName: keyof L_Device;
Expand All @@ -25,10 +26,10 @@ export class CameraButtonsComponent extends ConfigOptionsInterpreter implements
@Input() device?: L_Device;

buttonConfigs: ButtonConfig[] = [
{ name: 'Enable', description: 'camera', value: DEFAULT_CAMERACONFIG_VALUES.enableButton, propertyName: 'DeviceEnabled' },
{ name: 'Motion', description: 'detection', value: DEFAULT_CAMERACONFIG_VALUES.motionButton, propertyName: 'DeviceMotionDetection' },
{ name: 'Light', description: 'light', value: DEFAULT_CAMERACONFIG_VALUES.lightButton, propertyName: 'DeviceLight' },
{ name: 'IndoorChime', description: 'indoor chime', value: DEFAULT_CAMERACONFIG_VALUES.indoorChimeButton!, propertyName: 'DeviceChimeIndoor' },
{ name: 'Enable', button: 'enableButton', description: 'camera', value: DEFAULT_CAMERACONFIG_VALUES.enableButton, propertyName: 'DeviceEnabled' },
{ name: 'Motion', button: 'motionButton', description: 'detection', value: DEFAULT_CAMERACONFIG_VALUES.motionButton, propertyName: 'DeviceMotionDetection' },
{ name: 'Light', button: 'lightButton', description: 'light', value: DEFAULT_CAMERACONFIG_VALUES.lightButton, propertyName: 'DeviceLight' },
{ name: 'IndoorChime', button: 'indoorChimeButton', description: 'indoor chime', value: DEFAULT_CAMERACONFIG_VALUES.indoorChimeButton!, propertyName: 'DeviceChimeIndoor' },
];

constructor(
Expand All @@ -47,8 +48,8 @@ export class CameraButtonsComponent extends ConfigOptionsInterpreter implements

this.buttonConfigs = this.buttonConfigs.filter((buttonConfig) => {
if (this.device && this.device[buttonConfig.propertyName]) {
if (buttonConfig.name in config) {
buttonConfig.value = config[buttonConfig.name] ?? buttonConfig.value;
if (buttonConfig.button in config) {
buttonConfig.value = config[buttonConfig.button] ?? buttonConfig.value;
}
return true; // Keep the buttonConfig
} else {
Expand All @@ -60,7 +61,7 @@ export class CameraButtonsComponent extends ConfigOptionsInterpreter implements
update(): void {
const updated: Record<string, boolean> = {};
this.buttonConfigs.forEach(buttonConfig => {
updated[buttonConfig.name.toLowerCase()] = buttonConfig.value;
updated[buttonConfig.button] = buttonConfig.value;
});

this.updateDeviceConfig(updated, this.device!);
Expand Down
12 changes: 2 additions & 10 deletions src/configui/app/config-options/enable-hsv/enable-hsv.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,6 @@ export class EnableHsvComponent extends ConfigOptionsInterpreter implements OnIn
this.value = config['hsv'];
}

if (config && Object.prototype.hasOwnProperty.call(config, 'hsvConfig')) {
Object.entries(config['hsvConfig']).forEach(([key, value]) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const obj = this as any;
obj[key] = value;
});
}

try {

if (this.device) {
Expand All @@ -96,8 +88,8 @@ export class EnableHsvComponent extends ConfigOptionsInterpreter implements OnIn
}

update() {
this.updateConfig({
this.updateDeviceConfig({
hsv: this.value,
});
}, this.device!);
}
}
8 changes: 4 additions & 4 deletions src/plugin/controller/recordingDelegate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,14 @@ export class RecordingDelegate implements CameraRecordingDelegate {
const videoParams = await FFmpegParameters.forVideoRecording();
const audioParams = await FFmpegParameters.forAudioRecording();

const hsvConfig: VideoConfig = this.cameraConfig.hsvConfig ?? {};
const videoConfig: VideoConfig = this.cameraConfig.videoConfig ?? {};

if (this.cameraConfig.videoConfig && this.cameraConfig.videoConfig.videoProcessor) {
hsvConfig.videoProcessor = this.cameraConfig.videoConfig.videoProcessor;
videoConfig.videoProcessor = this.cameraConfig.videoConfig.videoProcessor;
}

videoParams.setupForRecording(hsvConfig, this.configuration!);
audioParams.setupForRecording(hsvConfig, this.configuration!);
videoParams.setupForRecording(videoConfig, this.configuration!);
audioParams.setupForRecording(videoConfig, this.configuration!);

const rtsp = is_rtsp_ready(this.camera, this.cameraConfig);

Expand Down
1 change: 0 additions & 1 deletion src/plugin/utils/configTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export type CameraConfig = {
talkbackChannels?: number;
hsv?: boolean;
hsvRecordingDuration?: number;
hsvConfig?: VideoConfig;
indoorChimeButton?: boolean;
};

Expand Down

0 comments on commit 3aaf19e

Please sign in to comment.