mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-22 00:36:34 +00:00
Set mandatory bool service data without a default value to false (#11094)
This commit is contained in:
parent
abeaa63005
commit
b0b953bfac
@ -130,6 +130,33 @@ export class HaServiceControl extends LitElement {
|
|||||||
this._value = this.value;
|
this._value = this.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (oldValue?.service !== this.value?.service) {
|
||||||
|
let updatedDefaultValue = false;
|
||||||
|
if (this._value && serviceData) {
|
||||||
|
// Set mandatory bools without a default value to false
|
||||||
|
this._value.data ??= {};
|
||||||
|
serviceData.fields.forEach((field) => {
|
||||||
|
if (
|
||||||
|
field.selector &&
|
||||||
|
field.required &&
|
||||||
|
field.default === undefined &&
|
||||||
|
"boolean" in field.selector &&
|
||||||
|
this._value!.data![field.key] === undefined
|
||||||
|
) {
|
||||||
|
updatedDefaultValue = true;
|
||||||
|
this._value!.data![field.key] = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (updatedDefaultValue) {
|
||||||
|
fireEvent(this, "value-changed", {
|
||||||
|
value: {
|
||||||
|
...this._value,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (this._value?.data) {
|
if (this._value?.data) {
|
||||||
const yamlEditor = this._yamlEditor;
|
const yamlEditor = this._yamlEditor;
|
||||||
if (yamlEditor && yamlEditor.value !== this._value.data) {
|
if (yamlEditor && yamlEditor.value !== this._value.data) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user