diff --git a/src/dialogs/lcn-create-entity-dialog.ts b/src/dialogs/lcn-create-entity-dialog.ts index 1136620..98fcf3a 100644 --- a/src/dialogs/lcn-create-entity-dialog.ts +++ b/src/dialogs/lcn-create-entity-dialog.ts @@ -12,7 +12,7 @@ import { stopPropagation } from "@ha/common/dom/stop_propagation"; import { haStyleDialog } from "@ha/resources/styles"; import type { HomeAssistant } from "@ha/types"; import type { LCN, LcnDeviceConfig, LcnEntityConfig } from "types/lcn"; -import { addressToString, stringToAddress } from "helpers/address_conversion"; +import { addressToString, stringToAddress, addressToHumanString } from "helpers/address_conversion"; import "./lcn-config-binary-sensor"; import "./lcn-config-climate"; import "./lcn-config-cover"; @@ -74,7 +74,7 @@ export class CreateEntityDialog extends LitElement { } protected render() { - if (!this._params) { + if (!this._params || !this.lcn || !this._deviceConfig) { return nothing; } return html` @@ -100,7 +100,7 @@ export class CreateEntityDialog extends LitElement { (deviceConfig) => html`
${deviceConfig.name}
-
(${addressToString(deviceConfig.address)})
+
(${addressToHumanString(deviceConfig.address)})
`, )} diff --git a/src/dialogs/show-dialog-create-entity.ts b/src/dialogs/show-dialog-create-entity.ts index 822927e..722497b 100644 --- a/src/dialogs/show-dialog-create-entity.ts +++ b/src/dialogs/show-dialog-create-entity.ts @@ -3,19 +3,19 @@ import { LCN, LcnEntityConfig, LcnDeviceConfig } from "types/lcn"; export interface LcnEntityDialogParams { lcn: LCN; - deviceConfig: LcnDeviceConfig; - createEntity: (values: Partial) => Promise; + deviceConfig: LcnDeviceConfig | undefined; + createEntity: (entityParams: Partial) => Promise; } export const loadLCNCreateEntityDialog = () => import("./lcn-create-entity-dialog"); export const showLCNCreateEntityDialog = ( element: HTMLElement, - lcnEntityParams: LcnEntityDialogParams, + lcnEntityDialogParams: LcnEntityDialogParams, ): void => { fireEvent(element, "show-dialog", { dialogTag: "lcn-create-entity-dialog", dialogImport: loadLCNCreateEntityDialog, - dialogParams: lcnEntityParams, + dialogParams: lcnEntityDialogParams, }); }; diff --git a/src/helpers/address_conversion.ts b/src/helpers/address_conversion.ts index 2943d90..326a038 100644 --- a/src/helpers/address_conversion.ts +++ b/src/helpers/address_conversion.ts @@ -15,3 +15,7 @@ export function stringToAddress(address_str: string): LcnAddress { const address: LcnAddress = [address_id, segment_id, is_group]; return address; } + +export function addressToHumanString(address: LcnAddress): string { + return `S${address[0]} ${address[2] ? "G" : "M"}${address[1]}`; +} diff --git a/src/lcn-entities-page.ts b/src/lcn-entities-page.ts index 7b23871..aed11da 100644 --- a/src/lcn-entities-page.ts +++ b/src/lcn-entities-page.ts @@ -481,7 +481,7 @@ export class LCNEntitiesPage extends LitElement { private async _addEntity() { showLCNCreateEntityDialog(this, { lcn: this.lcn, - deviceConfig: this._deviceConfig, + deviceConfig: this._deviceConfig, createEntity: async (entityParams) => { if (await addEntity(this.hass, this.lcn.config_entry, entityParams)) { updateEntityConfigs(this);