Use constant for Home Assistant bluetooth node in graph (#25595)
parent
7fa697a768
commit
18aaa44d2d
|
@ -32,6 +32,9 @@ import { throttle } from "../../../../../common/util/throttle";
|
||||||
|
|
||||||
const UPDATE_THROTTLE_TIME = 10000;
|
const UPDATE_THROTTLE_TIME = 10000;
|
||||||
|
|
||||||
|
const CORE_SOURCE_ID = "ha";
|
||||||
|
const CORE_SOURCE_LABEL = "Home Assistant";
|
||||||
|
|
||||||
@customElement("bluetooth-network-visualization")
|
@customElement("bluetooth-network-visualization")
|
||||||
export class BluetoothNetworkVisualization extends LitElement {
|
export class BluetoothNetworkVisualization extends LitElement {
|
||||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||||
|
@ -130,7 +133,7 @@ export class BluetoothNetworkVisualization extends LitElement {
|
||||||
): NetworkData => {
|
): NetworkData => {
|
||||||
const categories = [
|
const categories = [
|
||||||
{
|
{
|
||||||
name: this.hass.localize("ui.panel.config.bluetooth.core"),
|
name: CORE_SOURCE_LABEL,
|
||||||
symbol: "roundRect",
|
symbol: "roundRect",
|
||||||
itemStyle: {
|
itemStyle: {
|
||||||
color: colorVariables["primary-color"],
|
color: colorVariables["primary-color"],
|
||||||
|
@ -160,8 +163,8 @@ export class BluetoothNetworkVisualization extends LitElement {
|
||||||
];
|
];
|
||||||
const nodes: NetworkNode[] = [
|
const nodes: NetworkNode[] = [
|
||||||
{
|
{
|
||||||
id: "ha",
|
id: CORE_SOURCE_ID,
|
||||||
name: this.hass.localize("ui.panel.config.bluetooth.core"),
|
name: CORE_SOURCE_LABEL,
|
||||||
category: 0,
|
category: 0,
|
||||||
value: 4,
|
value: 4,
|
||||||
symbol: "roundRect",
|
symbol: "roundRect",
|
||||||
|
@ -183,7 +186,7 @@ export class BluetoothNetworkVisualization extends LitElement {
|
||||||
polarDistance: 0.25,
|
polarDistance: 0.25,
|
||||||
});
|
});
|
||||||
links.push({
|
links.push({
|
||||||
source: "ha",
|
source: CORE_SOURCE_ID,
|
||||||
target: scanner.source,
|
target: scanner.source,
|
||||||
value: 0,
|
value: 0,
|
||||||
symbol: "none",
|
symbol: "none",
|
||||||
|
@ -234,8 +237,8 @@ export class BluetoothNetworkVisualization extends LitElement {
|
||||||
);
|
);
|
||||||
|
|
||||||
private _getBluetoothDeviceName(id: string): string {
|
private _getBluetoothDeviceName(id: string): string {
|
||||||
if (id === "ha") {
|
if (id === CORE_SOURCE_ID) {
|
||||||
return this.hass.localize("ui.panel.config.bluetooth.core");
|
return CORE_SOURCE_LABEL;
|
||||||
}
|
}
|
||||||
if (this._sourceDevices[id]) {
|
if (this._sourceDevices[id]) {
|
||||||
return (
|
return (
|
||||||
|
@ -262,7 +265,7 @@ export class BluetoothNetworkVisualization extends LitElement {
|
||||||
const sourceName = this._getBluetoothDeviceName(source);
|
const sourceName = this._getBluetoothDeviceName(source);
|
||||||
const targetName = this._getBluetoothDeviceName(target);
|
const targetName = this._getBluetoothDeviceName(target);
|
||||||
tooltipText = `${sourceName} → ${targetName}`;
|
tooltipText = `${sourceName} → ${targetName}`;
|
||||||
if (source !== "ha") {
|
if (source !== CORE_SOURCE_ID) {
|
||||||
tooltipText += ` <b>${this.hass.localize("ui.panel.config.bluetooth.rssi")}:</b> ${value}`;
|
tooltipText += ` <b>${this.hass.localize("ui.panel.config.bluetooth.rssi")}:</b> ${value}`;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue