Skip to content

Commit

Permalink
bticino: Implement HKSV recording for the bticino and switch the stre…
Browse files Browse the repository at this point in the history
…am to rtsp (#1220)

* Implement HKSV recording for the bticino and switch the stream to rtsp

* Implement HKSV recording for the bticino and switch the stream to rtsp

---------

Co-authored-by: Marc Vanbrabant <[email protected]>
  • Loading branch information
slyoldfox and Marc Vanbrabant authored Dec 12, 2023
1 parent 3f1b45c commit 1c96a7d
Show file tree
Hide file tree
Showing 7 changed files with 283 additions and 101 deletions.
6 changes: 3 additions & 3 deletions plugins/bticino/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/bticino/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@scrypted/bticino",
"version": "0.0.12",
"version": "0.0.13",
"scripts": {
"scrypted-setup-project": "scrypted-setup-project",
"prescrypted-setup-project": "scrypted-package-json",
Expand Down
301 changes: 205 additions & 96 deletions plugins/bticino/src/bticino-camera.ts

Large diffs are not rendered by default.

64 changes: 64 additions & 0 deletions plugins/bticino/src/bticino-mute-switch.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { ScryptedDeviceBase, HttpRequest, HttpResponse, HttpRequestHandler, OnOff } from "@scrypted/sdk";
import { BticinoSipCamera } from "./bticino-camera";

export class BticinoMuteSwitch extends ScryptedDeviceBase implements OnOff, HttpRequestHandler {
private timeout : NodeJS.Timeout

constructor(private camera: BticinoSipCamera) {
super( camera.nativeId + "-mute-switch");
this.on = false;
this.timeout = setTimeout( () => this.syncStatus() , 5000 )
}

turnOff(): Promise<void> {
this.on = false
return this.camera.muteRinger(false)
}

turnOn(): Promise<void> {
this.on = true
return this.camera.muteRinger(true)
}

syncStatus() {
this.camera.muteStatus().then( (value) => {
this.on = value["status"]
} ).catch( (e) => { this.camera.console.error(e) } ).finally( () => {
this.timeout = setTimeout( () => this.syncStatus() , 60000 )
} )
}

cancelTimer() {
if( this.timeout ) {
clearTimeout(this.timeout)
}
}

public async onRequest(request: HttpRequest, response: HttpResponse): Promise<void> {
if (request.url.endsWith('/disabled')) {
this.on = false
response.send('Success', {
code: 200,
});
} else if( request.url.endsWith('/enabled') ) {
this.on = true
response.send('Success', {
code: 200,
});
} else if( request.url.endsWith('/enable') ) {
this.turnOn()
response.send('Success', {
code: 200,
});
} else if( request.url.endsWith('/disable') ) {
this.turnOff()
response.send('Success', {
code: 200,
});
} else {
response.send('Unsupported operation', {
code: 400,
});
}
}
}
1 change: 1 addition & 0 deletions plugins/bticino/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export class BticinoSipPlugin extends ScryptedDeviceBase implements DeviceProvid
ScryptedInterface.Settings,
ScryptedInterface.Intercom,
ScryptedInterface.BinarySensor,
ScryptedInterface.MotionSensor,
ScryptedDeviceType.DeviceProvider,
ScryptedInterface.HttpRequestHandler,
ScryptedInterface.VideoClips,
Expand Down
2 changes: 1 addition & 1 deletion plugins/bticino/src/sip-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class SipHelper {
if( !md5 ) {
md5 = crypto.createHash('md5').update( camera.nativeId ).digest("hex")
md5 = md5.substring(0, 8) + '-' + md5.substring(8, 12) + '-' + md5.substring(12,16) + '-' + md5.substring(16, 32)
camera.storage.setItem('md5has', md5)
camera.storage.setItem('md5hash', md5)
}
return md5
}
Expand Down
8 changes: 8 additions & 0 deletions plugins/bticino/src/storage-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ export class BticinoStorageSettings {
defaultValue: 600,
placeholder: '600',
},
thumbnailCacheTime: {
title: 'Thumbnail cache time',
type: 'number',
range: [60, 86400],
description: 'How long the snapshot is cached before taking a new one. (in seconds)',
defaultValue: 300,
placeholder: '300',
},
sipdebug: {
title: 'SIP debug logging',
type: 'boolean',
Expand Down

0 comments on commit 1c96a7d

Please sign in to comment.