Allow config entries to show the reason (#8974)

This commit is contained in:
Paulus Schoutsen 2021-04-23 00:25:09 -07:00 committed by GitHub
parent c296a60bab
commit 3f21c87a3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 8 deletions

View File

@ -39,6 +39,7 @@ const createConfigEntry = (
supports_options: false, supports_options: false,
supports_unload: true, supports_unload: true,
disabled_by: null, disabled_by: null,
reason: null,
...override, ...override,
}); });
@ -76,6 +77,10 @@ const migrationErrorEntry = createConfigEntry("Migration Error", {
const setupRetryEntry = createConfigEntry("Setup Retry", { const setupRetryEntry = createConfigEntry("Setup Retry", {
state: "setup_retry", state: "setup_retry",
}); });
const setupRetryReasonEntry = createConfigEntry("Setup Retry", {
state: "setup_retry",
reason: "Unable to connect",
});
const failedUnloadEntry = createConfigEntry("Failed Unload", { const failedUnloadEntry = createConfigEntry("Failed Unload", {
state: "failed_unload", state: "failed_unload",
}); });
@ -135,6 +140,7 @@ const configEntries: Array<{
{ items: [setupErrorEntry] }, { items: [setupErrorEntry] },
{ items: [migrationErrorEntry] }, { items: [migrationErrorEntry] },
{ items: [setupRetryEntry] }, { items: [setupRetryEntry] },
{ items: [setupRetryReasonEntry] },
{ items: [failedUnloadEntry] }, { items: [failedUnloadEntry] },
{ items: [notLoadedEntry] }, { items: [notLoadedEntry] },
{ {

View File

@ -16,6 +16,7 @@ export interface ConfigEntry {
supports_options: boolean; supports_options: boolean;
supports_unload: boolean; supports_unload: boolean;
disabled_by: "user" | null; disabled_by: "user" | null;
reason: string | null;
} }
export interface ConfigEntryMutableParams { export interface ConfigEntryMutableParams {

View File

@ -199,7 +199,9 @@ export class HaIntegrationCard extends LitElement {
stateText = [ stateText = [
`ui.panel.config.integrations.config_entry.state.${item.state}`, `ui.panel.config.integrations.config_entry.state.${item.state}`,
]; ];
stateTextExtra = html` stateTextExtra = item.reason
? html`: ${item.reason}`
: html`
<br /> <br />
<a href="/config/logs" <a href="/config/logs"
>${this.hass.localize( >${this.hass.localize(