Link to device from browser mod panel

This commit is contained in:
2022-09-02 21:12:39 +00:00
parent e2f1dfdaf2
commit 98aaacba81
3 changed files with 29 additions and 6 deletions

View File

@@ -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."""

View File

@@ -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())