mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-24 09:46:36 +00:00
20230301.0 (#15657)
This commit is contained in:
commit
db1f81e0ef
@ -119,7 +119,6 @@
|
||||
"lit/no-template-map": "off",
|
||||
"lit/no-native-attributes": "warn",
|
||||
"lit/no-this-assign-in-render": "warn",
|
||||
"lit/prefer-nothing": "warn",
|
||||
"lit-a11y/click-events-have-key-events": ["off"],
|
||||
"lit-a11y/no-autofocus": "off",
|
||||
"lit-a11y/alt-text": "warn",
|
||||
|
1
.github/dependabot.yml
vendored
1
.github/dependabot.yml
vendored
@ -18,4 +18,3 @@ updates:
|
||||
# Ignore rollup and plugins until everything else is updated
|
||||
- dependency-name: "*rollup*"
|
||||
- dependency-name: "@rollup/*"
|
||||
- dependency-name: "serve"
|
||||
|
@ -53,13 +53,25 @@ module.exports.definedVars = ({ isProdBuild, latestBuild, defineOverlay }) => ({
|
||||
...defineOverlay,
|
||||
});
|
||||
|
||||
const htmlMinifierOptions = {
|
||||
caseSensitive: true,
|
||||
collapseWhitespace: true,
|
||||
conservativeCollapse: true,
|
||||
decodeEntities: true,
|
||||
removeComments: true,
|
||||
removeRedundantAttributes: true,
|
||||
minifyCSS: {
|
||||
level: 0,
|
||||
},
|
||||
};
|
||||
|
||||
module.exports.terserOptions = (latestBuild) => ({
|
||||
safari10: !latestBuild,
|
||||
ecma: latestBuild ? undefined : 5,
|
||||
output: { comments: false },
|
||||
});
|
||||
|
||||
module.exports.babelOptions = ({ latestBuild }) => ({
|
||||
module.exports.babelOptions = ({ latestBuild, isProdBuild }) => ({
|
||||
babelrc: false,
|
||||
compact: false,
|
||||
presets: [
|
||||
@ -67,7 +79,7 @@ module.exports.babelOptions = ({ latestBuild }) => ({
|
||||
"@babel/preset-env",
|
||||
{
|
||||
useBuiltIns: "entry",
|
||||
corejs: { version: "3.28", proposals: true },
|
||||
corejs: { version: "3.29", proposals: true },
|
||||
bugfixes: true,
|
||||
},
|
||||
],
|
||||
@ -93,12 +105,26 @@ module.exports.babelOptions = ({ latestBuild }) => ({
|
||||
"@babel/plugin-syntax-import-meta",
|
||||
"@babel/plugin-syntax-dynamic-import",
|
||||
"@babel/plugin-syntax-top-level-await",
|
||||
// Support various proposals
|
||||
"@babel/plugin-proposal-optional-chaining",
|
||||
"@babel/plugin-proposal-nullish-coalescing-operator",
|
||||
["@babel/plugin-proposal-decorators", { decoratorsBeforeExport: true }],
|
||||
["@babel/plugin-proposal-private-methods", { loose: true }],
|
||||
["@babel/plugin-proposal-private-property-in-object", { loose: true }],
|
||||
["@babel/plugin-proposal-class-properties", { loose: true }],
|
||||
// Minify template literals for production
|
||||
isProdBuild && [
|
||||
"template-html-minifier",
|
||||
{
|
||||
modules: {
|
||||
lit: ["html", "svg", { name: "css", encapsulation: "style" }],
|
||||
"@polymer/polymer/lib/utils/html-tag": ["html"],
|
||||
},
|
||||
strictCSS: true,
|
||||
htmlMinifier: htmlMinifierOptions,
|
||||
failOnError: true, // we can turn this off in case of false positives
|
||||
},
|
||||
],
|
||||
].filter(Boolean),
|
||||
exclude: [
|
||||
// \\ for Windows, / for Mac OS and Linux
|
||||
|
@ -43,7 +43,14 @@ const createRollupConfig = ({
|
||||
preserveEntrySignatures: false,
|
||||
plugins: [
|
||||
ignore({
|
||||
files: bundle.emptyPackages({ latestBuild }),
|
||||
files: bundle
|
||||
.emptyPackages({ latestBuild })
|
||||
// TEMP HACK: Makes Rollup build work again
|
||||
.concat(
|
||||
require.resolve(
|
||||
"@webcomponents/scoped-custom-element-registry/scoped-custom-element-registry.min"
|
||||
)
|
||||
),
|
||||
}),
|
||||
resolve({
|
||||
extensions,
|
||||
@ -54,7 +61,7 @@ const createRollupConfig = ({
|
||||
commonjs(),
|
||||
json(),
|
||||
babel({
|
||||
...bundle.babelOptions({ latestBuild }),
|
||||
...bundle.babelOptions({ latestBuild, isProdBuild }),
|
||||
extensions,
|
||||
babelHelpers: isWDS ? "inline" : "bundled",
|
||||
}),
|
||||
|
@ -51,7 +51,7 @@ const createWebpackConfig = ({
|
||||
use: {
|
||||
loader: "babel-loader",
|
||||
options: {
|
||||
...bundle.babelOptions({ latestBuild }),
|
||||
...bundle.babelOptions({ latestBuild, isProdBuild }),
|
||||
cacheDirectory: !isProdBuild,
|
||||
cacheCompression: false,
|
||||
},
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { html, TemplateResult } from "lit";
|
||||
import { html, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { mockHistory } from "../../../../demo/src/stubs/history";
|
||||
import { LovelaceConfig } from "../../../../src/data/lovelace";
|
||||
@ -18,9 +18,9 @@ class HcDemo extends HassElement {
|
||||
|
||||
@state() private _lovelaceConfig?: LovelaceConfig;
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this._lovelaceConfig) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
return html`
|
||||
<hc-lovelace
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { mdiTelevision } from "@mdi/js";
|
||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
||||
import { customElement, state } from "lit/decorators";
|
||||
import { CastManager } from "../../../src/cast/cast_manager";
|
||||
import { castSendShowDemo } from "../../../src/cast/receiver_messages";
|
||||
@ -20,12 +20,12 @@ class CastDemoRow extends LitElement implements LovelaceRow {
|
||||
// No config possible.
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (
|
||||
!this._castManager ||
|
||||
this._castManager.castState === "NO_DEVICES_AVAILABLE"
|
||||
) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
return html`
|
||||
<ha-svg-icon .path=${mdiTelevision}></ha-svg-icon>
|
||||
|
@ -1,5 +1,5 @@
|
||||
import "@material/mwc-button";
|
||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { until } from "lit/directives/until";
|
||||
import "../../../src/components/ha-card";
|
||||
@ -30,9 +30,9 @@ export class HADemoCard extends LitElement implements LovelaceCard {
|
||||
|
||||
public setConfig(_config: LovelaceCardConfig) {}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (this._hidden) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
return html`
|
||||
<ha-card>
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { html, css } from "lit";
|
||||
import { css, html, nothing } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import { until } from "lit/directives/until";
|
||||
import { HaMarkdown } from "../../../src/components/ha-markdown";
|
||||
@ -10,7 +10,7 @@ class PageDescription extends HaMarkdown {
|
||||
|
||||
render() {
|
||||
if (!PAGES[this.page].description) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
|
||||
return html`
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { dump } from "js-yaml";
|
||||
import { html, css, LitElement, TemplateResult } from "lit";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import "../../../../src/components/ha-card";
|
||||
import "../../../../src/components/ha-yaml-editor";
|
||||
@ -127,9 +127,9 @@ export class DemoAutomationDescribeAction extends LitElement {
|
||||
|
||||
@state() _action = initialAction;
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this.hass) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
return html`
|
||||
<ha-card header="Actions">
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { dump } from "js-yaml";
|
||||
import { css, html, LitElement, TemplateResult } from "lit";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import "../../../../src/components/ha-card";
|
||||
import "../../../../src/components/ha-yaml-editor";
|
||||
@ -53,9 +53,9 @@ export class DemoAutomationDescribeCondition extends LitElement {
|
||||
|
||||
@state() _condition = initialCondition;
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this.hass) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
|
||||
return html`
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { dump } from "js-yaml";
|
||||
import { css, html, LitElement, TemplateResult } from "lit";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import "../../../../src/components/ha-card";
|
||||
import "../../../../src/components/ha-yaml-editor";
|
||||
@ -64,9 +64,9 @@ export class DemoAutomationDescribeTrigger extends LitElement {
|
||||
|
||||
@state() _trigger = initialTrigger;
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this.hass) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
|
||||
return html`
|
||||
|
@ -1,5 +1,6 @@
|
||||
/* eslint-disable lit/no-template-arrow */
|
||||
import { html, css, LitElement, TemplateResult } from "lit";
|
||||
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import "../../../../src/components/ha-card";
|
||||
import "../../../../src/components/trace/hat-script-graph";
|
||||
@ -29,9 +30,9 @@ const traces: DemoTrace[] = [
|
||||
export class DemoAutomationTraceTimeline extends LitElement {
|
||||
@property({ attribute: false }) hass?: HomeAssistant;
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this.hass) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
return html`
|
||||
${traces.map(
|
||||
|
@ -1,14 +1,15 @@
|
||||
/* eslint-disable lit/no-template-arrow */
|
||||
import { html, css, LitElement, TemplateResult } from "lit";
|
||||
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import "../../../../src/components/ha-card";
|
||||
import "../../../../src/components/trace/hat-script-graph";
|
||||
import "../../../../src/components/trace/hat-trace-timeline";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { provideHass } from "../../../../src/fake_data/provide_hass";
|
||||
import { HomeAssistant } from "../../../../src/types";
|
||||
import { DemoTrace } from "../../data/traces/types";
|
||||
import { basicTrace } from "../../data/traces/basic_trace";
|
||||
import { motionLightTrace } from "../../data/traces/motion-light-trace";
|
||||
import { DemoTrace } from "../../data/traces/types";
|
||||
|
||||
const traces: DemoTrace[] = [basicTrace, motionLightTrace];
|
||||
|
||||
@ -18,9 +19,9 @@ export class DemoAutomationTrace extends LitElement {
|
||||
|
||||
@state() private _selected = {};
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this.hass) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
return html`
|
||||
${traces.map(
|
||||
|
@ -2,7 +2,7 @@ import {
|
||||
HassEntity,
|
||||
HassEntityAttributeBase,
|
||||
} from "home-assistant-js-websocket";
|
||||
import { css, html, LitElement, TemplateResult } from "lit";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import memoizeOne from "memoize-one";
|
||||
import { computeDomain } from "../../../../src/common/entity/compute_domain";
|
||||
@ -387,9 +387,9 @@ export class DemoEntityState extends LitElement {
|
||||
hass.updateTranslations("config", "en");
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this.hass) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
|
||||
return html`
|
||||
|
@ -1,22 +1,22 @@
|
||||
import { html, css, LitElement, TemplateResult } from "lit";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import "../../../../src/components/ha-formfield";
|
||||
import "../../../../src/components/ha-switch";
|
||||
|
||||
import { classMap } from "lit/directives/class-map";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { classMap } from "lit/directives/class-map";
|
||||
import { IntegrationManifest } from "../../../../src/data/integration";
|
||||
|
||||
import { DeviceRegistryEntry } from "../../../../src/data/device_registry";
|
||||
import { EntityRegistryEntry } from "../../../../src/data/entity_registry";
|
||||
import { provideHass } from "../../../../src/fake_data/provide_hass";
|
||||
import { HomeAssistant } from "../../../../src/types";
|
||||
import "../../../../src/panels/config/integrations/ha-integration-card";
|
||||
import "../../../../src/panels/config/integrations/ha-ignored-config-entry-card";
|
||||
import "../../../../src/panels/config/integrations/ha-config-flow-card";
|
||||
import type {
|
||||
ConfigEntryExtended,
|
||||
DataEntryFlowProgressExtended,
|
||||
} from "../../../../src/panels/config/integrations/ha-config-integrations";
|
||||
import { DeviceRegistryEntry } from "../../../../src/data/device_registry";
|
||||
import { EntityRegistryEntry } from "../../../../src/data/entity_registry";
|
||||
import "../../../../src/panels/config/integrations/ha-ignored-config-entry-card";
|
||||
import "../../../../src/panels/config/integrations/ha-integration-card";
|
||||
import { HomeAssistant } from "../../../../src/types";
|
||||
|
||||
const createConfigEntry = (
|
||||
title: string,
|
||||
@ -231,9 +231,9 @@ export class DemoIntegrationCard extends LitElement {
|
||||
|
||||
@state() isCloud = false;
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this.hass) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
return html`
|
||||
<div class="container">
|
||||
|
@ -6,6 +6,7 @@ import {
|
||||
CSSResultGroup,
|
||||
html,
|
||||
LitElement,
|
||||
nothing,
|
||||
PropertyValues,
|
||||
TemplateResult,
|
||||
} from "lit";
|
||||
@ -73,8 +74,8 @@ export class HassioAddonStore extends LitElement {
|
||||
}
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
let repos: TemplateResult[] = [];
|
||||
protected render() {
|
||||
let repos: (TemplateResult | typeof nothing)[] = [];
|
||||
|
||||
if (this.supervisor.store.repositories) {
|
||||
repos = this.addonRepositories(
|
||||
@ -173,7 +174,7 @@ export class HassioAddonStore extends LitElement {
|
||||
.supervisor=${this.supervisor}
|
||||
></hassio-addon-repository>
|
||||
`
|
||||
: html``;
|
||||
: nothing;
|
||||
})
|
||||
);
|
||||
|
||||
|
@ -4,7 +4,7 @@ import {
|
||||
html,
|
||||
LitElement,
|
||||
PropertyValues,
|
||||
TemplateResult,
|
||||
nothing,
|
||||
} from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import memoizeOne from "memoize-one";
|
||||
@ -47,9 +47,9 @@ class HassioAddonNetwork extends LitElement {
|
||||
this._setNetworkConfig();
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this._config) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
|
||||
const hasHiddenOptions = Object.keys(this._config).find(
|
||||
|
@ -8,7 +8,7 @@ import {
|
||||
html,
|
||||
LitElement,
|
||||
PropertyValues,
|
||||
TemplateResult,
|
||||
nothing,
|
||||
} from "lit";
|
||||
import { customElement, property, query, state } from "lit/decorators";
|
||||
import { classMap } from "lit/directives/class-map";
|
||||
@ -160,9 +160,9 @@ export class HassioBackups extends LitElement {
|
||||
}))
|
||||
);
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this.supervisor) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
return html`
|
||||
<hass-tabs-subpage-data-table
|
||||
|
@ -1,6 +1,13 @@
|
||||
import { mdiFolder, mdiHomeAssistant, mdiPuzzle } from "@mdi/js";
|
||||
import { PaperInputElement } from "@polymer/paper-input/paper-input";
|
||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||
import {
|
||||
css,
|
||||
CSSResultGroup,
|
||||
html,
|
||||
LitElement,
|
||||
TemplateResult,
|
||||
nothing,
|
||||
} from "lit";
|
||||
import { customElement, property, query } from "lit/decorators";
|
||||
import { atLeastVersion } from "../../../src/common/config/version";
|
||||
import { formatDate } from "../../../src/common/datetime/format_date";
|
||||
@ -11,9 +18,9 @@ import "../../../src/components/ha-formfield";
|
||||
import "../../../src/components/ha-radio";
|
||||
import type { HaRadio } from "../../../src/components/ha-radio";
|
||||
import {
|
||||
HassioBackupDetail,
|
||||
HassioFullBackupCreateParams,
|
||||
HassioPartialBackupCreateParams,
|
||||
HassioBackupDetail,
|
||||
} from "../../../src/data/hassio/backup";
|
||||
import { Supervisor } from "../../../src/data/supervisor/supervisor";
|
||||
import { PolymerChangedEvent } from "../../../src/polymer-types";
|
||||
@ -115,9 +122,9 @@ export class SupervisorBackupContent extends LitElement {
|
||||
this.supervisor?.localize(`backup.${key}`) ||
|
||||
this.localize!(`ui.panel.page-onboarding.restore.${key}`);
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this.onboarding && !this.supervisor) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
const foldersSection =
|
||||
this.backupType === "partial" ? this._getSection("folders") : undefined;
|
||||
|
@ -1,6 +1,6 @@
|
||||
import "@material/mwc-button";
|
||||
import { mdiHomeAssistant } from "@mdi/js";
|
||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import memoizeOne from "memoize-one";
|
||||
import "../../../src/components/buttons/ha-progress-button";
|
||||
@ -33,14 +33,14 @@ export class HassioUpdate extends LitElement {
|
||||
).length
|
||||
);
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this.supervisor) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
|
||||
const updatesAvailable = this._pendingUpdates(this.supervisor);
|
||||
if (!updatesAvailable) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
|
||||
return html`
|
||||
@ -80,9 +80,9 @@ export class HassioUpdate extends LitElement {
|
||||
name: string,
|
||||
key: string,
|
||||
object: HassioHomeAssistantInfo | HassioSupervisorInfo | HassioHassOSInfo
|
||||
): TemplateResult {
|
||||
) {
|
||||
if (!object.update_available) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
return html`
|
||||
<ha-card outlined>
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { mdiClose } from "@mdi/js";
|
||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { fireEvent } from "../../../../src/common/dom/fire_event";
|
||||
import "../../../../src/components/ha-header-bar";
|
||||
@ -36,9 +36,9 @@ export class DialogHassioBackupUpload
|
||||
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this._dialogParams) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
|
||||
return html`
|
||||
|
@ -1,9 +1,11 @@
|
||||
import { ActionDetail } from "@material/mwc-list";
|
||||
import "@material/mwc-list/mwc-list-item";
|
||||
import { mdiClose, mdiDotsVertical } from "@mdi/js";
|
||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, query, state } from "lit/decorators";
|
||||
import { atLeastVersion } from "../../../../src/common/config/version";
|
||||
import { fireEvent } from "../../../../src/common/dom/fire_event";
|
||||
import { stopPropagation } from "../../../../src/common/dom/stop_propagation";
|
||||
import { slugify } from "../../../../src/common/string/slugify";
|
||||
import "../../../../src/components/buttons/ha-progress-button";
|
||||
import "../../../../src/components/ha-alert";
|
||||
@ -11,11 +13,11 @@ import "../../../../src/components/ha-button-menu";
|
||||
import "../../../../src/components/ha-header-bar";
|
||||
import "../../../../src/components/ha-icon-button";
|
||||
import { getSignedPath } from "../../../../src/data/auth";
|
||||
import { extractApiErrorMessage } from "../../../../src/data/hassio/common";
|
||||
import {
|
||||
fetchHassioBackupInfo,
|
||||
HassioBackupDetail,
|
||||
} from "../../../../src/data/hassio/backup";
|
||||
import { extractApiErrorMessage } from "../../../../src/data/hassio/common";
|
||||
import {
|
||||
showAlertDialog,
|
||||
showConfirmationDialog,
|
||||
@ -27,8 +29,6 @@ import { fileDownload } from "../../../../src/util/file_download";
|
||||
import "../../components/supervisor-backup-content";
|
||||
import type { SupervisorBackupContent } from "../../components/supervisor-backup-content";
|
||||
import { HassioBackupDialogParams } from "./show-dialog-hassio-backup";
|
||||
import { atLeastVersion } from "../../../../src/common/config/version";
|
||||
import { stopPropagation } from "../../../../src/common/dom/stop_propagation";
|
||||
|
||||
@customElement("dialog-hassio-backup")
|
||||
class HassioBackupDialog
|
||||
@ -62,9 +62,9 @@ class HassioBackupDialog
|
||||
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this._dialogParams || !this._backup) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
return html`
|
||||
<ha-dialog
|
||||
|
@ -1,15 +1,15 @@
|
||||
import "@material/mwc-button";
|
||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, query, state } from "lit/decorators";
|
||||
import { fireEvent } from "../../../../src/common/dom/fire_event";
|
||||
import "../../../../src/components/ha-alert";
|
||||
import "../../../../src/components/buttons/ha-progress-button";
|
||||
import "../../../../src/components/ha-alert";
|
||||
import { createCloseHeading } from "../../../../src/components/ha-dialog";
|
||||
import { extractApiErrorMessage } from "../../../../src/data/hassio/common";
|
||||
import {
|
||||
createHassioFullBackup,
|
||||
createHassioPartialBackup,
|
||||
} from "../../../../src/data/hassio/backup";
|
||||
import { extractApiErrorMessage } from "../../../../src/data/hassio/common";
|
||||
import { showAlertDialog } from "../../../../src/dialogs/generic/show-dialog-box";
|
||||
import { haStyle, haStyleDialog } from "../../../../src/resources/styles";
|
||||
import { HomeAssistant } from "../../../../src/types";
|
||||
@ -42,9 +42,9 @@ class HassioCreateBackupDialog extends LitElement {
|
||||
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this._dialogParams) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
return html`
|
||||
<ha-dialog
|
||||
|
@ -1,5 +1,5 @@
|
||||
import "@material/mwc-list/mwc-list-item";
|
||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import memoizeOne from "memoize-one";
|
||||
import { fireEvent } from "../../../../src/common/dom/fire_event";
|
||||
@ -55,9 +55,9 @@ class HassioDatadiskDialog extends LitElement {
|
||||
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this.dialogParams) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
return html`
|
||||
<ha-dialog
|
||||
|
8
hassio/src/dialogs/hardware/dialog-hassio-hardware.ts
Executable file → Normal file
8
hassio/src/dialogs/hardware/dialog-hassio-hardware.ts
Executable file → Normal file
@ -1,13 +1,13 @@
|
||||
import { mdiClose } from "@mdi/js";
|
||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import memoizeOne from "memoize-one";
|
||||
import { fireEvent } from "../../../../src/common/dom/fire_event";
|
||||
import "../../../../src/components/search-input";
|
||||
import { stringCompare } from "../../../../src/common/string/compare";
|
||||
import "../../../../src/components/ha-dialog";
|
||||
import "../../../../src/components/ha-expansion-panel";
|
||||
import "../../../../src/components/ha-icon-button";
|
||||
import "../../../../src/components/search-input";
|
||||
import { HassioHardwareInfo } from "../../../../src/data/hassio/hardware";
|
||||
import { dump } from "../../../../src/resources/js-yaml-dump";
|
||||
import { haStyle, haStyleDialog } from "../../../../src/resources/styles";
|
||||
@ -53,9 +53,9 @@ class HassioHardwareDialog extends LitElement {
|
||||
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this._dialogParams) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
|
||||
const devices = _filterDevices(
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { createCloseHeading } from "../../../../src/components/ha-dialog";
|
||||
import "../../../../src/components/ha-markdown";
|
||||
@ -27,9 +27,9 @@ class HassioMarkdownDialog extends LitElement {
|
||||
this._opened = false;
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this._opened) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
return html`
|
||||
<ha-dialog
|
||||
|
@ -5,7 +5,7 @@ import "@material/mwc-tab";
|
||||
import "@material/mwc-tab-bar";
|
||||
import { mdiClose } from "@mdi/js";
|
||||
import { PaperInputElement } from "@polymer/paper-input/paper-input";
|
||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { cache } from "lit/directives/cache";
|
||||
import { fireEvent } from "../../../../src/common/dom/fire_event";
|
||||
@ -83,9 +83,9 @@ export class DialogHassioNetwork
|
||||
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this._params || !this._interface) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
|
||||
return html`
|
||||
|
@ -1,11 +1,11 @@
|
||||
import "@polymer/paper-tooltip/paper-tooltip";
|
||||
import "@material/mwc-button/mwc-button";
|
||||
import { mdiDelete, mdiDeleteOff } from "@mdi/js";
|
||||
import "@polymer/paper-input/paper-input";
|
||||
import type { PaperInputElement } from "@polymer/paper-input/paper-input";
|
||||
import "@polymer/paper-item/paper-item";
|
||||
import "@polymer/paper-item/paper-item-body";
|
||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||
import "@polymer/paper-tooltip/paper-tooltip";
|
||||
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, query, state } from "lit/decorators";
|
||||
import memoizeOne from "memoize-one";
|
||||
import { fireEvent } from "../../../../src/common/dom/fire_event";
|
||||
@ -19,14 +19,14 @@ import {
|
||||
HassioAddonRepository,
|
||||
} from "../../../../src/data/hassio/addon";
|
||||
import { extractApiErrorMessage } from "../../../../src/data/hassio/common";
|
||||
import { haStyle, haStyleDialog } from "../../../../src/resources/styles";
|
||||
import type { HomeAssistant } from "../../../../src/types";
|
||||
import { HassioRepositoryDialogParams } from "./show-dialog-repositories";
|
||||
import {
|
||||
addStoreRepository,
|
||||
fetchStoreRepositories,
|
||||
removeStoreRepository,
|
||||
} from "../../../../src/data/supervisor/store";
|
||||
import { haStyle, haStyleDialog } from "../../../../src/resources/styles";
|
||||
import type { HomeAssistant } from "../../../../src/types";
|
||||
import { HassioRepositoryDialogParams } from "./show-dialog-repositories";
|
||||
|
||||
@customElement("dialog-hassio-repositories")
|
||||
class HassioRepositoriesDialog extends LitElement {
|
||||
@ -82,9 +82,9 @@ class HassioRepositoriesDialog extends LitElement {
|
||||
.map((repo) => repo.slug)
|
||||
);
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this._dialogParams?.supervisor || this._repositories === undefined) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
const repositories = this._filteredRepositories(this._repositories);
|
||||
const usedRepositories = this._filteredUsedRepositories(
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { sanitizeUrl } from "@braintree/sanitize-url";
|
||||
import { html, LitElement, TemplateResult } from "lit";
|
||||
import { html, LitElement, TemplateResult, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { navigate } from "../../src/common/navigate";
|
||||
import {
|
||||
@ -101,13 +101,13 @@ class HassioMyRedirect extends LitElement {
|
||||
navigate(url, { replace: true });
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (this._error) {
|
||||
return html`<hass-error-screen
|
||||
.error=${this._error}
|
||||
></hass-error-screen>`;
|
||||
}
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
|
||||
private _createRedirectUrl(redirect: Redirect): string {
|
||||
|
@ -5,7 +5,7 @@ import {
|
||||
html,
|
||||
LitElement,
|
||||
PropertyValues,
|
||||
TemplateResult,
|
||||
nothing,
|
||||
} from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import memoizeOne from "memoize-one";
|
||||
@ -116,12 +116,12 @@ class UpdateAvailableCard extends LitElement {
|
||||
storeAddons.find((addon) => addon.slug === slug)
|
||||
);
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (
|
||||
!this._updateType ||
|
||||
(this._updateType === "addon" && !this._addonInfo)
|
||||
) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
|
||||
const changelog = changelogUrl(this._updateType, this._version_latest);
|
||||
|
12
package.json
12
package.json
@ -100,7 +100,7 @@
|
||||
"app-datepicker": "^5.1.0",
|
||||
"chart.js": "^3.3.2",
|
||||
"comlink": "^4.4.1",
|
||||
"core-js": "^3.28.0",
|
||||
"core-js": "^3.29.0",
|
||||
"cropperjs": "^1.5.13",
|
||||
"date-fns": "^2.29.3",
|
||||
"date-fns-tz": "^2.0.0",
|
||||
@ -108,7 +108,7 @@
|
||||
"deep-freeze": "^0.0.1",
|
||||
"fuse.js": "^6.6.2",
|
||||
"google-timezones-json": "^1.0.2",
|
||||
"hls.js": "^1.3.3",
|
||||
"hls.js": "^1.3.4",
|
||||
"home-assistant-js-websocket": "^8.0.1",
|
||||
"idb-keyval": "^6.2.0",
|
||||
"intl-messageformat": "^10.3.1",
|
||||
@ -178,14 +178,16 @@
|
||||
"@types/marked": "^4",
|
||||
"@types/mocha": "^10",
|
||||
"@types/qrcode": "^1.5.0",
|
||||
"@types/serve-handler": "^6",
|
||||
"@types/sortablejs": "^1",
|
||||
"@types/tar": "^6",
|
||||
"@types/webspeechapi": "^0.0.29",
|
||||
"@typescript-eslint/eslint-plugin": "^5.53.0",
|
||||
"@typescript-eslint/parser": "^5.53.0",
|
||||
"@typescript-eslint/eslint-plugin": "^5.54.0",
|
||||
"@typescript-eslint/parser": "^5.54.0",
|
||||
"@web/dev-server": "^0.1.35",
|
||||
"@web/dev-server-rollup": "^0.2.11",
|
||||
"babel-loader": "^9.1.2",
|
||||
"babel-plugin-template-html-minifier": "^4.1.0",
|
||||
"chai": "^4.3.7",
|
||||
"del": "^7.0.0",
|
||||
"eslint": "^8.35.0",
|
||||
@ -229,7 +231,7 @@
|
||||
"rollup-plugin-string": "^3.0.0",
|
||||
"rollup-plugin-terser": "^5.3.0",
|
||||
"rollup-plugin-visualizer": "^5.9.0",
|
||||
"serve": "^11.3.2",
|
||||
"serve-handler": "^6.1.5",
|
||||
"sinon": "^15.0.1",
|
||||
"source-map-url": "^0.4.1",
|
||||
"systemjs": "^6.14.0",
|
||||
|
@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "home-assistant-frontend"
|
||||
version = "20230227.0"
|
||||
version = "20230301.0"
|
||||
license = {text = "Apache-2.0"}
|
||||
description = "The Home Assistant frontend"
|
||||
readme = "README.md"
|
||||
|
@ -5,8 +5,8 @@ import {
|
||||
CSSResultGroup,
|
||||
html,
|
||||
LitElement,
|
||||
nothing,
|
||||
PropertyValues,
|
||||
TemplateResult,
|
||||
} from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import "../components/ha-alert";
|
||||
@ -134,11 +134,11 @@ export class HaAuthFlow extends litLocalizeLiteMixin(LitElement) {
|
||||
}, 500);
|
||||
}
|
||||
|
||||
private _renderForm(): TemplateResult {
|
||||
private _renderForm() {
|
||||
switch (this._state) {
|
||||
case "step":
|
||||
if (this._step == null) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
return html`
|
||||
${this._renderStep(this._step)}
|
||||
@ -176,11 +176,11 @@ export class HaAuthFlow extends litLocalizeLiteMixin(LitElement) {
|
||||
</ha-alert>
|
||||
`;
|
||||
default:
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
}
|
||||
|
||||
private _renderStep(step: DataEntryFlowStep): TemplateResult {
|
||||
private _renderStep(step: DataEntryFlowStep) {
|
||||
switch (step.type) {
|
||||
case "abort":
|
||||
return html`
|
||||
@ -202,7 +202,7 @@ export class HaAuthFlow extends litLocalizeLiteMixin(LitElement) {
|
||||
.content=${this._computeStepDescription(step)}
|
||||
></ha-markdown>
|
||||
`
|
||||
: html``}
|
||||
: nothing}
|
||||
<ha-form
|
||||
.data=${this._stepData}
|
||||
.schema=${autocompleteLoginFields(step.data_schema)}
|
||||
@ -228,7 +228,7 @@ export class HaAuthFlow extends litLocalizeLiteMixin(LitElement) {
|
||||
: ""}
|
||||
`;
|
||||
default:
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
/** Constants to be used in the frontend. */
|
||||
|
||||
import {
|
||||
mdiAccount,
|
||||
mdiAirFilter,
|
||||
mdiAlert,
|
||||
mdiAngleAcute,
|
||||
@ -48,7 +47,6 @@ import {
|
||||
mdiProgressClock,
|
||||
mdiRayVertex,
|
||||
mdiRemote,
|
||||
mdiRobot,
|
||||
mdiRobotVacuum,
|
||||
mdiScriptText,
|
||||
mdiSineWave,
|
||||
@ -59,15 +57,12 @@ import {
|
||||
mdiThermostat,
|
||||
mdiTimerOutline,
|
||||
mdiTransmissionTower,
|
||||
mdiVideo,
|
||||
mdiWater,
|
||||
mdiWaterPercent,
|
||||
mdiWeatherCloudy,
|
||||
mdiWeatherPouring,
|
||||
mdiWeatherRainy,
|
||||
mdiWeatherWindy,
|
||||
mdiWeight,
|
||||
mdiWhiteBalanceSunny,
|
||||
mdiWifi,
|
||||
} from "@mdi/js";
|
||||
|
||||
@ -82,9 +77,7 @@ export const DEFAULT_DOMAIN_ICON = mdiBookmark;
|
||||
export const FIXED_DOMAIN_ICONS = {
|
||||
alert: mdiAlert,
|
||||
air_quality: mdiAirFilter,
|
||||
automation: mdiRobot,
|
||||
calendar: mdiCalendar,
|
||||
camera: mdiVideo,
|
||||
climate: mdiThermostat,
|
||||
configurator: mdiCog,
|
||||
conversation: mdiMicrophoneMessage,
|
||||
@ -105,7 +98,6 @@ export const FIXED_DOMAIN_ICONS = {
|
||||
notify: mdiCommentAlert,
|
||||
number: mdiRayVertex,
|
||||
persistent_notification: mdiBell,
|
||||
person: mdiAccount,
|
||||
plant: mdiFlower,
|
||||
proximity: mdiAppleSafari,
|
||||
remote: mdiRemote,
|
||||
@ -116,13 +108,10 @@ export const FIXED_DOMAIN_ICONS = {
|
||||
sensor: mdiEye,
|
||||
siren: mdiBullhorn,
|
||||
simple_alarm: mdiBell,
|
||||
sun: mdiWhiteBalanceSunny,
|
||||
text: mdiFormTextbox,
|
||||
timer: mdiTimerOutline,
|
||||
updater: mdiCloudUpload,
|
||||
vacuum: mdiRobotVacuum,
|
||||
water_heater: mdiThermometer,
|
||||
weather: mdiWeatherCloudy,
|
||||
zone: mdiMapMarkerRadius,
|
||||
};
|
||||
|
||||
|
@ -30,6 +30,8 @@ import {
|
||||
mdiPowerPlug,
|
||||
mdiPowerPlugOff,
|
||||
mdiRestart,
|
||||
mdiRobot,
|
||||
mdiRobotOff,
|
||||
mdiSpeaker,
|
||||
mdiSpeakerOff,
|
||||
mdiSpeakerPause,
|
||||
@ -41,7 +43,12 @@ import {
|
||||
mdiTelevisionPlay,
|
||||
mdiToggleSwitchVariant,
|
||||
mdiToggleSwitchVariantOff,
|
||||
mdiVideo,
|
||||
mdiVideoOff,
|
||||
mdiWaterBoiler,
|
||||
mdiWaterBoilerOff,
|
||||
mdiWeatherNight,
|
||||
mdiWhiteBalanceSunny,
|
||||
} from "@mdi/js";
|
||||
import { HassEntity } from "home-assistant-js-websocket";
|
||||
import { UpdateEntity, updateIsInstalling } from "../../data/update";
|
||||
@ -83,6 +90,9 @@ export const domainIconWithoutDefault = (
|
||||
case "alarm_control_panel":
|
||||
return alarmPanelIcon(compareState);
|
||||
|
||||
case "automation":
|
||||
return compareState === "off" ? mdiRobotOff : mdiRobot;
|
||||
|
||||
case "binary_sensor":
|
||||
return binarySensorIcon(compareState, stateObj);
|
||||
|
||||
@ -96,6 +106,9 @@ export const domainIconWithoutDefault = (
|
||||
return mdiGestureTapButton;
|
||||
}
|
||||
|
||||
case "camera":
|
||||
return compareState === "off" ? mdiVideoOff : mdiVideo;
|
||||
|
||||
case "cover":
|
||||
return coverIcon(compareState, stateObj);
|
||||
|
||||
@ -221,7 +234,7 @@ export const domainIconWithoutDefault = (
|
||||
|
||||
case "sun":
|
||||
return stateObj?.state === "above_horizon"
|
||||
? FIXED_DOMAIN_ICONS[domain]
|
||||
? mdiWhiteBalanceSunny
|
||||
: mdiWeatherNight;
|
||||
|
||||
case "switch_as_x":
|
||||
@ -237,6 +250,9 @@ export const domainIconWithoutDefault = (
|
||||
: mdiPackageUp
|
||||
: mdiPackage;
|
||||
|
||||
case "water_heater":
|
||||
return compareState === "off" ? mdiWaterBoilerOff : mdiWaterBoiler;
|
||||
|
||||
case "weather":
|
||||
return weatherIcon(stateObj?.state);
|
||||
}
|
||||
|
@ -143,7 +143,10 @@ export class StateHistoryChartTimeline extends LitElement {
|
||||
}
|
||||
},
|
||||
afterUpdate: (y) => {
|
||||
if (this._yWidth !== Math.floor(y.width)) {
|
||||
if (
|
||||
this._yWidth !== Math.floor(y.width) &&
|
||||
y.ticks.length === this.data.length
|
||||
) {
|
||||
this._yWidth = Math.floor(y.width);
|
||||
fireEvent(this, "y-width-changed", {
|
||||
value: this._yWidth,
|
||||
|
@ -4,11 +4,12 @@ import {
|
||||
CSSResultGroup,
|
||||
html,
|
||||
LitElement,
|
||||
nothing,
|
||||
PropertyValues,
|
||||
TemplateResult,
|
||||
} from "lit";
|
||||
import { customElement, property, state, eventOptions } from "lit/decorators";
|
||||
import { customElement, eventOptions, property, state } from "lit/decorators";
|
||||
import { isComponentLoaded } from "../../common/config/is_component_loaded";
|
||||
import { restoreScroll } from "../../common/decorators/restore-scroll";
|
||||
import {
|
||||
HistoryResult,
|
||||
LineChartUnit,
|
||||
@ -17,7 +18,6 @@ import {
|
||||
import type { HomeAssistant } from "../../types";
|
||||
import "./state-history-chart-line";
|
||||
import "./state-history-chart-timeline";
|
||||
import { restoreScroll } from "../../common/decorators/restore-scroll";
|
||||
|
||||
const CANVAS_TIMELINE_ROWS_CHUNK = 10; // Split up the canvases to avoid hitting the render limit
|
||||
|
||||
@ -71,7 +71,7 @@ export class StateHistoryCharts extends LitElement {
|
||||
// @ts-ignore
|
||||
@restoreScroll(".container") private _savedScrollPos?: number;
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!isComponentLoaded(this.hass, "history")) {
|
||||
return html`<div class="info">
|
||||
${this.hass.localize("ui.components.history_charts.history_disabled")}
|
||||
@ -130,9 +130,9 @@ export class StateHistoryCharts extends LitElement {
|
||||
private _renderHistoryItem = (
|
||||
item: TimelineEntity[] | LineChartUnit,
|
||||
index: number
|
||||
): TemplateResult => {
|
||||
) => {
|
||||
if (!item || index === undefined) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
if (!Array.isArray(item)) {
|
||||
return html`<div class="entry-container">
|
||||
|
@ -6,6 +6,7 @@ import {
|
||||
CSSResultGroup,
|
||||
html,
|
||||
LitElement,
|
||||
nothing,
|
||||
PropertyValues,
|
||||
TemplateResult,
|
||||
} from "lit";
|
||||
@ -73,7 +74,7 @@ export interface DataTableColumnData<T = any> extends DataTableSortColumnData {
|
||||
title: TemplateResult | string;
|
||||
label?: TemplateResult | string;
|
||||
type?: "numeric" | "icon" | "icon-button" | "overflow-menu";
|
||||
template?: (data: any, row: T) => TemplateResult | string;
|
||||
template?: (data: any, row: T) => TemplateResult | string | typeof nothing;
|
||||
width?: string;
|
||||
maxWidth?: string;
|
||||
grows?: boolean;
|
||||
@ -352,13 +353,10 @@ export class HaDataTable extends LitElement {
|
||||
`;
|
||||
}
|
||||
|
||||
private _renderRow = (
|
||||
row: DataTableRowData,
|
||||
index: number
|
||||
): TemplateResult => {
|
||||
private _renderRow = (row: DataTableRowData, index: number) => {
|
||||
// not sure how this happens...
|
||||
if (!row) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
if (row.append) {
|
||||
return html` <div class="mdc-data-table__row">${row.content}</div> `;
|
||||
|
@ -67,11 +67,11 @@ const sortData = (
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure "undefined" is always sorted to the bottom
|
||||
if (valA === undefined && valB !== undefined) {
|
||||
// Ensure "undefined" and "null" are always sorted to the bottom
|
||||
if (valA == null && valB != null) {
|
||||
return 1;
|
||||
}
|
||||
if (valB === undefined && valA !== undefined) {
|
||||
if (valB == null && valA != null) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
import "@material/mwc-button/mwc-button";
|
||||
import { UnsubscribeFunc } from "home-assistant-js-websocket";
|
||||
import { html, LitElement, PropertyValues, TemplateResult } from "lit";
|
||||
import { ComboBoxLitRenderer } from "@vaadin/combo-box/lit";
|
||||
import { UnsubscribeFunc } from "home-assistant-js-websocket";
|
||||
import { html, LitElement, PropertyValues, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import memoizeOne from "memoize-one";
|
||||
import { fireEvent } from "../../common/dom/fire_event";
|
||||
@ -230,9 +230,9 @@ export class HaAreaDevicesPicker extends SubscribeMixin(LitElement) {
|
||||
}
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this._devices || !this._areas || !this._entities) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
const areas = this._getAreasWithDevices(
|
||||
this._devices,
|
||||
|
@ -1,5 +1,5 @@
|
||||
import "@material/mwc-list/mwc-list-item";
|
||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
||||
import { property, state } from "lit/decorators";
|
||||
import { fireEvent } from "../../common/dom/fire_event";
|
||||
import {
|
||||
@ -85,9 +85,9 @@ export abstract class HaDeviceAutomationPicker<
|
||||
return `${this._automations[idx].device_id}_${idx}`;
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (this._renderEmpty) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
const value = this._value;
|
||||
return html`
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { css, html, LitElement, TemplateResult } from "lit";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import { fireEvent } from "../../common/dom/fire_event";
|
||||
import { PolymerChangedEvent } from "../../polymer-types";
|
||||
@ -49,9 +49,9 @@ class HaDevicesPicker extends LitElement {
|
||||
|
||||
@property() public entityFilter?: HaDevicePickerEntityFilterFunc;
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this.hass) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
|
||||
const currentDevices = this._currentDevices;
|
||||
|
@ -1,5 +1,5 @@
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import { css, html, LitElement, TemplateResult } from "lit";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import memoizeOne from "memoize-one";
|
||||
import { fireEvent } from "../../common/dom/fire_event";
|
||||
@ -76,9 +76,9 @@ class HaEntitiesPickerLight extends LitElement {
|
||||
|
||||
@property() public entityFilter?: HaEntityPickerEntityFilterFunc;
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this.hass) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
|
||||
const currentEntities = this._currentEntities;
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { HassEntity } from "home-assistant-js-websocket";
|
||||
import { html, LitElement, PropertyValues, TemplateResult } from "lit";
|
||||
import { html, LitElement, PropertyValues, nothing } from "lit";
|
||||
import { customElement, property, query } from "lit/decorators";
|
||||
import { formatAttributeName } from "../../data/entity_attributes";
|
||||
import { PolymerChangedEvent } from "../../polymer-types";
|
||||
@ -60,9 +60,9 @@ class HaEntityAttributePicker extends LitElement {
|
||||
}
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this.hass) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
|
||||
return html`
|
||||
|
@ -1,14 +1,14 @@
|
||||
import { HassEntity } from "home-assistant-js-websocket";
|
||||
import { html, LitElement, PropertyValues, TemplateResult } from "lit";
|
||||
import { html, LitElement, PropertyValues, nothing } from "lit";
|
||||
import { customElement, property, query } from "lit/decorators";
|
||||
import { fireEvent } from "../../common/dom/fire_event";
|
||||
import { computeStateDisplay } from "../../common/entity/compute_state_display";
|
||||
import { PolymerChangedEvent } from "../../polymer-types";
|
||||
import { getStates } from "../../common/entity/get_states";
|
||||
import { formatAttributeValue } from "../../data/entity_attributes";
|
||||
import { PolymerChangedEvent } from "../../polymer-types";
|
||||
import { HomeAssistant } from "../../types";
|
||||
import "../ha-combo-box";
|
||||
import type { HaComboBox } from "../ha-combo-box";
|
||||
import { formatAttributeValue } from "../../data/entity_attributes";
|
||||
import { fireEvent } from "../../common/dom/fire_event";
|
||||
|
||||
export type HaEntityPickerEntityFilterFunc = (entityId: HassEntity) => boolean;
|
||||
|
||||
@ -64,9 +64,9 @@ class HaEntityStatePicker extends LitElement {
|
||||
}
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this.hass) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
|
||||
return html`
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import { fireEvent } from "../../common/dom/fire_event";
|
||||
import type { PolymerChangedEvent } from "../../polymer-types";
|
||||
@ -56,9 +56,9 @@ class HaStatisticsPicker extends LitElement {
|
||||
})
|
||||
public ignoreRestrictionsOnFirstStatistic = false;
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this.hass) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
|
||||
const ignoreRestriction =
|
||||
|
@ -6,7 +6,7 @@ import {
|
||||
html,
|
||||
LitElement,
|
||||
PropertyValues,
|
||||
TemplateResult,
|
||||
nothing,
|
||||
} from "lit";
|
||||
import { property, state } from "lit/decorators";
|
||||
import { ifDefined } from "lit/directives/if-defined";
|
||||
@ -45,7 +45,7 @@ export class StateBadge extends LitElement {
|
||||
return this.stateColor || (domain === "light" && this.stateColor !== false);
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
const stateObj = this.stateObj;
|
||||
|
||||
// We either need a `stateObj` or one override
|
||||
@ -56,7 +56,7 @@ export class StateBadge extends LitElement {
|
||||
}
|
||||
|
||||
if (!this._showIcon) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
|
||||
const domain = stateObj ? computeStateDomain(stateObj) : undefined;
|
||||
|
@ -1,6 +1,6 @@
|
||||
import "@polymer/paper-tooltip/paper-tooltip";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import { computeStateName } from "../../common/entity/compute_state_name";
|
||||
import { computeRTL } from "../../common/util/compute_rtl";
|
||||
@ -21,9 +21,9 @@ class StateInfo extends LitElement {
|
||||
|
||||
@property() public color?: string;
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this.hass || !this.stateObj) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
|
||||
const name = computeStateName(this.stateObj);
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { html, LitElement, TemplateResult } from "lit";
|
||||
import { ComboBoxLitRenderer } from "@vaadin/combo-box/lit";
|
||||
import { html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, query, state } from "lit/decorators";
|
||||
import { isComponentLoaded } from "../common/config/is_component_loaded";
|
||||
import { fireEvent } from "../common/dom/fire_event";
|
||||
@ -54,9 +54,9 @@ class HaAddonPicker extends LitElement {
|
||||
this._getAddons();
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this._addons) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
return html`
|
||||
<ha-combo-box
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { HassEntity } from "home-assistant-js-websocket";
|
||||
import { css, html, LitElement, TemplateResult } from "lit";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import { fireEvent } from "../common/dom/fire_event";
|
||||
import { SubscribeMixin } from "../mixins/subscribe-mixin";
|
||||
@ -60,9 +60,9 @@ export class HaAreasPicker extends SubscribeMixin(LitElement) {
|
||||
|
||||
@property({ type: Boolean }) public required?: boolean;
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this.hass) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
|
||||
const currentAreas = this._currentAreas;
|
||||
|
@ -1,5 +1,12 @@
|
||||
import { HassEntity } from "home-assistant-js-websocket";
|
||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||
import {
|
||||
css,
|
||||
CSSResultGroup,
|
||||
html,
|
||||
LitElement,
|
||||
TemplateResult,
|
||||
nothing,
|
||||
} from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import {
|
||||
formatAttributeName,
|
||||
@ -21,9 +28,9 @@ class HaAttributes extends LitElement {
|
||||
|
||||
@state() private _expanded = false;
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this.stateObj) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
|
||||
const attributes = this.computeDisplayAttributes(
|
||||
@ -32,7 +39,7 @@ class HaAttributes extends LitElement {
|
||||
)
|
||||
);
|
||||
if (attributes.length === 0) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
|
||||
return html`
|
||||
|
@ -1,5 +1,5 @@
|
||||
import "@material/mwc-list/mwc-list-item";
|
||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import memoizeOne from "memoize-one";
|
||||
import { fireEvent } from "../common/dom/fire_event";
|
||||
@ -51,9 +51,9 @@ class HaBluePrintPicker extends LitElement {
|
||||
);
|
||||
});
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this.hass) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
return html`
|
||||
<ha-select
|
||||
|
@ -4,7 +4,7 @@ import {
|
||||
html,
|
||||
LitElement,
|
||||
PropertyValues,
|
||||
TemplateResult,
|
||||
nothing,
|
||||
} from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { isComponentLoaded } from "../common/config/is_component_loaded";
|
||||
@ -76,9 +76,9 @@ export class HaCameraStream extends LitElement {
|
||||
this._connected = false;
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this.stateObj) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
if (__DEMO__ || this._shouldRenderMJPEG) {
|
||||
return html`<img
|
||||
@ -102,7 +102,7 @@ export class HaCameraStream extends LitElement {
|
||||
.url=${this._url}
|
||||
.posterUrl=${this._posterUrl}
|
||||
></ha-hls-player>`
|
||||
: html``;
|
||||
: nothing;
|
||||
}
|
||||
if (this.stateObj.attributes.frontend_stream_type === STREAM_TYPE_WEB_RTC) {
|
||||
return html`<ha-web-rtc-player
|
||||
@ -115,7 +115,7 @@ export class HaCameraStream extends LitElement {
|
||||
.posterUrl=${this._posterUrl}
|
||||
></ha-web-rtc-player>`;
|
||||
}
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
|
||||
private get _shouldRenderMJPEG() {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
|
||||
@customElement("ha-card")
|
||||
@ -70,11 +70,11 @@ export class HaCard extends LitElement {
|
||||
`;
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
return html`
|
||||
${this.header
|
||||
? html`<h1 class="card-header">${this.header}</h1>`
|
||||
: html``}
|
||||
: nothing}
|
||||
<slot></slot>
|
||||
`;
|
||||
}
|
||||
|
@ -1,16 +1,16 @@
|
||||
import "@material/mwc-list/mwc-list-item";
|
||||
import { html, LitElement, TemplateResult } from "lit";
|
||||
import { ComboBoxLitRenderer } from "@vaadin/combo-box/lit";
|
||||
import { html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, query, state } from "lit/decorators";
|
||||
import { fireEvent } from "../common/dom/fire_event";
|
||||
import { PolymerChangedEvent } from "../polymer-types";
|
||||
import { HomeAssistant } from "../types";
|
||||
import type { HaComboBox } from "./ha-combo-box";
|
||||
import { caseInsensitiveStringCompare } from "../common/string/compare";
|
||||
import { ConfigEntry, getConfigEntries } from "../data/config_entries";
|
||||
import { domainToName } from "../data/integration";
|
||||
import { caseInsensitiveStringCompare } from "../common/string/compare";
|
||||
import { PolymerChangedEvent } from "../polymer-types";
|
||||
import { HomeAssistant } from "../types";
|
||||
import { brandsUrl } from "../util/brands-url";
|
||||
import "./ha-combo-box";
|
||||
import type { HaComboBox } from "./ha-combo-box";
|
||||
|
||||
export interface ConfigEntryExtended extends ConfigEntry {
|
||||
localized_domain_name?: string;
|
||||
@ -72,9 +72,9 @@ class HaConfigEntryPicker extends LitElement {
|
||||
/>
|
||||
</mwc-list-item>`;
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this._configEntries) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
return html`
|
||||
<ha-combo-box
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { mdiStop } from "@mdi/js";
|
||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import { classMap } from "lit/directives/class-map";
|
||||
import { computeCloseIcon, computeOpenIcon } from "../common/entity/cover_icon";
|
||||
@ -20,9 +20,9 @@ class HaCoverControls extends LitElement {
|
||||
|
||||
@property({ attribute: false }) public stateObj!: CoverEntity;
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this.stateObj) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
|
||||
return html`
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { mdiArrowBottomLeft, mdiArrowTopRight, mdiStop } from "@mdi/js";
|
||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import { classMap } from "lit/directives/class-map";
|
||||
import { supportsFeature } from "../common/entity/supports-feature";
|
||||
@ -19,9 +19,9 @@ class HaCoverTiltControls extends LitElement {
|
||||
|
||||
@property({ attribute: false }) stateObj!: CoverEntity;
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this.stateObj) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
|
||||
return html` <ha-icon-button
|
||||
|
@ -1,6 +1,6 @@
|
||||
import "@material/mwc-button/mwc-button";
|
||||
import "app-datepicker";
|
||||
import { css, html, LitElement } from "lit";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { fireEvent } from "../common/dom/fire_event";
|
||||
import { nextRender } from "../common/util/render-status";
|
||||
@ -38,7 +38,7 @@ export class HaDialogDatePicker extends LitElement {
|
||||
|
||||
render() {
|
||||
if (!this._params) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
return html`<ha-dialog open @closed=${this.closeDialog}>
|
||||
<app-datepicker
|
||||
|
@ -5,7 +5,7 @@ import {
|
||||
html,
|
||||
LitElement,
|
||||
PropertyValues,
|
||||
TemplateResult,
|
||||
nothing,
|
||||
} from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { fireEvent } from "../common/dom/fire_event";
|
||||
@ -156,9 +156,9 @@ export class HaIcon extends LitElement {
|
||||
}
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this.icon) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
if (this._legacy) {
|
||||
return html`<iron-icon .icon=${this.icon}></iron-icon>`;
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import "./ha-markdown-element";
|
||||
|
||||
@ -15,9 +15,9 @@ export class HaMarkdown extends LitElement {
|
||||
|
||||
@property({ type: Boolean }) public breaks = false;
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this.content) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
|
||||
return html`<ha-markdown-element
|
||||
|
@ -54,9 +54,9 @@ export class HaNetwork extends LitElement {
|
||||
|
||||
@state() private _expanded?: boolean;
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (this.networkConfig === undefined) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
const configured_adapters = this.networkConfig.configured_adapters || [];
|
||||
return html`
|
||||
|
@ -5,7 +5,7 @@ import {
|
||||
html,
|
||||
LitElement,
|
||||
PropertyValues,
|
||||
TemplateResult,
|
||||
nothing,
|
||||
} from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { fireEvent } from "../common/dom/fire_event";
|
||||
@ -70,9 +70,9 @@ export class HaRelatedItems extends SubscribeMixin(LitElement) {
|
||||
}
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this._related) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
if (Object.keys(this._related).length === 0) {
|
||||
return html`
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { HassEntity } from "home-assistant-js-websocket";
|
||||
import { html, LitElement, PropertyValues, TemplateResult } from "lit";
|
||||
import { html, LitElement, PropertyValues, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import memoizeOne from "memoize-one";
|
||||
import { ensureArray } from "../../common/array/ensure-array";
|
||||
@ -61,9 +61,9 @@ export class HaAreaSelector extends LitElement {
|
||||
}
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (this._hasIntegration(this.selector) && !this._entitySources) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
|
||||
if (!this.selector.area?.multiple) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { HassEntity } from "home-assistant-js-websocket";
|
||||
import { html, LitElement } from "lit";
|
||||
import { html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import memoizeOne from "memoize-one";
|
||||
import { ensureArray } from "../../common/array/ensure-array";
|
||||
@ -66,7 +66,7 @@ export class HaDeviceSelector extends LitElement {
|
||||
|
||||
protected render() {
|
||||
if (this._hasIntegration(this.selector) && !this._entitySources) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
|
||||
if (!this.selector.device?.multiple) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { HassEntity } from "home-assistant-js-websocket";
|
||||
import { html, LitElement, PropertyValues } from "lit";
|
||||
import { html, LitElement, PropertyValues, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { ensureArray } from "../../common/array/ensure-array";
|
||||
import {
|
||||
@ -39,7 +39,7 @@ export class HaEntitySelector extends LitElement {
|
||||
|
||||
protected render() {
|
||||
if (this._hasIntegration(this.selector) && !this._entitySources) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
|
||||
if (!this.selector.entity?.multiple) {
|
||||
|
@ -5,7 +5,7 @@ import {
|
||||
html,
|
||||
LitElement,
|
||||
PropertyValues,
|
||||
TemplateResult,
|
||||
nothing,
|
||||
} from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import memoizeOne from "memoize-one";
|
||||
@ -70,9 +70,9 @@ export class HaTargetSelector extends LitElement {
|
||||
}
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (this._hasIntegration(this.selector) && !this._entitySources) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
|
||||
return html`<ha-target-picker
|
||||
|
@ -29,6 +29,7 @@ import {
|
||||
html,
|
||||
LitElement,
|
||||
PropertyValues,
|
||||
nothing,
|
||||
} from "lit";
|
||||
import { customElement, eventOptions, property, state } from "lit/decorators";
|
||||
import { classMap } from "lit/directives/class-map";
|
||||
@ -241,7 +242,7 @@ class HaSidebar extends SubscribeMixin(LitElement) {
|
||||
|
||||
protected render() {
|
||||
if (!this.hass) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
|
||||
// prettier-ignore
|
||||
|
@ -12,7 +12,7 @@ import {
|
||||
import "@polymer/paper-tooltip/paper-tooltip";
|
||||
import { ComboBoxLightOpenedChangedEvent } from "@vaadin/combo-box/vaadin-combo-box-light";
|
||||
import { HassEntity, HassServiceTarget } from "home-assistant-js-websocket";
|
||||
import { css, CSSResultGroup, html, LitElement, unsafeCSS } from "lit";
|
||||
import { css, CSSResultGroup, html, LitElement, unsafeCSS, nothing } from "lit";
|
||||
import { customElement, property, query, state } from "lit/decorators";
|
||||
import { classMap } from "lit/directives/class-map";
|
||||
import { ensureArray } from "../common/array/ensure-array";
|
||||
@ -278,7 +278,7 @@ export class HaTargetPicker extends LitElement {
|
||||
|
||||
private _renderPicker() {
|
||||
if (!this._addMode) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
return html`<mwc-menu-surface
|
||||
open
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { mdiLightbulbOutline } from "@mdi/js";
|
||||
import { css, html, LitElement, TemplateResult } from "lit";
|
||||
import { property, customElement } from "lit/decorators";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import { HomeAssistant } from "../types";
|
||||
|
||||
import "./ha-svg-icon";
|
||||
@ -9,9 +9,9 @@ import "./ha-svg-icon";
|
||||
class HaTip extends LitElement {
|
||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||
|
||||
public render(): TemplateResult {
|
||||
public render() {
|
||||
if (!this.hass) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
|
||||
return html`
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { DEFAULT_SCHEMA, dump, load, Schema } from "js-yaml";
|
||||
import { html, LitElement, TemplateResult } from "lit";
|
||||
import { html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { fireEvent } from "../common/dom/fire_event";
|
||||
import type { HomeAssistant } from "../types";
|
||||
@ -56,9 +56,9 @@ export class HaYamlEditor extends LitElement {
|
||||
}
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (this._yaml === undefined) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
return html`
|
||||
${this.label
|
||||
|
@ -2,7 +2,7 @@ import { animate } from "@lit-labs/motion";
|
||||
import "@material/mwc-list/mwc-list";
|
||||
import "@material/mwc-list/mwc-list-item";
|
||||
import { mdiClose, mdiDelete } from "@mdi/js";
|
||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { repeat } from "lit/directives/repeat";
|
||||
import { fireEvent } from "../../common/dom/fire_event";
|
||||
@ -18,11 +18,11 @@ import {
|
||||
import { showConfirmationDialog } from "../../dialogs/generic/show-dialog-box";
|
||||
import { haStyleDialog } from "../../resources/styles";
|
||||
import type { HomeAssistant } from "../../types";
|
||||
import "../ha-check-list-item";
|
||||
import "../ha-circular-progress";
|
||||
import "../ha-dialog";
|
||||
import "../ha-header-bar";
|
||||
import "../ha-svg-icon";
|
||||
import "../ha-check-list-item";
|
||||
import "./ha-media-player-browse";
|
||||
import "./ha-media-upload-button";
|
||||
import type { MediaManageDialogParams } from "./show-media-manage-dialog";
|
||||
@ -60,9 +60,9 @@ class DialogMediaManage extends LitElement {
|
||||
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this._params) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
|
||||
const children =
|
||||
|
@ -1,6 +1,5 @@
|
||||
import "../ha-header-bar";
|
||||
import { mdiArrowLeft, mdiClose } from "@mdi/js";
|
||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, query, state } from "lit/decorators";
|
||||
import { fireEvent, HASSDomEvent } from "../../common/dom/fire_event";
|
||||
import { computeRTLDirection } from "../../common/util/compute_rtl";
|
||||
@ -12,8 +11,9 @@ import type {
|
||||
import { haStyleDialog } from "../../resources/styles";
|
||||
import type { HomeAssistant } from "../../types";
|
||||
import "../ha-dialog";
|
||||
import "./ha-media-player-browse";
|
||||
import "../ha-header-bar";
|
||||
import "./ha-media-manage-button";
|
||||
import "./ha-media-player-browse";
|
||||
import type {
|
||||
HaMediaPlayerBrowse,
|
||||
MediaPlayerItemId,
|
||||
@ -49,9 +49,9 @@ class DialogMediaPlayerBrowse extends LitElement {
|
||||
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this._params || !this._navigateIds) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
|
||||
return html`
|
||||
|
@ -1,13 +1,13 @@
|
||||
import { mdiFolderEdit } from "@mdi/js";
|
||||
import "@material/mwc-button";
|
||||
import { css, html, LitElement, TemplateResult } from "lit";
|
||||
import { mdiFolderEdit } from "@mdi/js";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { fireEvent } from "../../common/dom/fire_event";
|
||||
import { MediaPlayerItem } from "../../data/media-player";
|
||||
import "../ha-svg-icon";
|
||||
import { isLocalMediaSourceContentId } from "../../data/media_source";
|
||||
import type { HomeAssistant } from "../../types";
|
||||
import "../ha-svg-icon";
|
||||
import { showMediaManageDialog } from "./show-media-manage-dialog";
|
||||
import { fireEvent } from "../../common/dom/fire_event";
|
||||
|
||||
declare global {
|
||||
interface HASSDomEvents {
|
||||
@ -23,12 +23,12 @@ class MediaManageButton extends LitElement {
|
||||
|
||||
@state() _uploading = 0;
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (
|
||||
!this.currentItem ||
|
||||
!isLocalMediaSourceContentId(this.currentItem.media_content_id || "")
|
||||
) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
return html`
|
||||
<mwc-button
|
||||
|
@ -13,6 +13,7 @@ import {
|
||||
LitElement,
|
||||
PropertyValues,
|
||||
TemplateResult,
|
||||
nothing,
|
||||
} from "lit";
|
||||
import {
|
||||
customElement,
|
||||
@ -311,7 +312,7 @@ export class HaMediaPlayerBrowse extends LitElement {
|
||||
}
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (this._error) {
|
||||
return html`
|
||||
<div class="container">
|
||||
@ -388,7 +389,7 @@ export class HaMediaPlayerBrowse extends LitElement {
|
||||
: ""}
|
||||
</div>
|
||||
`
|
||||
: html``}
|
||||
: nothing}
|
||||
<div class="header-info">
|
||||
<div class="breadcrumb">
|
||||
<h1 class="title">${currentItem.title}</h1>
|
||||
|
@ -1,17 +1,17 @@
|
||||
import { mdiUpload } from "@mdi/js";
|
||||
import "@material/mwc-button";
|
||||
import { css, html, LitElement, TemplateResult } from "lit";
|
||||
import { mdiUpload } from "@mdi/js";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { fireEvent } from "../../common/dom/fire_event";
|
||||
import { MediaPlayerItem } from "../../data/media-player";
|
||||
import "../ha-circular-progress";
|
||||
import "../ha-svg-icon";
|
||||
import {
|
||||
isLocalMediaSourceContentId,
|
||||
uploadLocalMedia,
|
||||
} from "../../data/media_source";
|
||||
import type { HomeAssistant } from "../../types";
|
||||
import { showAlertDialog } from "../../dialogs/generic/show-dialog-box";
|
||||
import type { HomeAssistant } from "../../types";
|
||||
import "../ha-circular-progress";
|
||||
import "../ha-svg-icon";
|
||||
|
||||
declare global {
|
||||
interface HASSDomEvents {
|
||||
@ -28,12 +28,12 @@ class MediaUploadButton extends LitElement {
|
||||
|
||||
@state() _uploading = 0;
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (
|
||||
!this.currentItem ||
|
||||
!isLocalMediaSourceContentId(this.currentItem.media_content_id || "")
|
||||
) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
return html`
|
||||
<mwc-button
|
||||
|
@ -14,6 +14,7 @@ import {
|
||||
LitElement,
|
||||
PropertyValues,
|
||||
TemplateResult,
|
||||
nothing,
|
||||
} from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { ifDefined } from "lit/directives/if-defined";
|
||||
@ -595,9 +596,9 @@ export class HaAutomationTracer extends LitElement {
|
||||
];
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this.trace) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
|
||||
const entries: TemplateResult[] = [];
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import { classMap } from "lit/directives/class-map";
|
||||
import { styleMap } from "lit/directives/style-map";
|
||||
@ -9,9 +9,9 @@ import { computeUserInitials } from "../../data/user";
|
||||
class PersonBadge extends LitElement {
|
||||
@property({ attribute: false }) public person?: Person;
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this.person) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
|
||||
const picture = this.person.picture;
|
||||
|
@ -4,7 +4,7 @@ import {
|
||||
html,
|
||||
LitElement,
|
||||
PropertyValues,
|
||||
TemplateResult,
|
||||
nothing,
|
||||
} from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { classMap } from "lit/directives/class-map";
|
||||
@ -47,9 +47,9 @@ class UserBadge extends LitElement {
|
||||
}
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this.hass || !this.user) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
const picture = this._personPicture;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { mdiClose } from "@mdi/js";
|
||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import { guard } from "lit/directives/guard";
|
||||
import memoizeOne from "memoize-one";
|
||||
@ -34,9 +34,9 @@ class HaUsersPickerLight extends LitElement {
|
||||
}
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this.hass || !this.users) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
|
||||
const notSelectedUsers = this._notSelectedUsers(this.users, this.value);
|
||||
|
@ -11,10 +11,8 @@ import {
|
||||
} from "date-fns/esm";
|
||||
import { Collection, getCollection } from "home-assistant-js-websocket";
|
||||
import { groupBy } from "../common/util/group-by";
|
||||
import { subscribeOne } from "../common/util/subscribe-one";
|
||||
import { HomeAssistant } from "../types";
|
||||
import { ConfigEntry, getConfigEntries } from "./config_entries";
|
||||
import { subscribeEntityRegistry } from "./entity_registry";
|
||||
import {
|
||||
fetchStatistics,
|
||||
getStatisticMetadata,
|
||||
@ -341,9 +339,8 @@ const getEnergyData = async (
|
||||
end?: Date,
|
||||
compare?: boolean
|
||||
): Promise<EnergyData> => {
|
||||
const [configEntries, entityRegistryEntries, info] = await Promise.all([
|
||||
const [configEntries, info] = await Promise.all([
|
||||
getConfigEntries(hass, { domain: "co2signal" }),
|
||||
subscribeOne(hass.connection, subscribeEntityRegistry),
|
||||
getEnergyInfo(hass),
|
||||
]);
|
||||
|
||||
@ -352,15 +349,14 @@ const getEnergyData = async (
|
||||
: undefined;
|
||||
|
||||
let co2SignalEntity: string | undefined;
|
||||
|
||||
if (co2SignalConfigEntry) {
|
||||
for (const entry of entityRegistryEntries) {
|
||||
if (entry.config_entry_id !== co2SignalConfigEntry.entry_id) {
|
||||
for (const entity of Object.values(hass.entities)) {
|
||||
if (entity.platform !== "co2signal") {
|
||||
continue;
|
||||
}
|
||||
|
||||
// The integration offers 2 entities. We want the % one.
|
||||
const co2State = hass.states[entry.entity_id];
|
||||
const co2State = hass.states[entity.entity_id];
|
||||
if (!co2State || co2State.attributes.unit_of_measurement !== "%") {
|
||||
continue;
|
||||
}
|
||||
@ -405,34 +401,35 @@ const getEnergyData = async (
|
||||
volume: lengthUnit === "km" ? "L" : "gal",
|
||||
};
|
||||
|
||||
const stats = {
|
||||
...(energyStatIds.length
|
||||
? await fetchStatistics(
|
||||
hass!,
|
||||
startMinHour,
|
||||
end,
|
||||
energyStatIds,
|
||||
period,
|
||||
energyUnits,
|
||||
["sum"]
|
||||
)
|
||||
: {}),
|
||||
...(waterStatIds.length
|
||||
? await fetchStatistics(
|
||||
hass!,
|
||||
startMinHour,
|
||||
end,
|
||||
waterStatIds,
|
||||
period,
|
||||
waterUnits,
|
||||
["sum"]
|
||||
)
|
||||
: {}),
|
||||
};
|
||||
const _energyStats: Statistics | Promise<Statistics> = energyStatIds.length
|
||||
? fetchStatistics(
|
||||
hass!,
|
||||
startMinHour,
|
||||
end,
|
||||
energyStatIds,
|
||||
period,
|
||||
energyUnits,
|
||||
["sum"]
|
||||
)
|
||||
: {};
|
||||
const _waterStats: Statistics | Promise<Statistics> = waterStatIds.length
|
||||
? fetchStatistics(
|
||||
hass!,
|
||||
startMinHour,
|
||||
end,
|
||||
waterStatIds,
|
||||
period,
|
||||
waterUnits,
|
||||
["sum"]
|
||||
)
|
||||
: {};
|
||||
|
||||
let statsCompare;
|
||||
let startCompare;
|
||||
let endCompare;
|
||||
let _energyStatsCompare: Statistics | Promise<Statistics> = {};
|
||||
let _waterStatsCompare: Statistics | Promise<Statistics> = {};
|
||||
|
||||
if (compare) {
|
||||
if (dayDifference > 27 && dayDifference < 32) {
|
||||
// When comparing a month, we want to start at the begining of the month
|
||||
@ -443,38 +440,36 @@ const getEnergyData = async (
|
||||
|
||||
const compareStartMinHour = addHours(startCompare, -1);
|
||||
endCompare = addMilliseconds(start, -1);
|
||||
|
||||
statsCompare = {
|
||||
...(energyStatIds.length
|
||||
? await fetchStatistics(
|
||||
hass!,
|
||||
compareStartMinHour,
|
||||
endCompare,
|
||||
energyStatIds,
|
||||
period,
|
||||
energyUnits,
|
||||
["sum"]
|
||||
)
|
||||
: {}),
|
||||
...(waterStatIds.length
|
||||
? await fetchStatistics(
|
||||
hass!,
|
||||
compareStartMinHour,
|
||||
endCompare,
|
||||
waterStatIds,
|
||||
period,
|
||||
waterUnits,
|
||||
["sum"]
|
||||
)
|
||||
: {}),
|
||||
};
|
||||
if (energyStatIds.length) {
|
||||
_energyStatsCompare = fetchStatistics(
|
||||
hass!,
|
||||
compareStartMinHour,
|
||||
endCompare,
|
||||
energyStatIds,
|
||||
period,
|
||||
energyUnits,
|
||||
["sum"]
|
||||
);
|
||||
}
|
||||
if (waterStatIds.length) {
|
||||
_waterStatsCompare = fetchStatistics(
|
||||
hass!,
|
||||
compareStartMinHour,
|
||||
endCompare,
|
||||
waterStatIds,
|
||||
period,
|
||||
waterUnits,
|
||||
["sum"]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
let fossilEnergyConsumption: FossilEnergyConsumption | undefined;
|
||||
let fossilEnergyConsumptionCompare: FossilEnergyConsumption | undefined;
|
||||
|
||||
let _fossilEnergyConsumption: undefined | Promise<FossilEnergyConsumption>;
|
||||
let _fossilEnergyConsumptionCompare:
|
||||
| undefined
|
||||
| Promise<FossilEnergyConsumption>;
|
||||
if (co2SignalEntity !== undefined) {
|
||||
fossilEnergyConsumption = await getFossilEnergyConsumption(
|
||||
_fossilEnergyConsumption = getFossilEnergyConsumption(
|
||||
hass!,
|
||||
start,
|
||||
consumptionStatIDs,
|
||||
@ -483,7 +478,7 @@ const getEnergyData = async (
|
||||
dayDifference > 35 ? "month" : dayDifference > 2 ? "day" : "hour"
|
||||
);
|
||||
if (compare) {
|
||||
fossilEnergyConsumptionCompare = await getFossilEnergyConsumption(
|
||||
_fossilEnergyConsumptionCompare = getFossilEnergyConsumption(
|
||||
hass!,
|
||||
startCompare,
|
||||
consumptionStatIDs,
|
||||
@ -494,6 +489,39 @@ const getEnergyData = async (
|
||||
}
|
||||
}
|
||||
|
||||
const statsMetadata: Record<string, StatisticsMetaData> = {};
|
||||
const _getStatisticMetadata:
|
||||
| Promise<StatisticsMetaData[]>
|
||||
| StatisticsMetaData[] = allStatIDs.length
|
||||
? getStatisticMetadata(hass, allStatIDs)
|
||||
: [];
|
||||
const [
|
||||
energyStats,
|
||||
waterStats,
|
||||
energyStatsCompare,
|
||||
waterStatsCompare,
|
||||
statsMetadataArray,
|
||||
fossilEnergyConsumption,
|
||||
fossilEnergyConsumptionCompare,
|
||||
] = await Promise.all([
|
||||
_energyStats,
|
||||
_waterStats,
|
||||
_energyStatsCompare,
|
||||
_waterStatsCompare,
|
||||
_getStatisticMetadata,
|
||||
_fossilEnergyConsumption,
|
||||
_fossilEnergyConsumptionCompare,
|
||||
]);
|
||||
const stats = { ...energyStats, ...waterStats };
|
||||
if (compare) {
|
||||
statsCompare = { ...energyStatsCompare, ...waterStatsCompare };
|
||||
}
|
||||
if (allStatIDs.length) {
|
||||
statsMetadataArray.forEach((x) => {
|
||||
statsMetadata[x.statistic_id] = x;
|
||||
});
|
||||
}
|
||||
|
||||
Object.values(stats).forEach((stat) => {
|
||||
// if the start of the first value is after the requested period, we have the first data point, and should add a zero point
|
||||
if (stat.length && new Date(stat[0].start) > startMinHour) {
|
||||
@ -507,12 +535,6 @@ const getEnergyData = async (
|
||||
}
|
||||
});
|
||||
|
||||
const statsMetadataArray = await getStatisticMetadata(hass, allStatIDs);
|
||||
const statsMetadata: Record<string, StatisticsMetaData> = {};
|
||||
statsMetadataArray.forEach((x) => {
|
||||
statsMetadata[x.statistic_id] = x;
|
||||
});
|
||||
|
||||
const data: EnergyData = {
|
||||
start,
|
||||
end,
|
||||
|
@ -523,3 +523,18 @@ export const isForecastHourly = (
|
||||
|
||||
return undefined;
|
||||
};
|
||||
|
||||
export type WeatherUnits = {
|
||||
precipitation_unit: string[];
|
||||
pressure_unit: string[];
|
||||
temperature_unit: string[];
|
||||
visibility_unit: string[];
|
||||
wind_speed_unit: string[];
|
||||
};
|
||||
|
||||
export const getWeatherConvertibleUnits = (
|
||||
hass: HomeAssistant
|
||||
): Promise<{ units: WeatherUnits }> =>
|
||||
hass.callWS({
|
||||
type: "weather/convertible_units",
|
||||
});
|
||||
|
@ -1,6 +1,6 @@
|
||||
import "@material/mwc-button/mwc-button";
|
||||
import { mdiDeleteOutline, mdiPlus } from "@mdi/js";
|
||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { fireEvent } from "../../common/dom/fire_event";
|
||||
import "../../components/ha-alert";
|
||||
@ -40,9 +40,9 @@ class DialogAliases extends LitElement {
|
||||
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this._params) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
|
||||
return html`
|
||||
|
@ -1,5 +1,5 @@
|
||||
import "@material/mwc-button/mwc-button";
|
||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { fireEvent } from "../../common/dom/fire_event";
|
||||
import { computeRTLDirection } from "../../common/util/compute_rtl";
|
||||
@ -45,9 +45,9 @@ class DialogConfigEntrySystemOptions extends LitElement {
|
||||
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this._params) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
|
||||
return html`
|
||||
|
@ -7,7 +7,7 @@ import {
|
||||
html,
|
||||
LitElement,
|
||||
PropertyValues,
|
||||
TemplateResult,
|
||||
nothing,
|
||||
} from "lit";
|
||||
import { customElement, state } from "lit/decorators";
|
||||
import { fireEvent, HASSDomEvent } from "../../common/dom/fire_event";
|
||||
@ -202,9 +202,9 @@ class DataEntryFlowDialog extends LitElement {
|
||||
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this._params) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
|
||||
return html`
|
||||
|
@ -1,19 +1,13 @@
|
||||
import "@material/mwc-button";
|
||||
import {
|
||||
CSSResultGroup,
|
||||
html,
|
||||
LitElement,
|
||||
TemplateResult,
|
||||
PropertyValues,
|
||||
} from "lit";
|
||||
import { CSSResultGroup, html, LitElement, PropertyValues, nothing } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import { fireEvent } from "../../common/dom/fire_event";
|
||||
import { DataEntryFlowStepAbort } from "../../data/data_entry_flow";
|
||||
import { HomeAssistant } from "../../types";
|
||||
import { showAddApplicationCredentialDialog } from "../../panels/config/application_credentials/show-dialog-add-application-credential";
|
||||
import { configFlowContentStyles } from "./styles";
|
||||
import { DataEntryFlowDialogParams } from "./show-dialog-data-entry-flow";
|
||||
import { HomeAssistant } from "../../types";
|
||||
import { showConfigFlowDialog } from "./show-dialog-config-flow";
|
||||
import { DataEntryFlowDialogParams } from "./show-dialog-data-entry-flow";
|
||||
import { configFlowContentStyles } from "./styles";
|
||||
|
||||
@customElement("step-flow-abort")
|
||||
class StepFlowAbort extends LitElement {
|
||||
@ -32,9 +26,9 @@ class StepFlowAbort extends LitElement {
|
||||
}
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (this.step.reason === "missing_credentials") {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
return html`
|
||||
<h2>${this.hass.localize(`component.${this.domain}.title`)}</h2>
|
||||
|
@ -1,5 +1,5 @@
|
||||
import "@material/mwc-button/mwc-button";
|
||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
||||
import { customElement, state } from "lit/decorators";
|
||||
import { fireEvent } from "../../common/dom/fire_event";
|
||||
import { createCloseHeading } from "../../components/ha-dialog";
|
||||
@ -29,9 +29,9 @@ class DomainTogglerDialog
|
||||
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this._params) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
|
||||
const domains = this._params.domains
|
||||
|
@ -1,6 +1,6 @@
|
||||
import "@material/mwc-button/mwc-button";
|
||||
import { mdiAlertOutline } from "@mdi/js";
|
||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, query, state } from "lit/decorators";
|
||||
import { classMap } from "lit/directives/class-map";
|
||||
import { ifDefined } from "lit/directives/if-defined";
|
||||
@ -35,9 +35,9 @@ class DialogBox extends LitElement {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this._params) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
|
||||
const confirmPrompt = this._params.confirmation || this._params.prompt;
|
||||
|
@ -128,7 +128,9 @@ export class HaMoreInfoToggle extends LitElement {
|
||||
static get styles(): CSSResultGroup {
|
||||
return css`
|
||||
ha-control-switch {
|
||||
height: 320px;
|
||||
height: 45vh;
|
||||
max-height: 320px;
|
||||
min-height: 200px;
|
||||
--control-switch-thickness: 100px;
|
||||
--control-switch-border-radius: 24px;
|
||||
--control-switch-padding: 6px;
|
||||
@ -138,7 +140,9 @@ export class HaMoreInfoToggle extends LitElement {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 100px;
|
||||
height: 320px;
|
||||
height: 45vh;
|
||||
max-height: 320px;
|
||||
min-height: 200px;
|
||||
padding: 6px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
@ -84,7 +84,9 @@ export class HaMoreInfoLightBrightness extends LitElement {
|
||||
static get styles(): CSSResultGroup {
|
||||
return css`
|
||||
ha-control-slider {
|
||||
height: 320px;
|
||||
height: 45vh;
|
||||
max-height: 320px;
|
||||
min-height: 200px;
|
||||
--control-slider-thickness: 100px;
|
||||
--control-slider-border-radius: 24px;
|
||||
--control-slider-color: var(--primary-color);
|
||||
|
@ -7,8 +7,8 @@ import {
|
||||
CSSResultGroup,
|
||||
html,
|
||||
LitElement,
|
||||
nothing,
|
||||
PropertyValues,
|
||||
TemplateResult,
|
||||
} from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import "../../../../components/ha-button-toggle-group";
|
||||
@ -62,9 +62,9 @@ class MoreInfoViewLightColorPicker extends LitElement {
|
||||
: undefined;
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this.params || !this.stateObj) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
|
||||
const supportsRgbww = lightSupportsColorMode(
|
||||
@ -97,15 +97,19 @@ class MoreInfoViewLightColorPicker extends LitElement {
|
||||
<div class="content">
|
||||
${this._mode === LightColorMode.COLOR_TEMP
|
||||
? html`
|
||||
<p class="color-temp-value">
|
||||
${this._ctSliderValue ? `${this._ctSliderValue} K` : nothing}
|
||||
</p>
|
||||
<ha-control-slider
|
||||
vertical
|
||||
class="color_temp"
|
||||
class="color-temp"
|
||||
label=${this.hass.localize("ui.card.light.color_temperature")}
|
||||
min="1"
|
||||
max="100"
|
||||
mode="cursor"
|
||||
.value=${this._ctSliderValue}
|
||||
@value-changed=${this._ctSliderChanged}
|
||||
@slider-moved=${this._ctSliderMoved}
|
||||
.min=${this.stateObj.attributes.min_color_temp_kelvin!}
|
||||
.max=${this.stateObj.attributes.max_color_temp_kelvin!}
|
||||
>
|
||||
@ -114,7 +118,7 @@ class MoreInfoViewLightColorPicker extends LitElement {
|
||||
: ""}
|
||||
${this._mode === "color"
|
||||
? html`
|
||||
<div class="segmentationContainer">
|
||||
<div class="segmentation-container">
|
||||
<ha-color-picker
|
||||
class="color"
|
||||
@colorselected=${this._colorPicked}
|
||||
@ -127,7 +131,7 @@ class MoreInfoViewLightColorPicker extends LitElement {
|
||||
<ha-icon-button
|
||||
.path=${mdiPalette}
|
||||
@click=${this._segmentClick}
|
||||
class="segmentationButton"
|
||||
class="segmentation-button"
|
||||
></ha-icon-button>
|
||||
</div>
|
||||
|
||||
@ -206,7 +210,11 @@ class MoreInfoViewLightColorPicker extends LitElement {
|
||||
this._brightnessAdjusted = maxVal;
|
||||
}
|
||||
}
|
||||
this._ctSliderValue = stateObj.attributes.color_temp_kelvin;
|
||||
this._ctSliderValue =
|
||||
stateObj.attributes.color_mode === LightColorMode.COLOR_TEMP
|
||||
? stateObj.attributes.color_temp_kelvin
|
||||
: undefined;
|
||||
|
||||
this._wvSliderValue =
|
||||
stateObj.attributes.color_mode === LightColorMode.RGBW
|
||||
? Math.round((stateObj.attributes.rgbw_color![3] * 100) / 255)
|
||||
@ -243,7 +251,7 @@ class MoreInfoViewLightColorPicker extends LitElement {
|
||||
public willUpdate(changedProps: PropertyValues) {
|
||||
super.willUpdate(changedProps);
|
||||
|
||||
if (!changedProps.has("params") || !changedProps.has("hass")) {
|
||||
if (!changedProps.has("params") && !changedProps.has("hass")) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -264,10 +272,11 @@ class MoreInfoViewLightColorPicker extends LitElement {
|
||||
}
|
||||
|
||||
this._modes = modes;
|
||||
this._mode =
|
||||
this.stateObj!.attributes.color_mode === LightColorMode.COLOR_TEMP
|
||||
this._mode = this.stateObj!.attributes.color_mode
|
||||
? this.stateObj!.attributes.color_mode === LightColorMode.COLOR_TEMP
|
||||
? LightColorMode.COLOR_TEMP
|
||||
: "color";
|
||||
: "color"
|
||||
: this._modes[0];
|
||||
}
|
||||
|
||||
this._updateSliderValues();
|
||||
@ -281,6 +290,16 @@ class MoreInfoViewLightColorPicker extends LitElement {
|
||||
this._mode = newMode;
|
||||
}
|
||||
|
||||
private _ctSliderMoved(ev: CustomEvent) {
|
||||
const ct = ev.detail.value;
|
||||
|
||||
if (isNaN(ct)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._ctSliderValue = ct;
|
||||
}
|
||||
|
||||
private _ctSliderChanged(ev: CustomEvent) {
|
||||
const ct = ev.detail.value;
|
||||
|
||||
@ -493,14 +512,14 @@ class MoreInfoViewLightColorPicker extends LitElement {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.segmentationContainer {
|
||||
.segmentation-container {
|
||||
position: relative;
|
||||
max-height: 500px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.segmentationButton {
|
||||
.segmentation-button {
|
||||
position: absolute;
|
||||
top: 5%;
|
||||
left: 0;
|
||||
@ -516,17 +535,29 @@ class MoreInfoViewLightColorPicker extends LitElement {
|
||||
}
|
||||
|
||||
ha-control-slider {
|
||||
height: 320px;
|
||||
height: 45vh;
|
||||
max-height: 320px;
|
||||
min-height: 200px;
|
||||
margin: 20px 0;
|
||||
--control-slider-thickness: 100px;
|
||||
--control-slider-border-radius: 24px;
|
||||
}
|
||||
|
||||
ha-labeled-slider {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.color_temp {
|
||||
--control-slider-thickness: 100px;
|
||||
--control-slider-border-radius: 24px;
|
||||
.color-temp-value {
|
||||
font-style: normal;
|
||||
font-weight: 500;
|
||||
font-size: 16px;
|
||||
height: 24px;
|
||||
line-height: 24px;
|
||||
letter-spacing: 0.1px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.color-temp {
|
||||
--control-slider-background: -webkit-linear-gradient(
|
||||
top,
|
||||
rgb(166, 209, 255) 0%,
|
||||
@ -534,6 +565,7 @@ class MoreInfoViewLightColorPicker extends LitElement {
|
||||
rgb(255, 160, 0) 100%
|
||||
);
|
||||
--control-slider-background-opacity: 1;
|
||||
margin-bottom: 44px;
|
||||
}
|
||||
|
||||
hr {
|
||||
|
@ -1,15 +1,15 @@
|
||||
import "@material/mwc-button";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import { css, html, LitElement, PropertyValues, TemplateResult } from "lit";
|
||||
import { customElement, property, state, query } from "lit/decorators";
|
||||
import { css, html, LitElement, PropertyValues, nothing } from "lit";
|
||||
import { customElement, property, query, state } from "lit/decorators";
|
||||
import { classMap } from "lit/directives/class-map";
|
||||
import "../../../components/ha-textfield";
|
||||
import { supportsFeature } from "../../../common/entity/supports-feature";
|
||||
import "../../../components/ha-textfield";
|
||||
import type { HaTextField } from "../../../components/ha-textfield";
|
||||
import {
|
||||
AlarmControlPanelEntityFeature,
|
||||
callAlarmAction,
|
||||
FORMAT_NUMBER,
|
||||
AlarmControlPanelEntityFeature,
|
||||
} from "../../../data/alarm_control_panel";
|
||||
import type { HomeAssistant } from "../../../types";
|
||||
|
||||
@ -67,9 +67,9 @@ export class MoreInfoAlarmControlPanel extends LitElement {
|
||||
}
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this.hass || !this.stateObj) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
|
||||
return html`
|
||||
|
@ -1,6 +1,6 @@
|
||||
import "@material/mwc-button";
|
||||
import { HassEntity } from "home-assistant-js-websocket";
|
||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import "../../../components/ha-relative-time";
|
||||
import { triggerAutomationActions } from "../../../data/automation";
|
||||
@ -13,9 +13,9 @@ class MoreInfoAutomation extends LitElement {
|
||||
|
||||
@property({ attribute: false }) public stateObj?: HassEntity;
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this.hass || !this.stateObj) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
|
||||
return html`
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
||||
import { property, state } from "lit/decorators";
|
||||
import "../../../components/ha-camera-stream";
|
||||
import { CameraEntity } from "../../../data/camera";
|
||||
@ -21,9 +21,9 @@ class MoreInfoCamera extends LitElement {
|
||||
this._attached = false;
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this._attached || !this.hass || !this.stateObj) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
|
||||
return html`
|
||||
|
@ -5,7 +5,7 @@ import {
|
||||
html,
|
||||
LitElement,
|
||||
PropertyValues,
|
||||
TemplateResult,
|
||||
nothing,
|
||||
} from "lit";
|
||||
import { property } from "lit/decorators";
|
||||
import { classMap } from "lit/directives/class-map";
|
||||
@ -36,9 +36,9 @@ class MoreInfoClimate extends LitElement {
|
||||
|
||||
private _resizeDebounce?: number;
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this.stateObj) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
|
||||
const hass = this.hass;
|
||||
|
@ -1,6 +1,6 @@
|
||||
import "@material/mwc-button";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import { css, html, LitElement, TemplateResult } from "lit";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import "../../../components/ha-alert";
|
||||
import "../../../components/ha-circular-progress";
|
||||
@ -18,9 +18,9 @@ export class MoreInfoConfigurator extends LitElement {
|
||||
|
||||
private _fieldInput = {};
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (this.stateObj?.state !== "configure") {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
|
||||
return html`
|
||||
|
@ -1,6 +1,6 @@
|
||||
import "@material/mwc-button";
|
||||
import { HassEntity } from "home-assistant-js-websocket";
|
||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import { isUnavailableState } from "../../../data/entity";
|
||||
import { HomeAssistant } from "../../../types";
|
||||
@ -11,9 +11,9 @@ class MoreInfoCounter extends LitElement {
|
||||
|
||||
@property() public stateObj?: HassEntity;
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this.hass || !this.stateObj) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
|
||||
const disabled = isUnavailableState(this.stateObj!.state);
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { css, CSSResult, html, LitElement, TemplateResult } from "lit";
|
||||
import { css, CSSResult, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import { attributeClassNames } from "../../../common/entity/attribute_class_names";
|
||||
import {
|
||||
@ -30,9 +30,9 @@ class MoreInfoCover extends LitElement {
|
||||
|
||||
@property({ attribute: false }) public stateObj!: CoverEntity;
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this.stateObj) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
|
||||
const _isTiltOnly = isTiltOnly(this.stateObj);
|
||||
@ -71,7 +71,7 @@ class MoreInfoCover extends LitElement {
|
||||
slot="extra"
|
||||
.stateObj=${this.stateObj}
|
||||
></ha-cover-tilt-controls> `
|
||||
: html``}
|
||||
: nothing}
|
||||
</ha-labeled-slider>`
|
||||
: !_isTiltOnly
|
||||
? html`
|
||||
@ -83,7 +83,7 @@ class MoreInfoCover extends LitElement {
|
||||
.stateObj=${this.stateObj}
|
||||
></ha-cover-tilt-controls>
|
||||
`
|
||||
: html``}
|
||||
: nothing}
|
||||
</div>
|
||||
</div>
|
||||
<ha-attributes
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { HassEntity } from "home-assistant-js-websocket";
|
||||
import { html, LitElement, TemplateResult } from "lit";
|
||||
import { html, LitElement, nothing } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import "../../../components/ha-attributes";
|
||||
import { HomeAssistant } from "../../../types";
|
||||
@ -10,9 +10,9 @@ class MoreInfoDefault extends LitElement {
|
||||
|
||||
@property() public stateObj?: HassEntity;
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this.hass || !this.stateObj) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
|
||||
return html`<ha-attributes
|
||||
|
@ -5,7 +5,7 @@ import {
|
||||
html,
|
||||
LitElement,
|
||||
PropertyValues,
|
||||
TemplateResult,
|
||||
nothing,
|
||||
} from "lit";
|
||||
import { property, state } from "lit/decorators";
|
||||
import { dynamicElement } from "../../../common/dom/dynamic-element-directive";
|
||||
@ -70,9 +70,9 @@ class MoreInfoGroup extends LitElement {
|
||||
}
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render() {
|
||||
if (!this.hass || !this.stateObj) {
|
||||
return html``;
|
||||
return nothing;
|
||||
}
|
||||
return html`${this._moreInfoType
|
||||
? dynamicElement(this._moreInfoType, {
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user