mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Split out service entities (#21076)
* Hide notify entiites from generated dashboard * Split out service entities on device info page * Update src/panels/lovelace/common/generate-lovelace-config.ts * Split service -> notify/assist
This commit is contained in:
parent
27afe9ecb7
commit
9c153bbd58
@ -31,6 +31,7 @@ import {
|
|||||||
mdiFormatListBulleted,
|
mdiFormatListBulleted,
|
||||||
mdiFormatListCheckbox,
|
mdiFormatListCheckbox,
|
||||||
mdiFormTextbox,
|
mdiFormTextbox,
|
||||||
|
mdiForumOutline,
|
||||||
mdiGauge,
|
mdiGauge,
|
||||||
mdiGoogleAssistant,
|
mdiGoogleAssistant,
|
||||||
mdiGoogleCirclesCommunities,
|
mdiGoogleCirclesCommunities,
|
||||||
@ -98,7 +99,7 @@ export const FIXED_DOMAIN_ICONS = {
|
|||||||
calendar: mdiCalendar,
|
calendar: mdiCalendar,
|
||||||
climate: mdiThermostat,
|
climate: mdiThermostat,
|
||||||
configurator: mdiCog,
|
configurator: mdiCog,
|
||||||
conversation: mdiMicrophoneMessage,
|
conversation: mdiForumOutline,
|
||||||
counter: mdiCounter,
|
counter: mdiCounter,
|
||||||
date: mdiCalendar,
|
date: mdiCalendar,
|
||||||
datetime: mdiCalendarClock,
|
datetime: mdiCalendarClock,
|
||||||
@ -235,6 +236,8 @@ export const SENSOR_ENTITIES = [
|
|||||||
"weather",
|
"weather",
|
||||||
];
|
];
|
||||||
|
|
||||||
|
export const ASSIST_ENTITIES = ["conversation", "stt", "tts"];
|
||||||
|
|
||||||
/** Domains that render an input element instead of a text value when displayed in a row.
|
/** Domains that render an input element instead of a text value when displayed in a row.
|
||||||
* Those rows should then not show a cursor pointer when hovered (which would normally
|
* Those rows should then not show a cursor pointer when hovered (which would normally
|
||||||
* be the default) unless the element itself enforces it (e.g. a button). Also those elements
|
* be the default) unless the element itself enforces it (e.g. a button). Also those elements
|
||||||
|
@ -24,7 +24,7 @@ import { customElement, property, state } from "lit/decorators";
|
|||||||
import { ifDefined } from "lit/directives/if-defined";
|
import { ifDefined } from "lit/directives/if-defined";
|
||||||
import memoizeOne from "memoize-one";
|
import memoizeOne from "memoize-one";
|
||||||
import { isComponentLoaded } from "../../../common/config/is_component_loaded";
|
import { isComponentLoaded } from "../../../common/config/is_component_loaded";
|
||||||
import { SENSOR_ENTITIES } from "../../../common/const";
|
import { SENSOR_ENTITIES, ASSIST_ENTITIES } from "../../../common/const";
|
||||||
import { computeDomain } from "../../../common/entity/compute_domain";
|
import { computeDomain } from "../../../common/entity/compute_domain";
|
||||||
import { computeStateDomain } from "../../../common/entity/compute_state_domain";
|
import { computeStateDomain } from "../../../common/entity/compute_state_domain";
|
||||||
import { computeStateName } from "../../../common/entity/compute_state_name";
|
import { computeStateName } from "../../../common/entity/compute_state_name";
|
||||||
@ -190,26 +190,42 @@ export class HaConfigDevicePage extends LitElement {
|
|||||||
|
|
||||||
private _entitiesByCategory = memoizeOne(
|
private _entitiesByCategory = memoizeOne(
|
||||||
(entities: EntityRegistryEntry[]) => {
|
(entities: EntityRegistryEntry[]) => {
|
||||||
const result = groupBy(entities, (entry) =>
|
const result = groupBy(entities, (entry) => {
|
||||||
entry.entity_category
|
const domain = computeDomain(entry.entity_id);
|
||||||
? entry.entity_category
|
|
||||||
: computeDomain(entry.entity_id) === "event"
|
if (entry.entity_category) {
|
||||||
? "event"
|
return entry.entity_category;
|
||||||
: SENSOR_ENTITIES.includes(computeDomain(entry.entity_id))
|
}
|
||||||
? "sensor"
|
|
||||||
: "control"
|
if (domain === "event" || domain === "notify") {
|
||||||
) as Record<
|
return domain;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SENSOR_ENTITIES.includes(domain)) {
|
||||||
|
return "sensor";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ASSIST_ENTITIES.includes(domain)) {
|
||||||
|
return "assist";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "control";
|
||||||
|
}) as Record<
|
||||||
| "control"
|
| "control"
|
||||||
| "event"
|
| "event"
|
||||||
| "sensor"
|
| "sensor"
|
||||||
|
| "assist"
|
||||||
|
| "notify"
|
||||||
| NonNullable<EntityRegistryEntry["entity_category"]>,
|
| NonNullable<EntityRegistryEntry["entity_category"]>,
|
||||||
EntityRegistryStateEntry[]
|
EntityRegistryStateEntry[]
|
||||||
>;
|
>;
|
||||||
for (const key of [
|
for (const key of [
|
||||||
|
"assist",
|
||||||
"config",
|
"config",
|
||||||
"control",
|
"control",
|
||||||
"diagnostic",
|
"diagnostic",
|
||||||
"event",
|
"event",
|
||||||
|
"notify",
|
||||||
"sensor",
|
"sensor",
|
||||||
]) {
|
]) {
|
||||||
if (!(key in result)) {
|
if (!(key in result)) {
|
||||||
@ -854,7 +870,15 @@ export class HaConfigDevicePage extends LitElement {
|
|||||||
</div>
|
</div>
|
||||||
<div class="column">
|
<div class="column">
|
||||||
${(
|
${(
|
||||||
["control", "sensor", "event", "config", "diagnostic"] as const
|
[
|
||||||
|
"control",
|
||||||
|
"sensor",
|
||||||
|
"notify",
|
||||||
|
"event",
|
||||||
|
"assist",
|
||||||
|
"config",
|
||||||
|
"diagnostic",
|
||||||
|
] as const
|
||||||
).map((category) =>
|
).map((category) =>
|
||||||
// Make sure we render controls if no other cards will be rendered
|
// Make sure we render controls if no other cards will be rendered
|
||||||
entitiesByCategory[category].length > 0 ||
|
entitiesByCategory[category].length > 0 ||
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { HassEntities, HassEntity } from "home-assistant-js-websocket";
|
import { HassEntities, HassEntity } from "home-assistant-js-websocket";
|
||||||
import { SENSOR_ENTITIES } from "../../../common/const";
|
import { SENSOR_ENTITIES, ASSIST_ENTITIES } from "../../../common/const";
|
||||||
import { computeDomain } from "../../../common/entity/compute_domain";
|
import { computeDomain } from "../../../common/entity/compute_domain";
|
||||||
import { computeStateDomain } from "../../../common/entity/compute_state_domain";
|
import { computeStateDomain } from "../../../common/entity/compute_state_domain";
|
||||||
import { computeStateName } from "../../../common/entity/compute_state_name";
|
import { computeStateName } from "../../../common/entity/compute_state_name";
|
||||||
@ -35,18 +35,16 @@ import { ButtonsHeaderFooterConfig } from "../header-footer/types";
|
|||||||
const HIDE_DOMAIN = new Set([
|
const HIDE_DOMAIN = new Set([
|
||||||
"automation",
|
"automation",
|
||||||
"configurator",
|
"configurator",
|
||||||
"conversation",
|
|
||||||
"device_tracker",
|
"device_tracker",
|
||||||
"event",
|
"event",
|
||||||
"geo_location",
|
"geo_location",
|
||||||
"notify",
|
"notify",
|
||||||
"persistent_notification",
|
"persistent_notification",
|
||||||
"script",
|
"script",
|
||||||
"stt",
|
|
||||||
"sun",
|
"sun",
|
||||||
"todo",
|
"todo",
|
||||||
"tts",
|
|
||||||
"zone",
|
"zone",
|
||||||
|
...ASSIST_ENTITIES,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const HIDE_PLATFORM = new Set(["mobile_app"]);
|
const HIDE_PLATFORM = new Set(["mobile_app"]);
|
||||||
|
@ -4012,6 +4012,8 @@
|
|||||||
"event": "Events",
|
"event": "Events",
|
||||||
"sensor": "Sensors",
|
"sensor": "Sensors",
|
||||||
"diagnostic": "Diagnostic",
|
"diagnostic": "Diagnostic",
|
||||||
|
"notify": "Notifiers",
|
||||||
|
"assist": "[%key:ui::panel::lovelace::menu::assist%]",
|
||||||
"config": "Configuration",
|
"config": "Configuration",
|
||||||
"add_entities_lovelace": "Add to dashboard",
|
"add_entities_lovelace": "Add to dashboard",
|
||||||
"none": "This device has no entities",
|
"none": "This device has no entities",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user