Skip to content

Commit

Permalink
20231204.0 (#18882)
Browse files Browse the repository at this point in the history
  • Loading branch information
bramkragten authored Dec 4, 2023
2 parents b854d23 + 6d0eb05 commit ae2e8e7
Show file tree
Hide file tree
Showing 13 changed files with 415 additions and 392 deletions.
32 changes: 16 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
"license": "Apache-2.0",
"type": "module",
"dependencies": {
"@babel/runtime": "7.23.4",
"@babel/runtime": "7.23.5",
"@braintree/sanitize-url": "6.0.4",
"@codemirror/autocomplete": "6.11.1",
"@codemirror/commands": "6.3.1",
"@codemirror/commands": "6.3.2",
"@codemirror/language": "6.9.3",
"@codemirror/legacy-modes": "6.3.3",
"@codemirror/search": "6.5.5",
Expand All @@ -43,12 +43,12 @@
"@formatjs/intl-numberformat": "8.9.0",
"@formatjs/intl-pluralrules": "5.2.10",
"@formatjs/intl-relativetimeformat": "11.2.10",
"@fullcalendar/core": "6.1.9",
"@fullcalendar/daygrid": "6.1.9",
"@fullcalendar/interaction": "6.1.9",
"@fullcalendar/list": "6.1.9",
"@fullcalendar/luxon3": "6.1.9",
"@fullcalendar/timegrid": "6.1.9",
"@fullcalendar/core": "6.1.10",
"@fullcalendar/daygrid": "6.1.10",
"@fullcalendar/interaction": "6.1.10",
"@fullcalendar/list": "6.1.10",
"@fullcalendar/luxon3": "6.1.10",
"@fullcalendar/timegrid": "6.1.10",
"@lezer/highlight": "1.2.0",
"@lit-labs/context": "0.4.1",
"@lit-labs/motion": "1.0.6",
Expand Down Expand Up @@ -130,7 +130,7 @@
"resize-observer-polyfill": "1.5.1",
"roboto-fontface": "0.10.0",
"rrule": "2.8.1",
"sortablejs": "1.15.0",
"sortablejs": "1.15.1",
"stacktrace-js": "2.0.2",
"superstruct": "1.0.3",
"tinykeys": "2.1.0",
Expand All @@ -152,11 +152,11 @@
"xss": "1.0.14"
},
"devDependencies": {
"@babel/core": "7.23.3",
"@babel/core": "7.23.5",
"@babel/helper-define-polyfill-provider": "0.4.3",
"@babel/plugin-proposal-decorators": "7.23.3",
"@babel/plugin-proposal-decorators": "7.23.5",
"@babel/plugin-transform-runtime": "7.23.4",
"@babel/preset-env": "7.23.3",
"@babel/preset-env": "7.23.5",
"@babel/preset-typescript": "7.23.3",
"@bundle-stats/plugin-webpack-filter": "4.8.3",
"@koa/cors": "4.0.0",
Expand All @@ -178,16 +178,16 @@
"@types/js-yaml": "4.0.9",
"@types/leaflet": "1.9.8",
"@types/leaflet-draw": "1.0.11",
"@types/luxon": "3.3.5",
"@types/luxon": "3.3.6",
"@types/mocha": "10.0.6",
"@types/qrcode": "1.5.5",
"@types/serve-handler": "6.1.4",
"@types/sortablejs": "1.15.7",
"@types/tar": "6.1.10",
"@types/ua-parser-js": "0.7.39",
"@types/webspeechapi": "0.0.29",
"@typescript-eslint/eslint-plugin": "6.12.0",
"@typescript-eslint/parser": "6.12.0",
"@typescript-eslint/eslint-plugin": "6.13.1",
"@typescript-eslint/parser": "6.13.1",
"@web/dev-server": "0.1.38",
"@web/dev-server-rollup": "0.4.1",
"babel-loader": "9.1.3",
Expand Down Expand Up @@ -255,7 +255,7 @@
"@polymer/polymer": "patch:@polymer/[email protected]#./.yarn/patches/@polymer/polymer/pr-5569.patch",
"@material/mwc-button@^0.25.3": "^0.27.0",
"lit": "2.8.0",
"clean-css": "5.3.2",
"clean-css": "5.3.3",
"@lit/reactive-element": "1.6.3",
"[email protected]": "patch:sortablejs@npm%3A1.15.0#./.yarn/patches/sortablejs-npm-1.15.0-f3a393abcc.patch",
"[email protected]": "patch:leaflet-draw@npm%3A1.0.4#./.yarn/patches/leaflet-draw-npm-1.0.4-0ca0ebcf65.patch"
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "home-assistant-frontend"
version = "20231130.0"
version = "20231204.0"
license = {text = "Apache-2.0"}
description = "The Home Assistant frontend"
readme = "README.md"
Expand Down
4 changes: 4 additions & 0 deletions src/auth/ha-authorize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,10 @@ export class HaAuthorize extends litLocalizeLiteMixin(LitElement) {
);
}

if (window.innerWidth > 450) {
import("../resources/particles");
}

// If we are logging into the instance that is hosting this auth form
// we will register the service worker to start preloading.
if (url.host === location.host) {
Expand Down
136 changes: 72 additions & 64 deletions src/auth/ha-local-auth-flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ export class HaLocalAuthFlow extends LitElement {
ha-button {
--mdc-typography-button-text-transform: none;
}
.forgot-password-container {
text-align: right;
padding: 8px 0 16px 0;
}
a.forgot-password {
color: var(--primary-color);
text-decoration: none;
Expand All @@ -177,7 +181,7 @@ export class HaLocalAuthFlow extends LitElement {
</style>
${this._error
? html`<ha-alert alert-type="error">${this._error}</ha-alert>`
: ""}
: nothing}
${this._step
? html`<ha-auth-flow
.clientId=${this.clientId}
Expand All @@ -188,72 +192,76 @@ export class HaLocalAuthFlow extends LitElement {
.localize=${this.localize}
></ha-auth-flow>`
: this._selectedUser
? html`<div class="login-form"><div class="person">
<ha-person-badge
.person=${this._persons[this._selectedUser]}
></ha-person-badge>
<p>${this._persons[this._selectedUser].name}</p>
</div>
<form>
<input
type="hidden"
name="username"
autocomplete="username"
.value=${this.authProvider.users[this._selectedUser]}
/>
<ha-auth-textfield
.type=${this._unmaskedPassword ? "text" : "password"}
id="password"
name="password"
.label=${this.localize(
"ui.panel.page-authorize.form.providers.homeassistant.step.init.data.password"
)}
required
autoValidate
autocomplete
iconTrailing
validationMessage="Required"
>
<ha-icon-button
toggles
.label=${
this.localize(
this._unmaskedPassword
? "ui.panel.page-authorize.form.hide_password"
: "ui.panel.page-authorize.form.show_password"
) || (this._unmaskedPassword ? "Hide password" : "Show password")
}
@click=${this._toggleUnmaskedPassword}
.path=${this._unmaskedPassword ? mdiEyeOff : mdiEye}
></ha-icon-button>
</ha-auth-textfield>
</div>
<div class="action space-between">
<mwc-button
@click=${this._restart}
.disabled=${this._submitting}
>
${this.localize("ui.panel.page-authorize.form.previous")}
</mwc-button>
<mwc-button
raised
@click=${this._handleSubmit}
.disabled=${this._submitting}
>
${this.localize("ui.panel.page-authorize.form.next")}
</mwc-button>
? html`<div class="login-form">
<div class="person">
<ha-person-badge
.person=${this._persons[this._selectedUser]}
></ha-person-badge>
<p>${this._persons[this._selectedUser].name}</p>
</div>
<div class="action">
<a class="forgot-password"
href="https://www.home-assistant.io/docs/locked_out/#forgot-password"
target="_blank"
rel="noreferrer noopener"
>${this.localize(
"ui.panel.page-authorize.forgot_password"
)}</a
<form>
<input
type="hidden"
name="username"
autocomplete="username"
readonly
.value=${this.authProvider.users[this._selectedUser]}
/>
<ha-auth-textfield
.type=${this._unmaskedPassword ? "text" : "password"}
autocomplete="current-password"
id="password"
name="password"
.label=${this.localize(
"ui.panel.page-authorize.form.providers.homeassistant.step.init.data.password"
)}
required
autoValidate
iconTrailing
validationMessage="Required"
>
<ha-icon-button
toggles
.label=${this.localize(
this._unmaskedPassword
? "ui.panel.page-authorize.form.hide_password"
: "ui.panel.page-authorize.form.show_password"
) ||
(this._unmaskedPassword
? "Hide password"
: "Show password")}
@click=${this._toggleUnmaskedPassword}
.path=${this._unmaskedPassword ? mdiEyeOff : mdiEye}
></ha-icon-button>
</ha-auth-textfield>
<div class="forgot-password-container">
<a
class="forgot-password"
href="https://www.home-assistant.io/docs/locked_out/#forgot-password"
target="_blank"
rel="noreferrer noopener"
>${this.localize(
"ui.panel.page-authorize.forgot_password"
)}</a
>
</div>
<div class="action space-between">
<mwc-button
@click=${this._restart}
.disabled=${this._submitting}
>
${this.localize("ui.panel.page-authorize.form.previous")}
</mwc-button>
<mwc-button
raised
@click=${this._handleSubmit}
.disabled=${this._submitting}
>
${this.localize("ui.panel.page-authorize.form.next")}
</mwc-button>
</div>
</form>`
</form>
</div>`
: html`<h1>
${this.localize("ui.panel.page-authorize.welcome_home")}
</h1>
Expand Down
50 changes: 28 additions & 22 deletions src/data/energy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,28 @@ const clearEnergyCollectionPreferences = (hass: HomeAssistant) => {
});
};

const scheduleHourlyRefresh = (collection: EnergyCollection) => {
if (collection._refreshTimeout) {
clearTimeout(collection._refreshTimeout);
}

if (collection._active && (!collection.end || collection.end > new Date())) {
// The stats are created every hour
// Schedule a refresh for 20 minutes past the hour
// If the end is larger than the current time.
const nextFetch = new Date();
if (nextFetch.getMinutes() >= 20) {
nextFetch.setHours(nextFetch.getHours() + 1);
}
nextFetch.setMinutes(20, 0, 0);

collection._refreshTimeout = window.setTimeout(
() => collection.refresh(),
nextFetch.getTime() - Date.now()
);
}
};

export const getEnergyDataCollection = (
hass: HomeAssistant,
options: { prefs?: EnergyPreferences; key?: string } = {}
Expand Down Expand Up @@ -609,28 +631,7 @@ export const getEnergyDataCollection = (
collection.prefs = await getEnergyPreferences(hass);
}

if (collection._refreshTimeout) {
clearTimeout(collection._refreshTimeout);
}

if (
collection._active &&
(!collection.end || collection.end > new Date())
) {
// The stats are created every hour
// Schedule a refresh for 20 minutes past the hour
// If the end is larger than the current time.
const nextFetch = new Date();
if (nextFetch.getMinutes() >= 20) {
nextFetch.setHours(nextFetch.getHours() + 1);
}
nextFetch.setMinutes(20, 0, 0);

collection._refreshTimeout = window.setTimeout(
() => collection.refresh(),
nextFetch.getTime() - Date.now()
);
}
scheduleHourlyRefresh(collection);

return getEnergyData(
hass,
Expand All @@ -647,6 +648,11 @@ export const getEnergyDataCollection = (
collection.subscribe = (subscriber: (data: EnergyData) => void) => {
const unsub = origSubscribe(subscriber);
collection._active++;

if (collection._refreshTimeout === undefined) {
scheduleHourlyRefresh(collection);
}

return () => {
collection._active--;
if (collection._active < 1) {
Expand Down
18 changes: 12 additions & 6 deletions src/data/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,8 @@ export const computeHistory = (
hass: HomeAssistant,
stateHistory: HistoryStates,
localize: LocalizeFunc,
sensorNumericalDeviceClasses: string[]
sensorNumericalDeviceClasses: string[],
splitDeviceClasses = false
): HistoryResult => {
const lineChartDevices: { [unit: string]: HistoryStates } = {};
const timelineDevices: TimelineEntity[] = [];
Expand Down Expand Up @@ -473,7 +474,7 @@ export const computeHistory = (
currentState?.attributes || numericStateFromHistory?.a
)?.device_class;

const key = computeGroupKey(unit, deviceClass);
const key = computeGroupKey(unit, deviceClass, splitDeviceClasses);

if (!unit) {
timelineDevices.push(
Expand All @@ -487,9 +488,13 @@ export const computeHistory = (
currentState
)
);
} else if (key in lineChartDevices && entityId in lineChartDevices[key]) {
} else if (
key &&
key in lineChartDevices &&
entityId in lineChartDevices[key]
) {
lineChartDevices[key][entityId].push(...stateInfo);
} else {
} else if (key) {
if (!(key in lineChartDevices)) {
lineChartDevices[key] = {};
}
Expand All @@ -514,5 +519,6 @@ export const computeHistory = (

export const computeGroupKey = (
unit: string | undefined,
device_class: string | undefined
) => `${unit}_${device_class || ""}`;
device_class: string | undefined,
splitDeviceClasses: boolean
) => (splitDeviceClasses ? `${unit}_${device_class || ""}` : unit);
2 changes: 1 addition & 1 deletion src/onboarding/ha-onboarding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ class HaOnboarding extends litLocalizeLiteMixin(HassElement) {
this._handleProgress(ev)
);
if (window.innerWidth > 450) {
import("./particles");
import("../resources/particles");
}
makeDialogManager(this, this.shadowRoot!);
import("../components/ha-language-picker");
Expand Down
Loading

0 comments on commit ae2e8e7

Please sign in to comment.