mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-27 03:06:41 +00:00
Update UI when service schema change (#9120)
This commit is contained in:
parent
a9c7a39a47
commit
9be4a00169
@ -1,5 +1,9 @@
|
|||||||
import { mdiHelpCircle } from "@mdi/js";
|
import { mdiHelpCircle } from "@mdi/js";
|
||||||
import { HassService, HassServiceTarget } from "home-assistant-js-websocket";
|
import {
|
||||||
|
HassService,
|
||||||
|
HassServices,
|
||||||
|
HassServiceTarget,
|
||||||
|
} from "home-assistant-js-websocket";
|
||||||
import {
|
import {
|
||||||
css,
|
css,
|
||||||
CSSResult,
|
CSSResult,
|
||||||
@ -73,7 +77,10 @@ export class HaServiceControl extends LitElement {
|
|||||||
this._checkedKeys = new Set();
|
this._checkedKeys = new Set();
|
||||||
}
|
}
|
||||||
|
|
||||||
const serviceData = this._getServiceInfo(this.value?.service);
|
const serviceData = this._getServiceInfo(
|
||||||
|
this.value?.service,
|
||||||
|
this.hass.services
|
||||||
|
);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
serviceData &&
|
serviceData &&
|
||||||
@ -122,15 +129,16 @@ export class HaServiceControl extends LitElement {
|
|||||||
return ENTITY_COMPONENT_DOMAINS.includes(domain) ? [domain] : null;
|
return ENTITY_COMPONENT_DOMAINS.includes(domain) ? [domain] : null;
|
||||||
});
|
});
|
||||||
|
|
||||||
private _getServiceInfo = memoizeOne((service?: string):
|
private _getServiceInfo = memoizeOne(
|
||||||
| ExtHassService
|
(
|
||||||
| undefined => {
|
service?: string,
|
||||||
if (!service) {
|
serviceDomains?: HassServices
|
||||||
|
): ExtHassService | undefined => {
|
||||||
|
if (!service || !serviceDomains) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
const domain = computeDomain(service);
|
const domain = computeDomain(service);
|
||||||
const serviceName = computeObjectId(service);
|
const serviceName = computeObjectId(service);
|
||||||
const serviceDomains = this.hass.services;
|
|
||||||
if (!(domain in serviceDomains)) {
|
if (!(domain in serviceDomains)) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
@ -152,10 +160,14 @@ export class HaServiceControl extends LitElement {
|
|||||||
? fields.filter((field) => field.selector).map((field) => field.key)
|
? fields.filter((field) => field.selector).map((field) => field.key)
|
||||||
: [],
|
: [],
|
||||||
};
|
};
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
protected render() {
|
protected render() {
|
||||||
const serviceData = this._getServiceInfo(this._value?.service);
|
const serviceData = this._getServiceInfo(
|
||||||
|
this._value?.service,
|
||||||
|
this.hass.services
|
||||||
|
);
|
||||||
|
|
||||||
const shouldRenderServiceDataYaml =
|
const shouldRenderServiceDataYaml =
|
||||||
(serviceData?.fields.length && !serviceData.hasSelector.length) ||
|
(serviceData?.fields.length && !serviceData.hasSelector.length) ||
|
||||||
|
Loading…
x
Reference in New Issue
Block a user