Skip to content

Commit

Permalink
Add mac and bluetooth address to the device info card
Browse files Browse the repository at this point in the history
  • Loading branch information
jpbede committed Oct 25, 2023
1 parent 7ce7cbb commit 4177591
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/panels/config/devices/device-detail/ha-device-info-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
import { haStyle } from "../../../../resources/styles";
import { HomeAssistant } from "../../../../types";
import { loadDeviceRegistryDetailDialog } from "../device-registry-detail/show-dialog-device-registry-detail";
import { titleCase } from "../../../../common/string/title-case";

@customElement("ha-device-info-card")
export class HaDeviceCard extends LitElement {
Expand Down Expand Up @@ -106,13 +107,31 @@ export class HaDeviceCard extends LitElement {
</div>
`
: ""}
${this._getAddresses().map(
(connection) => html`
<div class="extra-info">
${titleCase(connection[0])}: ${connection[1].toUpperCase()}
</div>
`
)}
<slot></slot>
</div>
<slot name="actions"></slot>
</ha-card>
`;
}

protected _getAddresses() {
const connections = [
...this.device.connections,
...this.device.identifiers,
];
const filtered = connections.filter(
(conn) => conn[0] === "mac" || conn[0] === "bluetooth"
);
return [...new Set(filtered)];
}

protected firstUpdated(changedProps) {
super.firstUpdated(changedProps);
loadDeviceRegistryDetailDialog();
Expand Down

0 comments on commit 4177591

Please sign in to comment.