Add support for fullyKiosk browser
This commit is contained in:
parent
cc4df1c349
commit
fec0d708c9
File diff suppressed because one or more lines are too long
@ -42,6 +42,7 @@ class BrowserModPlayer(MediaPlayerDevice, BrowserModEntity):
|
|||||||
@property
|
@property
|
||||||
def device_state_attributes(self):
|
def device_state_attributes(self):
|
||||||
return {
|
return {
|
||||||
|
"type": "browser",
|
||||||
**self._ws_data.get("browser", {}),
|
**self._ws_data.get("browser", {}),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
51
js/main.js
51
js/main.js
@ -55,6 +55,15 @@ class BrowserMod {
|
|||||||
window.addEventListener("touchstart", this.no_blackout.bind(this));
|
window.addEventListener("touchstart", this.no_blackout.bind(this));
|
||||||
provideHass(this);
|
provideHass(this);
|
||||||
|
|
||||||
|
if(window.fully)
|
||||||
|
{
|
||||||
|
this._fullyMotion = false;
|
||||||
|
this._motionTimeout = undefined;
|
||||||
|
fully.bind('screenOn', 'browser_mod.update();');
|
||||||
|
fully.bind('screenOff', 'browser_mod.update();');
|
||||||
|
fully.bind('onMotion', 'browser_mod.fullyMotion();');
|
||||||
|
}
|
||||||
|
|
||||||
this._blackout = document.createElement("div");
|
this._blackout = document.createElement("div");
|
||||||
this._blackout.style.cssText = `
|
this._blackout.style.cssText = `
|
||||||
position: fixed;
|
position: fixed;
|
||||||
@ -200,13 +209,44 @@ class BrowserMod {
|
|||||||
}
|
}
|
||||||
|
|
||||||
blackout(msg){
|
blackout(msg){
|
||||||
this._blackout.style.visibility = "visible";
|
if (window.fully)
|
||||||
|
{
|
||||||
|
fully.turnScreenOff();
|
||||||
|
} else {
|
||||||
|
this._blackout.style.visibility = "visible";
|
||||||
|
}
|
||||||
this.update();
|
this.update();
|
||||||
}
|
}
|
||||||
no_blackout(msg){
|
no_blackout(msg){
|
||||||
if(this.autoclose_popup_active)
|
if(this.autoclose_popup_active)
|
||||||
return this.close_popup();
|
return this.close_popup();
|
||||||
this._blackout.style.visibility = "hidden";
|
if (window.fully)
|
||||||
|
{
|
||||||
|
if (!fully.getScreenOn())
|
||||||
|
fully.turnScreenOn();
|
||||||
|
if (msg.brightness)
|
||||||
|
fully.setScreenBrightness(msg.brightness);
|
||||||
|
this.update();
|
||||||
|
} else {
|
||||||
|
if(this._blackout.style.visibility !== "hidden") {
|
||||||
|
this._blackout.style.visibility = "hidden";
|
||||||
|
this.update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
is_blackout(){
|
||||||
|
if (window.fully)
|
||||||
|
return !fully.getScreenOn();
|
||||||
|
return Boolean(this._blackout.style.visibility === "visible")
|
||||||
|
}
|
||||||
|
|
||||||
|
fullyMotion() {
|
||||||
|
this._fullyMotion = true;
|
||||||
|
clearTimeout(this._motionTimeout);
|
||||||
|
this._motionTimeout = setTimeout(() => {
|
||||||
|
this._fullyMotion = false;
|
||||||
|
this.update();
|
||||||
|
}, 5000);
|
||||||
this.update();
|
this.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,7 +267,12 @@ class BrowserMod {
|
|||||||
visibility: document.visibilityState,
|
visibility: document.visibilityState,
|
||||||
userAgent: navigator.userAgent,
|
userAgent: navigator.userAgent,
|
||||||
currentUser: this._hass && this._hass.user && this._hass.user.name,
|
currentUser: this._hass && this._hass.user && this._hass.user.name,
|
||||||
blackout: Boolean(this._blackout.style.visibility === "visible"),
|
blackout: this.is_blackout(),
|
||||||
|
fullyKiosk: window.fully ? true : undefined,
|
||||||
|
brightness: window.fully ? fully.getScreenBrightness() : undefined,
|
||||||
|
battery: window.fully ? fully.getBatteryLevel() : undefined,
|
||||||
|
charging: window.fully ? fully.isPlugged(): undefined,
|
||||||
|
motion: window.fully ? this._fullyMotion : undefined,
|
||||||
},
|
},
|
||||||
player: {
|
player: {
|
||||||
volume: this.player.volume,
|
volume: this.player.volume,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user