Bump TypeScript to 3.7 (#4282)

* Bump TypeScript to 3.7

* Update prettier to support ts 3.7

* Prettier

* More prettier

* Even more prettier
This commit is contained in:
Bram Kragten 2019-11-27 22:51:03 +01:00 committed by Paulus Schoutsen
parent b8a026397b
commit 8a39d18323
100 changed files with 1165 additions and 600 deletions

View File

@ -175,9 +175,9 @@ export class HcMain extends HassElement {
} catch (err) { } catch (err) {
// Generate a Lovelace config. // Generate a Lovelace config.
this._unsubLovelace = () => undefined; this._unsubLovelace = () => undefined;
const { const { generateLovelaceConfigFromHass } = await import(
generateLovelaceConfigFromHass, "../../../../src/panels/lovelace/common/generate-lovelace-config"
} = await import("../../../../src/panels/lovelace/common/generate-lovelace-config"); );
this._handleNewLovelaceConfig( this._handleNewLovelaceConfig(
await generateLovelaceConfigFromHass(this.hass!) await generateLovelaceConfigFromHass(this.hass!)
); );

View File

@ -53,7 +53,7 @@ class CardModder extends LitElement {
for (var k in this._config.style) { for (var k in this._config.style) {
if (window.cardTools.hasTemplate(this._config.style[k])) if (window.cardTools.hasTemplate(this._config.style[k]))
this.templated.push(k); this.templated.push(k);
this.card.style.setProperty(k, ''); this.card.style.setProperty(k, "");
target.style.setProperty( target.style.setProperty(
k, k,
window.cardTools.parseTemplate(this._config.style[k]) window.cardTools.parseTemplate(this._config.style[k])

View File

@ -12,5 +12,7 @@ import "./resources/hademo-icons";
/* polyfill for paper-dropdown */ /* polyfill for paper-dropdown */
setTimeout(() => { setTimeout(() => {
import(/* webpackChunkName: "polyfill-web-animations-next" */ "web-animations-js/web-animations-next-lite.min"); import(
/* webpackChunkName: "polyfill-web-animations-next" */ "web-animations-js/web-animations-next-lite.min"
);
}, 1000); }, 1000);

View File

@ -65,74 +65,79 @@ const generateHistory = (state, deltas) => {
const incrementalUnits = ["clients", "queries", "ads"]; const incrementalUnits = ["clients", "queries", "ads"];
export const mockHistory = (mockHass: MockHomeAssistant) => { export const mockHistory = (mockHass: MockHomeAssistant) => {
mockHass.mockAPI(new RegExp("history/period/.+"), ( mockHass.mockAPI(
hass, new RegExp("history/period/.+"),
// @ts-ignore (
method, hass,
path, // @ts-ignore
// @ts-ignore method,
parameters path,
) => { // @ts-ignore
const params = parseQuery<HistoryQueryParams>(path.split("?")[1]); parameters
const entities = params.filter_entity_id.split(","); ) => {
const params = parseQuery<HistoryQueryParams>(path.split("?")[1]);
const entities = params.filter_entity_id.split(",");
const results: HassEntity[][] = []; const results: HassEntity[][] = [];
for (const entityId of entities) { for (const entityId of entities) {
const state = hass.states[entityId]; const state = hass.states[entityId];
if (!state) { if (!state) {
continue; continue;
} }
if (!state.attributes.unit_of_measurement) { if (!state.attributes.unit_of_measurement) {
results.push(generateHistory(state, [state.state])); results.push(generateHistory(state, [state.state]));
continue; continue;
} }
const numberState = Number(state.state); const numberState = Number(state.state);
if (isNaN(numberState)) { if (isNaN(numberState)) {
// tslint:disable-next-line // tslint:disable-next-line
console.log( console.log(
"Ignoring state with unparsable state but with a unit", "Ignoring state with unparsable state but with a unit",
entityId, entityId,
state state
);
continue;
}
const statesToGenerate = 15;
let genFunc;
if (incrementalUnits.includes(state.attributes.unit_of_measurement)) {
let initial = Math.floor(
numberState * 0.4 + numberState * Math.random() * 0.2
);
const diff = Math.max(
1,
Math.floor((numberState - initial) / statesToGenerate)
);
genFunc = () => {
initial += diff;
return Math.min(numberState, initial);
};
} else {
const diff = Math.floor(
numberState * (numberState > 80 ? 0.05 : 0.5)
);
genFunc = () =>
numberState - diff + Math.floor(Math.random() * 2 * diff);
}
results.push(
generateHistory(
{
entity_id: state.entity_id,
attributes: state.attributes,
},
Array.from({ length: statesToGenerate }, genFunc)
)
); );
continue;
} }
return results;
const statesToGenerate = 15;
let genFunc;
if (incrementalUnits.includes(state.attributes.unit_of_measurement)) {
let initial = Math.floor(
numberState * 0.4 + numberState * Math.random() * 0.2
);
const diff = Math.max(
1,
Math.floor((numberState - initial) / statesToGenerate)
);
genFunc = () => {
initial += diff;
return Math.min(numberState, initial);
};
} else {
const diff = Math.floor(numberState * (numberState > 80 ? 0.05 : 0.5));
genFunc = () =>
numberState - diff + Math.floor(Math.random() * 2 * diff);
}
results.push(
generateHistory(
{
entity_id: state.entity_id,
attributes: state.attributes,
},
Array.from({ length: statesToGenerate }, genFunc)
)
);
} }
return results; );
});
}; };

View File

@ -12,9 +12,10 @@ export const mockLovelace = (
localizePromise: Promise<LocalizeFunc> localizePromise: Promise<LocalizeFunc>
) => { ) => {
hass.mockWS("lovelace/config", () => hass.mockWS("lovelace/config", () =>
Promise.all([selectedDemoConfig, localizePromise]).then( Promise.all([
([config, localize]) => config.lovelace(localize) selectedDemoConfig,
) localizePromise,
]).then(([config, localize]) => config.lovelace(localize))
); );
hass.mockWS("lovelace/config/save", () => Promise.resolve()); hass.mockWS("lovelace/config/save", () => Promise.resolve());

View File

@ -44,9 +44,7 @@ class HassioAddonAudio extends EventsMixin(PolymerElement) {
selected="{{selectedInput}}" selected="{{selectedInput}}"
> >
<template is="dom-repeat" items="[[inputDevices]]"> <template is="dom-repeat" items="[[inputDevices]]">
<paper-item device\$="[[item.device]]" <paper-item device$="[[item.device]]">[[item.name]]</paper-item>
>[[item.name]]</paper-item
>
</template> </template>
</paper-listbox> </paper-listbox>
</paper-dropdown-menu> </paper-dropdown-menu>
@ -57,9 +55,7 @@ class HassioAddonAudio extends EventsMixin(PolymerElement) {
selected="{{selectedOutput}}" selected="{{selectedOutput}}"
> >
<template is="dom-repeat" items="[[outputDevices]]"> <template is="dom-repeat" items="[[outputDevices]]">
<paper-item device\$="[[item.device]]" <paper-item device$="[[item.device]]">[[item.name]]</paper-item>
>[[item.name]]</paper-item
>
</template> </template>
</paper-listbox> </paper-listbox>
</paper-dropdown-menu> </paper-dropdown-menu>

View File

@ -569,7 +569,10 @@ class HassioAddonInfo extends EventsMixin(PolymerElement) {
openChangelog() { openChangelog() {
this.hass this.hass
.callApi("get", `hassio/addons/${this.addonSlug}/changelog`) .callApi("get", `hassio/addons/${this.addonSlug}/changelog`)
.then((resp) => resp, () => "Error getting changelog") .then(
(resp) => resp,
() => "Error getting changelog"
)
.then((content) => { .then((content) => {
showHassioMarkdownDialog(this, { showHassioMarkdownDialog(this, {
title: "Changelog", title: "Changelog",

View File

@ -74,9 +74,7 @@ export class HassioUpdate extends LitElement {
this.supervisorInfo.version, this.supervisorInfo.version,
this.supervisorInfo.last_version, this.supervisorInfo.last_version,
"hassio/supervisor/update", "hassio/supervisor/update",
`https://github.com//home-assistant/hassio/releases/tag/${ `https://github.com//home-assistant/hassio/releases/tag/${this.supervisorInfo.last_version}`
this.supervisorInfo.last_version
}`
)} )}
${this.hassOsInfo ${this.hassOsInfo
? this._renderUpdateCard( ? this._renderUpdateCard(
@ -84,9 +82,7 @@ export class HassioUpdate extends LitElement {
this.hassOsInfo.version, this.hassOsInfo.version,
this.hassOsInfo.version_latest, this.hassOsInfo.version_latest,
"hassio/hassos/update", "hassio/hassos/update",
`https://github.com//home-assistant/hassos/releases/tag/${ `https://github.com//home-assistant/hassos/releases/tag/${this.hassOsInfo.version_latest}`
this.hassOsInfo.version_latest
}`
) )
: ""} : ""}
</div> </div>

View File

@ -12,7 +12,9 @@ export const showHassioMarkdownDialog = (
fireEvent(element, "show-dialog", { fireEvent(element, "show-dialog", {
dialogTag: "dialog-hassio-markdown", dialogTag: "dialog-hassio-markdown",
dialogImport: () => dialogImport: () =>
import(/* webpackChunkName: "dialog-hassio-markdown" */ "./dialog-hassio-markdown"), import(
/* webpackChunkName: "dialog-hassio-markdown" */ "./dialog-hassio-markdown"
),
dialogParams, dialogParams,
}); });
}; };

View File

@ -12,7 +12,9 @@ export const showHassioSnapshotDialog = (
fireEvent(element, "show-dialog", { fireEvent(element, "show-dialog", {
dialogTag: "dialog-hassio-snapshot", dialogTag: "dialog-hassio-snapshot",
dialogImport: () => dialogImport: () =>
import(/* webpackChunkName: "dialog-hassio-snapshot" */ "./dialog-hassio-snapshot"), import(
/* webpackChunkName: "dialog-hassio-snapshot" */ "./dialog-hassio-snapshot"
),
dialogParams, dialogParams,
}); });
}; };

View File

@ -56,12 +56,16 @@ class HassioMain extends ProvideHassLitMixin(HassRouterPage) {
addon: { addon: {
tag: "hassio-addon-view", tag: "hassio-addon-view",
load: () => load: () =>
import(/* webpackChunkName: "hassio-addon-view" */ "./addon-view/hassio-addon-view"), import(
/* webpackChunkName: "hassio-addon-view" */ "./addon-view/hassio-addon-view"
),
}, },
ingress: { ingress: {
tag: "hassio-ingress-view", tag: "hassio-ingress-view",
load: () => load: () =>
import(/* webpackChunkName: "hassio-ingress-view" */ "./ingress-view/hassio-ingress-view"), import(
/* webpackChunkName: "hassio-ingress-view" */ "./ingress-view/hassio-ingress-view"
),
}, },
}, },
}; };

View File

@ -105,15 +105,15 @@
"xss": "^1.0.6" "xss": "^1.0.6"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.4.0", "@babel/core": "^7.7.4",
"@babel/plugin-external-helpers": "^7.2.0", "@babel/plugin-external-helpers": "^7.7.4",
"@babel/plugin-proposal-class-properties": "^7.4.0", "@babel/plugin-proposal-class-properties": "^7.7.4",
"@babel/plugin-proposal-decorators": "^7.4.0", "@babel/plugin-proposal-decorators": "^7.7.4",
"@babel/plugin-proposal-object-rest-spread": "^7.4.0", "@babel/plugin-proposal-object-rest-spread": "^7.7.4",
"@babel/plugin-syntax-dynamic-import": "^7.2.0", "@babel/plugin-syntax-dynamic-import": "^7.7.4",
"@babel/plugin-transform-react-jsx": "^7.3.0", "@babel/plugin-transform-react-jsx": "^7.7.4",
"@babel/preset-env": "^7.4.2", "@babel/preset-env": "^7.7.4",
"@babel/preset-typescript": "^7.4.0", "@babel/preset-typescript": "^7.7.4",
"@types/chai": "^4.1.7", "@types/chai": "^4.1.7",
"@types/chromecast-caf-receiver": "^3.0.12", "@types/chromecast-caf-receiver": "^3.0.12",
"@types/chromecast-caf-sender": "^1.0.1", "@types/chromecast-caf-sender": "^1.0.1",
@ -155,18 +155,18 @@
"merge-stream": "^1.0.1", "merge-stream": "^1.0.1",
"mocha": "^6.0.2", "mocha": "^6.0.2",
"parse5": "^5.1.0", "parse5": "^5.1.0",
"prettier": "^1.16.4", "prettier": "^1.19.1",
"raw-loader": "^2.0.0", "raw-loader": "^2.0.0",
"reify": "^0.18.1", "reify": "^0.18.1",
"require-dir": "^1.2.0", "require-dir": "^1.2.0",
"sinon": "^7.3.1", "sinon": "^7.3.1",
"terser-webpack-plugin": "^1.2.3", "terser-webpack-plugin": "^1.2.3",
"ts-mocha": "^6.0.0", "ts-mocha": "^6.0.0",
"tslint": "^5.14.0", "tslint": "^5.20.1",
"tslint-config-prettier": "^1.18.0", "tslint-config-prettier": "^1.18.0",
"tslint-eslint-rules": "^5.4.0", "tslint-eslint-rules": "^5.4.0",
"tslint-plugin-prettier": "^2.0.1", "tslint-plugin-prettier": "^2.0.1",
"typescript": "^3.6.3", "typescript": "^3.7.2",
"web-component-tester": "^6.9.2", "web-component-tester": "^6.9.2",
"webpack": "^4.40.2", "webpack": "^4.40.2",
"webpack-cli": "^3.3.9", "webpack-cli": "^3.3.9",

View File

@ -98,9 +98,7 @@ class HaAuthFlow extends litLocalizeLiteMixin(LitElement) {
<ha-markdown <ha-markdown
allowsvg allowsvg
.content=${this.localize( .content=${this.localize(
`ui.panel.page-authorize.form.providers.${ `ui.panel.page-authorize.form.providers.${step.handler[0]}.abort.${step.reason}`
step.handler[0]
}.abort.${step.reason}`
)} )}
></ha-markdown> ></ha-markdown>
`; `;
@ -229,9 +227,7 @@ class HaAuthFlow extends litLocalizeLiteMixin(LitElement) {
} }
private _computeStepDescription(step: DataEntryFlowStepForm) { private _computeStepDescription(step: DataEntryFlowStepForm) {
const resourceKey = `ui.panel.page-authorize.form.providers.${ const resourceKey = `ui.panel.page-authorize.form.providers.${step.handler[0]}.step.${step.step_id}.description`;
step.handler[0]
}.step.${step.step_id}.description`;
const args: string[] = []; const args: string[] = [];
const placeholders = step.description_placeholders || {}; const placeholders = step.description_placeholders || {};
Object.keys(placeholders).forEach((key) => { Object.keys(placeholders).forEach((key) => {
@ -245,9 +241,7 @@ class HaAuthFlow extends litLocalizeLiteMixin(LitElement) {
// Returns a callback for ha-form to calculate labels per schema object // Returns a callback for ha-form to calculate labels per schema object
return (schema) => return (schema) =>
this.localize( this.localize(
`ui.panel.page-authorize.form.providers.${step.handler[0]}.step.${ `ui.panel.page-authorize.form.providers.${step.handler[0]}.step.${step.step_id}.data.${schema.name}`
step.step_id
}.data.${schema.name}`
); );
} }
@ -255,9 +249,7 @@ class HaAuthFlow extends litLocalizeLiteMixin(LitElement) {
// Returns a callback for ha-form to calculate error messages // Returns a callback for ha-form to calculate error messages
return (error) => return (error) =>
this.localize( this.localize(
`ui.panel.page-authorize.form.providers.${ `ui.panel.page-authorize.form.providers.${step.handler[0]}.error.${error}`
step.handler[0]
}.error.${error}`
); );
} }

View File

@ -11,7 +11,9 @@ import "./ha-auth-flow";
import { AuthProvider, fetchAuthProviders } from "../data/auth"; import { AuthProvider, fetchAuthProviders } from "../data/auth";
import { registerServiceWorker } from "../util/register-service-worker"; import { registerServiceWorker } from "../util/register-service-worker";
import(/* webpackChunkName: "pick-auth-provider" */ "../auth/ha-pick-auth-provider"); import(
/* webpackChunkName: "pick-auth-provider" */ "../auth/ha-pick-auth-provider"
);
interface QueryParams { interface QueryParams {
client_id?: string; client_id?: string;

View File

@ -10,11 +10,11 @@ function toLocaleDateStringSupportsOptions() {
return false; return false;
} }
export default (toLocaleDateStringSupportsOptions() export default toLocaleDateStringSupportsOptions()
? (dateObj: Date, locales: string) => ? (dateObj: Date, locales: string) =>
dateObj.toLocaleDateString(locales, { dateObj.toLocaleDateString(locales, {
year: "numeric", year: "numeric",
month: "long", month: "long",
day: "numeric", day: "numeric",
}) })
: (dateObj: Date) => fecha.format(dateObj, "mediumDate")); : (dateObj: Date) => fecha.format(dateObj, "mediumDate");

View File

@ -10,7 +10,7 @@ function toLocaleStringSupportsOptions() {
return false; return false;
} }
export default (toLocaleStringSupportsOptions() export default toLocaleStringSupportsOptions()
? (dateObj: Date, locales: string) => ? (dateObj: Date, locales: string) =>
dateObj.toLocaleString(locales, { dateObj.toLocaleString(locales, {
year: "numeric", year: "numeric",
@ -19,4 +19,4 @@ export default (toLocaleStringSupportsOptions()
hour: "numeric", hour: "numeric",
minute: "2-digit", minute: "2-digit",
}) })
: (dateObj: Date) => fecha.format(dateObj, "haDateTime")); : (dateObj: Date) => fecha.format(dateObj, "haDateTime");

View File

@ -10,10 +10,10 @@ function toLocaleTimeStringSupportsOptions() {
return false; return false;
} }
export default (toLocaleTimeStringSupportsOptions() export default toLocaleTimeStringSupportsOptions()
? (dateObj: Date, locales: string) => ? (dateObj: Date, locales: string) =>
dateObj.toLocaleTimeString(locales, { dateObj.toLocaleTimeString(locales, {
hour: "numeric", hour: "numeric",
minute: "2-digit", minute: "2-digit",
}) })
: (dateObj: Date) => fecha.format(dateObj, "shortTime")); : (dateObj: Date) => fecha.format(dateObj, "shortTime");

View File

@ -60,7 +60,7 @@ export const applyThemesOnElement = (
element.updateStyles(styles); element.updateStyles(styles);
} else if (window.ShadyCSS) { } else if (window.ShadyCSS) {
// implement updateStyles() method of Polymer elements // implement updateStyles() method of Polymer elements
window.ShadyCSS.styleSubtree(/** @type {!HTMLElement} */ (element), styles); window.ShadyCSS.styleSubtree(/** @type {!HTMLElement} */ element, styles);
} }
if (!updateMeta) { if (!updateMeta) {

View File

@ -11,7 +11,9 @@ export const setupLeafletMap = async (
throw new Error("Cannot setup Leaflet map on disconnected element"); throw new Error("Cannot setup Leaflet map on disconnected element");
} }
// tslint:disable-next-line // tslint:disable-next-line
const Leaflet = (await import(/* webpackChunkName: "leaflet" */ "leaflet")) as LeafletModuleType; const Leaflet = (await import(
/* webpackChunkName: "leaflet" */ "leaflet"
)) as LeafletModuleType;
Leaflet.Icon.Default.imagePath = "/static/images/leaflet/images/"; Leaflet.Icon.Default.imagePath = "/static/images/leaflet/images/";
const map = Leaflet.map(mapElement); const map = Leaflet.map(mapElement);

View File

@ -215,7 +215,9 @@ class HaChartBase extends mixinBehaviors(
} }
if (scriptsLoaded === null) { if (scriptsLoaded === null) {
scriptsLoaded = import(/* webpackChunkName: "load_chart" */ "../../resources/ha-chart-scripts.js"); scriptsLoaded = import(
/* webpackChunkName: "load_chart" */ "../../resources/ha-chart-scripts.js"
);
} }
scriptsLoaded.then((ChartModule) => { scriptsLoaded.then((ChartModule) => {
this.ChartClass = ChartModule.default; this.ChartClass = ChartModule.default;

View File

@ -122,8 +122,9 @@ class HaCameraStream extends LitElement {
private async _startHls(): Promise<void> { private async _startHls(): Promise<void> {
// tslint:disable-next-line // tslint:disable-next-line
const Hls = ((await import(/* webpackChunkName: "hls.js" */ "hls.js")) as any) const Hls = ((await import(
.default as HLSModule; /* webpackChunkName: "hls.js" */ "hls.js"
)) as any).default as HLSModule;
let hlsSupported = Hls.isSupported(); let hlsSupported = Hls.isSupported();
const videoEl = this._videoEl; const videoEl = this._videoEl;

View File

@ -72,9 +72,7 @@ class HaClimateState extends LocalizeMixin(PolymerElement) {
computeCurrentStatus(hass, stateObj) { computeCurrentStatus(hass, stateObj) {
if (!hass || !stateObj) return null; if (!hass || !stateObj) return null;
if (stateObj.attributes.current_temperature != null) { if (stateObj.attributes.current_temperature != null) {
return `${stateObj.attributes.current_temperature} ${ return `${stateObj.attributes.current_temperature} ${hass.config.unit_system.temperature}`;
hass.config.unit_system.temperature
}`;
} }
if (stateObj.attributes.current_humidity != null) { if (stateObj.attributes.current_humidity != null) {
return `${stateObj.attributes.current_humidity} %`; return `${stateObj.attributes.current_humidity} %`;
@ -89,22 +87,16 @@ class HaClimateState extends LocalizeMixin(PolymerElement) {
stateObj.attributes.target_temp_low != null && stateObj.attributes.target_temp_low != null &&
stateObj.attributes.target_temp_high != null stateObj.attributes.target_temp_high != null
) { ) {
return `${stateObj.attributes.target_temp_low}-${ return `${stateObj.attributes.target_temp_low}-${stateObj.attributes.target_temp_high} ${hass.config.unit_system.temperature}`;
stateObj.attributes.target_temp_high
} ${hass.config.unit_system.temperature}`;
} }
if (stateObj.attributes.temperature != null) { if (stateObj.attributes.temperature != null) {
return `${stateObj.attributes.temperature} ${ return `${stateObj.attributes.temperature} ${hass.config.unit_system.temperature}`;
hass.config.unit_system.temperature
}`;
} }
if ( if (
stateObj.attributes.target_humidity_low != null && stateObj.attributes.target_humidity_low != null &&
stateObj.attributes.target_humidity_high != null stateObj.attributes.target_humidity_high != null
) { ) {
return `${stateObj.attributes.target_humidity_low}-${ return `${stateObj.attributes.target_humidity_low}-${stateObj.attributes.target_humidity_high}%`;
stateObj.attributes.target_humidity_high
}%`;
} }
if (stateObj.attributes.humidity != null) { if (stateObj.attributes.humidity != null) {
return `${stateObj.attributes.humidity} %`; return `${stateObj.attributes.humidity} %`;
@ -121,9 +113,7 @@ class HaClimateState extends LocalizeMixin(PolymerElement) {
const stateString = localize(`state.climate.${stateObj.state}`); const stateString = localize(`state.climate.${stateObj.state}`);
return stateObj.attributes.hvac_action return stateObj.attributes.hvac_action
? `${localize( ? `${localize(
`state_attributes.climate.hvac_action.${ `state_attributes.climate.hvac_action.${stateObj.attributes.hvac_action}`
stateObj.attributes.hvac_action
}`
)} (${stateString})` )} (${stateString})`
: stateString; : stateString;
} }

View File

@ -58,14 +58,10 @@ class HaWaterHeaterState extends LocalizeMixin(PolymerElement) {
stateObj.attributes.target_temp_low != null && stateObj.attributes.target_temp_low != null &&
stateObj.attributes.target_temp_high != null stateObj.attributes.target_temp_high != null
) { ) {
return `${stateObj.attributes.target_temp_low} - ${ return `${stateObj.attributes.target_temp_low} - ${stateObj.attributes.target_temp_high} ${hass.config.unit_system.temperature}`;
stateObj.attributes.target_temp_high
} ${hass.config.unit_system.temperature}`;
} }
if (stateObj.attributes.temperature != null) { if (stateObj.attributes.temperature != null) {
return `${stateObj.attributes.temperature} ${ return `${stateObj.attributes.temperature} ${hass.config.unit_system.temperature}`;
hass.config.unit_system.temperature
}`;
} }
return ""; return "";

View File

@ -19,9 +19,7 @@ export interface Stream {
} }
export const computeMJPEGStreamUrl = (entity: CameraEntity) => export const computeMJPEGStreamUrl = (entity: CameraEntity) =>
`/api/camera_proxy_stream/${entity.entity_id}?token=${ `/api/camera_proxy_stream/${entity.entity_id}?token=${entity.attributes.access_token}`;
entity.attributes.access_token
}`;
export const fetchThumbnailUrlWithCache = ( export const fetchThumbnailUrlWithCache = (
hass: HomeAssistant, hass: HomeAssistant,

View File

@ -3,7 +3,7 @@ import { HomeAssistant } from "../types";
interface ProcessResults { interface ProcessResults {
card: { [key: string]: { [key: string]: string } }; card: { [key: string]: { [key: string]: string } };
speech: { speech: {
[SpeechType in "plain" | "ssml"]: { extra_data: any; speech: string } [SpeechType in "plain" | "ssml"]: { extra_data: any; speech: string };
}; };
} }

View File

@ -107,9 +107,7 @@ export const localizeDeviceAutomationAction = (
state ? computeStateName(state) : "<unknown>", state ? computeStateName(state) : "<unknown>",
"subtype", "subtype",
hass.localize( hass.localize(
`component.${action.domain}.device_automation.action_subtype.${ `component.${action.domain}.device_automation.action_subtype.${action.subtype}`
action.subtype
}`
) )
); );
}; };
@ -122,16 +120,12 @@ export const localizeDeviceAutomationCondition = (
? hass.states[condition.entity_id] ? hass.states[condition.entity_id]
: undefined; : undefined;
return hass.localize( return hass.localize(
`component.${condition.domain}.device_automation.condition_type.${ `component.${condition.domain}.device_automation.condition_type.${condition.type}`,
condition.type
}`,
"entity_name", "entity_name",
state ? computeStateName(state) : "<unknown>", state ? computeStateName(state) : "<unknown>",
"subtype", "subtype",
hass.localize( hass.localize(
`component.${condition.domain}.device_automation.condition_subtype.${ `component.${condition.domain}.device_automation.condition_subtype.${condition.subtype}`
condition.subtype
}`
) )
); );
}; };
@ -142,16 +136,12 @@ export const localizeDeviceAutomationTrigger = (
) => { ) => {
const state = trigger.entity_id ? hass.states[trigger.entity_id] : undefined; const state = trigger.entity_id ? hass.states[trigger.entity_id] : undefined;
return hass.localize( return hass.localize(
`component.${trigger.domain}.device_automation.trigger_type.${ `component.${trigger.domain}.device_automation.trigger_type.${trigger.type}`,
trigger.type
}`,
"entity_name", "entity_name",
state ? computeStateName(state) : "<unknown>", state ? computeStateName(state) : "<unknown>",
"subtype", "subtype",
hass.localize( hass.localize(
`component.${trigger.domain}.device_automation.trigger_subtype.${ `component.${trigger.domain}.device_automation.trigger_subtype.${trigger.subtype}`
trigger.subtype
}`
) )
); );
}; };

View File

@ -149,9 +149,7 @@ export const createHassioSession = async (hass: HomeAssistant) => {
"POST", "POST",
"hassio/ingress/session" "hassio/ingress/session"
); );
document.cookie = `ingress_session=${ document.cookie = `ingress_session=${response.data.session};path=/api/hassio_ingress/`;
response.data.session
};path=/api/hassio_ingress/`;
}; };
export const reloadHassioAddons = (hass: HomeAssistant) => export const reloadHassioAddons = (hass: HomeAssistant) =>

View File

@ -98,9 +98,7 @@ class DialogConfigEntrySystemOptions extends LitElement {
"ui.dialogs.config_entry_system_options.enable_new_entities_description", "ui.dialogs.config_entry_system_options.enable_new_entities_description",
"integration", "integration",
this.hass.localize( this.hass.localize(
`component.${ `component.${this._params.entry.domain}.config.title`
this._params.entry.domain
}.config.title`
) || this._params.entry.domain ) || this._params.entry.domain
)} )}
</p> </p>

View File

@ -10,7 +10,9 @@ export interface ConfigEntrySystemOptionsDialogParams {
} }
export const loadConfigEntrySystemOptionsDialog = () => export const loadConfigEntrySystemOptionsDialog = () =>
import(/* webpackChunkName: "config-entry-system-options" */ "./dialog-config-entry-system-options"); import(
/* webpackChunkName: "config-entry-system-options" */ "./dialog-config-entry-system-options"
);
export const showConfigEntrySystemOptionsDialog = ( export const showConfigEntrySystemOptionsDialog = (
element: HTMLElement, element: HTMLElement,

View File

@ -71,9 +71,7 @@ export const showConfigFlowDialog = (
renderShowFormStepFieldLabel(hass, step, field) { renderShowFormStepFieldLabel(hass, step, field) {
return hass.localize( return hass.localize(
`component.${step.handler}.config.step.${step.step_id}.data.${ `component.${step.handler}.config.step.${step.step_id}.data.${field.name}`
field.name
}`
); );
}, },

View File

@ -79,7 +79,9 @@ export interface DataEntryFlowDialogParams {
} }
export const loadDataEntryFlowDialog = () => export const loadDataEntryFlowDialog = () =>
import(/* webpackChunkName: "dialog-config-flow" */ "./dialog-data-entry-flow"); import(
/* webpackChunkName: "dialog-config-flow" */ "./dialog-data-entry-flow"
);
export const showFlowDialog = ( export const showFlowDialog = (
element: HTMLElement, element: HTMLElement,

View File

@ -54,9 +54,7 @@ export const showOptionsFlowDialog = (
renderShowFormStepFieldLabel(hass, step, field) { renderShowFormStepFieldLabel(hass, step, field) {
return hass.localize( return hass.localize(
`component.${configEntry.domain}.options.step.${step.step_id}.data.${ `component.${configEntry.domain}.options.step.${step.step_id}.data.${field.name}`
field.name
}`
); );
}, },

View File

@ -12,7 +12,9 @@ export interface DeviceRegistryDetailDialogParams {
} }
export const loadDeviceRegistryDetailDialog = () => export const loadDeviceRegistryDetailDialog = () =>
import(/* webpackChunkName: "device-registry-detail-dialog" */ "./dialog-device-registry-detail"); import(
/* webpackChunkName: "device-registry-detail-dialog" */ "./dialog-device-registry-detail"
);
export const showDeviceRegistryDetailDialog = ( export const showDeviceRegistryDetailDialog = (
element: HTMLElement, element: HTMLElement,

View File

@ -6,7 +6,9 @@ export interface HaDomainTogglerDialogParams {
} }
export const loadDomainTogglerDialog = () => export const loadDomainTogglerDialog = () =>
import(/* webpackChunkName: "dialog-domain-toggler" */ "./dialog-domain-toggler"); import(
/* webpackChunkName: "dialog-domain-toggler" */ "./dialog-domain-toggler"
);
export const showDomainTogglerDialog = ( export const showDomainTogglerDialog = (
element: HTMLElement, element: HTMLElement,

View File

@ -1,7 +1,9 @@
import { fireEvent } from "../../common/dom/fire_event"; import { fireEvent } from "../../common/dom/fire_event";
const loadVoiceCommandDialog = () => const loadVoiceCommandDialog = () =>
import(/* webpackChunkName: "ha-voice-command-dialog" */ "./ha-voice-command-dialog"); import(
/* webpackChunkName: "ha-voice-command-dialog" */ "./ha-voice-command-dialog"
);
export const showVoiceCommandDialog = (element: HTMLElement): void => { export const showVoiceCommandDialog = (element: HTMLElement): void => {
fireEvent(element, "show-dialog", { fireEvent(element, "show-dialog", {

View File

@ -5,7 +5,9 @@ export interface ZHADeviceInfoDialogParams {
} }
export const loadZHADeviceInfoDialog = () => export const loadZHADeviceInfoDialog = () =>
import(/* webpackChunkName: "dialog-zha-device-info" */ "./dialog-zha-device-info"); import(
/* webpackChunkName: "dialog-zha-device-info" */ "./dialog-zha-device-info"
);
export const showZHADeviceInfoDialog = ( export const showZHADeviceInfoDialog = (
element: HTMLElement, element: HTMLElement,

View File

@ -10,6 +10,8 @@ import "../auth/ha-authorize";
/* polyfill for paper-dropdown */ /* polyfill for paper-dropdown */
setTimeout( setTimeout(
() => () =>
import(/* webpackChunkName: "polyfill-web-animations-next" */ "web-animations-js/web-animations-next-lite.min"), import(
/* webpackChunkName: "polyfill-web-animations-next" */ "web-animations-js/web-animations-next-lite.min"
),
2000 2000
); );

View File

@ -27,9 +27,9 @@ const isExternal = location.search.includes("external_auth=1");
const authProm = isExternal const authProm = isExternal
? () => ? () =>
import(/* webpackChunkName: "external_auth" */ "../external_app/external_auth").then( import(
({ createExternalAuth }) => createExternalAuth(hassUrl) /* webpackChunkName: "external_auth" */ "../external_app/external_auth"
) ).then(({ createExternalAuth }) => createExternalAuth(hassUrl))
: () => : () =>
getAuth({ getAuth({
hassUrl, hassUrl,

View File

@ -74,20 +74,23 @@ export const provideHass = (
restResponses.push([path, callback]); restResponses.push([path, callback]);
} }
mockAPI(new RegExp("states/.+"), ( mockAPI(
// @ts-ignore new RegExp("states/.+"),
method, (
path, // @ts-ignore
parameters method,
) => { path,
const [domain, objectId] = path.substr(7).split(".", 2); parameters
if (!domain || !objectId) { ) => {
return; const [domain, objectId] = path.substr(7).split(".", 2);
if (!domain || !objectId) {
return;
}
addEntities(
getEntity(domain, objectId, parameters.state, parameters.attributes)
);
} }
addEntities( );
getEntity(domain, objectId, parameters.state, parameters.attributes)
);
});
const localLanguage = getLocalLanguage(); const localLanguage = getLocalLanguage();
@ -117,9 +120,7 @@ export const provideHass = (
? callback(msg) ? callback(msg)
: Promise.reject({ : Promise.reject({
code: "command_not_mocked", code: "command_not_mocked",
message: `WS Command ${ message: `WS Command ${msg.type} is not implemented in provide_hass.`,
msg.type
} is not implemented in provide_hass.`,
}); });
}, },
subscribeMessage: async (onChange, msg) => { subscribeMessage: async (onChange, msg) => {
@ -128,9 +129,7 @@ export const provideHass = (
? callback(msg, onChange) ? callback(msg, onChange)
: Promise.reject({ : Promise.reject({
code: "command_not_mocked", code: "command_not_mocked",
message: `WS Command ${ message: `WS Command ${msg.type} is not implemented in provide_hass.`,
msg.type
} is not implemented in provide_hass.`,
}); });
}, },
subscribeEvents: async ( subscribeEvents: async (

View File

@ -45,7 +45,9 @@ export class HomeAssistantAppEl extends HassElement {
this._initialize(); this._initialize();
setTimeout(registerServiceWorker, 1000); setTimeout(registerServiceWorker, 1000);
/* polyfill for paper-dropdown */ /* polyfill for paper-dropdown */
import(/* webpackChunkName: "polyfill-web-animations-next" */ "web-animations-js/web-animations-next-lite.min"); import(
/* webpackChunkName: "polyfill-web-animations-next" */ "web-animations-js/web-animations-next-lite.min"
);
} }
protected updated(changedProps: PropertyValues): void { protected updated(changedProps: PropertyValues): void {
@ -55,9 +57,10 @@ export class HomeAssistantAppEl extends HassElement {
this._updateHass({ panelUrl: this._panelUrl }); this._updateHass({ panelUrl: this._panelUrl });
} }
if (changedProps.has("hass")) { if (changedProps.has("hass")) {
this.hassChanged(this.hass!, changedProps.get("hass") as this.hassChanged(
| HomeAssistant this.hass!,
| undefined); changedProps.get("hass") as HomeAssistant | undefined
);
} }
} }

View File

@ -12,33 +12,59 @@ import { removeInitSkeleton } from "../util/init-skeleton";
const CACHE_COMPONENTS = ["lovelace", "states", "developer-tools"]; const CACHE_COMPONENTS = ["lovelace", "states", "developer-tools"];
const COMPONENTS = { const COMPONENTS = {
calendar: () => calendar: () =>
import(/* webpackChunkName: "panel-calendar" */ "../panels/calendar/ha-panel-calendar"), import(
/* webpackChunkName: "panel-calendar" */ "../panels/calendar/ha-panel-calendar"
),
config: () => config: () =>
import(/* webpackChunkName: "panel-config" */ "../panels/config/ha-panel-config"), import(
/* webpackChunkName: "panel-config" */ "../panels/config/ha-panel-config"
),
custom: () => custom: () =>
import(/* webpackChunkName: "panel-custom" */ "../panels/custom/ha-panel-custom"), import(
/* webpackChunkName: "panel-custom" */ "../panels/custom/ha-panel-custom"
),
"developer-tools": () => "developer-tools": () =>
import(/* webpackChunkName: "panel-developer-tools" */ "../panels/developer-tools/ha-panel-developer-tools"), import(
/* webpackChunkName: "panel-developer-tools" */ "../panels/developer-tools/ha-panel-developer-tools"
),
lovelace: () => lovelace: () =>
import(/* webpackChunkName: "panel-lovelace" */ "../panels/lovelace/ha-panel-lovelace"), import(
/* webpackChunkName: "panel-lovelace" */ "../panels/lovelace/ha-panel-lovelace"
),
states: () => states: () =>
import(/* webpackChunkName: "panel-states" */ "../panels/states/ha-panel-states"), import(
/* webpackChunkName: "panel-states" */ "../panels/states/ha-panel-states"
),
history: () => history: () =>
import(/* webpackChunkName: "panel-history" */ "../panels/history/ha-panel-history"), import(
/* webpackChunkName: "panel-history" */ "../panels/history/ha-panel-history"
),
iframe: () => iframe: () =>
import(/* webpackChunkName: "panel-iframe" */ "../panels/iframe/ha-panel-iframe"), import(
/* webpackChunkName: "panel-iframe" */ "../panels/iframe/ha-panel-iframe"
),
kiosk: () => kiosk: () =>
import(/* webpackChunkName: "panel-kiosk" */ "../panels/kiosk/ha-panel-kiosk"), import(
/* webpackChunkName: "panel-kiosk" */ "../panels/kiosk/ha-panel-kiosk"
),
logbook: () => logbook: () =>
import(/* webpackChunkName: "panel-logbook" */ "../panels/logbook/ha-panel-logbook"), import(
/* webpackChunkName: "panel-logbook" */ "../panels/logbook/ha-panel-logbook"
),
mailbox: () => mailbox: () =>
import(/* webpackChunkName: "panel-mailbox" */ "../panels/mailbox/ha-panel-mailbox"), import(
/* webpackChunkName: "panel-mailbox" */ "../panels/mailbox/ha-panel-mailbox"
),
map: () => map: () =>
import(/* webpackChunkName: "panel-map" */ "../panels/map/ha-panel-map"), import(/* webpackChunkName: "panel-map" */ "../panels/map/ha-panel-map"),
profile: () => profile: () =>
import(/* webpackChunkName: "panel-profile" */ "../panels/profile/ha-panel-profile"), import(
/* webpackChunkName: "panel-profile" */ "../panels/profile/ha-panel-profile"
),
"shopping-list": () => "shopping-list": () =>
import(/* webpackChunkName: "panel-shopping-list" */ "../panels/shopping-list/ha-panel-shopping-list"), import(
/* webpackChunkName: "panel-shopping-list" */ "../panels/shopping-list/ha-panel-shopping-list"
),
}; };
const getRoutes = (panels: Panels): RouterOptions => { const getRoutes = (panels: Panels): RouterOptions => {

View File

@ -84,8 +84,12 @@ class HaOnboarding extends litLocalizeLiteMixin(HassElement) {
protected firstUpdated(changedProps: PropertyValues) { protected firstUpdated(changedProps: PropertyValues) {
super.firstUpdated(changedProps); super.firstUpdated(changedProps);
this._fetchOnboardingSteps(); this._fetchOnboardingSteps();
import(/* webpackChunkName: "onboarding-integrations" */ "./onboarding-integrations"); import(
import(/* webpackChunkName: "onboarding-core-config" */ "./onboarding-core-config"); /* webpackChunkName: "onboarding-integrations" */ "./onboarding-integrations"
);
import(
/* webpackChunkName: "onboarding-core-config" */ "./onboarding-core-config"
);
registerServiceWorker(false); registerServiceWorker(false);
this.addEventListener("onboarding-step", (ev) => this._handleStepDone(ev)); this.addEventListener("onboarding-step", (ev) => this._handleStepDone(ev));
} }

View File

@ -124,7 +124,9 @@ class OnboardingIntegrations extends LitElement {
loadConfigFlowDialog(); loadConfigFlowDialog();
this._loadConfigEntries(); this._loadConfigEntries();
/* polyfill for paper-dropdown */ /* polyfill for paper-dropdown */
import(/* webpackChunkName: "polyfill-web-animations-next" */ "web-animations-js/web-animations-next-lite.min"); import(
/* webpackChunkName: "polyfill-web-animations-next" */ "web-animations-js/web-animations-next-lite.min"
);
} }
private _createFlow() { private _createFlow() {

View File

@ -14,7 +14,9 @@ export interface AreaRegistryDetailDialogParams {
} }
export const loadAreaRegistryDetailDialog = () => export const loadAreaRegistryDetailDialog = () =>
import(/* webpackChunkName: "area-registry-detail-dialog" */ "./dialog-area-registry-detail"); import(
/* webpackChunkName: "area-registry-detail-dialog" */ "./dialog-area-registry-detail"
);
export const showAreaRegistryDetailDialog = ( export const showAreaRegistryDetailDialog = (
element: HTMLElement, element: HTMLElement,

View File

@ -115,9 +115,7 @@ class HaAutomationPicker extends LitElement {
<a <a
href=${ifDefined( href=${ifDefined(
automation.attributes.id automation.attributes.id
? `/config/automation/edit/${ ? `/config/automation/edit/${automation.attributes.id}`
automation.attributes.id
}`
: undefined : undefined
)} )}
> >

View File

@ -6,7 +6,9 @@ export interface ThingtalkDialogParams {
} }
export const loadThingtalkDialog = () => export const loadThingtalkDialog = () =>
import(/* webpackChunkName: "thingtalk-dialog" */ "./thingtalk/dialog-thingtalk"); import(
/* webpackChunkName: "thingtalk-dialog" */ "./thingtalk/dialog-thingtalk"
);
export const showThingtalkDialog = ( export const showThingtalkDialog = (
element: HTMLElement, element: HTMLElement,

View File

@ -12,7 +12,9 @@ export const showCloudCertificateDialog = (
fireEvent(element, "show-dialog", { fireEvent(element, "show-dialog", {
dialogTag: "dialog-cloud-certificate", dialogTag: "dialog-cloud-certificate",
dialogImport: () => dialogImport: () =>
import(/* webpackChunkName: "dialog-cloud-certificate" */ "./dialog-cloud-certificate"), import(
/* webpackChunkName: "dialog-cloud-certificate" */ "./dialog-cloud-certificate"
),
dialogParams: webhookDialogParams, dialogParams: webhookDialogParams,
}); });
}; };

View File

@ -15,7 +15,9 @@ export const showManageCloudhookDialog = (
fireEvent(element, "show-dialog", { fireEvent(element, "show-dialog", {
dialogTag: "dialog-manage-cloudhook", dialogTag: "dialog-manage-cloudhook",
dialogImport: () => dialogImport: () =>
import(/* webpackChunkName: "cloud-webhook-manage-dialog" */ "./dialog-manage-cloudhook"), import(
/* webpackChunkName: "cloud-webhook-manage-dialog" */ "./dialog-manage-cloudhook"
),
dialogParams: webhookDialogParams, dialogParams: webhookDialogParams,
}); });
}; };

View File

@ -46,12 +46,16 @@ class HaConfigCloud extends HassRouterPage {
register: { register: {
tag: "cloud-register", tag: "cloud-register",
load: () => load: () =>
import(/* webpackChunkName: "cloud-register" */ "./register/cloud-register"), import(
/* webpackChunkName: "cloud-register" */ "./register/cloud-register"
),
}, },
"forgot-password": { "forgot-password": {
tag: "cloud-forgot-password", tag: "cloud-forgot-password",
load: () => load: () =>
import(/* webpackChunkName: "cloud-forgot-password" */ "./forgot-password/cloud-forgot-password"), import(
/* webpackChunkName: "cloud-forgot-password" */ "./forgot-password/cloud-forgot-password"
),
}, },
account: { account: {
tag: "cloud-account", tag: "cloud-account",
@ -59,7 +63,9 @@ class HaConfigCloud extends HassRouterPage {
"google-assistant": { "google-assistant": {
tag: "cloud-google-assistant", tag: "cloud-google-assistant",
load: () => load: () =>
import(/* webpackChunkName: "cloud-google-assistant" */ "./google-assistant/cloud-google-assistant"), import(
/* webpackChunkName: "cloud-google-assistant" */ "./google-assistant/cloud-google-assistant"
),
}, },
alexa: { alexa: {
tag: "cloud-alexa", tag: "cloud-alexa",

View File

@ -6,7 +6,9 @@ export interface EntityRegistryDetailDialogParams {
} }
export const loadEntityRegistryDetailDialog = () => export const loadEntityRegistryDetailDialog = () =>
import(/* webpackChunkName: "entity-registry-detail-dialog" */ "./dialog-entity-registry-detail"); import(
/* webpackChunkName: "entity-registry-detail-dialog" */ "./dialog-entity-registry-detail"
);
export const showEntityRegistryDetailDialog = ( export const showEntityRegistryDetailDialog = (
element: HTMLElement, element: HTMLElement,

View File

@ -31,82 +31,114 @@ class HaPanelConfig extends HassRouterPage {
area_registry: { area_registry: {
tag: "ha-config-area-registry", tag: "ha-config-area-registry",
load: () => load: () =>
import(/* webpackChunkName: "panel-config-area-registry" */ "./area_registry/ha-config-area-registry"), import(
/* webpackChunkName: "panel-config-area-registry" */ "./area_registry/ha-config-area-registry"
),
}, },
automation: { automation: {
tag: "ha-config-automation", tag: "ha-config-automation",
load: () => load: () =>
import(/* webpackChunkName: "panel-config-automation" */ "./automation/ha-config-automation"), import(
/* webpackChunkName: "panel-config-automation" */ "./automation/ha-config-automation"
),
}, },
cloud: { cloud: {
tag: "ha-config-cloud", tag: "ha-config-cloud",
load: () => load: () =>
import(/* webpackChunkName: "panel-config-cloud" */ "./cloud/ha-config-cloud"), import(
/* webpackChunkName: "panel-config-cloud" */ "./cloud/ha-config-cloud"
),
}, },
core: { core: {
tag: "ha-config-core", tag: "ha-config-core",
load: () => load: () =>
import(/* webpackChunkName: "panel-config-core" */ "./core/ha-config-core"), import(
/* webpackChunkName: "panel-config-core" */ "./core/ha-config-core"
),
}, },
devices: { devices: {
tag: "ha-config-devices", tag: "ha-config-devices",
load: () => load: () =>
import(/* webpackChunkName: "panel-config-devices" */ "./devices/ha-config-devices"), import(
/* webpackChunkName: "panel-config-devices" */ "./devices/ha-config-devices"
),
}, },
server_control: { server_control: {
tag: "ha-config-server-control", tag: "ha-config-server-control",
load: () => load: () =>
import(/* webpackChunkName: "panel-config-server-control" */ "./server_control/ha-config-server-control"), import(
/* webpackChunkName: "panel-config-server-control" */ "./server_control/ha-config-server-control"
),
}, },
customize: { customize: {
tag: "ha-config-customize", tag: "ha-config-customize",
load: () => load: () =>
import(/* webpackChunkName: "panel-config-customize" */ "./customize/ha-config-customize"), import(
/* webpackChunkName: "panel-config-customize" */ "./customize/ha-config-customize"
),
}, },
dashboard: { dashboard: {
tag: "ha-config-dashboard", tag: "ha-config-dashboard",
load: () => load: () =>
import(/* webpackChunkName: "panel-config-dashboard" */ "./dashboard/ha-config-dashboard"), import(
/* webpackChunkName: "panel-config-dashboard" */ "./dashboard/ha-config-dashboard"
),
}, },
entity_registry: { entity_registry: {
tag: "ha-config-entity-registry", tag: "ha-config-entity-registry",
load: () => load: () =>
import(/* webpackChunkName: "panel-config-entity-registry" */ "./entity_registry/ha-config-entity-registry"), import(
/* webpackChunkName: "panel-config-entity-registry" */ "./entity_registry/ha-config-entity-registry"
),
}, },
integrations: { integrations: {
tag: "ha-config-integrations", tag: "ha-config-integrations",
load: () => load: () =>
import(/* webpackChunkName: "panel-config-integrations" */ "./integrations/ha-config-integrations"), import(
/* webpackChunkName: "panel-config-integrations" */ "./integrations/ha-config-integrations"
),
}, },
person: { person: {
tag: "ha-config-person", tag: "ha-config-person",
load: () => load: () =>
import(/* webpackChunkName: "panel-config-person" */ "./person/ha-config-person"), import(
/* webpackChunkName: "panel-config-person" */ "./person/ha-config-person"
),
}, },
script: { script: {
tag: "ha-config-script", tag: "ha-config-script",
load: () => load: () =>
import(/* webpackChunkName: "panel-config-script" */ "./script/ha-config-script"), import(
/* webpackChunkName: "panel-config-script" */ "./script/ha-config-script"
),
}, },
scene: { scene: {
tag: "ha-config-scene", tag: "ha-config-scene",
load: () => load: () =>
import(/* webpackChunkName: "panel-config-scene" */ "./scene/ha-config-scene"), import(
/* webpackChunkName: "panel-config-scene" */ "./scene/ha-config-scene"
),
}, },
users: { users: {
tag: "ha-config-users", tag: "ha-config-users",
load: () => load: () =>
import(/* webpackChunkName: "panel-config-users" */ "./users/ha-config-users"), import(
/* webpackChunkName: "panel-config-users" */ "./users/ha-config-users"
),
}, },
zha: { zha: {
tag: "zha-config-panel", tag: "zha-config-panel",
load: () => load: () =>
import(/* webpackChunkName: "panel-config-zha" */ "./zha/zha-config-panel"), import(
/* webpackChunkName: "panel-config-zha" */ "./zha/zha-config-panel"
),
}, },
zwave: { zwave: {
tag: "ha-config-zwave", tag: "ha-config-zwave",
load: () => load: () =>
import(/* webpackChunkName: "panel-config-zwave" */ "./zwave/ha-config-zwave"), import(
/* webpackChunkName: "panel-config-zwave" */ "./zwave/ha-config-zwave"
),
}, },
}, },
}; };

View File

@ -108,9 +108,7 @@ export default class DeviceCondition extends Component<any, any> {
// Returns a callback for ha-form to calculate labels per schema object // Returns a callback for ha-form to calculate labels per schema object
return (schema) => return (schema) =>
localize( localize(
`ui.panel.config.automation.editor.condition.type.device.extra_fields.${ `ui.panel.config.automation.editor.condition.type.device.extra_fields.${schema.name}`
schema.name
}`
) || schema.name; ) || schema.name;
} }
} }

View File

@ -127,9 +127,7 @@ export default class DeviceActionEditor extends Component<
// Returns a callback for ha-form to calculate labels per schema object // Returns a callback for ha-form to calculate labels per schema object
return (schema) => return (schema) =>
localize( localize(
`ui.panel.config.automation.editor.actions.type.device_id.extra_fields.${ `ui.panel.config.automation.editor.actions.type.device_id.extra_fields.${schema.name}`
schema.name
}`
) || schema.name; ) || schema.name;
} }
} }

View File

@ -109,9 +109,7 @@ export default class DeviceTrigger extends Component<any, any> {
// Returns a callback for ha-form to calculate labels per schema object // Returns a callback for ha-form to calculate labels per schema object
return (schema) => return (schema) =>
localize( localize(
`ui.panel.config.automation.editor.triggers.type.device.extra_fields.${ `ui.panel.config.automation.editor.triggers.type.device.extra_fields.${schema.name}`
schema.name
}`
) || schema.name; ) || schema.name;
} }
} }

View File

@ -167,9 +167,9 @@ class HaConfigPerson extends LitElement {
users: this._allowedUsers(users, entry), users: this._allowedUsers(users, entry),
createEntry: async (values) => { createEntry: async (values) => {
const created = await createPerson(this.hass!, values); const created = await createPerson(this.hass!, values);
this._storageItems = this._storageItems!.concat(created).sort( this._storageItems = this._storageItems!.concat(
(ent1, ent2) => compare(ent1.name, ent2.name) created
); ).sort((ent1, ent2) => compare(ent1.name, ent2.name));
}, },
updateEntry: async (values) => { updateEntry: async (values) => {
const updated = await updatePerson(this.hass!, entry!.id, values); const updated = await updatePerson(this.hass!, entry!.id, values);

View File

@ -11,7 +11,9 @@ export interface PersonDetailDialogParams {
} }
export const loadPersonDetailDialog = () => export const loadPersonDetailDialog = () =>
import(/* webpackChunkName: "person-detail-dialog" */ "./dialog-person-detail"); import(
/* webpackChunkName: "person-detail-dialog" */ "./dialog-person-detail"
);
export const showPersonDetailDialog = ( export const showPersonDetailDialog = (
element: HTMLElement, element: HTMLElement,

View File

@ -112,7 +112,9 @@ class HaUserPicker extends EventsMixin(
dialogShowEvent: "show-add-user", dialogShowEvent: "show-add-user",
dialogTag: "ha-dialog-add-user", dialogTag: "ha-dialog-add-user",
dialogImport: () => dialogImport: () =>
import(/* webpackChunkName: "ha-dialog-add-user" */ "./ha-dialog-add-user"), import(
/* webpackChunkName: "ha-dialog-add-user" */ "./ha-dialog-add-user"
),
}); });
} }
} }

View File

@ -97,10 +97,9 @@ export class HaConfigZha extends LitElement {
private async _fetchBindableDevices(): Promise<void> { private async _fetchBindableDevices(): Promise<void> {
if (this._selectedDevice && this.hass) { if (this._selectedDevice && this.hass) {
this._bindableDevices = (await fetchBindableDevices( this._bindableDevices = (
this.hass, await fetchBindableDevices(this.hass, this._selectedDevice!.ieee)
this._selectedDevice!.ieee ).sort(sortZHADevices);
)).sort(sortZHADevices);
} }
} }

View File

@ -21,12 +21,16 @@ class ZHAConfigPanel extends HassRouterPage {
configuration: { configuration: {
tag: "ha-config-zha", tag: "ha-config-zha",
load: () => load: () =>
import(/* webpackChunkName: "zha-configuration-page" */ "./ha-config-zha"), import(
/* webpackChunkName: "zha-configuration-page" */ "./ha-config-zha"
),
}, },
add: { add: {
tag: "zha-add-devices-page", tag: "zha-add-devices-page",
load: () => load: () =>
import(/* webpackChunkName: "zha-add-devices-page" */ "./zha-add-devices-page"), import(
/* webpackChunkName: "zha-add-devices-page" */ "./zha-add-devices-page"
),
}, },
}, },
}; };

View File

@ -137,7 +137,9 @@ class OzwLog extends LocalizeMixin(EventsMixin(PolymerElement)) {
dialogShowEvent: "show-ozwlog-dialog", dialogShowEvent: "show-ozwlog-dialog",
dialogTag: "zwave-log-dialog", dialogTag: "zwave-log-dialog",
dialogImport: () => dialogImport: () =>
import(/* webpackChunkName: "zwave-log-dialog" */ "./zwave-log-dialog"), import(
/* webpackChunkName: "zwave-log-dialog" */ "./zwave-log-dialog"
),
}); });
} }
} }

View File

@ -21,7 +21,9 @@ const registerDialog = (element: HTMLElement) =>
dialogShowEvent, dialogShowEvent,
dialogTag, dialogTag,
dialogImport: () => dialogImport: () =>
import(/* webpackChunkName: "system-log-detail-dialog" */ "./dialog-system-log-detail"), import(
/* webpackChunkName: "system-log-detail-dialog" */ "./dialog-system-log-detail"
),
}); });
export const showSystemLogDetailDialog = ( export const showSystemLogDetailDialog = (

View File

@ -40,7 +40,9 @@ const BUTTONS = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "", "0", "clear"];
@customElement("hui-alarm-panel-card") @customElement("hui-alarm-panel-card")
class HuiAlarmPanelCard extends LitElement implements LovelaceCard { class HuiAlarmPanelCard extends LitElement implements LovelaceCard {
public static async getConfigElement() { public static async getConfigElement() {
await import(/* webpackChunkName: "hui-alarm-panel-card-editor" */ "../editor/config-elements/hui-alarm-panel-card-editor"); await import(
/* webpackChunkName: "hui-alarm-panel-card-editor" */ "../editor/config-elements/hui-alarm-panel-card-editor"
);
return document.createElement("hui-alarm-panel-card-editor"); return document.createElement("hui-alarm-panel-card-editor");
} }

View File

@ -23,7 +23,9 @@ import { applyThemesOnElement } from "../../../common/dom/apply_themes_on_elemen
@customElement("hui-entities-card") @customElement("hui-entities-card")
class HuiEntitiesCard extends LitElement implements LovelaceCard { class HuiEntitiesCard extends LitElement implements LovelaceCard {
public static async getConfigElement(): Promise<LovelaceCardEditor> { public static async getConfigElement(): Promise<LovelaceCardEditor> {
await import(/* webpackChunkName: "hui-entities-card-editor" */ "../editor/config-elements/hui-entities-card-editor"); await import(
/* webpackChunkName: "hui-entities-card-editor" */ "../editor/config-elements/hui-entities-card-editor"
);
return document.createElement("hui-entities-card-editor"); return document.createElement("hui-entities-card-editor");
} }

View File

@ -34,7 +34,9 @@ import { ActionHandlerEvent } from "../../../data/lovelace";
@customElement("hui-entity-button-card") @customElement("hui-entity-button-card")
class HuiEntityButtonCard extends LitElement implements LovelaceCard { class HuiEntityButtonCard extends LitElement implements LovelaceCard {
public static async getConfigElement(): Promise<LovelaceCardEditor> { public static async getConfigElement(): Promise<LovelaceCardEditor> {
await import(/* webpackChunkName: "hui-entity-button-card-editor" */ "../editor/config-elements/hui-entity-button-card-editor"); await import(
/* webpackChunkName: "hui-entity-button-card-editor" */ "../editor/config-elements/hui-entity-button-card-editor"
);
return document.createElement("hui-entity-button-card-editor"); return document.createElement("hui-entity-button-card-editor");
} }

View File

@ -33,7 +33,9 @@ export const severityMap = {
@customElement("hui-gauge-card") @customElement("hui-gauge-card")
class HuiGaugeCard extends LitElement implements LovelaceCard { class HuiGaugeCard extends LitElement implements LovelaceCard {
public static async getConfigElement(): Promise<LovelaceCardEditor> { public static async getConfigElement(): Promise<LovelaceCardEditor> {
await import(/* webpackChunkName: "hui-gauge-card-editor" */ "../editor/config-elements/hui-gauge-card-editor"); await import(
/* webpackChunkName: "hui-gauge-card-editor" */ "../editor/config-elements/hui-gauge-card-editor"
);
return document.createElement("hui-gauge-card-editor"); return document.createElement("hui-gauge-card-editor");
} }
public static getStubConfig(): object { public static getStubConfig(): object {

View File

@ -32,7 +32,9 @@ import { handleAction } from "../common/handle-action";
@customElement("hui-glance-card") @customElement("hui-glance-card")
export class HuiGlanceCard extends LitElement implements LovelaceCard { export class HuiGlanceCard extends LitElement implements LovelaceCard {
public static async getConfigElement(): Promise<LovelaceCardEditor> { public static async getConfigElement(): Promise<LovelaceCardEditor> {
await import(/* webpackChunkName: "hui-glance-card-editor" */ "../editor/config-elements/hui-glance-card-editor"); await import(
/* webpackChunkName: "hui-glance-card-editor" */ "../editor/config-elements/hui-glance-card-editor"
);
return document.createElement("hui-glance-card-editor"); return document.createElement("hui-glance-card-editor");
} }

View File

@ -9,7 +9,9 @@ import { processConfigEntities } from "../common/process-config-entities";
class HuiHistoryGraphCard extends PolymerElement { class HuiHistoryGraphCard extends PolymerElement {
static async getConfigElement() { static async getConfigElement() {
await import(/* webpackChunkName: "hui-history-graph-card-editor" */ "../editor/config-elements/hui-history-graph-card-editor"); await import(
/* webpackChunkName: "hui-history-graph-card-editor" */ "../editor/config-elements/hui-history-graph-card-editor"
);
return document.createElement("hui-history-graph-card-editor"); return document.createElement("hui-history-graph-card-editor");
} }

View File

@ -17,7 +17,9 @@ import { IframeCardConfig } from "./types";
@customElement("hui-iframe-card") @customElement("hui-iframe-card")
export class HuiIframeCard extends LitElement implements LovelaceCard { export class HuiIframeCard extends LitElement implements LovelaceCard {
public static async getConfigElement(): Promise<LovelaceCardEditor> { public static async getConfigElement(): Promise<LovelaceCardEditor> {
await import(/* webpackChunkName: "hui-iframe-card-editor" */ "../editor/config-elements/hui-iframe-card-editor"); await import(
/* webpackChunkName: "hui-iframe-card-editor" */ "../editor/config-elements/hui-iframe-card-editor"
);
return document.createElement("hui-iframe-card-editor"); return document.createElement("hui-iframe-card-editor");
} }
public static getStubConfig(): object { public static getStubConfig(): object {

View File

@ -33,7 +33,9 @@ import { SUPPORT_BRIGHTNESS } from "../../../data/light";
@customElement("hui-light-card") @customElement("hui-light-card")
export class HuiLightCard extends LitElement implements LovelaceCard { export class HuiLightCard extends LitElement implements LovelaceCard {
public static async getConfigElement(): Promise<LovelaceCardEditor> { public static async getConfigElement(): Promise<LovelaceCardEditor> {
await import(/* webpackChunkName: "hui-light-card-editor" */ "../editor/config-elements/hui-light-card-editor"); await import(
/* webpackChunkName: "hui-light-card-editor" */ "../editor/config-elements/hui-light-card-editor"
);
return document.createElement("hui-light-card-editor"); return document.createElement("hui-light-card-editor");
} }
public static getStubConfig(): object { public static getStubConfig(): object {
@ -165,9 +167,9 @@ export class HuiLightCard extends LitElement implements LovelaceCard {
} }
private _dragEvent(e: any): void { private _dragEvent(e: any): void {
this.shadowRoot!.querySelector(".brightness")!.innerHTML = `${ this.shadowRoot!.querySelector(
e.detail.value ".brightness"
} %`; )!.innerHTML = `${e.detail.value} %`;
this._showBrightness(); this._showBrightness();
this._hideBrightness(); this._hideBrightness();
} }

View File

@ -34,7 +34,9 @@ import { classMap } from "lit-html/directives/class-map";
@customElement("hui-map-card") @customElement("hui-map-card")
class HuiMapCard extends LitElement implements LovelaceCard { class HuiMapCard extends LitElement implements LovelaceCard {
public static async getConfigElement() { public static async getConfigElement() {
await import(/* webpackChunkName: "hui-map-card-editor" */ "../editor/config-elements/hui-map-card-editor"); await import(
/* webpackChunkName: "hui-map-card-editor" */ "../editor/config-elements/hui-map-card-editor"
);
return document.createElement("hui-map-card-editor"); return document.createElement("hui-map-card-editor");
} }

View File

@ -23,7 +23,9 @@ import { applyThemesOnElement } from "../../../common/dom/apply_themes_on_elemen
@customElement("hui-markdown-card") @customElement("hui-markdown-card")
export class HuiMarkdownCard extends LitElement implements LovelaceCard { export class HuiMarkdownCard extends LitElement implements LovelaceCard {
public static async getConfigElement(): Promise<LovelaceCardEditor> { public static async getConfigElement(): Promise<LovelaceCardEditor> {
await import(/* webpackChunkName: "hui-markdown-card-editor" */ "../editor/config-elements/hui-markdown-card-editor"); await import(
/* webpackChunkName: "hui-markdown-card-editor" */ "../editor/config-elements/hui-markdown-card-editor"
);
return document.createElement("hui-markdown-card-editor"); return document.createElement("hui-markdown-card-editor");
} }

View File

@ -4,7 +4,9 @@ import LegacyWrapperCard from "./hui-legacy-wrapper-card";
class HuiMediaControlCard extends LegacyWrapperCard { class HuiMediaControlCard extends LegacyWrapperCard {
static async getConfigElement() { static async getConfigElement() {
await import(/* webpackChunkName: "hui-media-control-card-editor" */ "../editor/config-elements/hui-media-control-card-editor"); await import(
/* webpackChunkName: "hui-media-control-card-editor" */ "../editor/config-elements/hui-media-control-card-editor"
);
return document.createElement("hui-media-control-card-editor"); return document.createElement("hui-media-control-card-editor");
} }

View File

@ -24,7 +24,9 @@ import { handleAction } from "../common/handle-action";
@customElement("hui-picture-card") @customElement("hui-picture-card")
export class HuiPictureCard extends LitElement implements LovelaceCard { export class HuiPictureCard extends LitElement implements LovelaceCard {
public static async getConfigElement(): Promise<LovelaceCardEditor> { public static async getConfigElement(): Promise<LovelaceCardEditor> {
await import(/* webpackChunkName: "hui-picture-card-editor" */ "../editor/config-elements/hui-picture-card-editor"); await import(
/* webpackChunkName: "hui-picture-card-editor" */ "../editor/config-elements/hui-picture-card-editor"
);
return document.createElement("hui-picture-card-editor"); return document.createElement("hui-picture-card-editor");
} }
public static getStubConfig(): object { public static getStubConfig(): object {

View File

@ -32,7 +32,9 @@ import { handleAction } from "../common/handle-action";
@customElement("hui-picture-entity-card") @customElement("hui-picture-entity-card")
class HuiPictureEntityCard extends LitElement implements LovelaceCard { class HuiPictureEntityCard extends LitElement implements LovelaceCard {
public static async getConfigElement(): Promise<LovelaceCardEditor> { public static async getConfigElement(): Promise<LovelaceCardEditor> {
await import(/* webpackChunkName: "hui-picture-entity-card-editor" */ "../editor/config-elements/hui-picture-entity-card-editor"); await import(
/* webpackChunkName: "hui-picture-entity-card-editor" */ "../editor/config-elements/hui-picture-entity-card-editor"
);
return document.createElement("hui-picture-entity-card-editor"); return document.createElement("hui-picture-entity-card-editor");
} }
public static getStubConfig(): object { public static getStubConfig(): object {
@ -58,7 +60,9 @@ class HuiPictureEntityCard extends LitElement implements LovelaceCard {
if ( if (
computeDomain(config.entity) !== "camera" && computeDomain(config.entity) !== "camera" &&
(!config.image && !config.state_image && !config.camera_image) !config.image &&
!config.state_image &&
!config.camera_image
) { ) {
throw new Error("No image source configured."); throw new Error("No image source configured.");
} }

View File

@ -36,7 +36,9 @@ const STATES_OFF = new Set(["closed", "locked", "not_home", "off"]);
@customElement("hui-picture-glance-card") @customElement("hui-picture-glance-card")
class HuiPictureGlanceCard extends LitElement implements LovelaceCard { class HuiPictureGlanceCard extends LitElement implements LovelaceCard {
public static async getConfigElement(): Promise<LovelaceCardEditor> { public static async getConfigElement(): Promise<LovelaceCardEditor> {
await import(/* webpackChunkName: "hui-picture-glance-card-editor" */ "../editor/config-elements/hui-picture-glance-card-editor"); await import(
/* webpackChunkName: "hui-picture-glance-card-editor" */ "../editor/config-elements/hui-picture-glance-card-editor"
);
return document.createElement("hui-picture-glance-card-editor"); return document.createElement("hui-picture-glance-card-editor");
} }
public static getStubConfig(): object { public static getStubConfig(): object {

View File

@ -33,7 +33,9 @@ const SENSORS = {
@customElement("hui-plant-status-card") @customElement("hui-plant-status-card")
class HuiPlantStatusCard extends LitElement implements LovelaceCard { class HuiPlantStatusCard extends LitElement implements LovelaceCard {
public static async getConfigElement(): Promise<LovelaceCardEditor> { public static async getConfigElement(): Promise<LovelaceCardEditor> {
await import(/* webpackChunkName: "hui-plant-status-card-editor" */ "../editor/config-elements/hui-plant-status-card-editor"); await import(
/* webpackChunkName: "hui-plant-status-card-editor" */ "../editor/config-elements/hui-plant-status-card-editor"
);
return document.createElement("hui-plant-status-card-editor"); return document.createElement("hui-plant-status-card-editor");
} }

View File

@ -108,8 +108,14 @@ const coordinates = (
history.forEach((item) => (item.state = Number(item.state))); history.forEach((item) => (item.state = Number(item.state)));
history = history.filter((item) => !Number.isNaN(item.state)); history = history.filter((item) => !Number.isNaN(item.state));
const min = Math.min.apply(Math, history.map((item) => item.state)); const min = Math.min.apply(
const max = Math.max.apply(Math, history.map((item) => item.state)); Math,
history.map((item) => item.state)
);
const max = Math.max.apply(
Math,
history.map((item) => item.state)
);
const now = new Date().getTime(); const now = new Date().getTime();
const reduce = (res, item, point) => { const reduce = (res, item, point) => {
@ -141,7 +147,9 @@ const coordinates = (
@customElement("hui-sensor-card") @customElement("hui-sensor-card")
class HuiSensorCard extends LitElement implements LovelaceCard { class HuiSensorCard extends LitElement implements LovelaceCard {
public static async getConfigElement(): Promise<LovelaceCardEditor> { public static async getConfigElement(): Promise<LovelaceCardEditor> {
await import(/* webpackChunkName: "hui-sensor-card-editor" */ "../editor/config-elements/hui-sensor-card-editor"); await import(
/* webpackChunkName: "hui-sensor-card-editor" */ "../editor/config-elements/hui-sensor-card-editor"
);
return document.createElement("hui-sensor-card-editor"); return document.createElement("hui-sensor-card-editor");
} }

View File

@ -30,7 +30,9 @@ import { applyThemesOnElement } from "../../../common/dom/apply_themes_on_elemen
@customElement("hui-shopping-list-card") @customElement("hui-shopping-list-card")
class HuiShoppingListCard extends LitElement implements LovelaceCard { class HuiShoppingListCard extends LitElement implements LovelaceCard {
public static async getConfigElement(): Promise<LovelaceCardEditor> { public static async getConfigElement(): Promise<LovelaceCardEditor> {
await import(/* webpackChunkName: "hui-shopping-list-editor" */ "../editor/config-elements/hui-shopping-list-editor"); await import(
/* webpackChunkName: "hui-shopping-list-editor" */ "../editor/config-elements/hui-shopping-list-editor"
);
return document.createElement("hui-shopping-list-card-editor"); return document.createElement("hui-shopping-list-card-editor");
} }

View File

@ -47,7 +47,9 @@ const modeIcons: { [mode in HvacMode]: string } = {
@customElement("hui-thermostat-card") @customElement("hui-thermostat-card")
export class HuiThermostatCard extends LitElement implements LovelaceCard { export class HuiThermostatCard extends LitElement implements LovelaceCard {
public static async getConfigElement(): Promise<LovelaceCardEditor> { public static async getConfigElement(): Promise<LovelaceCardEditor> {
await import(/* webpackChunkName: "hui-thermostat-card-editor" */ "../editor/config-elements/hui-thermostat-card-editor"); await import(
/* webpackChunkName: "hui-thermostat-card-editor" */ "../editor/config-elements/hui-thermostat-card-editor"
);
return document.createElement("hui-thermostat-card-editor"); return document.createElement("hui-thermostat-card-editor");
} }
@ -179,9 +181,7 @@ export class HuiThermostatCard extends LitElement implements LovelaceCard {
${ ${
stateObj.attributes.hvac_action stateObj.attributes.hvac_action
? this.hass!.localize( ? this.hass!.localize(
`state_attributes.climate.hvac_action.${ `state_attributes.climate.hvac_action.${stateObj.attributes.hvac_action}`
stateObj.attributes.hvac_action
}`
) )
: this.hass!.localize(`state.climate.${stateObj.state}`) : this.hass!.localize(`state.climate.${stateObj.state}`)
} }
@ -191,9 +191,7 @@ export class HuiThermostatCard extends LitElement implements LovelaceCard {
? html` ? html`
- -
${this.hass!.localize( ${this.hass!.localize(
`state_attributes.climate.preset_mode.${ `state_attributes.climate.preset_mode.${stateObj.attributes.preset_mode}`
stateObj.attributes.preset_mode
}`
) || stateObj.attributes.preset_mode} ) || stateObj.attributes.preset_mode}
` `
: "" : ""

View File

@ -65,7 +65,9 @@ const weatherIcons = {
@customElement("hui-weather-forecast-card") @customElement("hui-weather-forecast-card")
class HuiWeatherForecastCard extends LitElement implements LovelaceCard { class HuiWeatherForecastCard extends LitElement implements LovelaceCard {
public static async getConfigElement(): Promise<LovelaceCardEditor> { public static async getConfigElement(): Promise<LovelaceCardEditor> {
await import(/* webpackChunkName: "hui-weather-forecast-card-editor" */ "../editor/config-elements/hui-weather-forecast-card-editor"); await import(
/* webpackChunkName: "hui-weather-forecast-card-editor" */ "../editor/config-elements/hui-weather-forecast-card-editor"
);
return document.createElement("hui-weather-forecast-card-editor"); return document.createElement("hui-weather-forecast-card-editor");
} }
public static getStubConfig(): object { public static getStubConfig(): object {
@ -218,7 +220,9 @@ class HuiWeatherForecastCard extends LitElement implements LovelaceCard {
? html` ? html`
${new Date(item.datetime).toLocaleTimeString( ${new Date(item.datetime).toLocaleTimeString(
this.hass!.language, this.hass!.language,
{ hour: "numeric" } {
hour: "numeric",
}
)} )}
` `
: ""} : ""}

View File

@ -287,9 +287,10 @@ const generateViewConfig = (
splitted.groups.forEach((groupEntity) => { splitted.groups.forEach((groupEntity) => {
cards = cards.concat( cards = cards.concat(
computeCards( computeCards(
groupEntity.attributes.entity_id.map( groupEntity.attributes.entity_id.map((entityId): [
(entityId): [string, HassEntity] => [entityId, entities[entityId]] string,
), HassEntity
] => [entityId, entities[entityId]]),
{ {
title: computeStateName(groupEntity), title: computeStateName(groupEntity),
show_header_toggle: groupEntity.attributes.control !== "hidden", show_header_toggle: groupEntity.attributes.control !== "hidden",
@ -303,9 +304,10 @@ const generateViewConfig = (
.forEach((domain) => { .forEach((domain) => {
cards = cards.concat( cards = cards.concat(
computeCards( computeCards(
ungroupedEntitites[domain].map( ungroupedEntitites[domain].map((entityId): [string, HassEntity] => [
(entityId): [string, HassEntity] => [entityId, entities[entityId]] entityId,
), entities[entityId],
]),
{ {
title: localize(`domain.${domain}`), title: localize(`domain.${domain}`),
} }
@ -418,7 +420,9 @@ export const generateLovelaceConfigFromData = async (
// User has no entities // User has no entities
if (views.length === 1 && views[0].cards!.length === 0) { if (views.length === 1 && views[0].cards!.length === 0) {
import(/* webpackChunkName: "hui-empty-state-card" */ "../cards/hui-empty-state-card"); import(
/* webpackChunkName: "hui-empty-state-card" */ "../cards/hui-empty-state-card"
);
views[0].cards!.push({ views[0].cards!.push({
type: "custom:hui-empty-state-card", type: "custom:hui-empty-state-card",
}); });

View File

@ -32,9 +32,9 @@ export const loadLovelaceResources = (
break; break;
case "html": case "html":
import(/* webpackChunkName: "import-href-polyfill" */ "../../../resources/html-import/import-href").then( import(
({ importHref }) => importHref(normalizedUrl) /* webpackChunkName: "import-href-polyfill" */ "../../../resources/html-import/import-href"
); ).then(({ importHref }) => importHref(normalizedUrl));
break; break;
default: default:

View File

@ -23,7 +23,9 @@ const registerEditCardDialog = (element: HTMLElement): Event =>
dialogShowEvent, dialogShowEvent,
dialogTag, dialogTag,
dialogImport: () => dialogImport: () =>
import(/* webpackChunkName: "hui-dialog-edit-card" */ "./hui-dialog-edit-card"), import(
/* webpackChunkName: "hui-dialog-edit-card" */ "./hui-dialog-edit-card"
),
}); });
export const showEditCardDialog = ( export const showEditCardDialog = (

View File

@ -20,7 +20,9 @@ const registerEditCardDialog = (element: HTMLElement): Event =>
dialogShowEvent: "show-move-card-view", dialogShowEvent: "show-move-card-view",
dialogTag: "hui-dialog-move-card-view", dialogTag: "hui-dialog-move-card-view",
dialogImport: () => dialogImport: () =>
import(/* webpackChunkName: "hui-dialog-move-card-view" */ "./hui-dialog-move-card-view"), import(
/* webpackChunkName: "hui-dialog-move-card-view" */ "./hui-dialog-move-card-view"
),
}); });
export const showMoveCardViewDialog = ( export const showMoveCardViewDialog = (

View File

@ -17,7 +17,9 @@ const registerEditLovelaceDialog = (element: HTMLElement): Event =>
dialogShowEvent, dialogShowEvent,
dialogTag, dialogTag,
dialogImport: () => dialogImport: () =>
import(/* webpackChunkName: "hui-dialog-edit-lovelace" */ "./hui-dialog-edit-lovelace"), import(
/* webpackChunkName: "hui-dialog-edit-lovelace" */ "./hui-dialog-edit-lovelace"
),
}); });
export const showEditLovelaceDialog = ( export const showEditLovelaceDialog = (

View File

@ -13,7 +13,9 @@ export const showSelectViewDialog = (
fireEvent(element, "show-dialog", { fireEvent(element, "show-dialog", {
dialogTag: "hui-dialog-select-view", dialogTag: "hui-dialog-select-view",
dialogImport: () => dialogImport: () =>
import(/* webpackChunkName: "hui-dialog-select-view" */ "./hui-dialog-select-view"), import(
/* webpackChunkName: "hui-dialog-select-view" */ "./hui-dialog-select-view"
),
dialogParams: selectViewDialogParams, dialogParams: selectViewDialogParams,
}); });
}; };

View File

@ -27,7 +27,9 @@ export const showSaveDialog = (
dialogShowEvent, dialogShowEvent,
dialogTag, dialogTag,
dialogImport: () => dialogImport: () =>
import(/* webpackChunkName: "hui-dialog-save-config" */ "./hui-dialog-save-config"), import(
/* webpackChunkName: "hui-dialog-save-config" */ "./hui-dialog-save-config"
),
}); });
} }
fireEvent(element, dialogShowEvent, saveDialogParams); fireEvent(element, dialogShowEvent, saveDialogParams);

View File

@ -27,7 +27,9 @@ const registerEditViewDialog = (element: HTMLElement): Event =>
dialogShowEvent, dialogShowEvent,
dialogTag, dialogTag,
dialogImport: () => dialogImport: () =>
import(/* webpackChunkName: "hui-dialog-edit-view" */ "./hui-dialog-edit-view"), import(
/* webpackChunkName: "hui-dialog-edit-view" */ "./hui-dialog-edit-view"
),
}); });
export const showEditViewDialog = ( export const showEditViewDialog = (

View File

@ -650,13 +650,13 @@ class HUIRoot extends LitElement {
if (viewIndex === "hass-unused-entities") { if (viewIndex === "hass-unused-entities") {
const unusedEntities = document.createElement("hui-unused-entities"); const unusedEntities = document.createElement("hui-unused-entities");
// Wait for promise to resolve so that the element has been upgraded. // Wait for promise to resolve so that the element has been upgraded.
import(/* webpackChunkName: "hui-unused-entities" */ "./editor/unused-entities/hui-unused-entities").then( import(
() => { /* webpackChunkName: "hui-unused-entities" */ "./editor/unused-entities/hui-unused-entities"
unusedEntities.hass = this.hass!; ).then(() => {
unusedEntities.lovelace = this.lovelace!; unusedEntities.hass = this.hass!;
unusedEntities.narrow = this.narrow; unusedEntities.lovelace = this.lovelace!;
} unusedEntities.narrow = this.narrow;
); });
if (this.config.background) { if (this.config.background) {
unusedEntities.style.setProperty( unusedEntities.style.setProperty(
"--lovelace-background", "--lovelace-background",

View File

@ -157,7 +157,9 @@ class HaPanelMailbox extends EventsMixin(LocalizeMixin(PolymerElement)) {
dialogShowEvent: "show-audio-message-dialog", dialogShowEvent: "show-audio-message-dialog",
dialogTag: "ha-dialog-show-audio-message", dialogTag: "ha-dialog-show-audio-message",
dialogImport: () => dialogImport: () =>
import(/* webpackChunkName: "ha-dialog-show-audio-message" */ "./ha-dialog-show-audio-message"), import(
/* webpackChunkName: "ha-dialog-show-audio-message" */ "./ha-dialog-show-audio-message"
),
}); });
} }
this.hassChanged = this.hassChanged.bind(this); this.hassChanged = this.hassChanged.bind(this);

View File

@ -34,9 +34,7 @@ class HaEntityMarker extends EventsMixin(PolymerElement) {
</style> </style>
<div class="marker"> <div class="marker">
<template is="dom-if" if="[[entityName]]" <template is="dom-if" if="[[entityName]]">[[entityName]]</template>
>[[entityName]]</template
>
<template is="dom-if" if="[[entityPicture]]"> <template is="dom-if" if="[[entityPicture]]">
<iron-image <iron-image
sizing="cover" sizing="cover"

View File

@ -288,9 +288,7 @@ class HaMfaModuleSetupFlow extends LocalizeMixin(EventsMixin(PolymerElement)) {
_computeStepDescription(localize, step) { _computeStepDescription(localize, step) {
const args = [ const args = [
`component.auth.mfa_setup.${step.handler}.step.${ `component.auth.mfa_setup.${step.handler}.step.${step.step_id}.description`,
step.step_id
}.description`,
]; ];
const placeholders = step.description_placeholders || {}; const placeholders = step.description_placeholders || {};
Object.keys(placeholders).forEach((key) => { Object.keys(placeholders).forEach((key) => {
@ -304,9 +302,7 @@ class HaMfaModuleSetupFlow extends LocalizeMixin(EventsMixin(PolymerElement)) {
// Returns a callback for ha-form to calculate labels per schema object // Returns a callback for ha-form to calculate labels per schema object
return (schema) => return (schema) =>
localize( localize(
`component.auth.mfa_setup.${step.handler}.step.${step.step_id}.data.${ `component.auth.mfa_setup.${step.handler}.step.${step.step_id}.data.${schema.name}`
schema.name
}`
) || schema.name; ) || schema.name;
} }

View File

@ -84,7 +84,9 @@ class HaMfaModulesCard extends EventsMixin(LocalizeMixin(PolymerElement)) {
dialogShowEvent: "show-mfa-module-setup-flow", dialogShowEvent: "show-mfa-module-setup-flow",
dialogTag: "ha-mfa-module-setup-flow", dialogTag: "ha-mfa-module-setup-flow",
dialogImport: () => dialogImport: () =>
import(/* webpackChunkName: "ha-mfa-module-setup-flow" */ "./ha-mfa-module-setup-flow"), import(
/* webpackChunkName: "ha-mfa-module-setup-flow" */ "./ha-mfa-module-setup-flow"
),
}); });
} }
} }

View File

@ -30,7 +30,9 @@ export default <T extends Constructor<HassBaseEl>>(superClass: T) =>
if (askWrite()) { if (askWrite()) {
this.updateComplete this.updateComplete
.then(() => .then(() =>
import(/* webpackChunkName: "ha-store-auth-card" */ "../dialogs/ha-store-auth-card") import(
/* webpackChunkName: "ha-store-auth-card" */ "../dialogs/ha-store-auth-card"
)
) )
.then(() => { .then(() => {
const el = document.createElement("ha-store-auth-card"); const el = document.createElement("ha-store-auth-card");

View File

@ -7,7 +7,9 @@ export default <T extends Constructor<HassBaseEl>>(superClass: T) =>
protected firstUpdated(changedProps) { protected firstUpdated(changedProps) {
super.firstUpdated(changedProps); super.firstUpdated(changedProps);
// Need to load in advance because when disconnected, can't dynamically load code. // Need to load in advance because when disconnected, can't dynamically load code.
import(/* webpackChunkName: "notification-manager" */ "../managers/notification-manager"); import(
/* webpackChunkName: "notification-manager" */ "../managers/notification-manager"
);
} }
protected hassReconnected() { protected hassReconnected() {

View File

@ -19,7 +19,9 @@ export default <T extends Constructor<HassBaseEl>>(superClass: T) =>
this.addEventListener("hass-more-info", (e) => this._handleMoreInfo(e)); this.addEventListener("hass-more-info", (e) => this._handleMoreInfo(e));
// Load it once we are having the initial rendering done. // Load it once we are having the initial rendering done.
import(/* webpackChunkName: "more-info-dialog" */ "../dialogs/ha-more-info-dialog"); import(
/* webpackChunkName: "more-info-dialog" */ "../dialogs/ha-more-info-dialog"
);
} }
private async _handleMoreInfo(ev) { private async _handleMoreInfo(ev) {

View File

@ -10,7 +10,9 @@ export default <T extends Constructor<HassBaseEl>>(superClass: T) =>
dialogShowEvent: "hass-notification", dialogShowEvent: "hass-notification",
dialogTag: "notification-manager", dialogTag: "notification-manager",
dialogImport: () => dialogImport: () =>
import(/* webpackChunkName: "notification-manager" */ "../managers/notification-manager"), import(
/* webpackChunkName: "notification-manager" */ "../managers/notification-manager"
),
}); });
} }
}; };

View File

@ -6,7 +6,9 @@ const JS_CACHE = {};
export const loadCustomPanel = (panelConfig): Promise<unknown> => { export const loadCustomPanel = (panelConfig): Promise<unknown> => {
if (panelConfig.html_url) { if (panelConfig.html_url) {
const toLoad = [ const toLoad = [
import(/* webpackChunkName: "import-href-polyfill" */ "../../resources/html-import/import-href"), import(
/* webpackChunkName: "import-href-polyfill" */ "../../resources/html-import/import-href"
),
]; ];
if (!panelConfig.embed_iframe) { if (!panelConfig.embed_iframe) {

View File

@ -105,9 +105,7 @@ async function fetchTranslation(fingerprint) {
}); });
if (!response.ok) { if (!response.ok) {
throw new Error( throw new Error(
`Fail to fetch translation ${fingerprint}: HTTP response status is ${ `Fail to fetch translation ${fingerprint}: HTTP response status is ${response.status}`
response.status
}`
); );
} }
return response.json(); return response.json();

932
yarn.lock

File diff suppressed because it is too large Load Diff