mirror of
https://github.com/home-assistant/frontend.git
synced 2026-12-02 01:30:11 +00:00
Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d0a47d3b46 | ||
|
|
cfef6362d1 | ||
|
|
8706c4073b | ||
|
|
82ccac2769 | ||
|
|
04d62c7726 |
No files matched your search
@@ -104,6 +104,10 @@ export const DOMAINS_HIDE_DEFAULT_MORE_INFO = [
|
||||
/** Domains that should have the history hidden in the more info dialog. */
|
||||
export const DOMAINS_MORE_INFO_NO_HISTORY = ["camera", "configurator"];
|
||||
|
||||
/** Whether the info view explains why the entity isn't available instead of showing it. */
|
||||
export const computeShowUnavailableInfo = (stateObj?: HassEntity) =>
|
||||
!stateObj || Boolean(stateObj.attributes.restored);
|
||||
|
||||
export const computeShowHistoryComponent = (
|
||||
hass: HomeAssistant,
|
||||
entityId: string
|
||||
|
||||
@@ -84,6 +84,7 @@ import { showConfirmationDialog } from "../generic/show-dialog-box";
|
||||
import {
|
||||
computeShowHistoryComponent,
|
||||
computeShowLogBookComponent,
|
||||
computeShowUnavailableInfo,
|
||||
DOMAINS_WITH_MORE_INFO,
|
||||
EDITABLE_DOMAINS_WITH_ID,
|
||||
EDITABLE_DOMAINS_WITH_UNIQUE_ID,
|
||||
@@ -185,6 +186,8 @@ export class MoreInfoDialog extends DirtyStateProviderMixin<
|
||||
|
||||
@state() private _entry?: ExtEntityRegistryEntry | null;
|
||||
|
||||
private _entryLoadFailed = false;
|
||||
|
||||
@state() private _infoEditMode = false;
|
||||
|
||||
@state() private _detailsYamlMode = false;
|
||||
@@ -220,16 +223,26 @@ export class MoreInfoDialog extends DirtyStateProviderMixin<
|
||||
}
|
||||
|
||||
private async _loadEntityRegistryEntry() {
|
||||
if (!this._entityId) {
|
||||
const entityId = this._entityId;
|
||||
if (!entityId) {
|
||||
return;
|
||||
}
|
||||
if (this._entry?.entity_id !== entityId) {
|
||||
this._entry = undefined;
|
||||
}
|
||||
let entry: ExtEntityRegistryEntry | null | undefined;
|
||||
let failed = false;
|
||||
try {
|
||||
this._entry = await getExtendedEntityRegistryEntry(
|
||||
this.hass.callWS,
|
||||
this._entityId
|
||||
);
|
||||
} catch (_e) {
|
||||
this._entry = null;
|
||||
entry = await getExtendedEntityRegistryEntry(this.hass.callWS, entityId);
|
||||
} catch (err: any) {
|
||||
// Other errors, like a lost connection, don't tell whether it's
|
||||
// registered, so it loads again on reconnect
|
||||
failed = err?.code !== "not_found";
|
||||
entry = failed ? undefined : null;
|
||||
}
|
||||
if (this._entityId === entityId) {
|
||||
this._entry = entry;
|
||||
this._entryLoadFailed = failed;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -254,6 +267,7 @@ export class MoreInfoDialog extends DirtyStateProviderMixin<
|
||||
this._entityId = undefined;
|
||||
this._parentEntityIds = [];
|
||||
this._entry = undefined;
|
||||
this._entryLoadFailed = false;
|
||||
this._infoEditMode = false;
|
||||
this._detailsYamlMode = false;
|
||||
this._initialView = DEFAULT_VIEW;
|
||||
@@ -288,7 +302,8 @@ export class MoreInfoDialog extends DirtyStateProviderMixin<
|
||||
|
||||
private _shouldShowHistory(domain: string): boolean {
|
||||
return (
|
||||
DOMAINS_WITH_MORE_INFO.includes(domain) &&
|
||||
(DOMAINS_WITH_MORE_INFO.includes(domain) ||
|
||||
computeShowUnavailableInfo(this.hass.states[this._entityId!])) &&
|
||||
(computeShowHistoryComponent(this.hass, this._entityId!) ||
|
||||
computeShowLogBookComponent(this.hass, this._entityId!))
|
||||
);
|
||||
@@ -1075,6 +1090,14 @@ export class MoreInfoDialog extends DirtyStateProviderMixin<
|
||||
this._mediaNaturalWidth = undefined;
|
||||
this._cameraControlsHeight = undefined;
|
||||
}
|
||||
if (
|
||||
this._entryLoadFailed &&
|
||||
changedProps.has("hass") &&
|
||||
this.hass.connected &&
|
||||
!(changedProps.get("hass") as HomeAssistant | undefined)?.connected
|
||||
) {
|
||||
this._loadEntityRegistryEntry();
|
||||
}
|
||||
}
|
||||
|
||||
protected firstUpdated(changedProps: PropertyValues<this>) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { css, html, LitElement } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import { computeDomain } from "../../common/entity/compute_domain";
|
||||
import type { ExtEntityRegistryEntry } from "../../data/entity/entity_registry";
|
||||
@@ -8,12 +8,14 @@ import {
|
||||
computeShowHistoryComponent,
|
||||
computeShowLogBookComponent,
|
||||
computeShowNewMoreInfo,
|
||||
computeShowUnavailableInfo,
|
||||
DOMAINS_FULL_HEIGHT_MORE_INFO,
|
||||
DOMAINS_NO_INFO,
|
||||
DOMAINS_WITH_MORE_INFO,
|
||||
} from "./const";
|
||||
import "./ha-more-info-history";
|
||||
import "./ha-more-info-logbook";
|
||||
import "./ha-more-info-unavailable";
|
||||
import "./more-info-content";
|
||||
|
||||
@customElement("ha-more-info-info")
|
||||
@@ -31,41 +33,21 @@ export class MoreInfoInfo extends LitElement {
|
||||
protected render() {
|
||||
const entityId = this.entityId;
|
||||
const stateObj = this.hass.states[entityId] as HassEntity | undefined;
|
||||
const entityRegObj = this.hass.entities[entityId];
|
||||
|
||||
if (!stateObj || computeShowUnavailableInfo(stateObj)) {
|
||||
return html`<ha-more-info-unavailable
|
||||
.entry=${this.entry}
|
||||
.stateObj=${stateObj}
|
||||
></ha-more-info-unavailable>`;
|
||||
}
|
||||
|
||||
const domain = computeDomain(entityId);
|
||||
const isNewMoreInfo = stateObj && computeShowNewMoreInfo(stateObj);
|
||||
const isNewMoreInfo = computeShowNewMoreInfo(stateObj);
|
||||
const isFullHeight =
|
||||
isNewMoreInfo || DOMAINS_FULL_HEIGHT_MORE_INFO.includes(domain);
|
||||
|
||||
return html`
|
||||
<div class="container" data-domain=${domain}>
|
||||
${
|
||||
!stateObj
|
||||
? html`<ha-alert alert-type="warning">
|
||||
${
|
||||
this.entry?.disabled_by
|
||||
? this.hass.localize(
|
||||
"ui.dialogs.entity_registry.editor.entity_disabled"
|
||||
)
|
||||
: this.hass.localize(
|
||||
"ui.dialogs.entity_registry.editor.unavailable"
|
||||
)
|
||||
}
|
||||
</ha-alert>`
|
||||
: nothing
|
||||
}
|
||||
${
|
||||
stateObj?.attributes.restored && entityRegObj
|
||||
? html`<ha-alert alert-type="warning">
|
||||
${this.hass.localize(
|
||||
"ui.dialogs.more_info_control.restored.no_longer_provided",
|
||||
{
|
||||
integration: entityRegObj.platform,
|
||||
}
|
||||
)}
|
||||
</ha-alert>`
|
||||
: nothing
|
||||
}
|
||||
<div class="content">
|
||||
${
|
||||
DOMAINS_NO_INFO.includes(domain) || isNewMoreInfo
|
||||
@@ -153,10 +135,6 @@ export class MoreInfoInfo extends LitElement {
|
||||
ha-more-info-logbook {
|
||||
margin-inline: calc(var(--ha-space-6) * -1);
|
||||
}
|
||||
|
||||
ha-alert {
|
||||
display: block;
|
||||
}
|
||||
`;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,455 @@
|
||||
import {
|
||||
mdiCancel,
|
||||
mdiHelpCircleOutline,
|
||||
mdiPowerPlugOffOutline,
|
||||
} from "@mdi/js";
|
||||
import type { ContextType } from "@lit/context";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { PropertyValues } from "lit";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { classMap } from "lit/directives/class-map";
|
||||
import "@home-assistant/components/card";
|
||||
import { consume } from "../../common/decorators/consume";
|
||||
import { transform } from "../../common/decorators/transform";
|
||||
import { fireEvent } from "../../common/dom/fire_event";
|
||||
import { navigate } from "../../common/navigate";
|
||||
import {
|
||||
adaptiveDialogModeContext,
|
||||
type DialogSheetMode,
|
||||
} from "../../components/ha-adaptive-dialog";
|
||||
import "../../components/ha-alert";
|
||||
import "../../components/ha-button";
|
||||
import "../../components/ha-empty-state";
|
||||
import "../../components/ha-relative-time";
|
||||
import type { ConfigEntry } from "../../data/config_entries";
|
||||
import { ERROR_STATES } from "../../data/config_entries";
|
||||
import {
|
||||
apiContext,
|
||||
configContext,
|
||||
configEntriesContext,
|
||||
formattersContext,
|
||||
internationalizationContext,
|
||||
} from "../../data/context";
|
||||
import { UNAVAILABLE, UNKNOWN } from "../../data/entity/entity";
|
||||
import type { HistoryStates } from "../../data/history";
|
||||
import type { ExtEntityRegistryEntry } from "../../data/entity/entity_registry";
|
||||
import { updateEntityRegistryEntry } from "../../data/entity/entity_registry";
|
||||
import { domainToName } from "../../data/integration";
|
||||
import { renderConfigEntryError } from "../../panels/config/integrations/render-config-entry-error";
|
||||
import { showAlertDialog } from "../generic/show-dialog-box";
|
||||
|
||||
/**
|
||||
* @element ha-more-info-unavailable
|
||||
* @summary Info view of an entity that has no state or that its integration
|
||||
* doesn't provide, with the reason and how to make it available again.
|
||||
*/
|
||||
@customElement("ha-more-info-unavailable")
|
||||
export class HaMoreInfoUnavailable extends LitElement {
|
||||
/** `undefined` while the entry loads, `null` when the entity isn't registered. */
|
||||
@property({ attribute: false }) public entry?: ExtEntityRegistryEntry | null;
|
||||
|
||||
/** The `restored` state core keeps while the integration doesn't provide the entity. */
|
||||
@property({ attribute: false }) public stateObj?: HassEntity;
|
||||
|
||||
@state()
|
||||
@consume({ context: internationalizationContext, subscribe: true })
|
||||
private _i18n!: ContextType<typeof internationalizationContext>;
|
||||
|
||||
@state()
|
||||
@consume({ context: configContext, subscribe: true })
|
||||
@transform<ContextType<typeof configContext>, boolean>({
|
||||
transformer: ({ user }) => Boolean(user?.is_admin),
|
||||
})
|
||||
private _isAdmin = false;
|
||||
|
||||
@consume({ context: apiContext, subscribe: true })
|
||||
private _api!: ContextType<typeof apiContext>;
|
||||
|
||||
@state()
|
||||
@consume({ context: formattersContext, subscribe: true })
|
||||
private _formatters!: ContextType<typeof formattersContext>;
|
||||
|
||||
@state()
|
||||
@consume({ context: configEntriesContext, subscribe: true })
|
||||
private _configEntries?: ConfigEntry[];
|
||||
|
||||
/** `null` when the history has no state from before. */
|
||||
@state() private _lastKnown?: { state: string; until: Date } | null;
|
||||
|
||||
@state()
|
||||
@consume({ context: adaptiveDialogModeContext, subscribe: true })
|
||||
private _dialogMode?: DialogSheetMode;
|
||||
|
||||
@state() private _enabling = false;
|
||||
|
||||
private _lastKnownRequest = 0;
|
||||
|
||||
@state() private _error?: string;
|
||||
|
||||
protected willUpdate(changedProps: PropertyValues<this>) {
|
||||
super.willUpdate(changedProps);
|
||||
const platform = this.entry?.platform;
|
||||
if (platform && changedProps.get("entry")?.platform !== platform) {
|
||||
// Only the titles of loaded integrations are fetched by default
|
||||
this._i18n.loadBackendTranslation("title", platform);
|
||||
}
|
||||
if (
|
||||
changedProps.has("stateObj") &&
|
||||
changedProps.get("stateObj")?.last_changed !== this.stateObj?.last_changed
|
||||
) {
|
||||
this._fetchLastKnown();
|
||||
}
|
||||
}
|
||||
|
||||
private async _fetchLastKnown() {
|
||||
this._lastKnown = undefined;
|
||||
const request = ++this._lastKnownRequest;
|
||||
const stateObj = this.stateObj;
|
||||
if (!stateObj) {
|
||||
return;
|
||||
}
|
||||
const end = new Date(stateObj.last_changed);
|
||||
// Short periods first, as a sensor can write thousands of states a day
|
||||
for (const days of [1, 7, 30]) {
|
||||
let history: HistoryStates;
|
||||
try {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
history = await this._api.callWS<HistoryStates>({
|
||||
type: "history/history_during_period",
|
||||
start_time: new Date(end.getTime() - days * 86400000).toISOString(),
|
||||
end_time: end.toISOString(),
|
||||
entity_ids: [stateObj.entity_id],
|
||||
minimal_response: true,
|
||||
no_attributes: true,
|
||||
});
|
||||
} catch (_err) {
|
||||
this._lastKnown = null;
|
||||
return;
|
||||
}
|
||||
if (request !== this._lastKnownRequest) {
|
||||
return;
|
||||
}
|
||||
const states = history[stateObj.entity_id] ?? [];
|
||||
for (let i = states.length - 1; i >= 0; i--) {
|
||||
if (states[i].s !== UNAVAILABLE && states[i].s !== UNKNOWN) {
|
||||
const next = states[i + 1];
|
||||
this._lastKnown = {
|
||||
state: states[i].s,
|
||||
until: next ? new Date((next.lc ?? next.lu) * 1000) : end,
|
||||
};
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
this._lastKnown = null;
|
||||
}
|
||||
|
||||
protected render() {
|
||||
return html`
|
||||
<div
|
||||
class=${classMap({
|
||||
container: true,
|
||||
"bottom-sheet": this._dialogMode === "bottom-sheet",
|
||||
})}
|
||||
>
|
||||
${this._renderContent()}
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
private _renderContent() {
|
||||
if (this.entry === undefined) {
|
||||
return nothing;
|
||||
}
|
||||
|
||||
const localize = this._i18n.localize;
|
||||
|
||||
if (this.entry === null) {
|
||||
return html`
|
||||
<ha-empty-state
|
||||
.icon=${mdiHelpCircleOutline}
|
||||
.heading=${localize(
|
||||
"ui.dialogs.more_info_control.unavailable.not_found_title"
|
||||
)}
|
||||
.description=${localize(
|
||||
"ui.dialogs.more_info_control.unavailable.not_found"
|
||||
)}
|
||||
></ha-empty-state>
|
||||
`;
|
||||
}
|
||||
|
||||
const entry = this.entry;
|
||||
const integration = domainToName(localize, entry.platform);
|
||||
|
||||
if (!entry.disabled_by) {
|
||||
const configEntry = entry.config_entry_id
|
||||
? this._configEntries?.find(
|
||||
(item) => item.entry_id === entry.config_entry_id
|
||||
)
|
||||
: undefined;
|
||||
return html`
|
||||
<ha-empty-state
|
||||
.icon=${mdiPowerPlugOffOutline}
|
||||
.heading=${localize(
|
||||
"ui.dialogs.more_info_control.unavailable.not_provided_title"
|
||||
)}
|
||||
.description=${this._notProvidedDescription(integration, configEntry)}
|
||||
>
|
||||
${this._renderDetails(configEntry)}
|
||||
${this._isAdmin ? this._renderOpenIntegration() : nothing}
|
||||
</ha-empty-state>
|
||||
`;
|
||||
}
|
||||
|
||||
const canEnable =
|
||||
entry.disabled_by === "user" || entry.disabled_by === "integration";
|
||||
|
||||
return html`
|
||||
<ha-empty-state
|
||||
.icon=${mdiCancel}
|
||||
.heading=${localize(
|
||||
"ui.dialogs.more_info_control.unavailable.disabled_title"
|
||||
)}
|
||||
.description=${localize(
|
||||
`ui.dialogs.more_info_control.unavailable.disabled_by.${entry.disabled_by}`,
|
||||
{ integration }
|
||||
)}
|
||||
>
|
||||
${
|
||||
this._error
|
||||
? html`<ha-alert alert-type="error">${this._error}</ha-alert>`
|
||||
: nothing
|
||||
}
|
||||
${
|
||||
!this._isAdmin
|
||||
? nothing
|
||||
: canEnable
|
||||
? html`
|
||||
<ha-button
|
||||
.loading=${this._enabling}
|
||||
.disabled=${this._enabling}
|
||||
@click=${this._enableEntry}
|
||||
>
|
||||
${localize(
|
||||
"ui.dialogs.more_info_control.unavailable.enable_entity"
|
||||
)}
|
||||
</ha-button>
|
||||
`
|
||||
: entry.disabled_by === "device" && entry.device_id
|
||||
? html`
|
||||
<ha-button appearance="plain" @click=${this._openDevice}>
|
||||
${localize(
|
||||
"ui.dialogs.more_info_control.unavailable.open_device"
|
||||
)}
|
||||
</ha-button>
|
||||
`
|
||||
: this._renderOpenIntegration()
|
||||
}
|
||||
</ha-empty-state>
|
||||
`;
|
||||
}
|
||||
|
||||
private _notProvidedDescription(
|
||||
integration: string,
|
||||
configEntry?: ConfigEntry
|
||||
) {
|
||||
const localize = this._i18n.localize;
|
||||
const key = "ui.dialogs.more_info_control.unavailable.integration_state";
|
||||
switch (configEntry?.state) {
|
||||
case "setup_retry":
|
||||
return localize(`${key}.setup_retry`, { integration });
|
||||
case "setup_error":
|
||||
case "migration_error":
|
||||
return localize(`${key}.setup_error`, { integration });
|
||||
case "setup_in_progress":
|
||||
return localize(`${key}.setup_in_progress`, { integration });
|
||||
case "not_loaded":
|
||||
case "failed_unload":
|
||||
case "unload_in_progress":
|
||||
return localize(`${key}.not_loaded`, { integration });
|
||||
default:
|
||||
return localize(
|
||||
this.stateObj
|
||||
? `${key}.no_longer_provided`
|
||||
: "ui.dialogs.more_info_control.unavailable.not_provided",
|
||||
{ integration }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private _renderDetails(configEntry?: ConfigEntry) {
|
||||
const localize = this._i18n.localize;
|
||||
const key = "ui.dialogs.more_info_control.unavailable.details";
|
||||
const reason =
|
||||
this._isAdmin &&
|
||||
configEntry?.reason &&
|
||||
ERROR_STATES.includes(configEntry.state)
|
||||
? renderConfigEntryError(this._i18n, configEntry)
|
||||
: undefined;
|
||||
// Only the history tells since when, the restored state's last_changed is the last restart
|
||||
const lastKnown = this.stateObj ? this._lastKnown : undefined;
|
||||
if (!reason && !lastKnown) {
|
||||
return nothing;
|
||||
}
|
||||
return html`
|
||||
<hac-card>
|
||||
<dl>
|
||||
${
|
||||
reason
|
||||
? html`<div class="stacked">
|
||||
<dt>${localize(`${key}.reason`)}</dt>
|
||||
<dd>${reason}</dd>
|
||||
</div>`
|
||||
: nothing
|
||||
}
|
||||
${
|
||||
lastKnown
|
||||
? html`<div>
|
||||
<dt>${localize(`${key}.unavailable_since`)}</dt>
|
||||
<dd>
|
||||
<ha-relative-time
|
||||
.datetime=${lastKnown.until}
|
||||
capitalize
|
||||
></ha-relative-time>
|
||||
</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>${localize(`${key}.last_known_state`)}</dt>
|
||||
<dd>
|
||||
${this._formatters.formatEntityState(
|
||||
this.stateObj!,
|
||||
lastKnown.state
|
||||
)}
|
||||
</dd>
|
||||
</div>`
|
||||
: nothing
|
||||
}
|
||||
</dl>
|
||||
</hac-card>
|
||||
`;
|
||||
}
|
||||
|
||||
private _renderOpenIntegration() {
|
||||
return html`
|
||||
<ha-button appearance="plain" @click=${this._openIntegration}>
|
||||
${this._i18n.localize(
|
||||
"ui.dialogs.more_info_control.unavailable.open_integration"
|
||||
)}
|
||||
</ha-button>
|
||||
`;
|
||||
}
|
||||
|
||||
private _openIntegration() {
|
||||
navigate(`/config/integrations/integration/${this.entry!.platform}`);
|
||||
}
|
||||
|
||||
private _openDevice() {
|
||||
navigate(`/config/devices/device/${this.entry!.device_id}`);
|
||||
}
|
||||
|
||||
private async _enableEntry() {
|
||||
this._error = undefined;
|
||||
this._enabling = true;
|
||||
try {
|
||||
const result = await updateEntityRegistryEntry(
|
||||
this._api.callWS,
|
||||
this.entry!.entity_id,
|
||||
{ disabled_by: null }
|
||||
);
|
||||
fireEvent(this, "entity-entry-updated", result.entity_entry);
|
||||
if (result.require_restart) {
|
||||
showAlertDialog(this, {
|
||||
text: this._i18n.localize(
|
||||
"ui.dialogs.entity_registry.editor.enabled_restart_confirm"
|
||||
),
|
||||
});
|
||||
}
|
||||
if (result.reload_delay) {
|
||||
showAlertDialog(this, {
|
||||
text: this._i18n.localize(
|
||||
"ui.dialogs.entity_registry.editor.enabled_delay_confirm",
|
||||
{ delay: result.reload_delay }
|
||||
),
|
||||
});
|
||||
}
|
||||
} catch (err: any) {
|
||||
this._error = err.message;
|
||||
} finally {
|
||||
this._enabling = false;
|
||||
}
|
||||
}
|
||||
|
||||
static styles = css`
|
||||
:host {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.container {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
min-height: 400px;
|
||||
}
|
||||
|
||||
/* The bottom sheet has a fixed height, which is lower on a phone in landscape */
|
||||
.container.bottom-sheet {
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
ha-empty-state {
|
||||
flex: 1;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
hac-card {
|
||||
width: 100%;
|
||||
--hac-card-content-padding: var(--ha-space-3) var(--ha-space-4);
|
||||
}
|
||||
|
||||
dl {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--ha-space-2);
|
||||
margin: 0;
|
||||
text-align: start;
|
||||
}
|
||||
|
||||
dl > div {
|
||||
display: flex;
|
||||
gap: var(--ha-space-4);
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
dl > div.stacked {
|
||||
flex-direction: column;
|
||||
gap: 0;
|
||||
}
|
||||
|
||||
.stacked dd {
|
||||
text-align: start;
|
||||
}
|
||||
|
||||
dt {
|
||||
flex: none;
|
||||
color: var(--secondary-text-color);
|
||||
}
|
||||
|
||||
dd {
|
||||
margin: 0;
|
||||
text-align: end;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
ha-alert {
|
||||
display: block;
|
||||
text-align: start;
|
||||
}
|
||||
`;
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
"ha-more-info-unavailable": HaMoreInfoUnavailable;
|
||||
}
|
||||
}
|
||||
@@ -134,7 +134,7 @@ import {
|
||||
getLabelsTableColumn,
|
||||
} from "../common/data-table-columns";
|
||||
import { configSections } from "../config-sections";
|
||||
import { renderConfigEntryError } from "../integrations/ha-config-integration-page";
|
||||
import { renderConfigEntryError } from "../integrations/render-config-entry-error";
|
||||
import "../integrations/ha-integration-overflow-menu";
|
||||
import { showLabelDetailDialog } from "../labels/show-dialog-label-detail";
|
||||
import {
|
||||
|
||||
@@ -46,7 +46,7 @@ import type { LoggedError } from "../../../data/system_log";
|
||||
import { fetchSystemLog } from "../../../data/system_log";
|
||||
import { DialogMixin } from "../../../dialogs/dialog-mixin";
|
||||
import { haStyleDialog } from "../../../resources/styles";
|
||||
import { renderConfigEntryError } from "./ha-config-integration-page";
|
||||
import { renderConfigEntryError } from "./render-config-entry-error";
|
||||
import type { ConfigEntryHealthDialogParams } from "./show-dialog-config-entry-health";
|
||||
|
||||
const STATUS_ICONS: Record<HealthStatus, string> = {
|
||||
|
||||
@@ -75,11 +75,9 @@ import {
|
||||
showPromptDialog,
|
||||
} from "../../lovelace/custom-card-helpers";
|
||||
import "./ha-config-entry-device-row";
|
||||
import {
|
||||
renderConfigEntryError,
|
||||
type ConfigEntryData,
|
||||
} from "./ha-config-integration-page";
|
||||
import type { ConfigEntryData } from "./ha-config-integration-page";
|
||||
import "./ha-config-sub-entry-row";
|
||||
import { renderConfigEntryError } from "./render-config-entry-error";
|
||||
import { offerMarketplaceUninstall } from "./offer-marketplace-uninstall";
|
||||
|
||||
@customElement("ha-config-entry-row")
|
||||
|
||||
@@ -13,10 +13,9 @@ import {
|
||||
mdiWeb,
|
||||
} from "@mdi/js";
|
||||
import type { UnsubscribeFunc } from "home-assistant-js-websocket";
|
||||
import type { CSSResultGroup, PropertyValues, TemplateResult } from "lit";
|
||||
import type { CSSResultGroup, PropertyValues } from "lit";
|
||||
import { LitElement, css, html, nothing } from "lit";
|
||||
import { customElement, property, queryAll, state } from "lit/decorators";
|
||||
import { until } from "lit/directives/until";
|
||||
import memoizeOne from "memoize-one";
|
||||
import { ensureArray } from "../../../common/array/ensure-array";
|
||||
import { isComponentLoaded } from "../../../common/config/is_component_loaded";
|
||||
@@ -116,46 +115,6 @@ export interface ConfigEntryData {
|
||||
// The AI settings show how to connect to the MCP server and its APIs.
|
||||
const AI_SETTINGS_DOMAINS = ["mcp", "mcp_server"];
|
||||
|
||||
export const renderConfigEntryError = (
|
||||
hass: Pick<HomeAssistant, "localize" | "loadBackendTranslation">,
|
||||
entry: ConfigEntry
|
||||
): TemplateResult => {
|
||||
if (entry.reason) {
|
||||
if (entry.error_reason_translation_key) {
|
||||
// The error may be translated by another integration, e.g. one raised by
|
||||
// a shared helper and owned by the homeassistant integration.
|
||||
const translationDomain =
|
||||
entry.error_reason_translation_domain || entry.domain;
|
||||
const lokalisePromExc = hass
|
||||
.loadBackendTranslation("exceptions", translationDomain)
|
||||
.then(
|
||||
(localize) =>
|
||||
localize(
|
||||
`component.${translationDomain}.exceptions.${entry.error_reason_translation_key}.message`,
|
||||
entry.error_reason_translation_placeholders ?? undefined
|
||||
) || entry.reason
|
||||
);
|
||||
return html`${until(lokalisePromExc)}`;
|
||||
}
|
||||
const lokalisePromError = hass
|
||||
.loadBackendTranslation("config", entry.domain)
|
||||
.then(
|
||||
(localize) =>
|
||||
localize(`component.${entry.domain}.config.error.${entry.reason}`) ||
|
||||
entry.reason
|
||||
);
|
||||
return html`${until(lokalisePromError, entry.reason)}`;
|
||||
}
|
||||
return html`
|
||||
<br />
|
||||
<a href=${`/config/logs?search=${encodeURIComponent(entry.domain)}`}>
|
||||
${hass.localize(
|
||||
"ui.panel.config.integrations.config_entry.check_the_logs"
|
||||
)}
|
||||
</a>
|
||||
`;
|
||||
};
|
||||
|
||||
@customElement("ha-config-integration-page")
|
||||
class HaConfigIntegrationPage extends SubscribeMixin(LitElement) {
|
||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||
|
||||
@@ -55,7 +55,7 @@ import { haStyle } from "../../../../../resources/styles";
|
||||
import type { HomeAssistant, Route } from "../../../../../types";
|
||||
import { brandsUrl } from "../../../../../util/brands-url";
|
||||
import { fileDownload } from "../../../../../util/file_download";
|
||||
import { renderConfigEntryError } from "../../ha-config-integration-page";
|
||||
import { renderConfigEntryError } from "../../render-config-entry-error";
|
||||
import {
|
||||
attentionCount,
|
||||
devicesWithEntities,
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
import type { TemplateResult } from "lit";
|
||||
import { html } from "lit";
|
||||
import { until } from "lit/directives/until";
|
||||
import type { ConfigEntry } from "../../../data/config_entries";
|
||||
import type { HomeAssistant } from "../../../types";
|
||||
|
||||
export const renderConfigEntryError = (
|
||||
hass: Pick<HomeAssistant, "localize" | "loadBackendTranslation">,
|
||||
entry: ConfigEntry
|
||||
): TemplateResult => {
|
||||
if (entry.reason) {
|
||||
if (entry.error_reason_translation_key) {
|
||||
// The error may be translated by another integration, e.g. one raised by
|
||||
// a shared helper and owned by the homeassistant integration.
|
||||
const translationDomain =
|
||||
entry.error_reason_translation_domain || entry.domain;
|
||||
const lokalisePromExc = hass
|
||||
.loadBackendTranslation("exceptions", translationDomain)
|
||||
.then(
|
||||
(localize) =>
|
||||
localize(
|
||||
`component.${translationDomain}.exceptions.${entry.error_reason_translation_key}.message`,
|
||||
entry.error_reason_translation_placeholders ?? undefined
|
||||
) || entry.reason
|
||||
);
|
||||
return html`${until(lokalisePromExc)}`;
|
||||
}
|
||||
const lokalisePromError = hass
|
||||
.loadBackendTranslation("config", entry.domain)
|
||||
.then(
|
||||
(localize) =>
|
||||
localize(`component.${entry.domain}.config.error.${entry.reason}`) ||
|
||||
entry.reason
|
||||
);
|
||||
return html`${until(lokalisePromError, entry.reason)}`;
|
||||
}
|
||||
return html`
|
||||
<br />
|
||||
<a href=${`/config/logs?search=${encodeURIComponent(entry.domain)}`}>
|
||||
${hass.localize(
|
||||
"ui.panel.config.integrations.config_entry.check_the_logs"
|
||||
)}
|
||||
</a>
|
||||
`;
|
||||
};
|
||||
@@ -2082,8 +2082,33 @@
|
||||
"remote": {
|
||||
"activity": "Current activity"
|
||||
},
|
||||
"restored": {
|
||||
"no_longer_provided": "This entity is no longer being provided by the {integration} integration. If the entity is no longer in use, delete it in settings."
|
||||
"unavailable": {
|
||||
"not_found_title": "Entity not found",
|
||||
"not_found": "Home Assistant doesn't know this entity. It might have been deleted, or its entity ID might have changed.",
|
||||
"not_provided_title": "Entity isn't available",
|
||||
"not_provided": "The {integration} integration isn't providing this entity right now. If you just enabled it, it shows up once the integration has reloaded.",
|
||||
"disabled_title": "Entity is disabled",
|
||||
"disabled_by": {
|
||||
"user": "Home Assistant doesn't track or control this entity while it's disabled. Enable it to use it again.",
|
||||
"integration": "The {integration} integration disables this entity by default. Enable it to use it.",
|
||||
"config_entry": "The {integration} integration entry of this entity is disabled. Enable the entry to use this entity again.",
|
||||
"device": "The device of this entity is disabled. Enable the device to use this entity again."
|
||||
},
|
||||
"integration_state": {
|
||||
"setup_retry": "The {integration} integration can't connect right now and keeps trying.",
|
||||
"setup_error": "The {integration} integration couldn't be set up.",
|
||||
"setup_in_progress": "The {integration} integration is still starting.",
|
||||
"not_loaded": "The {integration} integration isn't loaded.",
|
||||
"no_longer_provided": "The {integration} integration isn't providing this entity. If you just enabled it, it shows up once the integration has reloaded. If you don't use it anymore, you can delete it in the settings."
|
||||
},
|
||||
"details": {
|
||||
"reason": "Reason",
|
||||
"unavailable_since": "Unavailable since",
|
||||
"last_known_state": "Last known state"
|
||||
},
|
||||
"enable_entity": "Enable entity",
|
||||
"open_device": "Open device",
|
||||
"open_integration": "Open integration"
|
||||
},
|
||||
"vacuum": {
|
||||
"status": "Status",
|
||||
|
||||
Reference in new issue
Block a user