diff --git a/custom_components/browser_mod/browser.py b/custom_components/browser_mod/browser.py index 7b24cb0..44c55ec 100644 --- a/custom_components/browser_mod/browser.py +++ b/custom_components/browser_mod/browser.py @@ -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.""" diff --git a/custom_components/browser_mod/connection.py b/custom_components/browser_mod/connection.py index df7672f..ee10a68 100644 --- a/custom_components/browser_mod/connection.py +++ b/custom_components/browser_mod/connection.py @@ -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()) diff --git a/js/config_panel/registered-browsers-card.ts b/js/config_panel/registered-browsers-card.ts index eb4af6f..6893544 100644 --- a/js/config_panel/registered-browsers-card.ts +++ b/js/config_panel/registered-browsers-card.ts @@ -46,21 +46,31 @@ class BrowserModRegisteredBrowsersCard extends LitElement { return html`
- ${Object.keys(window.browser_mod.browsers).map( - (d) => html` + ${Object.keys(window.browser_mod.browsers).map((d) => { + const browser = window.browser_mod.browsers[d]; + return html` ${d} Last connected: + ${browser.meta && browser.meta !== "default" + ? html` + + + + + + ` + : ""} - ` - )} + `; + })}
${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); } `; }