Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updates and fixes #115

Merged
merged 12 commits into from
Jul 18, 2022
Merged
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Change Log

## 2.1.0 (beta) (11/07/2022)
## 2.1.0 (beta) (18/07/2022)

### Added

- switch to manually reset alarm via homekit
- switch to manually trigger alarm via homekit (this can be used to trigger the alarm with homekit automations) see #26
- setting to disable log file storage to disk (possible fix for #93)

### Changed
- Complete redesign of the config ui screen
Expand All @@ -22,6 +23,9 @@
- Updated to latest version of eufy-security-client (2.1.0)
- Added Dark Mode to config ui
- Added product images to devices page in config ui
- limit value for maximum streaming duration to prevent unexpected behaviour (see #111)
- Updated to latest version of eufy-security-client (2.1.1) (fix for #72 and #38)
- RTSP setting is now only avaiable on compatible devices

### Fixed
- [Bug]: package.json reqiures the wrong node version #44
Expand Down
212 changes: 109 additions & 103 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"bootstrap": "^5.1.3",
"bunyan": "^1.8.15",
"bunyan-debug-stream": "^2.0.1",
"eufy-security-client": "2.1.0",
"eufy-security-client": "2.1.1",
"ffmpeg-for-homebridge": "0.1.4",
"pick-port": "^1.0.1",
"rxjs": "~7.5.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
<hr />
<app-enable-detailed-logging></app-enable-detailed-logging>
<hr />
<app-omit-log-files></app-omit-log-files>
<hr />
<app-clean-cache></app-clean-cache>
<hr />
<app-guard-modes-mapping></app-guard-modes-mapping>
Expand Down
2 changes: 2 additions & 0 deletions src/configui/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import { GuardModesMappingComponent } from './config-options/guard-modes-mapping
import { ResetPluginComponent } from './config-options/reset-plugin/reset-plugin.component';
import { ResetConfirmationComponent } from './reset-confirmation/reset-confirmation.component';
import { ManualAlarmModesComponent } from './config-options/manual-alarm-modes/manual-alarm-modes.component';
import { OmitLogFilesComponent } from './config-options/omit-log-files/omit-log-files.component';

@NgModule({
declarations: [
Expand Down Expand Up @@ -71,6 +72,7 @@ import { ManualAlarmModesComponent } from './config-options/manual-alarm-modes/m
ResetPluginComponent,
ResetConfirmationComponent,
ManualAlarmModesComponent,
OmitLogFilesComponent,
],
imports: [BrowserModule, FormsModule, NgbModule, AppRoutingModule, FontAwesomeModule],
providers: [{ provide: LocationStrategy, useClass: HashLocationStrategy }],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<app-enable-camera [accessory]="accessory"></app-enable-camera>
<hr />
<app-livestream-cache [accessory]="accessory"></app-livestream-cache>
<hr />
<app-rtsp-streaming [accessory]="accessory"></app-rtsp-streaming>
<hr *ngIf="supportsRTSP" />
<app-rtsp-streaming [accessory]="accessory" *ngIf="supportsRTSP"></app-rtsp-streaming>
<hr />
<app-enable-audio [accessory]="accessory"></app-enable-audio>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export class CameraConfigOptionsComponent implements OnInit {
showEnhancedSnapshotBehaviour = true;
isDoorbell = false;
isCamera = false;
supportsRTSP = false;

constructor(private pluginService: PluginService, private route: ActivatedRoute) { }

Expand All @@ -25,6 +26,7 @@ export class CameraConfigOptionsComponent implements OnInit {
if (this.accessory) {
this.isDoorbell = Device.isDoorbell(this.accessory.type);
this.isCamera = Device.isCamera(this.accessory.type);
this.supportsRTSP = Device.supportsRTSP(this.accessory.type);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<div class="settingsItem row p-3">
<div class="d-flex justify-content-between align-items-center mb-2">
<span>Don't store log files</span>

<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" role="switch" [(ngModel)]="value" id="flexSwitchCheckDefault" (change)="update()">
</div>

</div>
<small><i>
This setting prevents log files to be stored to disk. If enabled, log messages will only be written to the Homebridge UI log window.
</i></small>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { Component, OnInit } from '@angular/core';
import { PluginService } from '../../plugin.service';
import { ConfigOptionsInterpreter } from '../config-options-interpreter';

@Component({
selector: 'app-omit-log-files',
templateUrl: './omit-log-files.component.html',
styles: [
],
})
export class OmitLogFilesComponent extends ConfigOptionsInterpreter implements OnInit {

constructor(pluginService: PluginService) {
super(pluginService);
}

ngOnInit(): void {
this.readValue();
}

/** Customize from here */
/** updateConfig() will overwrite any settings that you'll provide */
/** Don't try and 'append'/'push' to arrays this way - add a custom method instead */
/** see config option to ignore devices as example */

/** updateConfig() takes an optional second parameter to specify the accessoriy for which the setting is changed */

value = false;

readValue() {
if (Object.prototype.hasOwnProperty.call(this.config, 'omitLogFiles')) {
this.value = this.config['omitLogFiles'];
}
}

update() {
this.updateConfig({
omitLogFiles: this.value,
});
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
</div>
<small><i>
Try to utilize RTSP capabilities of some devices. This may result in improved streaming stability.
<p></p>
Please be advised that RTSP must be enable within Eufy App first!<br />
<b>This setting may not be working with devices that are not compatible with rtsp (such as Doorbell or Floodlight)</b>
</i></small>
</div>
19 changes: 19 additions & 0 deletions src/configui/app/util/eufy-security-client.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,23 @@ export class Device {
}
return false;
}

static supportsRTSP(type: number): boolean {
return (
type === DeviceType.CAMERA ||
type === DeviceType.CAMERA2 ||
type === DeviceType.CAMERA2C ||
type === DeviceType.CAMERA2C_PRO ||
type === DeviceType.CAMERA_E ||
type === DeviceType.INDOOR_CAMERA ||
type === DeviceType.INDOOR_CAMERA_1080 ||
type === DeviceType.INDOOR_OUTDOOR_CAMERA_1080P ||
type === DeviceType.INDOOR_OUTDOOR_CAMERA_1080P_NO_LIGHT ||
type === DeviceType.INDOOR_OUTDOOR_CAMERA_2K ||
type === DeviceType.INDOOR_PT_CAMERA ||
type === DeviceType.INDOOR_PT_CAMERA_1080 ||
type === DeviceType.INDOOR_COST_DOWN_CAMERA ||
type === DeviceType.FLOODLIGHT_CAMERA_8423
);
}
}
1 change: 1 addition & 0 deletions src/plugin/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface EufySecurityPlatformConfig extends PlatformConfig {
username: string;
password: string;
enableDetailedLogging: number;
omitLogFiles: boolean;
enableCamera: boolean;
CameraMaxLivestreamDuration: number;
pollingIntervalMinutes: number;
Expand Down
80 changes: 51 additions & 29 deletions src/plugin/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,53 +71,68 @@ export class EufySecurityPlatform implements DynamicPlatformPlugin {

this.eufyPath = this.api.user.storagePath() + '/eufysecurity';

if (!fs.existsSync(this.eufyPath)) {
fs.mkdirSync(this.eufyPath);
}

const plugin = require('../package.json');

this.log = bunyan.createLogger({
name: '[EufySecurity-' + plugin.version + ']',
hostname: '',
streams: [{
level: (this.config.enableDetailedLogging) ? 'debug' : 'info',
type: 'raw',
stream: bunyanDebugStream({
forceColor: true,
showProcess: false,
showPid: false,
showDate: (time) => {
return '[' + time.toLocaleString('en-US') + ']';
},
}),
}, {
const omitLogFiles = this.config.omitLogFiles ?? false;

const logStreams: bunyan.Stream[] = [{
level: (this.config.enableDetailedLogging) ? 'debug' : 'info',
type: 'raw',
stream: bunyanDebugStream({
forceColor: true,
showProcess: false,
showPid: false,
showDate: (time) => {
return '[' + time.toLocaleString('en-US') + ']';
},
}),
}];

if (!omitLogFiles) {
logStreams.push({
level: (this.config.enableDetailedLogging) ? 'debug' : 'info',
type: 'rotating-file',
path: this.eufyPath + '/log-lib.log',
period: '1d', // daily rotation
count: 3, // keep 3 back copies
}],
serializers: bunyanDebugStream.stdSerializers,
});
});
}

this.logLib = bunyan.createLogger({
this.log = bunyan.createLogger({
name: '[EufySecurity-' + plugin.version + ']',
hostname: '',
streams: [{
level: (this.config.enableDetailedLogging) ? 'debug' : 'info',
type: 'file',
path: this.eufyPath + '/log-lib.log',
}],
streams: logStreams,
serializers: bunyanDebugStream.stdSerializers,
});

if (!omitLogFiles) {
this.logLib = bunyan.createLogger({
name: '[EufySecurity-' + plugin.version + ']',
hostname: '',
streams: [{
level: (this.config.enableDetailedLogging) ? 'debug' : 'info',
type: 'file',
path: this.eufyPath + '/log-lib.log',
}],
});
}

this.log.warn('warning: planned changes, see https://github.com/homebridge-eufy-security/plugin/issues/1');

const library = require('../node_modules/eufy-security-client/package.json');
this.log.debug('plugin data store: ' + this.eufyPath);
this.log.debug('Using bropats eufy-security-client library in version ' + library.version);

this.clean_config();

if (!fs.existsSync(this.eufyPath)) {
fs.mkdirSync(this.eufyPath);
if (omitLogFiles) {
this.log.info('log file storage will be omitted.');
}

this.clean_config();

this.eufyConfig = {
username: this.config.username,
password: this.config.password,
Expand Down Expand Up @@ -199,7 +214,14 @@ export class EufySecurityPlatform implements DynamicPlatformPlugin {
this.cleanCachedAccessories();
}, 45 * 1000);

this.eufyClient.setCameraMaxLivestreamDuration(this.config.CameraMaxLivestreamDuration ?? 30);
let cameraMaxLivestreamDuration = this.config.CameraMaxLivestreamDuration ?? 30;
if (cameraMaxLivestreamDuration > 86400) {
cameraMaxLivestreamDuration = 86400;
// eslint-disable-next-line max-len
this.log.warn('Your maximum livestream duration value is too large. Since this can cause problems it was reset to 86400 seconds (1 day maximum).');
}

this.eufyClient.setCameraMaxLivestreamDuration(cameraMaxLivestreamDuration);
this.log.debug('CameraMaxLivestreamDuration:', this.eufyClient.getCameraMaxLivestreamDuration());
}

Expand Down