mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-20 15:56:35 +00:00
Handle predefined options in Z-Wave config panel
This commit is contained in:
parent
b60f2e3201
commit
96ae78927b
@ -230,10 +230,26 @@ class ZWaveJSNodeConfig extends LitElement {
|
|||||||
item: ZWaveJSNodeConfigParam
|
item: ZWaveJSNodeConfigParam
|
||||||
): TemplateResult {
|
): TemplateResult {
|
||||||
const result = this._results[id];
|
const result = this._results[id];
|
||||||
|
let type = item.configuration_value_type;
|
||||||
|
|
||||||
const isTypeBoolean =
|
if (
|
||||||
item.configuration_value_type === "boolean" ||
|
type === "manual_entry" &&
|
||||||
this._isEnumeratedBool(item);
|
item.metadata.states &&
|
||||||
|
item.metadata.min != null &&
|
||||||
|
item.metadata.max != null &&
|
||||||
|
item.metadata.max - item.metadata.min <= 100
|
||||||
|
) {
|
||||||
|
// https://github.com/zwave-js/backlog/issues/59
|
||||||
|
type = "enumerated";
|
||||||
|
for (let i = item.metadata.min; i <= item.metadata.max; i++) {
|
||||||
|
if (i in item.metadata.states) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
item.metadata.states[i] = i.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const isTypeBoolean = type === "boolean" || this._isEnumeratedBool(item);
|
||||||
|
|
||||||
const labelAndDescription = html`
|
const labelAndDescription = html`
|
||||||
<span slot="prefix" class="prefix">
|
<span slot="prefix" class="prefix">
|
||||||
@ -294,7 +310,7 @@ class ZWaveJSNodeConfig extends LitElement {
|
|||||||
? this.hass.localize(
|
? this.hass.localize(
|
||||||
item.metadata.default === 1 ? "ui.common.yes" : "ui.common.no"
|
item.metadata.default === 1 ? "ui.common.yes" : "ui.common.no"
|
||||||
)
|
)
|
||||||
: item.configuration_value_type === "enumerated"
|
: type === "enumerated"
|
||||||
? item.metadata.states[item.metadata.default] ||
|
? item.metadata.states[item.metadata.default] ||
|
||||||
item.metadata.default
|
item.metadata.default
|
||||||
: item.metadata.default
|
: item.metadata.default
|
||||||
@ -319,8 +335,7 @@ class ZWaveJSNodeConfig extends LitElement {
|
|||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
if (type === "manual_entry") {
|
||||||
if (item.configuration_value_type === "manual_entry") {
|
|
||||||
return html`${labelAndDescription}
|
return html`${labelAndDescription}
|
||||||
<ha-textfield
|
<ha-textfield
|
||||||
type="number"
|
type="number"
|
||||||
@ -340,7 +355,7 @@ class ZWaveJSNodeConfig extends LitElement {
|
|||||||
</ha-textfield>`;
|
</ha-textfield>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.configuration_value_type === "enumerated") {
|
if (type === "enumerated") {
|
||||||
return html`
|
return html`
|
||||||
${labelAndDescription}
|
${labelAndDescription}
|
||||||
<ha-select
|
<ha-select
|
||||||
|
Loading…
x
Reference in New Issue
Block a user