Skip to content

Commit

Permalink
Add serials and hardware types in DeviceTable (#31)
Browse files Browse the repository at this point in the history
* Add hardware types

* Fix linter issues
  • Loading branch information
alengwenus authored Nov 9, 2024
1 parent bec1a32 commit b9774a6
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 1 deletion.
65 changes: 65 additions & 0 deletions src/helpers/hardware_types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
export function getHardwareType(hardwareId: number): string | undefined {
switch (hardwareId) {
case 1:
return "LCN-SW1.0";
case 2:
return "LCN-SW1.1";
case 3:
return "LCN-UP1.0";
case 4:
return "LCN-UP2";
case 5:
return "LCN-SW2";
case 6:
return "LCN-UP-Profi1-Plus";
case 7:
return "LCN-DI12";
case 8:
return "LCN-HU";
case 9:
return "LCN-SH";
case 10:
return "LCN-UP2";
case 11:
return "LCN-UPP";
case 12:
return "LCN-SK";
case 14:
return "LCN-LD";
case 15:
return "LCN-SH-Plus";
case 17:
return "LCN-UPS";
case 18:
return "LCN_UPS24V";
case 19:
return "LCN-GTM";
case 20:
return "LCN-SHS";
case 21:
return "LCN-ESD";
case 22:
return "LCN-EB2";
case 23:
return "LCN-MRS";
case 24:
return "LCN-EB11";
case 25:
return "LCN-UMR";
case 26:
return "LCN-UPU";
case 27:
return "LCN-UMR24V";
case 28:
return "LCN-SHD";
case 29:
return "LCN-SHU";
case 30:
return "LCN-SR6";
case 31:
return "LCN-UMF";
case 32:
return "LCN-WBH";
}
return undefined;
}
29 changes: 28 additions & 1 deletion src/lcn-devices-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { navigate } from "@ha/common/navigate";
import type { HASSDomEvent } from "@ha/common/dom/fire_event";
import { updateDeviceConfigs, updateEntityConfigs } from "components/events";
import { renderBrandLogo } from "helpers/brand_logo";
import { getHardwareType } from "helpers/hardware_types";
import { ProgressDialog } from "./dialogs/progress-dialog";
import {
loadLCNCreateDeviceDialog,
Expand Down Expand Up @@ -143,10 +144,36 @@ export class LCNConfigDashboard extends LitElement {
sortable: true,
filterable: true,
},
hardware_serial: {
title: this.lcn.localize("hardware-serial"),
sortable: true,
filterable: true,
defaultHidden: true,
template: (entry) =>
entry.hardware_serial !== -1 ? entry.hardware_serial.toString(16).toUpperCase() : "-",
},
software_serial: {
title: this.lcn.localize("software-serial"),
sortable: true,
filterable: true,
defaultHidden: true,
template: (entry) =>
entry.software_serial !== -1 ? entry.software_serial.toString(16).toUpperCase() : "-",
},
hardware_type: {
title: this.lcn.localize("hardware-type"),
sortable: true,
filterable: true,
defaultHidden: true,
template: (entry) => {
const type = getHardwareType(entry.hardware_type);
if (type) return type;
return "-";
},
},
delete: {
title: this.lcn.localize("delete"),
showNarrow: true,
moveable: false,
type: "icon-button",
template: (entry) => {
const handler = (_ev) => this._deleteDevices([entry]);
Expand Down
3 changes: 3 additions & 0 deletions src/localize/languages/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
"name": "Name",
"entity-id": "Entitäts-ID",
"type": "Typ",
"hardware-serial": "Seriennummer",
"software-serial": "Firmware",
"hardware-type": "Hardware",
"resource": "Ressource",
"create": "Erstellen",
"dismiss": "Abbrechen",
Expand Down
3 changes: 3 additions & 0 deletions src/localize/languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
"name": "Name",
"entity-id": "Entity ID",
"type": "Type",
"hardware-serial": "Serial number",
"software-serial": "Firmware",
"hardware-type": "Hardware",
"resource": "Resource",
"create": "Create",
"dismiss": "Dismiss",
Expand Down

0 comments on commit b9774a6

Please sign in to comment.