Skip to content

Commit

Permalink
Timing tweaks. Fix #105
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasloven committed Jun 11, 2020
1 parent 9848d6a commit f94d046
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 29 deletions.
2 changes: 1 addition & 1 deletion custom_components/browser_mod/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

async def async_setup(hass, config):

await setup_connection(hass, config)
setup_view(hass)

aliases = {}
Expand All @@ -31,7 +32,6 @@ async def async_setup(hass, config):
await hass.helpers.discovery.async_load_platform("light", DOMAIN, {}, config)
await hass.helpers.discovery.async_load_platform("camera", DOMAIN, {}, config)

await setup_connection(hass, config)

await setup_service(hass)

Expand Down
18 changes: 9 additions & 9 deletions custom_components/browser_mod/browser_mod.js

Large diffs are not rendered by default.

43 changes: 26 additions & 17 deletions js/browser-player-editor.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@
import { LitElement, html, css } from "card-tools/src/lit-element";
import { registerCard } from "card-tools/src/editor";

class BrowserPlayerEditor extends LitElement {
setConfig(config) {
const bases = [customElements.whenDefined('home-assistant-main'), customElements.whenDefined('hui-view')];
Promise.race(bases).then(() => {

}
render() {
return html`
<div>
Nothing to configure.
</div>
`;
}
}
const LitElement = customElements.get('home-assistant-main')
? Object.getPrototypeOf(customElements.get('home-assistant-main'))
: Object.getPrototypeOf(customElements.get('hui-view'));
const html = LitElement.prototype.html;
const css = LitElement.prototype.css;

if(!customElements.get("browser-player-editor")) {
customElements.define("browser-player-editor", BrowserPlayerEditor);
window.customCards = window.customCards || [];
window.customCards.push({type:"browser-player", name: "Browser Player", preview: true});
}
class BrowserPlayerEditor extends LitElement {
setConfig(config) {

}
render() {
return html`
<div>
Nothing to configure.
</div>
`;
}
}

if(!customElements.get("browser-player-editor")) {
customElements.define("browser-player-editor", BrowserPlayerEditor);
window.customCards = window.customCards || [];
window.customCards.push({type:"browser-player", name: "Browser Player", preview: true});
}
});
11 changes: 10 additions & 1 deletion js/browser-player.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
import { LitElement, html, css } from "card-tools/src/lit-element";
import { deviceID } from "card-tools/src/deviceId"
import { moreInfo } from "card-tools/src/more-info"
import "./browser-player-editor.js"

const bases = [customElements.whenDefined('home-assistant-main'), customElements.whenDefined('hui-view')];
Promise.race(bases).then(() => {

const LitElement = customElements.get('home-assistant-main')
? Object.getPrototypeOf(customElements.get('home-assistant-main'))
: Object.getPrototypeOf(customElements.get('hui-view'));
const html = LitElement.prototype.html;
const css = LitElement.prototype.css;

class BrowserPlayer extends LitElement {

static get properties() {
Expand Down Expand Up @@ -114,3 +122,4 @@ class BrowserPlayer extends LitElement {

if(!customElements.get("browser-player"))
customElements.define("browser-player", BrowserPlayer);
});
6 changes: 5 additions & 1 deletion js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,4 +440,8 @@ class BrowserMod {

}

window.browser_mod = window.browser_mod || new BrowserMod();

const bases = [customElements.whenDefined('home-assistant-main'), customElements.whenDefined('hui-view')];
Promise.race(bases).then(() => {
window.browser_mod = window.browser_mod || new BrowserMod();
});

0 comments on commit f94d046

Please sign in to comment.