Skip to content

Commit

Permalink
fix config key and device edit initial value
Browse files Browse the repository at this point in the history
  • Loading branch information
farmio committed Dec 18, 2023
1 parent 8ca81a3 commit 3314043
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/components/knx-configure-switch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ export class KNXConfigureSwitch extends LitElement {
label: `${groupAddress.address} - ${groupAddress.name}`,
}));
logger.debug("config", this.config);
const device = this.config.device
? deviceFromIdentifier(this.hass, this.config.device)
const device = this.config.device_id
? deviceFromIdentifier(this.hass, this.config.device_id)
: undefined;
const deviceName = device ? device.name_by_user ?? device.name : "";

Expand Down Expand Up @@ -122,8 +122,8 @@ export class KNXConfigureSwitch extends LitElement {
<div slot="description">A device allows to group multiple entities.</div>
<knx-device-picker
.hass=${this.hass}
.key=${"device"}
.value=${this.config.device}
.key=${"device_id"}
.value=${this.config.device_id}
@value-changed=${this._updateConfig}
></knx-device-picker>
</ha-settings-row>
Expand All @@ -133,7 +133,7 @@ export class KNXConfigureSwitch extends LitElement {
<ha-selector
.hass=${this.hass}
.label=${"Name"}
.required=${!this.config.device}
.required=${!this.config.device_id}
.selector=${{
text: { type: "text", prefix: deviceName },
}}
Expand Down
7 changes: 6 additions & 1 deletion src/components/knx-device-picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class KnxDevicePicker extends LitElement {
@state() private _showCreateDeviceDialog = false;

// value is the knx identifier, not the device id
@state() private _deviceId?: string;
private _deviceId?: string;

private _suggestion?: string;

Expand Down Expand Up @@ -120,6 +120,11 @@ class KnxDevicePicker extends LitElement {
if ((!this._init && this.hass) || (this._init && changedProps.has("_opened") && this._opened)) {
this._init = true;
const devices = this._getDevices(knxDevices(this.hass), this.hass.areas);
const deviceId = this.value
? devices.find((d) => d.identifier === this.value)?.id
: undefined;
this.comboBox.value = deviceId;
this._deviceId = deviceId;
this.comboBox.items = devices;
this.comboBox.filteredItems = devices;
}
Expand Down

0 comments on commit 3314043

Please sign in to comment.