mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-28 11:46:42 +00:00
display values as hex so that they match the zigbee spec docs (#2751)
This commit is contained in:
parent
3f6bbffcd6
commit
8bf2a2f8db
7
src/panels/config/zha/functions.ts
Normal file
7
src/panels/config/zha/functions.ts
Normal file
@ -0,0 +1,7 @@
|
||||
export const formatAsPaddedHex = (value: string | number): string => {
|
||||
let hex = value;
|
||||
if (typeof value === "string") {
|
||||
hex = parseInt(value, 16);
|
||||
}
|
||||
return "0x" + hex.toString(16).padStart(4, "0");
|
||||
};
|
@ -28,6 +28,7 @@ import {
|
||||
ItemSelectedEvent,
|
||||
SetAttributeServiceData,
|
||||
} from "./types";
|
||||
import { formatAsPaddedHex } from "./functions";
|
||||
|
||||
export class ZHAClusterAttributes extends LitElement {
|
||||
public hass?: HomeAssistant;
|
||||
@ -102,7 +103,10 @@ export class ZHAClusterAttributes extends LitElement {
|
||||
${this._attributes.map(
|
||||
(entry) => html`
|
||||
<paper-item
|
||||
>${entry.name + " (id: " + entry.id + ")"}</paper-item
|
||||
>${entry.name +
|
||||
" (id: " +
|
||||
formatAsPaddedHex(entry.id) +
|
||||
")"}</paper-item
|
||||
>
|
||||
`
|
||||
)}
|
||||
|
@ -24,6 +24,7 @@ import {
|
||||
IssueCommandServiceData,
|
||||
ItemSelectedEvent,
|
||||
} from "./types";
|
||||
import { formatAsPaddedHex } from "./functions";
|
||||
|
||||
export class ZHAClusterCommands extends LitElement {
|
||||
public hass?: HomeAssistant;
|
||||
@ -94,7 +95,10 @@ export class ZHAClusterCommands extends LitElement {
|
||||
${this._commands.map(
|
||||
(entry) => html`
|
||||
<paper-item
|
||||
>${entry.name + " (id: " + entry.id + ")"}</paper-item
|
||||
>${entry.name +
|
||||
" (id: " +
|
||||
formatAsPaddedHex(entry.id) +
|
||||
")"}</paper-item
|
||||
>
|
||||
`
|
||||
)}
|
||||
|
@ -16,6 +16,7 @@ import { haStyle } from "../../../resources/ha-style";
|
||||
import { HomeAssistant } from "../../../types";
|
||||
import "../ha-config-section";
|
||||
import { ItemSelectedEvent } from "./types";
|
||||
import { formatAsPaddedHex } from "./functions";
|
||||
|
||||
declare global {
|
||||
// for fire event
|
||||
@ -27,9 +28,9 @@ declare global {
|
||||
}
|
||||
|
||||
const computeClusterKey = (cluster: Cluster): string => {
|
||||
return `${cluster.name} (Endpoint id: ${cluster.endpoint_id}, Id: ${
|
||||
cluster.id
|
||||
}, Type: ${cluster.type})`;
|
||||
return `${cluster.name} (Endpoint id: ${
|
||||
cluster.endpoint_id
|
||||
}, Id: ${formatAsPaddedHex(cluster.id)}, Type: ${cluster.type})`;
|
||||
};
|
||||
|
||||
export class ZHAClusters extends LitElement {
|
||||
|
Loading…
x
Reference in New Issue
Block a user