Link to device from browser mod panel
This commit is contained in:
parent
e2f1dfdaf2
commit
98aaacba81
@ -167,6 +167,16 @@ class BrowserModBrowser:
|
|||||||
device = dr.async_get_device({(DOMAIN, self.browserID)})
|
device = dr.async_get_device({(DOMAIN, self.browserID)})
|
||||||
dr.async_remove_device(device.id)
|
dr.async_remove_device(device.id)
|
||||||
|
|
||||||
|
def get_device_id(self, hass):
|
||||||
|
er = entity_registry.async_get(hass)
|
||||||
|
entities = list(self.entities.values())
|
||||||
|
if len(entities):
|
||||||
|
entity = entities[0]
|
||||||
|
entry = er.async_get(entity.entity_id)
|
||||||
|
if entry:
|
||||||
|
return entry.device_id
|
||||||
|
return "default"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def connection(self):
|
def connection(self):
|
||||||
"""The current websocket connections for this Browser."""
|
"""The current websocket connections for this Browser."""
|
||||||
|
@ -62,7 +62,9 @@ async def async_setup_connection(hass):
|
|||||||
dev.update_settings(hass, store.get_browser(browserID).asdict())
|
dev.update_settings(hass, store.get_browser(browserID).asdict())
|
||||||
dev.open_connection(connection, msg["id"])
|
dev.open_connection(connection, msg["id"])
|
||||||
await store.set_browser(
|
await store.set_browser(
|
||||||
browserID, last_seen=datetime.now(tz=timezone.utc).isoformat()
|
browserID,
|
||||||
|
last_seen=datetime.now(tz=timezone.utc).isoformat(),
|
||||||
|
meta=dev.get_device_id(hass),
|
||||||
)
|
)
|
||||||
send_update(store.asdict())
|
send_update(store.asdict())
|
||||||
|
|
||||||
|
@ -46,21 +46,31 @@ class BrowserModRegisteredBrowsersCard extends LitElement {
|
|||||||
return html`
|
return html`
|
||||||
<ha-card header="Registered Browsers" outlined>
|
<ha-card header="Registered Browsers" outlined>
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
${Object.keys(window.browser_mod.browsers).map(
|
${Object.keys(window.browser_mod.browsers).map((d) => {
|
||||||
(d) => html` <ha-settings-row>
|
const browser = window.browser_mod.browsers[d];
|
||||||
|
return html` <ha-settings-row>
|
||||||
<span slot="heading"> ${d} </span>
|
<span slot="heading"> ${d} </span>
|
||||||
<span slot="description">
|
<span slot="description">
|
||||||
Last connected:
|
Last connected:
|
||||||
<ha-relative-time
|
<ha-relative-time
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.datetime=${window.browser_mod.browsers[d].last_seen}
|
.datetime=${browser.last_seen}
|
||||||
></ha-relative-time>
|
></ha-relative-time>
|
||||||
</span>
|
</span>
|
||||||
|
${browser.meta && browser.meta !== "default"
|
||||||
|
? html`
|
||||||
|
<a href="config/devices/device/${browser.meta}">
|
||||||
|
<ha-icon-button>
|
||||||
|
<ha-icon .icon=${"mdi:devices"}></ha-icon>
|
||||||
|
</ha-icon-button>
|
||||||
|
</a>
|
||||||
|
`
|
||||||
|
: ""}
|
||||||
<ha-icon-button .browserID=${d} @click=${this.unregister_browser}>
|
<ha-icon-button .browserID=${d} @click=${this.unregister_browser}>
|
||||||
<ha-icon .icon=${"mdi:delete"}></ha-icon>
|
<ha-icon .icon=${"mdi:delete"}></ha-icon>
|
||||||
</ha-icon-button>
|
</ha-icon-button>
|
||||||
</ha-settings-row>`
|
</ha-settings-row>`;
|
||||||
)}
|
})}
|
||||||
</div>
|
</div>
|
||||||
${window.browser_mod.browsers["CAST"] === undefined
|
${window.browser_mod.browsers["CAST"] === undefined
|
||||||
? html`
|
? html`
|
||||||
@ -79,6 +89,7 @@ class BrowserModRegisteredBrowsersCard extends LitElement {
|
|||||||
return css`
|
return css`
|
||||||
ha-icon-button > * {
|
ha-icon-button > * {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
color: var(--primary-text-color);
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user