mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-19 07:16:39 +00:00
Update lint rules (#9563)
Updated deps Added `unused-imports`, prefer arrow, and import order
This commit is contained in:
parent
12f7366968
commit
e797c01761
@ -35,55 +35,51 @@
|
||||
"es6": true
|
||||
},
|
||||
"rules": {
|
||||
"class-methods-use-this": 0,
|
||||
"new-cap": 0,
|
||||
"prefer-template": 0,
|
||||
"object-shorthand": 0,
|
||||
"func-names": 0,
|
||||
"prefer-arrow-callback": 0,
|
||||
"no-underscore-dangle": 0,
|
||||
"strict": 0,
|
||||
"prefer-spread": 0,
|
||||
"no-plusplus": 0,
|
||||
"no-bitwise": 2,
|
||||
"comma-dangle": 0,
|
||||
"vars-on-top": 0,
|
||||
"no-continue": 0,
|
||||
"no-param-reassign": 0,
|
||||
"no-multi-assign": 0,
|
||||
"no-console": 2,
|
||||
"radix": 0,
|
||||
"no-alert": 0,
|
||||
"no-return-await": 0,
|
||||
"no-nested-ternary": 0,
|
||||
"prefer-destructuring": 0,
|
||||
"class-methods-use-this": "off",
|
||||
"new-cap": "off",
|
||||
"prefer-template": "off",
|
||||
"object-shorthand": "off",
|
||||
"func-names": "off",
|
||||
"no-underscore-dangle": "off",
|
||||
"strict": "off",
|
||||
"no-plusplus": "off",
|
||||
"no-bitwise": "error",
|
||||
"comma-dangle": "off",
|
||||
"vars-on-top": "off",
|
||||
"no-continue": "off",
|
||||
"no-param-reassign": "off",
|
||||
"no-multi-assign": "off",
|
||||
"no-console": "error",
|
||||
"radix": "off",
|
||||
"no-alert": "off",
|
||||
"no-nested-ternary": "off",
|
||||
"prefer-destructuring": "off",
|
||||
"no-restricted-globals": [2, "event"],
|
||||
"prefer-promise-reject-errors": 0,
|
||||
"import/order": 0,
|
||||
"import/prefer-default-export": 0,
|
||||
"import/no-unresolved": 0,
|
||||
"import/no-cycle": 0,
|
||||
"prefer-promise-reject-errors": "off",
|
||||
"import/prefer-default-export": "off",
|
||||
"import/no-default-export": "off",
|
||||
"import/no-unresolved": "off",
|
||||
"import/no-cycle": "off",
|
||||
"import/extensions": [
|
||||
2,
|
||||
"error",
|
||||
"ignorePackages",
|
||||
{ "ts": "never", "js": "never" }
|
||||
],
|
||||
"no-restricted-syntax": ["error", "LabeledStatement", "WithStatement"],
|
||||
"object-curly-newline": 0,
|
||||
"default-case": 0,
|
||||
"wc/no-self-class": 0,
|
||||
"no-shadow": 0,
|
||||
"@typescript-eslint/camelcase": 0,
|
||||
"@typescript-eslint/ban-ts-comment": 0,
|
||||
"@typescript-eslint/no-use-before-define": 0,
|
||||
"@typescript-eslint/no-non-null-assertion": 0,
|
||||
"@typescript-eslint/no-explicit-any": 0,
|
||||
"@typescript-eslint/no-unused-vars": 0,
|
||||
"@typescript-eslint/explicit-function-return-type": 0,
|
||||
"@typescript-eslint/explicit-module-boundary-types": 0,
|
||||
"object-curly-newline": "off",
|
||||
"default-case": "off",
|
||||
"wc/no-self-class": "off",
|
||||
"no-shadow": "off",
|
||||
"@typescript-eslint/camelcase": "off",
|
||||
"@typescript-eslint/ban-ts-comment": "off",
|
||||
"@typescript-eslint/no-use-before-define": "off",
|
||||
"@typescript-eslint/no-non-null-assertion": "off",
|
||||
"@typescript-eslint/no-explicit-any": "off",
|
||||
"@typescript-eslint/explicit-function-return-type": "off",
|
||||
"@typescript-eslint/explicit-module-boundary-types": "off",
|
||||
"@typescript-eslint/no-shadow": ["error"],
|
||||
"@typescript-eslint/naming-convention": [
|
||||
0,
|
||||
"off",
|
||||
{
|
||||
"selector": "default",
|
||||
"format": ["camelCase", "snake_case"],
|
||||
@ -101,9 +97,21 @@
|
||||
"format": ["PascalCase"]
|
||||
}
|
||||
],
|
||||
"lit/attribute-value-entities": 0
|
||||
"@typescript-eslint/no-unused-vars": "off",
|
||||
"unused-imports/no-unused-vars": [
|
||||
"error",
|
||||
{
|
||||
"vars": "all",
|
||||
"varsIgnorePattern": "^_",
|
||||
"args": "after-used",
|
||||
"argsIgnorePattern": "^_",
|
||||
"ignoreRestSiblings": true
|
||||
}
|
||||
],
|
||||
"unused-imports/no-unused-imports": "error",
|
||||
"lit/attribute-value-entities": "off"
|
||||
},
|
||||
"plugins": ["disable", "import", "lit", "prettier", "@typescript-eslint"],
|
||||
"plugins": ["disable", "unused-imports"],
|
||||
"processor": "disable/disable",
|
||||
"ignorePatterns": ["src/resources/lit-virtualizer/*"]
|
||||
}
|
||||
|
@ -5,8 +5,8 @@ import {
|
||||
import { castContext } from "../cast_context";
|
||||
|
||||
export const castDemoLovelace: () => LovelaceConfig = () => {
|
||||
const touchSupported = castContext.getDeviceCapabilities()
|
||||
.touch_input_supported;
|
||||
const touchSupported =
|
||||
castContext.getDeviceCapabilities().touch_input_supported;
|
||||
return {
|
||||
views: [
|
||||
{
|
||||
|
@ -113,8 +113,7 @@ export const demoLovelaceArsaboo: DemoConfig["lovelace"] = (localize) => ({
|
||||
on: "/assets/arsaboo/icons/light_bulb_on.png",
|
||||
},
|
||||
state_filter: {
|
||||
on:
|
||||
"brightness(130%) saturate(1.5) drop-shadow(0px 0px 10px gold)",
|
||||
on: "brightness(130%) saturate(1.5) drop-shadow(0px 0px 10px gold)",
|
||||
off: "brightness(80%) saturate(0.8)",
|
||||
},
|
||||
style: {
|
||||
@ -196,8 +195,7 @@ export const demoLovelaceArsaboo: DemoConfig["lovelace"] = (localize) => ({
|
||||
on: "/assets/arsaboo/icons/light_bulb_on.png",
|
||||
},
|
||||
state_filter: {
|
||||
on:
|
||||
"brightness(130%) saturate(1.5) drop-shadow(0px 0px 10px gold)",
|
||||
on: "brightness(130%) saturate(1.5) drop-shadow(0px 0px 10px gold)",
|
||||
off: "brightness(80%) saturate(0.8)",
|
||||
},
|
||||
style: {
|
||||
@ -277,8 +275,7 @@ export const demoLovelaceArsaboo: DemoConfig["lovelace"] = (localize) => ({
|
||||
on: "/assets/arsaboo/icons/light_bulb_on.png",
|
||||
},
|
||||
state_filter: {
|
||||
on:
|
||||
"brightness(130%) saturate(1.5) drop-shadow(0px 0px 10px gold)",
|
||||
on: "brightness(130%) saturate(1.5) drop-shadow(0px 0px 10px gold)",
|
||||
off: "brightness(80%) saturate(0.8)",
|
||||
},
|
||||
style: {
|
||||
@ -315,8 +312,7 @@ export const demoLovelaceArsaboo: DemoConfig["lovelace"] = (localize) => ({
|
||||
on: "/assets/arsaboo/icons/light_bulb_on.png",
|
||||
},
|
||||
state_filter: {
|
||||
on:
|
||||
"brightness(130%) saturate(1.5) drop-shadow(0px 0px 10px gold)",
|
||||
on: "brightness(130%) saturate(1.5) drop-shadow(0px 0px 10px gold)",
|
||||
off: "brightness(80%) saturate(0.8)",
|
||||
},
|
||||
style: {
|
||||
|
@ -12,9 +12,8 @@ export const demoConfigs: Array<() => Promise<DemoConfig>> = [
|
||||
// eslint-disable-next-line import/no-mutable-exports
|
||||
export let selectedDemoConfigIndex = 0;
|
||||
// eslint-disable-next-line import/no-mutable-exports
|
||||
export let selectedDemoConfig: Promise<DemoConfig> = demoConfigs[
|
||||
selectedDemoConfigIndex
|
||||
]();
|
||||
export let selectedDemoConfig: Promise<DemoConfig> =
|
||||
demoConfigs[selectedDemoConfigIndex]();
|
||||
|
||||
export const setDemoConfig = async (
|
||||
hass: MockHomeAssistant,
|
||||
|
@ -980,8 +980,7 @@ export const demoEntitiesTeachingbirds: DemoConfig["entities"] = () =>
|
||||
icon: "mdi:account-off",
|
||||
custom_ui_state_card: "state-card-custom-ui",
|
||||
templates: {
|
||||
icon:
|
||||
"if (state === 'on') return 'mdi:account'; else if (state === 'off') return 'mdi:account-off';\n",
|
||||
icon: "if (state === 'on') return 'mdi:account'; else if (state === 'off') return 'mdi:account-off';\n",
|
||||
icon_color:
|
||||
"if (state === 'on') return 'rgb(56, 150, 56)'; else if (state === 'off') return 'rgb(249, 251, 255)';\n",
|
||||
},
|
||||
@ -1005,8 +1004,7 @@ export const demoEntitiesTeachingbirds: DemoConfig["entities"] = () =>
|
||||
icon: "mdi:account-multiple-minus",
|
||||
custom_ui_state_card: "state-card-custom-ui",
|
||||
templates: {
|
||||
icon:
|
||||
"if (state === 'on') return 'mdi:account-group'; else if (state === 'off') return 'mdi:account-multiple-minus';\n",
|
||||
icon: "if (state === 'on') return 'mdi:account-group'; else if (state === 'off') return 'mdi:account-multiple-minus';\n",
|
||||
icon_color:
|
||||
"if (state === 'on') return 'rgb(56, 150, 56)'; else if (state === 'off') return 'rgb(249, 251, 255)';\n",
|
||||
},
|
||||
|
@ -19,7 +19,7 @@ export class HADemoCard extends LitElement implements LovelaceCard {
|
||||
|
||||
@property({ attribute: false }) public hass!: MockHomeAssistant;
|
||||
|
||||
@state() private _switching?: boolean;
|
||||
@state() private _switching = false;
|
||||
|
||||
private _hidden = localStorage.hide_demo_card;
|
||||
|
||||
@ -27,12 +27,7 @@ export class HADemoCard extends LitElement implements LovelaceCard {
|
||||
return this._hidden ? 0 : 2;
|
||||
}
|
||||
|
||||
public setConfig(
|
||||
// @ts-ignore
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
config: LovelaceCardConfig
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||
) {}
|
||||
public setConfig(_config: LovelaceCardConfig) {}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
if (this._hidden) {
|
||||
|
@ -67,14 +67,7 @@ const incrementalUnits = ["clients", "queries", "ads"];
|
||||
export const mockHistory = (mockHass: MockHomeAssistant) => {
|
||||
mockHass.mockAPI(
|
||||
new RegExp("history/period/.+"),
|
||||
(
|
||||
hass,
|
||||
// @ts-ignore
|
||||
method,
|
||||
path,
|
||||
// @ts-ignore
|
||||
parameters
|
||||
) => {
|
||||
(hass, _method, path, _parameters) => {
|
||||
const params = parseQuery<HistoryQueryParams>(path.split("?")[1]);
|
||||
const entities = params.filter_entity_id.split(",");
|
||||
|
||||
@ -95,7 +88,7 @@ export const mockHistory = (mockHass: MockHomeAssistant) => {
|
||||
const numberState = Number(state.state);
|
||||
|
||||
if (isNaN(numberState)) {
|
||||
// eslint-disable-next-line
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(
|
||||
"Ignoring state with unparsable state but with a unit",
|
||||
entityId,
|
||||
|
@ -10,10 +10,9 @@ export const mockLovelace = (
|
||||
localizePromise: Promise<LocalizeFunc>
|
||||
) => {
|
||||
hass.mockWS("lovelace/config", () =>
|
||||
Promise.all([
|
||||
selectedDemoConfig,
|
||||
localizePromise,
|
||||
]).then(([config, localize]) => config.lovelace(localize))
|
||||
Promise.all([selectedDemoConfig, localizePromise]).then(
|
||||
([config, localize]) => config.lovelace(localize)
|
||||
)
|
||||
);
|
||||
|
||||
hass.mockWS("lovelace/config/save", () => Promise.resolve());
|
||||
|
@ -2,12 +2,12 @@ import { html, css, LitElement, TemplateResult } from "lit";
|
||||
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 { customElement, property, state } from "lit/decorators";
|
||||
|
||||
const traces: DemoTrace[] = [basicTrace, motionLightTrace];
|
||||
|
||||
|
@ -2,6 +2,8 @@ import { html, css, LitElement, TemplateResult } 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 { IntegrationManifest } from "../../../src/data/integration";
|
||||
|
||||
import { provideHass } from "../../../src/fake_data/provide_hass";
|
||||
@ -15,8 +17,6 @@ import type {
|
||||
} from "../../../src/panels/config/integrations/ha-config-integrations";
|
||||
import { DeviceRegistryEntry } from "../../../src/data/device_registry";
|
||||
import { EntityRegistryEntry } from "../../../src/data/entity_registry";
|
||||
import { classMap } from "lit/directives/class-map";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
|
||||
const createConfigEntry = (
|
||||
title: string,
|
||||
|
@ -2,6 +2,7 @@ import "../../../../src/components/ha-card";
|
||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||
import "../../../../src/components/ha-circular-progress";
|
||||
import "../../../../src/components/ha-markdown";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import {
|
||||
fetchHassioAddonDocumentation,
|
||||
HassioAddonDetails,
|
||||
@ -12,7 +13,6 @@ import { haStyle } from "../../../../src/resources/styles";
|
||||
import { HomeAssistant } from "../../../../src/types";
|
||||
import { hassioStyle } from "../../resources/hassio-style";
|
||||
import { Supervisor } from "../../../../src/data/supervisor/supervisor";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
|
||||
@customElement("hassio-addon-documentation-tab")
|
||||
class HassioAddonDocumentationDashboard extends LitElement {
|
||||
|
@ -41,7 +41,8 @@ const IP_VERSIONS = ["ipv4", "ipv6"];
|
||||
@customElement("dialog-hassio-network")
|
||||
export class DialogHassioNetwork
|
||||
extends LitElement
|
||||
implements HassDialog<HassioNetworkDialogParams> {
|
||||
implements HassDialog<HassioNetworkDialogParams>
|
||||
{
|
||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||
|
||||
@property({ attribute: false }) public supervisor!: Supervisor;
|
||||
@ -492,7 +493,7 @@ export class DialogHassioNetwork
|
||||
}
|
||||
|
||||
private _handleRadioValueChangedAp(ev: CustomEvent): void {
|
||||
const value = ((ev.target as any).value as string) as
|
||||
const value = (ev.target as any).value as string as
|
||||
| "open"
|
||||
| "wep"
|
||||
| "wpa-psk";
|
||||
|
@ -161,9 +161,9 @@ class HassioRegistriesDialog extends LitElement {
|
||||
|
||||
public focus(): void {
|
||||
this.updateComplete.then(() =>
|
||||
(this.shadowRoot?.querySelector(
|
||||
"[dialogInitialFocus]"
|
||||
) as HTMLElement)?.focus()
|
||||
(
|
||||
this.shadowRoot?.querySelector("[dialogInitialFocus]") as HTMLElement
|
||||
)?.focus()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -161,9 +161,9 @@ class HassioRepositoriesDialog extends LitElement {
|
||||
|
||||
public focus() {
|
||||
this.updateComplete.then(() =>
|
||||
(this.shadowRoot?.querySelector(
|
||||
"[dialogInitialFocus]"
|
||||
) as HTMLElement)?.focus()
|
||||
(
|
||||
this.shadowRoot?.querySelector("[dialogInitialFocus]") as HTMLElement
|
||||
)?.focus()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,8 @@ import { HassioSnapshotUploadDialogParams } from "./show-dialog-snapshot-upload"
|
||||
@customElement("dialog-hassio-snapshot-upload")
|
||||
export class DialogHassioSnapshotUpload
|
||||
extends LitElement
|
||||
implements HassDialog<HassioSnapshotUploadDialogParams> {
|
||||
implements HassDialog<HassioSnapshotUploadDialogParams>
|
||||
{
|
||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||
|
||||
@state() private _params?: HassioSnapshotUploadDialogParams;
|
||||
|
@ -30,7 +30,8 @@ import { HassioSnapshotDialogParams } from "./show-dialog-hassio-snapshot";
|
||||
@customElement("dialog-hassio-snapshot")
|
||||
class HassioSnapshotDialog
|
||||
extends LitElement
|
||||
implements HassDialog<HassioSnapshotDialogParams> {
|
||||
implements HassDialog<HassioSnapshotDialogParams>
|
||||
{
|
||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||
|
||||
@state() private _error?: string;
|
||||
@ -297,8 +298,7 @@ class HassioSnapshotDialog
|
||||
if (window.location.href.includes("ui.nabu.casa")) {
|
||||
const confirm = await showConfirmationDialog(this, {
|
||||
title: "Potential slow download",
|
||||
text:
|
||||
"Downloading snapshots over the Nabu Casa URL will take some time, it is recomended to use your local URL instead, do you want to continue?",
|
||||
text: "Downloading snapshots over the Nabu Casa URL will take some time, it is recomended to use your local URL instead, do you want to continue?",
|
||||
confirmText: "continue",
|
||||
dismissText: "cancel",
|
||||
});
|
||||
|
@ -49,9 +49,9 @@ class DialogSupervisorUpdate extends LitElement {
|
||||
|
||||
public focus(): void {
|
||||
this.updateComplete.then(() =>
|
||||
(this.shadowRoot?.querySelector(
|
||||
"[dialogInitialFocus]"
|
||||
) as HTMLElement)?.focus()
|
||||
(
|
||||
this.shadowRoot?.querySelector("[dialogInitialFocus]") as HTMLElement
|
||||
)?.focus()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -121,7 +121,7 @@ export class HassioMain extends SupervisorBaseElement {
|
||||
}
|
||||
} else {
|
||||
themeName =
|
||||
((this.hass.selectedTheme as unknown) as string) ||
|
||||
(this.hass.selectedTheme as unknown as string) ||
|
||||
this.hass.themes.default_theme;
|
||||
}
|
||||
|
||||
|
@ -1,19 +1,19 @@
|
||||
import { html, LitElement, TemplateResult } from "lit";
|
||||
import { sanitizeUrl } from "@braintree/sanitize-url";
|
||||
import { html, LitElement, TemplateResult } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { navigate } from "../../src/common/navigate";
|
||||
import {
|
||||
createSearchParam,
|
||||
extractSearchParamsObject,
|
||||
} from "../../src/common/url/search-params";
|
||||
import { Supervisor } from "../../src/data/supervisor/supervisor";
|
||||
import "../../src/layouts/hass-error-screen";
|
||||
import {
|
||||
ParamType,
|
||||
Redirect,
|
||||
Redirects,
|
||||
} from "../../src/panels/my/ha-panel-my";
|
||||
import { navigate } from "../../src/common/navigate";
|
||||
import { HomeAssistant, Route } from "../../src/types";
|
||||
import { Supervisor } from "../../src/data/supervisor/supervisor";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
|
||||
const REDIRECTS: Redirects = {
|
||||
supervisor: {
|
||||
|
@ -86,10 +86,8 @@ export class SupervisorBaseElement extends urlSyncMixin(
|
||||
const unsubs = Object.keys(this._unsubs);
|
||||
for (const collection of Object.keys(this._collections)) {
|
||||
if (!unsubs.includes(collection)) {
|
||||
this._unsubs[collection] = this._collections[
|
||||
collection
|
||||
].subscribe((data) =>
|
||||
this._updateSupervisor({ [collection]: data })
|
||||
this._unsubs[collection] = this._collections[collection].subscribe(
|
||||
(data) => this._updateSupervisor({ [collection]: data })
|
||||
);
|
||||
}
|
||||
}
|
||||
|
17
package.json
17
package.json
@ -172,21 +172,22 @@
|
||||
"@types/mocha": "^8.2.2",
|
||||
"@types/sortablejs": "^1.10.6",
|
||||
"@types/webspeechapi": "^0.0.29",
|
||||
"@typescript-eslint/eslint-plugin": "^4.22.0",
|
||||
"@typescript-eslint/parser": "^4.22.0",
|
||||
"@typescript-eslint/eslint-plugin": "^4.28.3",
|
||||
"@typescript-eslint/parser": "^4.28.3",
|
||||
"@web/dev-server": "^0.0.24",
|
||||
"@web/dev-server-rollup": "^0.2.11",
|
||||
"babel-loader": "^8.2.2",
|
||||
"chai": "^4.3.4",
|
||||
"del": "^4.0.0",
|
||||
"eslint": "^7.25.0",
|
||||
"eslint": "^7.30.0",
|
||||
"eslint-config-airbnb-typescript": "^12.3.1",
|
||||
"eslint-config-prettier": "^8.3.0",
|
||||
"eslint-import-resolver-webpack": "^0.13.1",
|
||||
"eslint-plugin-disable": "^2.0.1",
|
||||
"eslint-plugin-import": "^2.22.1",
|
||||
"eslint-plugin-lit": "^1.3.0",
|
||||
"eslint-plugin-import": "^2.23.4",
|
||||
"eslint-plugin-lit": "^1.5.1",
|
||||
"eslint-plugin-prettier": "^3.4.0",
|
||||
"eslint-plugin-unused-imports": "^1.1.2",
|
||||
"eslint-plugin-wc": "^1.3.0",
|
||||
"fancy-log": "^1.3.3",
|
||||
"fs-extra": "^7.0.1",
|
||||
@ -198,7 +199,7 @@
|
||||
"gulp-zopfli-green": "^3.0.1",
|
||||
"html-minifier": "^4.0.0",
|
||||
"husky": "^1.3.1",
|
||||
"lint-staged": "^10.5.4",
|
||||
"lint-staged": "^11.0.1",
|
||||
"lit-analyzer": "^1.2.1",
|
||||
"lodash.template": "^4.5.0",
|
||||
"magic-string": "^0.25.7",
|
||||
@ -207,7 +208,7 @@
|
||||
"mocha": "^8.4.0",
|
||||
"object-hash": "^2.0.3",
|
||||
"open": "^7.0.4",
|
||||
"prettier": "^2.0.4",
|
||||
"prettier": "^2.3.2",
|
||||
"require-dir": "^1.2.0",
|
||||
"rollup": "^2.8.2",
|
||||
"rollup-plugin-string": "^3.0.0",
|
||||
@ -220,7 +221,7 @@
|
||||
"terser-webpack-plugin": "^5.1.4",
|
||||
"ts-lit-plugin": "^1.2.1",
|
||||
"ts-mocha": "^8.0.0",
|
||||
"typescript": "^4.2.4",
|
||||
"typescript": "^4.3.5",
|
||||
"vinyl-buffer": "^1.0.1",
|
||||
"vinyl-source-stream": "^2.0.0",
|
||||
"webpack": "^5.43.0",
|
||||
|
@ -26,6 +26,9 @@ function checkToLocaleStringSupportsOptions() {
|
||||
return false;
|
||||
}
|
||||
|
||||
export const toLocaleDateStringSupportsOptions = checkToLocaleDateStringSupportsOptions();
|
||||
export const toLocaleTimeStringSupportsOptions = checkToLocaleTimeStringSupportsOptions();
|
||||
export const toLocaleStringSupportsOptions = checkToLocaleStringSupportsOptions();
|
||||
export const toLocaleDateStringSupportsOptions =
|
||||
checkToLocaleDateStringSupportsOptions();
|
||||
export const toLocaleTimeStringSupportsOptions =
|
||||
checkToLocaleTimeStringSupportsOptions();
|
||||
export const toLocaleStringSupportsOptions =
|
||||
checkToLocaleStringSupportsOptions();
|
||||
|
@ -82,67 +82,71 @@ class Storage {
|
||||
|
||||
const storage = new Storage();
|
||||
|
||||
export const LocalStorage = (
|
||||
storageKey?: string,
|
||||
property?: boolean,
|
||||
propertyOptions?: PropertyDeclaration
|
||||
): any => (clsElement: ClassElement) => {
|
||||
const key = String(clsElement.key);
|
||||
storageKey = storageKey || String(clsElement.key);
|
||||
const initVal = clsElement.initializer ? clsElement.initializer() : undefined;
|
||||
export const LocalStorage =
|
||||
(
|
||||
storageKey?: string,
|
||||
property?: boolean,
|
||||
propertyOptions?: PropertyDeclaration
|
||||
): any =>
|
||||
(clsElement: ClassElement) => {
|
||||
const key = String(clsElement.key);
|
||||
storageKey = storageKey || String(clsElement.key);
|
||||
const initVal = clsElement.initializer
|
||||
? clsElement.initializer()
|
||||
: undefined;
|
||||
|
||||
storage.addFromStorage(storageKey);
|
||||
storage.addFromStorage(storageKey);
|
||||
|
||||
const subscribe = (el: ReactiveElement): UnsubscribeFunc =>
|
||||
storage.subscribeChanges(storageKey!, (oldValue) => {
|
||||
el.requestUpdate(clsElement.key, oldValue);
|
||||
});
|
||||
const subscribe = (el: ReactiveElement): UnsubscribeFunc =>
|
||||
storage.subscribeChanges(storageKey!, (oldValue) => {
|
||||
el.requestUpdate(clsElement.key, oldValue);
|
||||
});
|
||||
|
||||
const getValue = (): any =>
|
||||
storage.hasKey(storageKey!) ? storage.getValue(storageKey!) : initVal;
|
||||
const getValue = (): any =>
|
||||
storage.hasKey(storageKey!) ? storage.getValue(storageKey!) : initVal;
|
||||
|
||||
const setValue = (el: ReactiveElement, value: any) => {
|
||||
let oldValue: unknown | undefined;
|
||||
if (property) {
|
||||
oldValue = getValue();
|
||||
}
|
||||
storage.setValue(storageKey!, value);
|
||||
if (property) {
|
||||
el.requestUpdate(clsElement.key, oldValue);
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
kind: "method",
|
||||
placement: "prototype",
|
||||
key: clsElement.key,
|
||||
descriptor: {
|
||||
set(this: ReactiveElement, value: unknown) {
|
||||
setValue(this, value);
|
||||
},
|
||||
get() {
|
||||
return getValue();
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
},
|
||||
finisher(cls: typeof ReactiveElement) {
|
||||
const setValue = (el: ReactiveElement, value: any) => {
|
||||
let oldValue: unknown | undefined;
|
||||
if (property) {
|
||||
const connectedCallback = cls.prototype.connectedCallback;
|
||||
const disconnectedCallback = cls.prototype.disconnectedCallback;
|
||||
cls.prototype.connectedCallback = function () {
|
||||
connectedCallback.call(this);
|
||||
this[`__unbsubLocalStorage${key}`] = subscribe(this);
|
||||
};
|
||||
cls.prototype.disconnectedCallback = function () {
|
||||
disconnectedCallback.call(this);
|
||||
this[`__unbsubLocalStorage${key}`]();
|
||||
};
|
||||
cls.createProperty(clsElement.key, {
|
||||
noAccessor: true,
|
||||
...propertyOptions,
|
||||
});
|
||||
oldValue = getValue();
|
||||
}
|
||||
},
|
||||
storage.setValue(storageKey!, value);
|
||||
if (property) {
|
||||
el.requestUpdate(clsElement.key, oldValue);
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
kind: "method",
|
||||
placement: "prototype",
|
||||
key: clsElement.key,
|
||||
descriptor: {
|
||||
set(this: ReactiveElement, value: unknown) {
|
||||
setValue(this, value);
|
||||
},
|
||||
get() {
|
||||
return getValue();
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
},
|
||||
finisher(cls: typeof ReactiveElement) {
|
||||
if (property) {
|
||||
const connectedCallback = cls.prototype.connectedCallback;
|
||||
const disconnectedCallback = cls.prototype.disconnectedCallback;
|
||||
cls.prototype.connectedCallback = function () {
|
||||
connectedCallback.call(this);
|
||||
this[`__unbsubLocalStorage${key}`] = subscribe(this);
|
||||
};
|
||||
cls.prototype.disconnectedCallback = function () {
|
||||
disconnectedCallback.call(this);
|
||||
this[`__unbsubLocalStorage${key}`]();
|
||||
};
|
||||
cls.createProperty(clsElement.key, {
|
||||
noAccessor: true,
|
||||
...propertyOptions,
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -1,33 +1,33 @@
|
||||
import type { LitElement } from "lit";
|
||||
import type { ClassElement } from "../../types";
|
||||
|
||||
export const restoreScroll = (selector: string): any => (
|
||||
element: ClassElement
|
||||
) => ({
|
||||
kind: "method",
|
||||
placement: "prototype",
|
||||
key: element.key,
|
||||
descriptor: {
|
||||
set(this: LitElement, value: number) {
|
||||
this[`__${String(element.key)}`] = value;
|
||||
export const restoreScroll =
|
||||
(selector: string): any =>
|
||||
(element: ClassElement) => ({
|
||||
kind: "method",
|
||||
placement: "prototype",
|
||||
key: element.key,
|
||||
descriptor: {
|
||||
set(this: LitElement, value: number) {
|
||||
this[`__${String(element.key)}`] = value;
|
||||
},
|
||||
get(this: LitElement) {
|
||||
return this[`__${String(element.key)}`];
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
},
|
||||
get(this: LitElement) {
|
||||
return this[`__${String(element.key)}`];
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
},
|
||||
finisher(cls: typeof LitElement) {
|
||||
const connectedCallback = cls.prototype.connectedCallback;
|
||||
cls.prototype.connectedCallback = function () {
|
||||
connectedCallback.call(this);
|
||||
if (this[element.key]) {
|
||||
const target = this.renderRoot.querySelector(selector);
|
||||
if (!target) {
|
||||
return;
|
||||
finisher(cls: typeof LitElement) {
|
||||
const connectedCallback = cls.prototype.connectedCallback;
|
||||
cls.prototype.connectedCallback = function () {
|
||||
connectedCallback.call(this);
|
||||
if (this[element.key]) {
|
||||
const target = this.renderRoot.querySelector(selector);
|
||||
if (!target) {
|
||||
return;
|
||||
}
|
||||
target.scrollTop = this[element.key];
|
||||
}
|
||||
target.scrollTop = this[element.key];
|
||||
}
|
||||
};
|
||||
},
|
||||
});
|
||||
};
|
||||
},
|
||||
});
|
||||
|
@ -67,9 +67,11 @@ class SearchInput extends LitElement {
|
||||
changedProps.has("noUnderline") &&
|
||||
(this.noUnderline || changedProps.get("noUnderline") !== undefined)
|
||||
) {
|
||||
(this._input.inputElement!.parentElement!.shadowRoot!.querySelector(
|
||||
"div.unfocused-line"
|
||||
) as HTMLElement).style.display = this.noUnderline ? "none" : "block";
|
||||
(
|
||||
this._input.inputElement!.parentElement!.shadowRoot!.querySelector(
|
||||
"div.unfocused-line"
|
||||
) as HTMLElement
|
||||
).style.display = this.noUnderline ? "none" : "block";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
// 3. Disallow dates based on week number.
|
||||
// 4. Disallow dates only consisting of a year.
|
||||
// https://regex101.com/r/kc5C14/3
|
||||
const regexp = /^\d{4}-(0[1-9]|1[0-2])-([12]\d|0[1-9]|3[01])[T| ](((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([.,]\d+(?!:))?)(\8[0-5]\d([.,]\d+)?)?([zZ]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)?)$/;
|
||||
const regexp =
|
||||
/^\d{4}-(0[1-9]|1[0-2])-([12]\d|0[1-9]|3[01])[T| ](((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([.,]\d+(?!:))?)(\8[0-5]\d([.,]\d+)?)?([zZ]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)?)$/;
|
||||
|
||||
export const isTimestamp = (input: string): boolean => regexp.test(input);
|
||||
|
@ -64,18 +64,18 @@ class HaCallServiceButton extends EventsMixin(PolymerElement) {
|
||||
this.hass
|
||||
.callService(this.domain, this.service, this.serviceData)
|
||||
.then(
|
||||
function () {
|
||||
() => {
|
||||
el.progress = false;
|
||||
el.$.progress.actionSuccess();
|
||||
eventData.success = true;
|
||||
},
|
||||
function () {
|
||||
() => {
|
||||
el.progress = false;
|
||||
el.$.progress.actionError();
|
||||
eventData.success = false;
|
||||
}
|
||||
)
|
||||
.then(function () {
|
||||
.then(() => {
|
||||
el.fire("hass-service-called", eventData);
|
||||
});
|
||||
}
|
||||
|
@ -176,9 +176,9 @@ export class StateHistoryChartTimeline extends LitElement {
|
||||
labelColor: (item) => ({
|
||||
borderColor: (item.dataset.data[item.dataIndex] as TimeLineData)
|
||||
.color!,
|
||||
backgroundColor: (item.dataset.data[
|
||||
item.dataIndex
|
||||
] as TimeLineData).color!,
|
||||
backgroundColor: (
|
||||
item.dataset.data[item.dataIndex] as TimeLineData
|
||||
).color!,
|
||||
}),
|
||||
},
|
||||
},
|
||||
|
@ -19,10 +19,9 @@ export class TextBarElement extends BarElement {
|
||||
draw(ctx) {
|
||||
super.draw(ctx);
|
||||
const options = this.options as TextBaroptions;
|
||||
const { x, y, base, width, text } = (this as BarElement<
|
||||
TextBarProps,
|
||||
TextBaroptions
|
||||
>).getProps(["x", "y", "base", "width", "text"]);
|
||||
const { x, y, base, width, text } = (
|
||||
this as BarElement<TextBarProps, TextBaroptions>
|
||||
).getProps(["x", "y", "base", "width", "text"]);
|
||||
|
||||
if (!text) {
|
||||
return;
|
||||
|
@ -1,4 +1,3 @@
|
||||
import { Layout1d, scroll } from "../../resources/lit-virtualizer";
|
||||
import deepClone from "deep-clone-simple";
|
||||
import {
|
||||
css,
|
||||
@ -19,6 +18,7 @@ import { classMap } from "lit/directives/class-map";
|
||||
import { ifDefined } from "lit/directives/if-defined";
|
||||
import { styleMap } from "lit/directives/style-map";
|
||||
import memoizeOne from "memoize-one";
|
||||
import { Layout1d, scroll } from "../../resources/lit-virtualizer";
|
||||
import { restoreScroll } from "../../common/decorators/restore-scroll";
|
||||
import { fireEvent } from "../../common/dom/fire_event";
|
||||
import "../../common/search/search-input";
|
||||
@ -360,9 +360,8 @@ export class HaDataTable extends LitElement {
|
||||
.rowId=${row[this.id]}
|
||||
@click=${this._handleRowClick}
|
||||
class="mdc-data-table__row ${classMap({
|
||||
"mdc-data-table__row--selected": this._checkedRows.includes(
|
||||
String(row[this.id])
|
||||
),
|
||||
"mdc-data-table__row--selected":
|
||||
this._checkedRows.includes(String(row[this.id])),
|
||||
clickable: this.clickable,
|
||||
})}"
|
||||
aria-selected=${ifDefined(
|
||||
@ -406,17 +405,15 @@ export class HaDataTable extends LitElement {
|
||||
"mdc-data-table__cell--icon": Boolean(
|
||||
column.type === "icon"
|
||||
),
|
||||
"mdc-data-table__cell--icon-button": Boolean(
|
||||
column.type === "icon-button"
|
||||
),
|
||||
"mdc-data-table__cell--icon-button":
|
||||
Boolean(column.type === "icon-button"),
|
||||
grows: Boolean(column.grows),
|
||||
forceLTR: Boolean(column.forceLTR),
|
||||
})}"
|
||||
style=${column.width
|
||||
? styleMap({
|
||||
[column.grows
|
||||
? "minWidth"
|
||||
: "width"]: column.width,
|
||||
[column.grows ? "minWidth" : "width"]:
|
||||
column.width,
|
||||
maxWidth: column.maxWidth
|
||||
? column.maxWidth
|
||||
: "",
|
||||
|
@ -15,6 +15,7 @@ import {
|
||||
PropertyValues,
|
||||
TemplateResult,
|
||||
} from "lit";
|
||||
import { ComboBoxLitRenderer, comboBoxRenderer } from "lit-vaadin-helpers";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import memoizeOne from "memoize-one";
|
||||
import { fireEvent } from "../../common/dom/fire_event";
|
||||
@ -38,7 +39,6 @@ import { PolymerChangedEvent } from "../../polymer-types";
|
||||
import { HomeAssistant } from "../../types";
|
||||
import "../ha-svg-icon";
|
||||
import "./ha-devices-picker";
|
||||
import { ComboBoxLitRenderer, comboBoxRenderer } from "lit-vaadin-helpers";
|
||||
|
||||
interface DevicesByArea {
|
||||
[areaId: string]: AreaDevices;
|
||||
|
@ -11,6 +11,7 @@ import {
|
||||
} from "lit";
|
||||
import { customElement, property, state, query } from "lit/decorators";
|
||||
import memoizeOne from "memoize-one";
|
||||
import { ComboBoxLitRenderer } from "lit-vaadin-helpers";
|
||||
import { fireEvent } from "../../common/dom/fire_event";
|
||||
import { computeDomain } from "../../common/entity/compute_domain";
|
||||
import { compare } from "../../common/string/compare";
|
||||
@ -33,7 +34,6 @@ import { PolymerChangedEvent } from "../../polymer-types";
|
||||
import { HomeAssistant } from "../../types";
|
||||
import "../ha-combo-box";
|
||||
import type { HaComboBox } from "../ha-combo-box";
|
||||
import { ComboBoxLitRenderer } from "lit-vaadin-helpers";
|
||||
|
||||
interface Device {
|
||||
name: string;
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { html, LitElement, TemplateResult } from "lit";
|
||||
import { customElement, property, state, query } from "lit/decorators";
|
||||
import { ComboBoxLitRenderer } from "lit-vaadin-helpers";
|
||||
import { isComponentLoaded } from "../common/config/is_component_loaded";
|
||||
import { fireEvent } from "../common/dom/fire_event";
|
||||
import { compare } from "../common/string/compare";
|
||||
@ -9,7 +10,6 @@ import { showAlertDialog } from "../dialogs/generic/show-dialog-box";
|
||||
import { PolymerChangedEvent } from "../polymer-types";
|
||||
import { HomeAssistant } from "../types";
|
||||
import { HaComboBox } from "./ha-combo-box";
|
||||
import { ComboBoxLitRenderer } from "lit-vaadin-helpers";
|
||||
|
||||
const rowRenderer: ComboBoxLitRenderer<HassioAddonInfo> = (item) => html`<style>
|
||||
paper-item {
|
||||
|
@ -2,6 +2,7 @@ import "@material/mwc-menu";
|
||||
import type { Corner, Menu } from "@material/mwc-menu";
|
||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||
import { customElement, property, query } from "lit/decorators";
|
||||
|
||||
@customElement("ha-button-menu")
|
||||
export class HaButtonMenu extends LitElement {
|
||||
@property() public corner: Corner = "TOP_START";
|
||||
|
@ -43,9 +43,9 @@ export class HaFileUpload extends LitElement {
|
||||
|
||||
protected updated(changedProperties: PropertyValues) {
|
||||
if (changedProperties.has("_drag") && !this.uploading) {
|
||||
(this.shadowRoot!.querySelector(
|
||||
"paper-input-container"
|
||||
) as any)._setFocused(this._drag);
|
||||
(
|
||||
this.shadowRoot!.querySelector("paper-input-container") as any
|
||||
)._setFocused(this._drag);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,8 +94,9 @@ export class HaFormMultiSelect extends LitElement implements HaFormElement {
|
||||
|
||||
protected firstUpdated() {
|
||||
this.updateComplete.then(() => {
|
||||
const input = (this.shadowRoot?.querySelector("paper-input")
|
||||
?.inputElement as any)?.inputElement;
|
||||
const input = (
|
||||
this.shadowRoot?.querySelector("paper-input")?.inputElement as any
|
||||
)?.inputElement;
|
||||
if (input) {
|
||||
input.style.textOverflow = "ellipsis";
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { Formfield } from "@material/mwc-formfield";
|
||||
import { css, CSSResultGroup } from "lit";
|
||||
import { customElement } from "lit/decorators";
|
||||
|
||||
@customElement("ha-formfield")
|
||||
// @ts-expect-error
|
||||
export class HaFormfield extends Formfield {
|
||||
|
@ -96,7 +96,7 @@ class HaHLSPlayer extends LitElement {
|
||||
const useExoPlayerPromise = this._getUseExoPlayer();
|
||||
const masterPlaylistPromise = fetch(this.url);
|
||||
|
||||
const Hls: typeof HlsType = (await import("hls.js/dist/hls.light.min.js"))
|
||||
const Hls: typeof HlsType = (await import("hls.js/dist/hls.light.min"))
|
||||
.default;
|
||||
let hlsSupported = Hls.isSupported();
|
||||
|
||||
@ -117,7 +117,8 @@ class HaHLSPlayer extends LitElement {
|
||||
|
||||
// Parse playlist assuming it is a master playlist. Match group 1 is whether hevc, match group 2 is regular playlist url
|
||||
// See https://tools.ietf.org/html/rfc8216 for HLS spec details
|
||||
const playlistRegexp = /#EXT-X-STREAM-INF:.*?(?:CODECS=".*?(hev1|hvc1)?\..*?".*?)?(?:\n|\r\n)(.+)/g;
|
||||
const playlistRegexp =
|
||||
/#EXT-X-STREAM-INF:.*?(?:CODECS=".*?(hev1|hvc1)?\..*?".*?)?(?:\n|\r\n)(.+)/g;
|
||||
const match = playlistRegexp.exec(masterPlaylist);
|
||||
const matchTwice = playlistRegexp.exec(masterPlaylist);
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { Radio } from "@material/mwc-radio";
|
||||
import { customElement } from "lit/decorators";
|
||||
|
||||
@customElement("ha-radio")
|
||||
export class HaRadio extends Radio {
|
||||
public firstUpdated() {
|
||||
|
@ -153,9 +153,8 @@ export class HaRelatedItems extends SubscribeMixin(LitElement) {
|
||||
</h3>
|
||||
<ul>
|
||||
${this._related.entity.map((entityId) => {
|
||||
const entity: HassEntity | undefined = this.hass.states[
|
||||
entityId
|
||||
];
|
||||
const entity: HassEntity | undefined =
|
||||
this.hass.states[entityId];
|
||||
if (!entity) {
|
||||
return "";
|
||||
}
|
||||
@ -203,9 +202,8 @@ export class HaRelatedItems extends SubscribeMixin(LitElement) {
|
||||
<h3>${this.hass.localize("ui.components.related-items.scene")}:</h3>
|
||||
<ul>
|
||||
${this._related.scene.map((sceneId) => {
|
||||
const scene: SceneEntity | undefined = this.hass.states[
|
||||
sceneId
|
||||
];
|
||||
const scene: SceneEntity | undefined =
|
||||
this.hass.states[sceneId];
|
||||
if (!scene) {
|
||||
return "";
|
||||
}
|
||||
@ -231,9 +229,8 @@ export class HaRelatedItems extends SubscribeMixin(LitElement) {
|
||||
</h3>
|
||||
<ul>
|
||||
${this._related.automation.map((automationId) => {
|
||||
const automation: HassEntity | undefined = this.hass.states[
|
||||
automationId
|
||||
];
|
||||
const automation: HassEntity | undefined =
|
||||
this.hass.states[automationId];
|
||||
if (!automation) {
|
||||
return "";
|
||||
}
|
||||
@ -260,9 +257,8 @@ export class HaRelatedItems extends SubscribeMixin(LitElement) {
|
||||
</h3>
|
||||
<ul>
|
||||
${this._related.script.map((scriptId) => {
|
||||
const script: HassEntity | undefined = this.hass.states[
|
||||
scriptId
|
||||
];
|
||||
const script: HassEntity | undefined =
|
||||
this.hass.states[scriptId];
|
||||
if (!script) {
|
||||
return "";
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { html, LitElement } from "lit";
|
||||
import { ComboBoxLitRenderer } from "lit-vaadin-helpers";
|
||||
import { property, state } from "lit/decorators";
|
||||
import memoizeOne from "memoize-one";
|
||||
import { fireEvent } from "../common/dom/fire_event";
|
||||
@ -6,7 +7,6 @@ import { LocalizeFunc } from "../common/translations/localize";
|
||||
import { domainToName } from "../data/integration";
|
||||
import { HomeAssistant } from "../types";
|
||||
import "./ha-combo-box";
|
||||
import { ComboBoxLitRenderer } from "lit-vaadin-helpers";
|
||||
|
||||
const rowRenderer: ComboBoxLitRenderer<{ service: string; name: string }> = (
|
||||
item
|
||||
|
@ -2,6 +2,7 @@ import { Switch } from "@material/mwc-switch";
|
||||
import { css, CSSResultGroup } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import { forwardHaptic } from "../data/haptics";
|
||||
|
||||
@customElement("ha-switch")
|
||||
// @ts-expect-error
|
||||
export class HaSwitch extends Switch {
|
||||
|
@ -180,9 +180,8 @@ export class HaLocationsEditor extends LitElement {
|
||||
const locationMarkers = {};
|
||||
const circles = {};
|
||||
|
||||
const defaultZoneRadiusColor = getComputedStyle(this).getPropertyValue(
|
||||
"--accent-color"
|
||||
);
|
||||
const defaultZoneRadiusColor =
|
||||
getComputedStyle(this).getPropertyValue("--accent-color");
|
||||
|
||||
this.locations.forEach((location: MarkerLocation) => {
|
||||
let icon: DivIcon | undefined;
|
||||
|
@ -132,9 +132,8 @@ export class HaMediaPlayerBrowse extends LitElement {
|
||||
return html``;
|
||||
}
|
||||
|
||||
const currentItem = this._mediaPlayerItems[
|
||||
this._mediaPlayerItems.length - 1
|
||||
];
|
||||
const currentItem =
|
||||
this._mediaPlayerItems[this._mediaPlayerItems.length - 1];
|
||||
|
||||
const previousItem: MediaPlayerItem | undefined =
|
||||
this._mediaPlayerItems.length > 1
|
||||
|
@ -111,14 +111,8 @@ export class HaTracePathDetails extends LitElement {
|
||||
|
||||
parts.push(
|
||||
data.map((trace, idx) => {
|
||||
const {
|
||||
path,
|
||||
timestamp,
|
||||
result,
|
||||
error,
|
||||
changed_variables,
|
||||
...rest
|
||||
} = trace as any;
|
||||
const { path, timestamp, result, error, changed_variables, ...rest } =
|
||||
trace as any;
|
||||
|
||||
return html`
|
||||
${curPath === this.selected.path
|
||||
|
@ -178,9 +178,8 @@ class HatScriptGraph extends LitElement {
|
||||
trace !== undefined && trace[0].result?.choice === i;
|
||||
this.renderedNodes[branch_path] = { config, path: branch_path };
|
||||
if (track_this) {
|
||||
this.trackedNodes[branch_path] = this.renderedNodes[
|
||||
branch_path
|
||||
];
|
||||
this.trackedNodes[branch_path] =
|
||||
this.renderedNodes[branch_path];
|
||||
}
|
||||
return html`
|
||||
<hat-graph>
|
||||
@ -489,9 +488,9 @@ class HatScriptGraph extends LitElement {
|
||||
: ""}
|
||||
${"condition" in this.trace.config
|
||||
? html`<hat-graph id="condition">
|
||||
${ensureArray(
|
||||
this.trace.config.condition
|
||||
)?.map((condition, i) => this.render_condition(condition!, i))}
|
||||
${ensureArray(this.trace.config.condition)?.map(
|
||||
(condition, i) => this.render_condition(condition!, i)
|
||||
)}
|
||||
</hat-graph>`
|
||||
: ""}
|
||||
${"action" in this.trace.config
|
||||
@ -535,12 +534,12 @@ class HatScriptGraph extends LitElement {
|
||||
}
|
||||
}
|
||||
|
||||
protected update(changedProps: PropertyValues<this>) {
|
||||
public willUpdate(changedProps: PropertyValues<this>) {
|
||||
super.willUpdate(changedProps);
|
||||
if (changedProps.has("trace")) {
|
||||
this.renderedNodes = {};
|
||||
this.trackedNodes = {};
|
||||
}
|
||||
super.update(changedProps);
|
||||
}
|
||||
|
||||
protected updated(changedProps: PropertyValues<this>) {
|
||||
|
@ -121,9 +121,8 @@ class LogbookRenderer {
|
||||
return;
|
||||
}
|
||||
|
||||
const previousEntryDate = this.pendingItems[
|
||||
this.pendingItems.length - 1
|
||||
][0];
|
||||
const previousEntryDate =
|
||||
this.pendingItems[this.pendingItems.length - 1][0];
|
||||
|
||||
// If logbook entry is too long after the last one,
|
||||
// add a time passed label
|
||||
|
@ -6,12 +6,13 @@ export const subscribeBootstrapIntegrations = (
|
||||
hass: HomeAssistant,
|
||||
callback: (message: BootstrapIntegrationsTimings) => void
|
||||
) => {
|
||||
const unsubProm = hass.connection.subscribeMessage<BootstrapIntegrationsTimings>(
|
||||
(message) => callback(message),
|
||||
{
|
||||
type: "subscribe_bootstrap_integrations",
|
||||
}
|
||||
);
|
||||
const unsubProm =
|
||||
hass.connection.subscribeMessage<BootstrapIntegrationsTimings>(
|
||||
(message) => callback(message),
|
||||
{
|
||||
type: "subscribe_bootstrap_integrations",
|
||||
}
|
||||
);
|
||||
|
||||
return unsubProm;
|
||||
};
|
||||
|
@ -9,7 +9,8 @@ export interface DiscoveryInformation {
|
||||
version: string;
|
||||
}
|
||||
|
||||
export const fetchDiscoveryInformation = async (): Promise<DiscoveryInformation> => {
|
||||
const response = await fetch("/api/discovery_info", { method: "GET" });
|
||||
return response.json();
|
||||
};
|
||||
export const fetchDiscoveryInformation =
|
||||
async (): Promise<DiscoveryInformation> => {
|
||||
const response = await fetch("/api/discovery_info", { method: "GET" });
|
||||
return response.json();
|
||||
};
|
||||
|
@ -14,7 +14,8 @@ import { HaDomainTogglerDialogParams } from "./show-dialog-domain-toggler";
|
||||
@customElement("dialog-domain-toggler")
|
||||
class DomainTogglerDialog
|
||||
extends LitElement
|
||||
implements HassDialog<HaDomainTogglerDialogParams> {
|
||||
implements HassDialog<HaDomainTogglerDialogParams>
|
||||
{
|
||||
public hass!: HomeAssistant;
|
||||
|
||||
@state() private _params?: HaDomainTogglerDialogParams;
|
||||
|
@ -136,12 +136,12 @@ class MoreInfoConfigurator extends PolymerElement {
|
||||
this.isConfiguring = true;
|
||||
|
||||
this.hass.callService("configurator", "configure", data).then(
|
||||
function () {
|
||||
() => {
|
||||
this.isConfiguring = false;
|
||||
}.bind(this),
|
||||
function () {
|
||||
},
|
||||
() => {
|
||||
this.isConfiguring = false;
|
||||
}.bind(this)
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -444,9 +444,7 @@ class MoreInfoLight extends LitElement {
|
||||
value = (value * 255) / 100;
|
||||
|
||||
const rgb = (getLightCurrentModeRgbColor(this.stateObj!)?.slice(0, 3) || [
|
||||
255,
|
||||
255,
|
||||
255,
|
||||
255, 255, 255,
|
||||
]) as [number, number, number];
|
||||
|
||||
this._setRgbWColor(
|
||||
|
@ -181,7 +181,7 @@ export class HuiNotificationDrawer extends EventsMixin(
|
||||
|
||||
const notifications = notificationsBackend.concat(configuratorEntities);
|
||||
|
||||
notifications.sort(function (n1, n2) {
|
||||
notifications.sort((n1, n2) => {
|
||||
const d1 = new Date(n1.created_at);
|
||||
const d2 = new Date(n2.created_at);
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
import { Layout1d, scroll } from "../../resources/lit-virtualizer";
|
||||
import "@material/mwc-list/mwc-list";
|
||||
import type { List } from "@material/mwc-list/mwc-list";
|
||||
import { SingleSelectedEvent } from "@material/mwc-list/mwc-list-foundation";
|
||||
@ -39,6 +38,7 @@ import { domainToName } from "../../data/integration";
|
||||
import { getPanelNameTranslationKey } from "../../data/panel";
|
||||
import { PageNavigation } from "../../layouts/hass-tabs-subpage";
|
||||
import { configSections } from "../../panels/config/ha-panel-config";
|
||||
import { Layout1d, scroll } from "../../resources/lit-virtualizer";
|
||||
import { haStyleDialog } from "../../resources/styles";
|
||||
import { HomeAssistant } from "../../types";
|
||||
import {
|
||||
|
@ -344,7 +344,8 @@ export class HaVoiceCommandDialog extends LitElement {
|
||||
}
|
||||
|
||||
private _scrollMessagesBottom() {
|
||||
this.messages.scrollTarget.scrollTop = this.messages.scrollTarget.scrollHeight;
|
||||
this.messages.scrollTarget.scrollTop =
|
||||
this.messages.scrollTarget.scrollHeight;
|
||||
if (this.messages.scrollTarget.scrollTop === 0) {
|
||||
fireEvent(this.messages, "iron-resize");
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ function initPushNotifications() {
|
||||
);
|
||||
}
|
||||
|
||||
self.addEventListener("push", function (event) {
|
||||
self.addEventListener("push", (event) => {
|
||||
let data;
|
||||
if (event.data) {
|
||||
data = event.data.json();
|
||||
@ -122,7 +122,7 @@ function initPushNotifications() {
|
||||
event.waitUntil(
|
||||
self.registration
|
||||
.showNotification(data.title, data)
|
||||
.then(function (/* notification */) {
|
||||
.then((/* notification */) => {
|
||||
firePushCallback(
|
||||
{
|
||||
type: "received",
|
||||
@ -136,7 +136,7 @@ function initPushNotifications() {
|
||||
}
|
||||
});
|
||||
|
||||
self.addEventListener("notificationclick", function (event) {
|
||||
self.addEventListener("notificationclick", (event) => {
|
||||
notificationEventCallback("clicked", event);
|
||||
|
||||
event.notification.close();
|
||||
@ -158,7 +158,7 @@ function initPushNotifications() {
|
||||
.matchAll({
|
||||
type: "window",
|
||||
})
|
||||
.then(function (windowClients) {
|
||||
.then((windowClients) => {
|
||||
let i;
|
||||
let client;
|
||||
for (i = 0; i < windowClients.length; i++) {
|
||||
@ -175,7 +175,7 @@ function initPushNotifications() {
|
||||
);
|
||||
});
|
||||
|
||||
self.addEventListener("notificationclose", function (event) {
|
||||
self.addEventListener("notificationclose", (event) => {
|
||||
notificationEventCallback("closed", event);
|
||||
});
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { isNavigationClick } from "../common/dom/is-navigation-click";
|
||||
import { html, PropertyValues } from "lit";
|
||||
import { customElement, state } from "lit/decorators";
|
||||
import { isNavigationClick } from "../common/dom/is-navigation-click";
|
||||
import { navigate } from "../common/navigate";
|
||||
import { getStorageDefaultPanelUrlPath } from "../data/panel";
|
||||
import "../resources/custom-card-support";
|
||||
|
@ -99,7 +99,7 @@ class SupervisorErrorScreen extends LitElement {
|
||||
}
|
||||
} else {
|
||||
themeName =
|
||||
((this.hass.selectedTheme as unknown) as string) ||
|
||||
(this.hass.selectedTheme as unknown as string) ||
|
||||
this.hass.themes.default_theme;
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ export const SubscribeMixin = <T extends Constructor<ReactiveElement>>(
|
||||
private __checkSubscribed(): void {
|
||||
if (
|
||||
this.__unsubs !== undefined ||
|
||||
!((this as unknown) as Element).isConnected ||
|
||||
!(this as unknown as Element).isConnected ||
|
||||
this.hass === undefined
|
||||
) {
|
||||
return;
|
||||
|
@ -254,7 +254,8 @@ class HaOnboarding extends litLocalizeLiteMixin(HassElement) {
|
||||
this._loading = true;
|
||||
|
||||
// Determine if oauth redirect has been provided
|
||||
const externalAuthParams = extractSearchParamsObject() as AuthUrlSearchParams;
|
||||
const externalAuthParams =
|
||||
extractSearchParamsObject() as AuthUrlSearchParams;
|
||||
const authParams =
|
||||
externalAuthParams.client_id && externalAuthParams.redirect_uri
|
||||
? externalAuthParams
|
||||
|
@ -52,9 +52,13 @@ class HaConfigAreaPage extends LitElement {
|
||||
|
||||
@state() private _related?: RelatedResult;
|
||||
|
||||
private _area = memoizeOne((areaId: string, areas: AreaRegistryEntry[]):
|
||||
| AreaRegistryEntry
|
||||
| undefined => areas.find((area) => area.area_id === areaId));
|
||||
private _area = memoizeOne(
|
||||
(
|
||||
areaId: string,
|
||||
areas: AreaRegistryEntry[]
|
||||
): AreaRegistryEntry | undefined =>
|
||||
areas.find((area) => area.area_id === areaId)
|
||||
);
|
||||
|
||||
private _memberships = memoizeOne(
|
||||
(
|
||||
|
@ -12,7 +12,8 @@ import { ActionElement, handleChangeEvent } from "../ha-automation-action-row";
|
||||
@customElement("ha-automation-action-wait_for_trigger")
|
||||
export class HaWaitForTriggerAction
|
||||
extends LitElement
|
||||
implements ActionElement {
|
||||
implements ActionElement
|
||||
{
|
||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||
|
||||
@property() public action!: WaitForTriggerAction;
|
||||
|
@ -20,13 +20,8 @@ export default class HaNumericStateCondition extends LitElement {
|
||||
}
|
||||
|
||||
public render() {
|
||||
const {
|
||||
value_template,
|
||||
entity_id,
|
||||
attribute,
|
||||
below,
|
||||
above,
|
||||
} = this.condition;
|
||||
const { value_template, entity_id, attribute, below, above } =
|
||||
this.condition;
|
||||
|
||||
return html`
|
||||
<ha-entity-picker
|
||||
|
@ -1,15 +1,15 @@
|
||||
import "@polymer/paper-dropdown-menu/paper-dropdown-menu-light";
|
||||
import { UnsubscribeFunc } from "home-assistant-js-websocket";
|
||||
import { html, LitElement } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { fireEvent } from "../../../../../common/dom/fire_event";
|
||||
import { ensureArray } from "../../../../../common/ensure-array";
|
||||
import {
|
||||
AutomationConfig,
|
||||
Trigger,
|
||||
TriggerCondition,
|
||||
} from "../../../../../data/automation";
|
||||
import { HomeAssistant } from "../../../../../types";
|
||||
import "@polymer/paper-dropdown-menu/paper-dropdown-menu-light";
|
||||
import { ensureArray } from "../../../../../common/ensure-array";
|
||||
import { UnsubscribeFunc } from "home-assistant-js-websocket";
|
||||
|
||||
@customElement("ha-automation-condition-trigger")
|
||||
export class HaTriggerCondition extends LitElement {
|
||||
|
@ -61,11 +61,12 @@ class HaAutomationPicker extends LitElement {
|
||||
if (filteredAutomations === null) {
|
||||
return [];
|
||||
}
|
||||
return (filteredAutomations
|
||||
? automations.filter((automation) =>
|
||||
filteredAutomations!.includes(automation.entity_id)
|
||||
)
|
||||
: automations
|
||||
return (
|
||||
filteredAutomations
|
||||
? automations.filter((automation) =>
|
||||
filteredAutomations!.includes(automation.entity_id)
|
||||
)
|
||||
: automations
|
||||
).map((automation) => ({
|
||||
...automation,
|
||||
name: computeStateName(automation),
|
||||
|
@ -433,8 +433,8 @@ export class HaAutomationTrace extends LitElement {
|
||||
|
||||
private _timelinePathPicked(ev) {
|
||||
const path = ev.detail.value;
|
||||
const nodes = this.shadowRoot!.querySelector("hat-script-graph")!
|
||||
.trackedNodes;
|
||||
const nodes =
|
||||
this.shadowRoot!.querySelector("hat-script-graph")!.trackedNodes;
|
||||
if (nodes[path]) {
|
||||
this._selected = nodes[path];
|
||||
}
|
||||
|
@ -197,9 +197,10 @@ export class ThingTalkPlaceholders extends SubscribeMixin(LitElement) {
|
||||
])
|
||||
)}`}
|
||||
.entityFilter=${(entityState: HassEntity) => {
|
||||
const devId = this._placeholderValues[type][
|
||||
placeholder.index
|
||||
][idx].device_id;
|
||||
const devId =
|
||||
this._placeholderValues[type][
|
||||
placeholder.index
|
||||
][idx].device_id;
|
||||
return this._deviceEntityLookup[
|
||||
devId
|
||||
].includes(entityState.entity_id);
|
||||
|
@ -7,6 +7,7 @@ import { fetchTags, Tag } from "../../../../../data/tag";
|
||||
import { HomeAssistant } from "../../../../../types";
|
||||
import { TriggerElement } from "../ha-automation-trigger-row";
|
||||
import "../../../../../components/ha-paper-dropdown-menu";
|
||||
|
||||
@customElement("ha-automation-trigger-tag")
|
||||
export class HaTagTrigger extends LitElement implements TriggerElement {
|
||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||
|
@ -22,11 +22,8 @@ export class CloudGooglePref extends LitElement {
|
||||
return html``;
|
||||
}
|
||||
|
||||
const {
|
||||
google_enabled,
|
||||
google_report_state,
|
||||
google_secure_devices_pin,
|
||||
} = this.cloudStatus.prefs;
|
||||
const { google_enabled, google_report_state, google_secure_devices_pin } =
|
||||
this.cloudStatus.prefs;
|
||||
|
||||
return html`
|
||||
<ha-card
|
||||
|
@ -28,11 +28,8 @@ export class CloudRemotePref extends LitElement {
|
||||
|
||||
const { remote_enabled } = this.cloudStatus.prefs;
|
||||
|
||||
const {
|
||||
remote_connected,
|
||||
remote_domain,
|
||||
remote_certificate,
|
||||
} = this.cloudStatus;
|
||||
const { remote_connected, remote_domain, remote_certificate } =
|
||||
this.cloudStatus;
|
||||
|
||||
if (!remote_certificate) {
|
||||
return html`
|
||||
|
@ -32,9 +32,8 @@ export class HaDeviceActionsOzw extends LitElement {
|
||||
|
||||
protected updated(changedProperties: PropertyValues) {
|
||||
if (changedProperties.has("device")) {
|
||||
const identifiers:
|
||||
| OZWNodeIdentifiers
|
||||
| undefined = getIdentifiersFromDevice(this.device);
|
||||
const identifiers: OZWNodeIdentifiers | undefined =
|
||||
getIdentifiersFromDevice(this.device);
|
||||
if (!identifiers) {
|
||||
return;
|
||||
}
|
||||
|
@ -33,9 +33,8 @@ export class HaDeviceInfoOzw extends LitElement {
|
||||
|
||||
protected updated(changedProperties: PropertyValues) {
|
||||
if (changedProperties.has("device")) {
|
||||
const identifiers:
|
||||
| OZWNodeIdentifiers
|
||||
| undefined = getIdentifiersFromDevice(this.device);
|
||||
const identifiers: OZWNodeIdentifiers | undefined =
|
||||
getIdentifiersFromDevice(this.device);
|
||||
if (!identifiers) {
|
||||
return;
|
||||
}
|
||||
|
@ -31,9 +31,8 @@ export class HaDeviceActionsZWaveJS extends LitElement {
|
||||
if (changedProperties.has("device")) {
|
||||
this._entryId = this.device.config_entries[0];
|
||||
|
||||
const identifiers:
|
||||
| ZWaveJSNodeIdentifiers
|
||||
| undefined = getIdentifiersFromDevice(this.device);
|
||||
const identifiers: ZWaveJSNodeIdentifiers | undefined =
|
||||
getIdentifiersFromDevice(this.device);
|
||||
if (!identifiers) {
|
||||
return;
|
||||
}
|
||||
|
@ -40,9 +40,8 @@ export class HaDeviceInfoZWaveJS extends LitElement {
|
||||
|
||||
protected updated(changedProperties: PropertyValues) {
|
||||
if (changedProperties.has("device")) {
|
||||
const identifiers:
|
||||
| ZWaveJSNodeIdentifiers
|
||||
| undefined = getIdentifiersFromDevice(this.device);
|
||||
const identifiers: ZWaveJSNodeIdentifiers | undefined =
|
||||
getIdentifiersFromDevice(this.device);
|
||||
if (!identifiers) {
|
||||
return;
|
||||
}
|
||||
|
@ -110,18 +110,19 @@ export class HaConfigDevicePage extends LitElement {
|
||||
)
|
||||
);
|
||||
|
||||
private _computeArea = memoizeOne((areas, device):
|
||||
| AreaRegistryEntry
|
||||
| undefined => {
|
||||
if (!areas || !device || !device.area_id) {
|
||||
return undefined;
|
||||
private _computeArea = memoizeOne(
|
||||
(areas, device): AreaRegistryEntry | undefined => {
|
||||
if (!areas || !device || !device.area_id) {
|
||||
return undefined;
|
||||
}
|
||||
return areas.find((area) => area.area_id === device.area_id);
|
||||
}
|
||||
return areas.find((area) => area.area_id === device.area_id);
|
||||
});
|
||||
);
|
||||
|
||||
private _batteryEntity = memoizeOne((entities: EntityRegistryEntry[]):
|
||||
| EntityRegistryEntry
|
||||
| undefined => findBatteryEntity(this.hass, entities));
|
||||
private _batteryEntity = memoizeOne(
|
||||
(entities: EntityRegistryEntry[]): EntityRegistryEntry | undefined =>
|
||||
findBatteryEntity(this.hass, entities)
|
||||
);
|
||||
|
||||
private _batteryChargingEntity = memoizeOne(
|
||||
(entities: EntityRegistryEntry[]): EntityRegistryEntry | undefined =>
|
||||
|
@ -100,9 +100,8 @@ export class EntityRegistrySettings extends SubscribeMixin(LitElement) {
|
||||
if (this.entry.entity_id !== this._origEntityId) {
|
||||
return html``;
|
||||
}
|
||||
const stateObj: HassEntity | undefined = this.hass.states[
|
||||
this.entry.entity_id
|
||||
];
|
||||
const stateObj: HassEntity | undefined =
|
||||
this.hass.states[this.entry.entity_id];
|
||||
const invalidDomainUpdate =
|
||||
computeDomain(this._entityId.trim()) !==
|
||||
computeDomain(this.entry.entity_id);
|
||||
|
@ -442,20 +442,18 @@ export class HaConfigEntities extends SubscribeMixin(LitElement) {
|
||||
this._entries
|
||||
);
|
||||
|
||||
const {
|
||||
filteredEntities,
|
||||
filteredDomains,
|
||||
} = this._filteredEntitiesAndDomains(
|
||||
this._entities,
|
||||
this._devices,
|
||||
this._areas,
|
||||
this._stateEntities,
|
||||
this._searchParms,
|
||||
this._showDisabled,
|
||||
this._showUnavailable,
|
||||
this._showReadOnly,
|
||||
this._entries
|
||||
);
|
||||
const { filteredEntities, filteredDomains } =
|
||||
this._filteredEntitiesAndDomains(
|
||||
this._entities,
|
||||
this._devices,
|
||||
this._areas,
|
||||
this._stateEntities,
|
||||
this._searchParms,
|
||||
this._showDisabled,
|
||||
this._showUnavailable,
|
||||
this._showReadOnly,
|
||||
this._entries
|
||||
);
|
||||
|
||||
const includeZHAFab = filteredDomains.includes("zha");
|
||||
|
||||
|
@ -54,9 +54,9 @@ class HaCounterForm extends LitElement {
|
||||
|
||||
public focus() {
|
||||
this.updateComplete.then(() =>
|
||||
(this.shadowRoot?.querySelector(
|
||||
"[dialogInitialFocus]"
|
||||
) as HTMLElement)?.focus()
|
||||
(
|
||||
this.shadowRoot?.querySelector("[dialogInitialFocus]") as HTMLElement
|
||||
)?.focus()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -32,9 +32,9 @@ class HaInputBooleanForm extends LitElement {
|
||||
|
||||
public focus() {
|
||||
this.updateComplete.then(() =>
|
||||
(this.shadowRoot?.querySelector(
|
||||
"[dialogInitialFocus]"
|
||||
) as HTMLElement)?.focus()
|
||||
(
|
||||
this.shadowRoot?.querySelector("[dialogInitialFocus]") as HTMLElement
|
||||
)?.focus()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -43,9 +43,9 @@ class HaInputDateTimeForm extends LitElement {
|
||||
|
||||
public focus() {
|
||||
this.updateComplete.then(() =>
|
||||
(this.shadowRoot?.querySelector(
|
||||
"[dialogInitialFocus]"
|
||||
) as HTMLElement)?.focus()
|
||||
(
|
||||
this.shadowRoot?.querySelector("[dialogInitialFocus]") as HTMLElement
|
||||
)?.focus()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -58,9 +58,9 @@ class HaInputNumberForm extends LitElement {
|
||||
|
||||
public focus() {
|
||||
this.updateComplete.then(() =>
|
||||
(this.shadowRoot?.querySelector(
|
||||
"[dialogInitialFocus]"
|
||||
) as HTMLElement)?.focus()
|
||||
(
|
||||
this.shadowRoot?.querySelector("[dialogInitialFocus]") as HTMLElement
|
||||
)?.focus()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -44,9 +44,9 @@ class HaInputSelectForm extends LitElement {
|
||||
|
||||
public focus() {
|
||||
this.updateComplete.then(() =>
|
||||
(this.shadowRoot?.querySelector(
|
||||
"[dialogInitialFocus]"
|
||||
) as HTMLElement)?.focus()
|
||||
(
|
||||
this.shadowRoot?.querySelector("[dialogInitialFocus]") as HTMLElement
|
||||
)?.focus()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -49,9 +49,9 @@ class HaInputTextForm extends LitElement {
|
||||
|
||||
public focus() {
|
||||
this.updateComplete.then(() =>
|
||||
(this.shadowRoot?.querySelector(
|
||||
"[dialogInitialFocus]"
|
||||
) as HTMLElement)?.focus()
|
||||
(
|
||||
this.shadowRoot?.querySelector("[dialogInitialFocus]") as HTMLElement
|
||||
)?.focus()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -35,9 +35,9 @@ class HaTimerForm extends LitElement {
|
||||
|
||||
public focus() {
|
||||
this.updateComplete.then(() =>
|
||||
(this.shadowRoot?.querySelector(
|
||||
"[dialogInitialFocus]"
|
||||
) as HTMLElement)?.focus()
|
||||
(
|
||||
this.shadowRoot?.querySelector("[dialogInitialFocus]") as HTMLElement
|
||||
)?.focus()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -38,80 +38,75 @@ export class HaConfigHelpers extends LitElement {
|
||||
|
||||
@state() private _stateItems: HassEntity[] = [];
|
||||
|
||||
private _columns = memoize(
|
||||
(narrow, _language): DataTableColumnContainer => {
|
||||
const columns: DataTableColumnContainer = {
|
||||
icon: {
|
||||
title: "",
|
||||
type: "icon",
|
||||
template: (icon, helper: any) => html`
|
||||
<ha-icon .icon=${icon || domainIcon(helper.type)}></ha-icon>
|
||||
`,
|
||||
},
|
||||
name: {
|
||||
title: this.hass.localize(
|
||||
"ui.panel.config.helpers.picker.headers.name"
|
||||
),
|
||||
sortable: true,
|
||||
filterable: true,
|
||||
grows: true,
|
||||
direction: "asc",
|
||||
template: (name, item: any) =>
|
||||
html`
|
||||
${name}
|
||||
${narrow
|
||||
? html` <div class="secondary">${item.entity_id}</div> `
|
||||
: ""}
|
||||
`,
|
||||
},
|
||||
};
|
||||
if (!narrow) {
|
||||
columns.entity_id = {
|
||||
title: this.hass.localize(
|
||||
"ui.panel.config.helpers.picker.headers.entity_id"
|
||||
),
|
||||
sortable: true,
|
||||
filterable: true,
|
||||
width: "25%",
|
||||
};
|
||||
}
|
||||
columns.type = {
|
||||
title: this.hass.localize(
|
||||
"ui.panel.config.helpers.picker.headers.type"
|
||||
),
|
||||
sortable: true,
|
||||
width: "25%",
|
||||
filterable: true,
|
||||
template: (type) =>
|
||||
html`
|
||||
${this.hass.localize(`ui.panel.config.helpers.types.${type}`) ||
|
||||
type}
|
||||
`,
|
||||
};
|
||||
columns.editable = {
|
||||
private _columns = memoize((narrow, _language): DataTableColumnContainer => {
|
||||
const columns: DataTableColumnContainer = {
|
||||
icon: {
|
||||
title: "",
|
||||
type: "icon",
|
||||
template: (editable) => html`
|
||||
${!editable
|
||||
? html`
|
||||
<div
|
||||
tabindex="0"
|
||||
style="display:inline-block; position: relative;"
|
||||
>
|
||||
<ha-icon icon="hass:pencil-off"></ha-icon>
|
||||
<paper-tooltip animation-delay="0" position="left">
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.entities.picker.status.readonly"
|
||||
)}
|
||||
</paper-tooltip>
|
||||
</div>
|
||||
`
|
||||
: ""}
|
||||
template: (icon, helper: any) => html`
|
||||
<ha-icon .icon=${icon || domainIcon(helper.type)}></ha-icon>
|
||||
`,
|
||||
},
|
||||
name: {
|
||||
title: this.hass.localize(
|
||||
"ui.panel.config.helpers.picker.headers.name"
|
||||
),
|
||||
sortable: true,
|
||||
filterable: true,
|
||||
grows: true,
|
||||
direction: "asc",
|
||||
template: (name, item: any) =>
|
||||
html`
|
||||
${name}
|
||||
${narrow
|
||||
? html` <div class="secondary">${item.entity_id}</div> `
|
||||
: ""}
|
||||
`,
|
||||
},
|
||||
};
|
||||
if (!narrow) {
|
||||
columns.entity_id = {
|
||||
title: this.hass.localize(
|
||||
"ui.panel.config.helpers.picker.headers.entity_id"
|
||||
),
|
||||
sortable: true,
|
||||
filterable: true,
|
||||
width: "25%",
|
||||
};
|
||||
return columns;
|
||||
}
|
||||
);
|
||||
columns.type = {
|
||||
title: this.hass.localize("ui.panel.config.helpers.picker.headers.type"),
|
||||
sortable: true,
|
||||
width: "25%",
|
||||
filterable: true,
|
||||
template: (type) =>
|
||||
html`
|
||||
${this.hass.localize(`ui.panel.config.helpers.types.${type}`) || type}
|
||||
`,
|
||||
};
|
||||
columns.editable = {
|
||||
title: "",
|
||||
type: "icon",
|
||||
template: (editable) => html`
|
||||
${!editable
|
||||
? html`
|
||||
<div
|
||||
tabindex="0"
|
||||
style="display:inline-block; position: relative;"
|
||||
>
|
||||
<ha-icon icon="hass:pencil-off"></ha-icon>
|
||||
<paper-tooltip animation-delay="0" position="left">
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.entities.picker.status.readonly"
|
||||
)}
|
||||
</paper-tooltip>
|
||||
</div>
|
||||
`
|
||||
: ""}
|
||||
`,
|
||||
};
|
||||
return columns;
|
||||
});
|
||||
|
||||
private _getItems = memoize((stateItems: HassEntity[]) =>
|
||||
stateItems.map((entityState) => ({
|
||||
|
@ -87,9 +87,8 @@ class IntegrationsCard extends LitElement {
|
||||
>
|
||||
`
|
||||
: "";
|
||||
const setupSeconds = this._setups?.[domain]?.seconds?.toFixed(
|
||||
2
|
||||
);
|
||||
const setupSeconds =
|
||||
this._setups?.[domain]?.seconds?.toFixed(2);
|
||||
return html`
|
||||
<tr>
|
||||
<td>
|
||||
@ -100,7 +99,11 @@ class IntegrationsCard extends LitElement {
|
||||
/>
|
||||
</td>
|
||||
<td class="name">
|
||||
${domainToName(this.hass.localize, domain, manifest)}<br />
|
||||
${domainToName(
|
||||
this.hass.localize,
|
||||
domain,
|
||||
manifest
|
||||
)}<br />
|
||||
<span class="domain">${domain}</span>
|
||||
${this.narrow
|
||||
? html`<div class="mobile-row">
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||
import memoizeOne from "memoize-one";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { computeRTLDirection } from "../../../../../common/util/compute_rtl";
|
||||
import "../../../../../components/ha-code-editor";
|
||||
import { createCloseHeading } from "../../../../../components/ha-dialog";
|
||||
@ -14,7 +15,6 @@ import type {
|
||||
import "../../../../../components/ha-circular-progress";
|
||||
import { fetchDevices, ZHADevice } from "../../../../../data/zha";
|
||||
import { fireEvent } from "../../../../../common/dom/fire_event";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
|
||||
export interface DeviceRowData extends DataTableRowData {
|
||||
id: string;
|
||||
|
@ -35,9 +35,8 @@ class DialogZHAReconfigureDevice extends LitElement {
|
||||
ClusterConfigurationStatus
|
||||
> = new Map();
|
||||
|
||||
@state() private _params:
|
||||
| ZHAReconfigureDeviceDialogParams
|
||||
| undefined = undefined;
|
||||
@state() private _params: ZHAReconfigureDeviceDialogParams | undefined =
|
||||
undefined;
|
||||
|
||||
@state() private _allSuccessful = true;
|
||||
|
||||
@ -341,9 +340,10 @@ class DialogZHAReconfigureDevice extends LitElement {
|
||||
this._unsubscribe();
|
||||
this._status = this._allSuccessful ? "finished" : "failed";
|
||||
} else {
|
||||
const clusterConfigurationStatus = this._clusterConfigurationStatuses!.get(
|
||||
message.zha_channel_msg_data.cluster_id
|
||||
);
|
||||
const clusterConfigurationStatus =
|
||||
this._clusterConfigurationStatuses!.get(
|
||||
message.zha_channel_msg_data.cluster_id
|
||||
);
|
||||
if (message.type === ZHA_CHANNEL_MSG_BIND) {
|
||||
if (!this._stages) {
|
||||
this._stages = ["binding"];
|
||||
|
@ -171,8 +171,9 @@ class ZHAAddDevicesPage extends LitElement {
|
||||
if (this.shadowRoot) {
|
||||
const paperTextArea = this.shadowRoot.querySelector("paper-textarea");
|
||||
if (paperTextArea) {
|
||||
const textArea = (paperTextArea.inputElement as IronAutogrowTextareaElement)
|
||||
.textarea;
|
||||
const textArea = (
|
||||
paperTextArea.inputElement as IronAutogrowTextareaElement
|
||||
).textarea;
|
||||
textArea.scrollTop = textArea.scrollHeight;
|
||||
}
|
||||
}
|
||||
|
@ -192,7 +192,8 @@ export class ZHAClusterCommands extends LitElement {
|
||||
|
||||
private _onManufacturerCodeOverrideChanged(value: ChangeEvent): void {
|
||||
this._manufacturerCodeOverride = value.detail!.value;
|
||||
this._issueClusterCommandServiceData = this._computeIssueClusterCommandServiceData();
|
||||
this._issueClusterCommandServiceData =
|
||||
this._computeIssueClusterCommandServiceData();
|
||||
}
|
||||
|
||||
private _onHelpTap(): void {
|
||||
@ -201,7 +202,8 @@ export class ZHAClusterCommands extends LitElement {
|
||||
|
||||
private _selectedCommandChanged(event: ItemSelectedEvent): void {
|
||||
this._selectedCommandIndex = event.target!.selected;
|
||||
this._issueClusterCommandServiceData = this._computeIssueClusterCommandServiceData();
|
||||
this._issueClusterCommandServiceData =
|
||||
this._computeIssueClusterCommandServiceData();
|
||||
}
|
||||
|
||||
static get styles(): CSSResultGroup {
|
||||
|
@ -10,6 +10,7 @@ import {
|
||||
PropertyValues,
|
||||
TemplateResult,
|
||||
} from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import { computeRTL } from "../../../../../common/util/compute_rtl";
|
||||
import "../../../../../components/ha-card";
|
||||
import "../../../../../components/ha-fab";
|
||||
@ -25,7 +26,6 @@ import {
|
||||
updateZHAConfiguration,
|
||||
ZHAConfiguration,
|
||||
} from "../../../../../data/zha";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
|
||||
export const zhaTabs: PageNavigation[] = [
|
||||
{
|
||||
|
@ -2,6 +2,8 @@ import "@polymer/paper-input/paper-input";
|
||||
import "@polymer/paper-listbox/paper-listbox";
|
||||
import { UnsubscribeFunc } from "home-assistant-js-websocket";
|
||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||
import memoizeOne from "memoize-one";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { fireEvent } from "../../../../../common/dom/fire_event";
|
||||
import { computeStateName } from "../../../../../common/entity/compute_state_name";
|
||||
import "../../../../../components/buttons/ha-call-service-button";
|
||||
@ -20,12 +22,10 @@ import {
|
||||
EntityRegistryEntry,
|
||||
updateEntityRegistryEntry,
|
||||
} from "../../../../../data/entity_registry";
|
||||
import memoizeOne from "memoize-one";
|
||||
import { EntityRegistryStateEntry } from "../../../devices/ha-config-device-page";
|
||||
import { compare } from "../../../../../common/string/compare";
|
||||
import { getIeeeTail } from "./functions";
|
||||
import { slugify } from "../../../../../common/string/slugify";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
|
||||
@customElement("zha-device-card")
|
||||
class ZHADeviceCard extends SubscribeMixin(LitElement) {
|
||||
|
@ -1,32 +1,31 @@
|
||||
import { css, CSSResultGroup, html, LitElement, PropertyValues } from "lit";
|
||||
|
||||
import "@material/mwc-button";
|
||||
import { css, CSSResultGroup, html, LitElement, PropertyValues } from "lit";
|
||||
import { customElement, property, query, state } from "lit/decorators";
|
||||
import {
|
||||
Edge,
|
||||
EdgeOptions,
|
||||
Network,
|
||||
Node,
|
||||
} from "vis-network/peer/esm/vis-network";
|
||||
import { navigate } from "../../../../../common/navigate";
|
||||
import "../../../../../common/search/search-input";
|
||||
import "../../../../../components/device/ha-device-picker";
|
||||
import "../../../../../components/ha-button-menu";
|
||||
import "../../../../../components/ha-checkbox";
|
||||
import type { HaCheckbox } from "../../../../../components/ha-checkbox";
|
||||
import "../../../../../components/ha-formfield";
|
||||
import "../../../../../components/ha-svg-icon";
|
||||
import { DeviceRegistryEntry } from "../../../../../data/device_registry";
|
||||
import {
|
||||
fetchDevices,
|
||||
refreshTopology,
|
||||
ZHADevice,
|
||||
} from "../../../../../data/zha";
|
||||
import "../../../../../layouts/hass-tabs-subpage";
|
||||
import type { HomeAssistant, Route } from "../../../../../types";
|
||||
import {
|
||||
Network,
|
||||
Edge,
|
||||
Node,
|
||||
EdgeOptions,
|
||||
} from "vis-network/peer/esm/vis-network";
|
||||
import "../../../../../common/search/search-input";
|
||||
import "../../../../../components/device/ha-device-picker";
|
||||
import "../../../../../components/ha-button-menu";
|
||||
import "../../../../../components/ha-svg-icon";
|
||||
import { PolymerChangedEvent } from "../../../../../polymer-types";
|
||||
import type { HomeAssistant, Route } from "../../../../../types";
|
||||
import { formatAsPaddedHex } from "./functions";
|
||||
import { DeviceRegistryEntry } from "../../../../../data/device_registry";
|
||||
import "../../../../../components/ha-checkbox";
|
||||
import type { HaCheckbox } from "../../../../../components/ha-checkbox";
|
||||
import { zhaTabs } from "./zha-config-dashboard";
|
||||
import { customElement, property, query, state } from "lit/decorators";
|
||||
import "../../../../../components/ha-formfield";
|
||||
|
||||
@customElement("zha-network-visualization-page")
|
||||
export class ZHANetworkVisualizationPage extends LitElement {
|
||||
@ -225,9 +224,9 @@ export class ZHANetworkVisualizationPage extends LitElement {
|
||||
});
|
||||
if (device.neighbors && device.neighbors.length > 0) {
|
||||
device.neighbors.forEach((neighbor) => {
|
||||
const idx = edges.findIndex(function (e) {
|
||||
return device.ieee === e.to && neighbor.ieee === e.from;
|
||||
});
|
||||
const idx = edges.findIndex(
|
||||
(e) => device.ieee === e.to && neighbor.ieee === e.from
|
||||
);
|
||||
if (idx === -1) {
|
||||
edges.push({
|
||||
from: device.ieee,
|
||||
|
@ -131,7 +131,7 @@ class ZwaveNodeProtection extends LocalizeMixin(PolymerElement) {
|
||||
let options = [];
|
||||
let value_id = -1;
|
||||
let selected = -1;
|
||||
this.protection.forEach(function (item) {
|
||||
this.protection.forEach((item) => {
|
||||
if (item.key === "options") options = item.value;
|
||||
else if (item.key === "value_id") value_id = item.value;
|
||||
else if (item.key === "selected") selected = item.value;
|
||||
|
@ -4,12 +4,12 @@ import "../../../../../components/ha-switch";
|
||||
import "../../../../../components/ha-formfield";
|
||||
import { CSSResultGroup, html, LitElement, TemplateResult, css } from "lit";
|
||||
import "../../../../../components/ha-circular-progress";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { createCloseHeading } from "../../../../../components/ha-dialog";
|
||||
import { haStyleDialog } from "../../../../../resources/styles";
|
||||
import { HomeAssistant } from "../../../../../types";
|
||||
import { ZWaveJSAddNodeDialogParams } from "./show-dialog-zwave_js-add-node";
|
||||
import { fireEvent } from "../../../../../common/dom/fire_event";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
|
||||
export interface ZWaveJSAddNodeDevice {
|
||||
id: string;
|
||||
|
@ -1,3 +1,5 @@
|
||||
import { mdiServerNetwork, mdiMathLog } from "@mdi/js";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import {
|
||||
HassRouterPage,
|
||||
RouterOptions,
|
||||
@ -6,9 +8,6 @@ import { HomeAssistant } from "../../../../../types";
|
||||
import { navigate } from "../../../../../common/navigate";
|
||||
import { PageNavigation } from "../../../../../layouts/hass-tabs-subpage";
|
||||
|
||||
import { mdiServerNetwork, mdiMathLog } from "@mdi/js";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
|
||||
export const configTabs: PageNavigation[] = [
|
||||
{
|
||||
translationKey: "ui.panel.config.zwave_js.navigation.network",
|
||||
|
@ -59,18 +59,18 @@ const getDevice = memoizeOne(
|
||||
entries?.find((device) => device.id === deviceId)
|
||||
);
|
||||
|
||||
const getNodeId = memoizeOne((device: DeviceRegistryEntry):
|
||||
| number
|
||||
| undefined => {
|
||||
const identifier = device.identifiers.find(
|
||||
(ident) => ident[0] === "zwave_js"
|
||||
);
|
||||
if (!identifier) {
|
||||
return undefined;
|
||||
}
|
||||
const getNodeId = memoizeOne(
|
||||
(device: DeviceRegistryEntry): number | undefined => {
|
||||
const identifier = device.identifiers.find(
|
||||
(ident) => ident[0] === "zwave_js"
|
||||
);
|
||||
if (!identifier) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return parseInt(identifier[1].split("-")[1]);
|
||||
});
|
||||
return parseInt(identifier[1].split("-")[1]);
|
||||
}
|
||||
);
|
||||
|
||||
@customElement("zwave_js-node-config")
|
||||
class ZWaveJSNodeConfig extends SubscribeMixin(LitElement) {
|
||||
|
@ -285,7 +285,8 @@ export class DialogLovelaceDashboardDetail extends LitElement {
|
||||
if (this._params!.dashboard) {
|
||||
await this._params!.updateDashboard(values);
|
||||
} else {
|
||||
(values as LovelaceDashboardCreateParams).url_path = this._urlPath.trim();
|
||||
(values as LovelaceDashboardCreateParams).url_path =
|
||||
this._urlPath.trim();
|
||||
(values as LovelaceDashboardCreateParams).mode = "storage";
|
||||
await this._params!.createDashboard(
|
||||
values as LovelaceDashboardCreateParams
|
||||
|
@ -168,8 +168,9 @@ export class HaConfigLovelaceDashboards extends LitElement {
|
||||
);
|
||||
|
||||
private _getItems = memoize((dashboards: LovelaceDashboard[]) => {
|
||||
const defaultMode = (this.hass.panels?.lovelace
|
||||
?.config as LovelacePanelConfig).mode;
|
||||
const defaultMode = (
|
||||
this.hass.panels?.lovelace?.config as LovelacePanelConfig
|
||||
).mode;
|
||||
const defaultUrlPath = this.hass.defaultPanel;
|
||||
const isDefault = defaultUrlPath === "lovelace";
|
||||
return [
|
||||
@ -261,9 +262,9 @@ export class HaConfigLovelaceDashboards extends LitElement {
|
||||
urlPath,
|
||||
createDashboard: async (values: LovelaceDashboardCreateParams) => {
|
||||
const created = await createDashboard(this.hass!, values);
|
||||
this._dashboards = this._dashboards!.concat(
|
||||
created
|
||||
).sort((res1, res2) => compare(res1.url_path, res2.url_path));
|
||||
this._dashboards = this._dashboards!.concat(created).sort(
|
||||
(res1, res2) => compare(res1.url_path, res2.url_path)
|
||||
);
|
||||
},
|
||||
updateDashboard: async (values) => {
|
||||
const updated = await updateDashboard(
|
||||
|
@ -220,9 +220,9 @@ class HaConfigPerson extends LitElement {
|
||||
users: this._allowedUsers(users, entry),
|
||||
createEntry: async (values) => {
|
||||
const created = await createPerson(this.hass!, values);
|
||||
this._storageItems = this._storageItems!.concat(
|
||||
created
|
||||
).sort((ent1, ent2) => compare(ent1.name, ent2.name));
|
||||
this._storageItems = this._storageItems!.concat(created).sort(
|
||||
(ent1, ent2) => compare(ent1.name, ent2.name)
|
||||
);
|
||||
},
|
||||
updateEntry: async (values) => {
|
||||
const updated = await updatePerson(this.hass!, entry!.id, values);
|
||||
|
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