Link the device info BLE address to the Advertisement Monitor (#25044)

* Link the device info BLE address to the Advertisement Monitor

* Link the device info BLE address to the Advertisement Monitor

* preen
This commit is contained in:
J. Nick Koston 2025-04-13 20:13:27 -10:00 committed by GitHub
parent 8fb7c1594a
commit 8ad4385d67
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 30 additions and 3 deletions

View File

@ -7,6 +7,7 @@ import "../../../../components/ha-card";
import type { DeviceRegistryEntry } from "../../../../data/device_registry";
import { haStyle } from "../../../../resources/styles";
import type { HomeAssistant } from "../../../../types";
import { createSearchParam } from "../../../../common/url/search-params";
@customElement("ha-device-info-card")
export class HaDeviceCard extends LitElement {
@ -102,8 +103,16 @@ export class HaDeviceCard extends LitElement {
${this._getAddresses().map(
([type, value]) => html`
<div class="extra-info">
${type === "mac" ? "MAC" : titleCase(type)}:
${value.toUpperCase()}
${type === "bluetooth"
? html`${titleCase(type)}
<a
href="/config/bluetooth/advertisement-monitor?${createSearchParam(
{ address: value }
)}"
>${value.toUpperCase()}</a
>`
: html`${type === "mac" ? "MAC" : titleCase(type)}:
${value.toUpperCase()}`}
</div>
`
)}

View File

@ -1,5 +1,5 @@
import type { UnsubscribeFunc } from "home-assistant-js-websocket";
import type { CSSResultGroup, TemplateResult } from "lit";
import type { CSSResultGroup, TemplateResult, PropertyValues } from "lit";
import { html, LitElement } from "lit";
import { customElement, property, state } from "lit/decorators";
import memoizeOne from "memoize-one";
@ -10,6 +10,7 @@ import type {
DataTableColumnContainer,
RowClickedEvent,
} from "../../../../../components/data-table/ha-data-table";
import { extractSearchParamsObject } from "../../../../../common/url/search-params";
import "../../../../../components/ha-fab";
import "../../../../../components/ha-icon-button";
import "../../../../../components/ha-relative-time";
@ -33,6 +34,8 @@ export class BluetoothAdvertisementMonitorPanel extends LitElement {
@property({ attribute: false }) public route!: Route;
@property({ attribute: false }) public address?: string;
@property({ type: Boolean }) public narrow = false;
@property({ attribute: "is-wide", type: Boolean }) public isWide = false;
@ -104,6 +107,20 @@ export class BluetoothAdvertisementMonitorPanel extends LitElement {
}
}
protected willUpdate(changedProps: PropertyValues) {
super.willUpdate(changedProps);
if (this.hasUpdated) {
return;
}
const searchParams = extractSearchParamsObject();
const address = searchParams.address;
if (address) {
this.address = address;
}
}
private _columns = memoizeOne(
(localize: LocalizeFunc): DataTableColumnContainer => {
const columns: DataTableColumnContainer<BluetoothDeviceData> = {
@ -198,6 +215,7 @@ export class BluetoothAdvertisementMonitorPanel extends LitElement {
.initialCollapsedGroups=${this._activeCollapsed}
@grouping-changed=${this._handleGroupingChanged}
@collapsed-changed=${this._handleCollapseChanged}
filter=${this.address || ""}
clickable
></hass-tabs-subpage-data-table>
`;