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)})
|
||||
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
|
||||
def connection(self):
|
||||
"""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.open_connection(connection, msg["id"])
|
||||
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())
|
||||
|
||||
|
@ -46,21 +46,31 @@ class BrowserModRegisteredBrowsersCard extends LitElement {
|
||||
return html`
|
||||
<ha-card header="Registered Browsers" outlined>
|
||||
<div class="card-content">
|
||||
${Object.keys(window.browser_mod.browsers).map(
|
||||
(d) => html` <ha-settings-row>
|
||||
${Object.keys(window.browser_mod.browsers).map((d) => {
|
||||
const browser = window.browser_mod.browsers[d];
|
||||
return html` <ha-settings-row>
|
||||
<span slot="heading"> ${d} </span>
|
||||
<span slot="description">
|
||||
Last connected:
|
||||
<ha-relative-time
|
||||
.hass=${this.hass}
|
||||
.datetime=${window.browser_mod.browsers[d].last_seen}
|
||||
.datetime=${browser.last_seen}
|
||||
></ha-relative-time>
|
||||
</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 .icon=${"mdi:delete"}></ha-icon>
|
||||
</ha-icon-button>
|
||||
</ha-settings-row>`
|
||||
)}
|
||||
</ha-settings-row>`;
|
||||
})}
|
||||
</div>
|
||||
${window.browser_mod.browsers["CAST"] === undefined
|
||||
? html`
|
||||
@ -79,6 +89,7 @@ class BrowserModRegisteredBrowsersCard extends LitElement {
|
||||
return css`
|
||||
ha-icon-button > * {
|
||||
display: flex;
|
||||
color: var(--primary-text-color);
|
||||
}
|
||||
`;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user