Much better camera support for FKB
This commit is contained in:
parent
87e939c6cb
commit
2ba8977118
@ -184,7 +184,7 @@ After restarting Home Assistant (and [clearing cache](https://github.com/thomasl
|
||||
|
||||
Be aware that keeping the camera on may make your device run hot and drain your battery.
|
||||
|
||||
The camera does not work well with Fully Kiosk Browser. If you're using FKB, use the built-in camera functionality instead. It's better in every way.
|
||||
For Fully Kiosk Browser, the camera requires Motion Detection (PLUS) to be enabled, and will only appear for the first time once motion has been detected. It does not need to be enabled in the configuration, though.
|
||||
|
||||
### binary_sensor
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
@ -5,8 +5,12 @@ from homeassistant.components.camera import Camera
|
||||
|
||||
from .helpers import setup_platform, BrowserModEntity
|
||||
|
||||
import logging
|
||||
|
||||
PLATFORM = "camera"
|
||||
|
||||
LOGGER = logging.Logger(__name__)
|
||||
|
||||
|
||||
async def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
||||
return setup_platform(hass, config, async_add_devices, PLATFORM, BrowserModCamera)
|
||||
@ -30,7 +34,7 @@ class BrowserModCamera(Camera, BrowserModEntity):
|
||||
self.schedule_update_ha_state()
|
||||
|
||||
def camera_image(self):
|
||||
return base64.b64decode(self.data.split(",")[1])
|
||||
return base64.b64decode(self.data.split(",")[-1])
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
|
10
js/camera.js
10
js/camera.js
@ -28,9 +28,15 @@ export const BrowserModCameraMixin = (C) =>
|
||||
|
||||
this._camera_framerate = 2;
|
||||
|
||||
window.addEventListener("click", () => this._video.play(), {
|
||||
window.addEventListener(
|
||||
"click",
|
||||
() => {
|
||||
if (this._video.ended || this._video.paused) this._video.play();
|
||||
},
|
||||
{
|
||||
once: true,
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
update_camera() {
|
||||
|
@ -66,12 +66,27 @@ export const FullyKioskMixin = (C) =>
|
||||
});
|
||||
}
|
||||
|
||||
startCamera() {
|
||||
if (this._fullyCameraTimer !== undefined) return;
|
||||
this._fullyCameraTimer = window.setInterval(() => {
|
||||
this.sendUpdate({
|
||||
camera: window.fully.getCamshotJpgBase64(),
|
||||
});
|
||||
}, 200);
|
||||
}
|
||||
stopCamera() {
|
||||
window.clearInterval(this._fullyCameraTimer);
|
||||
this._fullyCameraTimer = undefined;
|
||||
}
|
||||
|
||||
fullyMotionTriggered() {
|
||||
if (this._keepingAlive) return;
|
||||
this._fullyMotion = true;
|
||||
this.startCamera();
|
||||
clearTimeout(this._motionTimeout);
|
||||
this._motionTimeout = setTimeout(() => {
|
||||
this._fullyMotion = false;
|
||||
this.stopCamera();
|
||||
this.fully_update();
|
||||
}, 5000);
|
||||
this.fully_update();
|
||||
|
@ -129,7 +129,7 @@ class BrowserMod extends ext(BrowserModConnection, [
|
||||
if (msg.name) {
|
||||
this.entity_id = msg.name.toLowerCase();
|
||||
}
|
||||
if (msg.camera) {
|
||||
if (msg.camera && !this.isFully) {
|
||||
this.setup_camera();
|
||||
}
|
||||
this.config = { ...this.config, ...msg };
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "browser_mod",
|
||||
"private": true,
|
||||
"version": "1.4.0",
|
||||
"version": "1.5.0",
|
||||
"description": "",
|
||||
"scripts": {
|
||||
"build": "rollup -c",
|
||||
|
Loading…
x
Reference in New Issue
Block a user