mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-24 09:46:36 +00:00
Support zwave config parameters not on endpoint 0 (#16597)
Co-authored-by: Bram Kragten <mail@bramkragten.nl>
This commit is contained in:
parent
748925ede9
commit
b586210ff1
@ -234,6 +234,8 @@ export interface ZWaveJSNodeComment {
|
||||
|
||||
export interface ZWaveJSNodeConfigParam {
|
||||
property: number;
|
||||
property_key: number | null;
|
||||
endpoint: number;
|
||||
value: any;
|
||||
configuration_value_type: string;
|
||||
metadata: ZWaveJSNodeConfigParamMetadata;
|
||||
@ -255,6 +257,7 @@ export interface ZWaveJSSetConfigParamData {
|
||||
type: string;
|
||||
device_id: string;
|
||||
property: number;
|
||||
endpoint: number;
|
||||
property_key?: number;
|
||||
value: string | number;
|
||||
}
|
||||
@ -622,6 +625,7 @@ export const setZwaveNodeConfigParameter = (
|
||||
hass: HomeAssistant,
|
||||
device_id: string,
|
||||
property: number,
|
||||
endpoint: number,
|
||||
value: number,
|
||||
property_key?: number
|
||||
): Promise<ZWaveJSSetConfigParamResult> => {
|
||||
@ -629,6 +633,7 @@ export const setZwaveNodeConfigParameter = (
|
||||
type: "zwave_js/set_config_parameter",
|
||||
device_id,
|
||||
property,
|
||||
endpoint,
|
||||
value,
|
||||
property_key,
|
||||
};
|
||||
|
@ -12,6 +12,7 @@ import {
|
||||
CSSResultGroup,
|
||||
html,
|
||||
LitElement,
|
||||
nothing,
|
||||
PropertyValues,
|
||||
TemplateResult,
|
||||
} from "lit";
|
||||
@ -26,6 +27,7 @@ import "../../../../../components/ha-settings-row";
|
||||
import "../../../../../components/ha-svg-icon";
|
||||
import "../../../../../components/ha-switch";
|
||||
import "../../../../../components/ha-textfield";
|
||||
import { groupBy } from "../../../../../common/util/group-by";
|
||||
import {
|
||||
computeDeviceName,
|
||||
DeviceRegistryEntry,
|
||||
@ -35,6 +37,7 @@ import {
|
||||
fetchZwaveNodeConfigParameters,
|
||||
fetchZwaveNodeMetadata,
|
||||
setZwaveNodeConfigParameter,
|
||||
ZWaveJSNodeConfigParam,
|
||||
ZWaveJSNodeConfigParams,
|
||||
ZwaveJSNodeMetadata,
|
||||
ZWaveJSSetConfigParamResult,
|
||||
@ -171,29 +174,61 @@ class ZWaveJSNodeConfig extends SubscribeMixin(LitElement) {
|
||||
</em>
|
||||
</p>
|
||||
</div>
|
||||
<ha-card>
|
||||
${Object.entries(this._config).map(
|
||||
([id, item]) => html` <ha-settings-row
|
||||
class="config-item"
|
||||
.configId=${id}
|
||||
.narrow=${this.narrow}
|
||||
>
|
||||
${this._generateConfigBox(id, item)}
|
||||
</ha-settings-row>`
|
||||
)}
|
||||
</ha-card>
|
||||
${Object.entries(
|
||||
groupBy(Object.entries(this._config), ([_, item]) =>
|
||||
item.endpoint.toString()
|
||||
)
|
||||
).map(
|
||||
([endpoint, configParamEntries]) => html`<div class="content">
|
||||
<h3>
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.zwave_js.node_config.endpoint",
|
||||
"endpoint",
|
||||
endpoint
|
||||
)}
|
||||
</h3>
|
||||
<ha-card>
|
||||
${configParamEntries
|
||||
.sort(([_, paramA], [__, paramB]) =>
|
||||
paramA.property !== paramB.property
|
||||
? paramA.property - paramB.property
|
||||
: paramA.property_key! - paramB.property_key!
|
||||
)
|
||||
.map(
|
||||
([id, item]) => html` <ha-settings-row
|
||||
class="config-item"
|
||||
.configId=${id}
|
||||
.narrow=${this.narrow}
|
||||
>
|
||||
${this._generateConfigBox(id, item)}
|
||||
</ha-settings-row>`
|
||||
)}
|
||||
</ha-card>
|
||||
</div>`
|
||||
)}
|
||||
</ha-config-section>
|
||||
</hass-tabs-subpage>
|
||||
`;
|
||||
}
|
||||
|
||||
private _generateConfigBox(id, item): TemplateResult {
|
||||
private _generateConfigBox(
|
||||
id: string,
|
||||
item: ZWaveJSNodeConfigParam
|
||||
): TemplateResult {
|
||||
const result = this._results[id];
|
||||
const labelAndDescription = html`
|
||||
<span slot="prefix" class="prefix">
|
||||
${this.hass.localize("ui.panel.config.zwave_js.node_config.parameter")}
|
||||
<br />
|
||||
<span>${item.property}</span>
|
||||
${item.property_key !== null
|
||||
? html`<br />
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.zwave_js.node_config.bitmask"
|
||||
)}
|
||||
<br />
|
||||
<span>${item.property_key.toString(16)}</span>`
|
||||
: nothing}
|
||||
</span>
|
||||
<span slot="heading" class="heading" .title=${item.metadata.label}>
|
||||
${item.metadata.label}
|
||||
@ -202,14 +237,14 @@ class ZWaveJSNodeConfig extends SubscribeMixin(LitElement) {
|
||||
${item.metadata.description || item.metadata.label}
|
||||
${item.metadata.description !== null && !item.metadata.writeable
|
||||
? html`<br />`
|
||||
: ""}
|
||||
: nothing}
|
||||
${!item.metadata.writeable
|
||||
? html`<em>
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.zwave_js.node_config.parameter_is_read_only"
|
||||
)}
|
||||
</em>`
|
||||
: ""}
|
||||
: nothing}
|
||||
${result?.status
|
||||
? html`<p
|
||||
class="result ${classMap({
|
||||
@ -226,9 +261,9 @@ class ZWaveJSNodeConfig extends SubscribeMixin(LitElement) {
|
||||
)}
|
||||
${result.status === "error" && result.error
|
||||
? html` <br /><em>${result.error}</em> `
|
||||
: ""}
|
||||
: nothing}
|
||||
</p>`
|
||||
: ""}
|
||||
: nothing}
|
||||
</span>
|
||||
`;
|
||||
|
||||
@ -244,6 +279,7 @@ class ZWaveJSNodeConfig extends SubscribeMixin(LitElement) {
|
||||
<div class="switch">
|
||||
<ha-switch
|
||||
.property=${item.property}
|
||||
.endpoint=${item.endpoint}
|
||||
.propertyKey=${item.property_key}
|
||||
.checked=${item.value === 1}
|
||||
.key=${id}
|
||||
@ -262,6 +298,7 @@ class ZWaveJSNodeConfig extends SubscribeMixin(LitElement) {
|
||||
.min=${item.metadata.min}
|
||||
.max=${item.metadata.max}
|
||||
.property=${item.property}
|
||||
.endpoint=${item.endpoint}
|
||||
.propertyKey=${item.property_key}
|
||||
.key=${id}
|
||||
.disabled=${!item.metadata.writeable}
|
||||
@ -279,6 +316,7 @@ class ZWaveJSNodeConfig extends SubscribeMixin(LitElement) {
|
||||
.value=${item.value?.toString()}
|
||||
.key=${id}
|
||||
.property=${item.property}
|
||||
.endpoint=${item.endpoint}
|
||||
.propertyKey=${item.property_key}
|
||||
@selected=${this._dropdownSelected}
|
||||
>
|
||||
@ -295,7 +333,7 @@ class ZWaveJSNodeConfig extends SubscribeMixin(LitElement) {
|
||||
<p>${item.value}</p>`;
|
||||
}
|
||||
|
||||
private _isEnumeratedBool(item): boolean {
|
||||
private _isEnumeratedBool(item: ZWaveJSNodeConfigParam): boolean {
|
||||
// Some Z-Wave config values use a states list with two options where index 0 = Disabled and 1 = Enabled
|
||||
// We want those to be considered boolean and show a toggle switch
|
||||
const disabledStates = ["disable", "disabled"];
|
||||
@ -357,6 +395,7 @@ class ZWaveJSNodeConfig extends SubscribeMixin(LitElement) {
|
||||
this.hass,
|
||||
this._device!.id,
|
||||
target.property,
|
||||
target.endpoint,
|
||||
value,
|
||||
target.propertyKey ? target.propertyKey : undefined
|
||||
);
|
||||
|
@ -3778,6 +3778,7 @@
|
||||
"header": "Z-Wave Device Configuration",
|
||||
"introduction": "Manage and adjust device specific configuration parameters for the selected device",
|
||||
"attribution": "Device configuration parameters and descriptions are provided by the {device_database}",
|
||||
"endpoint": "Endpoint {endpoint}",
|
||||
"zwave_js_device_database": "Z-Wave JS Device Database",
|
||||
"battery_device_notice": "Battery devices must be awake to update their config. Please refer to your device manual for instructions on how to wake the device.",
|
||||
"parameter_is_read_only": "This parameter is read-only.",
|
||||
@ -3785,7 +3786,8 @@
|
||||
"set_param_accepted": "The parameter has been updated.",
|
||||
"set_param_queued": "The parameter change has been queued, and will be updated when the device wakes up.",
|
||||
"set_param_error": "An error occurred.",
|
||||
"parameter": "Parameter"
|
||||
"parameter": "Parameter",
|
||||
"bitmask": "Bitmask"
|
||||
},
|
||||
"node_status": {
|
||||
"unknown": "Unknown",
|
||||
|
Loading…
x
Reference in New Issue
Block a user