mirror of
https://github.com/home-assistant/frontend.git
synced 2025-04-29 15:57:20 +00:00
Fix entity names in notification (#2612)
This commit is contained in:
parent
30ab056aa4
commit
a090b291aa
@ -66,28 +66,34 @@ export default (superClass) =>
|
|||||||
try {
|
try {
|
||||||
await callService(conn, domain, service, serviceData);
|
await callService(conn, domain, service, serviceData);
|
||||||
|
|
||||||
let message;
|
const entityIds = Array.isArray(serviceData.entity_id)
|
||||||
let name;
|
? serviceData.entity_id
|
||||||
if (
|
: [serviceData.entity_id];
|
||||||
serviceData.entity_id &&
|
|
||||||
this.hass.states &&
|
const names = [];
|
||||||
this.hass.states[serviceData.entity_id]
|
for (const entityId of entityIds) {
|
||||||
) {
|
const stateObj = this.hass.states[entityId];
|
||||||
name = computeStateName(
|
if (stateObj) {
|
||||||
this.hass.states[serviceData.entity_id]
|
names.push(computeStateName(stateObj));
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (names.length === 0) {
|
||||||
|
names.push(entityIds[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
let message;
|
||||||
|
const name = names.join(", ");
|
||||||
if (service === "turn_on" && serviceData.entity_id) {
|
if (service === "turn_on" && serviceData.entity_id) {
|
||||||
message = this.hass.localize(
|
message = this.hass.localize(
|
||||||
"ui.notification_toast.entity_turned_on",
|
"ui.notification_toast.entity_turned_on",
|
||||||
"entity",
|
"entity",
|
||||||
name || serviceData.entity_id
|
name
|
||||||
);
|
);
|
||||||
} else if (service === "turn_off" && serviceData.entity_id) {
|
} else if (service === "turn_off" && serviceData.entity_id) {
|
||||||
message = this.hass.localize(
|
message = this.hass.localize(
|
||||||
"ui.notification_toast.entity_turned_off",
|
"ui.notification_toast.entity_turned_off",
|
||||||
"entity",
|
"entity",
|
||||||
name || serviceData.entity_id
|
name
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
message = this.hass.localize(
|
message = this.hass.localize(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user