mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-29 12:16:39 +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,
|
ItemSelectedEvent,
|
||||||
SetAttributeServiceData,
|
SetAttributeServiceData,
|
||||||
} from "./types";
|
} from "./types";
|
||||||
|
import { formatAsPaddedHex } from "./functions";
|
||||||
|
|
||||||
export class ZHAClusterAttributes extends LitElement {
|
export class ZHAClusterAttributes extends LitElement {
|
||||||
public hass?: HomeAssistant;
|
public hass?: HomeAssistant;
|
||||||
@ -102,7 +103,10 @@ export class ZHAClusterAttributes extends LitElement {
|
|||||||
${this._attributes.map(
|
${this._attributes.map(
|
||||||
(entry) => html`
|
(entry) => html`
|
||||||
<paper-item
|
<paper-item
|
||||||
>${entry.name + " (id: " + entry.id + ")"}</paper-item
|
>${entry.name +
|
||||||
|
" (id: " +
|
||||||
|
formatAsPaddedHex(entry.id) +
|
||||||
|
")"}</paper-item
|
||||||
>
|
>
|
||||||
`
|
`
|
||||||
)}
|
)}
|
||||||
|
@ -24,6 +24,7 @@ import {
|
|||||||
IssueCommandServiceData,
|
IssueCommandServiceData,
|
||||||
ItemSelectedEvent,
|
ItemSelectedEvent,
|
||||||
} from "./types";
|
} from "./types";
|
||||||
|
import { formatAsPaddedHex } from "./functions";
|
||||||
|
|
||||||
export class ZHAClusterCommands extends LitElement {
|
export class ZHAClusterCommands extends LitElement {
|
||||||
public hass?: HomeAssistant;
|
public hass?: HomeAssistant;
|
||||||
@ -94,7 +95,10 @@ export class ZHAClusterCommands extends LitElement {
|
|||||||
${this._commands.map(
|
${this._commands.map(
|
||||||
(entry) => html`
|
(entry) => html`
|
||||||
<paper-item
|
<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 { HomeAssistant } from "../../../types";
|
||||||
import "../ha-config-section";
|
import "../ha-config-section";
|
||||||
import { ItemSelectedEvent } from "./types";
|
import { ItemSelectedEvent } from "./types";
|
||||||
|
import { formatAsPaddedHex } from "./functions";
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
// for fire event
|
// for fire event
|
||||||
@ -27,9 +28,9 @@ declare global {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const computeClusterKey = (cluster: Cluster): string => {
|
const computeClusterKey = (cluster: Cluster): string => {
|
||||||
return `${cluster.name} (Endpoint id: ${cluster.endpoint_id}, Id: ${
|
return `${cluster.name} (Endpoint id: ${
|
||||||
cluster.id
|
cluster.endpoint_id
|
||||||
}, Type: ${cluster.type})`;
|
}, Id: ${formatAsPaddedHex(cluster.id)}, Type: ${cluster.type})`;
|
||||||
};
|
};
|
||||||
|
|
||||||
export class ZHAClusters extends LitElement {
|
export class ZHAClusters extends LitElement {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user