Skip to content

Commit

Permalink
20241002.0 (#22185)
Browse files Browse the repository at this point in the history
  • Loading branch information
bramkragten authored Oct 2, 2024
2 parents 268eb43 + c8930ce commit fdf9fab
Show file tree
Hide file tree
Showing 20 changed files with 478 additions and 344 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"@codemirror/legacy-modes": "6.4.1",
"@codemirror/search": "6.5.6",
"@codemirror/state": "6.4.1",
"@codemirror/view": "6.34.0",
"@codemirror/view": "6.34.1",
"@egjs/hammerjs": "2.0.17",
"@formatjs/intl-datetimeformat": "6.12.5",
"@formatjs/intl-displaynames": "6.6.8",
Expand Down Expand Up @@ -89,8 +89,8 @@
"@polymer/polymer": "3.5.1",
"@replit/codemirror-indentation-markers": "6.5.3",
"@thomasloven/round-slider": "0.6.0",
"@vaadin/combo-box": "24.4.9",
"@vaadin/vaadin-themable-mixin": "24.4.9",
"@vaadin/combo-box": "24.4.10",
"@vaadin/vaadin-themable-mixin": "24.4.10",
"@vibrant/color": "3.2.1-alpha.1",
"@vibrant/core": "3.2.1-alpha.1",
"@vibrant/quantizer-mmcq": "3.2.1-alpha.1",
Expand Down Expand Up @@ -172,7 +172,7 @@
"@types/babel__plugin-transform-runtime": "7.9.5",
"@types/chromecast-caf-receiver": "6.0.17",
"@types/chromecast-caf-sender": "1.0.10",
"@types/color-name": "1.1.4",
"@types/color-name": "2.0.0",
"@types/glob": "8.1.0",
"@types/html-minifier-terser": "7.0.2",
"@types/js-yaml": "4.0.9",
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 = "20240930.0"
version = "20241002.0"
license = {text = "Apache-2.0"}
description = "The Home Assistant frontend"
readme = "README.md"
Expand Down
33 changes: 29 additions & 4 deletions src/components/ha-color-picker.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { mdiInvertColorsOff, mdiPalette } from "@mdi/js";
import { css, html, LitElement, nothing } from "lit";
import { customElement, property } from "lit/decorators";
import { customElement, property, query } from "lit/decorators";
import { styleMap } from "lit/directives/style-map";
import { computeCssColor, THEME_COLORS } from "../common/color/compute-color";
import { fireEvent } from "../common/dom/fire_event";
import { stopPropagation } from "../common/dom/stop_propagation";
import { LocalizeKeys } from "../common/translations/localize";
import { HomeAssistant } from "../types";
import "./ha-list-item";
import "./ha-select";
import "./ha-md-divider";
import "./ha-select";
import type { HaSelect } from "./ha-select";

@customElement("ha-color-picker")
export class HaColorPicker extends LitElement {
Expand All @@ -32,7 +33,17 @@ export class HaColorPicker extends LitElement {

@property({ type: Boolean }) public disabled = false;

_valueSelected(ev) {
@query("ha-select") private _select!: HaSelect;

connectedCallback(): void {
super.connectedCallback();
// Refresh layout options when the field is connected to the DOM to ensure current value displayed
this._select.layoutOptions();
}

private _valueSelected(ev) {
ev.stopPropagation();
if (!this.isConnected) return;
const value = ev.target.value;
this.value = value === this.defaultColor ? undefined : value;
fireEvent(this, "value-changed", {
Expand All @@ -41,7 +52,13 @@ export class HaColorPicker extends LitElement {
}

render() {
const value = this.value || this.defaultColor;
const value = this.value || this.defaultColor || "";

const isCustom = !(
THEME_COLORS.has(value) ||
value === "none" ||
value === "state"
);

return html`
<ha-select
Expand Down Expand Up @@ -110,6 +127,14 @@ export class HaColorPicker extends LitElement {
</ha-list-item>
`
)}
${isCustom
? html`
<ha-list-item .value=${value} graphic="icon">
${value}
<span slot="graphic">${this.renderColorCircle(value)}</span>
</ha-list-item>
`
: nothing}
</ha-select>
`;
}
Expand Down
3 changes: 3 additions & 0 deletions src/data/recorder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,3 +332,6 @@ export const getDisplayUnit = (

export const isExternalStatistic = (statisticsId: string): boolean =>
statisticsId.includes(":");

export const updateStatisticsIssues = (hass: HomeAssistant) =>
hass.callWS({ type: "recorder/update_statistics_issues" });
4 changes: 2 additions & 2 deletions src/data/timer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ export const timerTimeRemaining = (

if (stateObj.state === "active") {
const now = new Date().getTime();
const madeActive = new Date(stateObj.last_changed).getTime();
timeRemaining = Math.max(timeRemaining - (now - madeActive) / 1000, 0);
const finishes = new Date(stateObj.attributes.finishes_at).getTime();
timeRemaining = Math.max((finishes - now) / 1000, 0);
}

return timeRemaining;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { css, html, LitElement, nothing, PropertyValues } from "lit";
import { customElement, property } from "lit/decorators";
import { fireEvent } from "../../common/dom/fire_event";
import "../../components/ha-circular-progress";
import { UNAVAILABLE } from "../../data/entity";
import { OFF, ON, UNAVAILABLE } from "../../data/entity";
import { HomeAssistant } from "../../types";
import { AssistantSetupStyles } from "./styles";

Expand All @@ -14,6 +14,8 @@ export class HaVoiceAssistantSetupStepUpdate extends LitElement {

private _updated = false;

private _refreshTimeout?: number;

protected override willUpdate(changedProperties: PropertyValues): void {
super.willUpdate(changedProperties);

Expand All @@ -28,17 +30,18 @@ export class HaVoiceAssistantSetupStepUpdate extends LitElement {
const oldState = oldHass.states[this.updateEntityId];
const newState = this.hass.states[this.updateEntityId];
if (
oldState?.state === UNAVAILABLE &&
newState?.state !== UNAVAILABLE
(oldState?.state === UNAVAILABLE &&
newState?.state !== UNAVAILABLE) ||
(oldState?.state === OFF && newState?.state === ON)
) {
// Device is rebooted, let's move on
this._tryUpdate();
this._tryUpdate(false);
}
}
}

if (changedProperties.has("updateEntityId")) {
this._tryUpdate();
this._tryUpdate(true);
}
}

Expand All @@ -54,7 +57,11 @@ export class HaVoiceAssistantSetupStepUpdate extends LitElement {

return html`<div class="content">
<img src="/static/icons/casita/loading.png" />
<h1>Updating your voice assistant</h1>
<h1>
${stateObj.state === OFF
? "Checking for updates"
: "Updating your voice assistant"}
</h1>
<p class="secondary">
We are making sure you have the latest and greatest version of your
voice assistant. This may take a few minutes.
Expand All @@ -75,7 +82,8 @@ export class HaVoiceAssistantSetupStepUpdate extends LitElement {
</div>`;
}

private async _tryUpdate() {
private async _tryUpdate(refreshUpdate: boolean) {
clearTimeout(this._refreshTimeout);
if (!this.updateEntityId) {
return;
}
Expand All @@ -91,6 +99,16 @@ export class HaVoiceAssistantSetupStepUpdate extends LitElement {
{},
{ entity_id: updateEntity.entity_id }
);
} else if (refreshUpdate) {
await this.hass.callService(
"homeassistant",
"update_entity",
{},
{ entity_id: this.updateEntityId }
);
this._refreshTimeout = window.setTimeout(() => {
this._nextStep();
}, 5000);
} else {
this._nextStep();
}
Expand Down
76 changes: 54 additions & 22 deletions src/panels/config/devices/ha-config-device-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import "../../../components/ha-button-menu";
import "../../../components/ha-icon-button";
import "../../../components/ha-icon-next";
import "../../../components/ha-svg-icon";
import "../../../components/ha-expansion-panel";
import { getSignedPath } from "../../../data/auth";
import {
ConfigEntry,
Expand Down Expand Up @@ -1354,16 +1355,14 @@ export class HaConfigDevicePage extends LitElement {
.filter((entity) => entity.newId)
.map(
(entity) =>
html`<li style="white-space: nowrap;">
${entity.oldId} -> ${entity.newId}
</li>`
html`<tr>
<td>${entity.oldId}</td>
<td>${entity.newId}</td>
</tr>`
);
const dialogNoRenames = entityIdRenames
.filter((entity) => !entity.newId)
.map(
(entity) =>
html`<li style="white-space: nowrap;">${entity.oldId}</li>`
);
.map((entity) => html`<li>${entity.oldId}</li>`);

if (dialogRenames.length) {
renameEntityid = await showConfirmationDialog(this, {
Expand All @@ -1372,17 +1371,46 @@ export class HaConfigDevicePage extends LitElement {
),
text: html`${this.hass.localize(
"ui.panel.config.devices.confirm_rename_entity_ids_warning"
)} <br /><br />${this.hass.localize(
"ui.panel.config.devices.confirm_rename_entity_will_rename"
)}:
${dialogRenames}
)} <br /><br />
<ha-expansion-panel outlined>
<span slot="header"
>${this.hass.localize(
"ui.panel.config.devices.confirm_rename_entity_will_rename",
{ count: dialogRenames.length }
)}</span
>
<div style="overflow: auto;">
<table style="width: 100%; text-align: var(--float-start);">
<tr>
<th>
${this.hass.localize(
"ui.panel.config.devices.confirm_rename_old"
)}
</th>
<th>
${this.hass.localize(
"ui.panel.config.devices.confirm_rename_new"
)}
</th>
</tr>
${dialogRenames}
</table>
</div>
</ha-expansion-panel>
${dialogNoRenames.length
? html`<br /><br />${this.hass.localize(
"ui.panel.config.devices.confirm_rename_entity_wont_rename",
{ deviceSlug: oldDeviceSlug }
)}:
${dialogNoRenames}`
: nothing}`,
? html`<ha-expansion-panel outlined>
<span slot="header"
>${this.hass.localize(
"ui.panel.config.devices.confirm_rename_entity_wont_rename",
{
count: dialogNoRenames.length,
deviceSlug: oldDeviceSlug,
}
)}</span
>
${dialogNoRenames}</ha-expansion-panel
>`
: nothing} `,
confirmText: this.hass.localize("ui.common.rename"),
dismissText: this.hass.localize("ui.common.no"),
warning: true,
Expand All @@ -1392,11 +1420,15 @@ export class HaConfigDevicePage extends LitElement {
title: this.hass.localize(
"ui.panel.config.devices.confirm_rename_entity_no_renamable_entity_ids"
),
text: html`${this.hass.localize(
"ui.panel.config.devices.confirm_rename_entity_wont_rename",
{ deviceSlug: oldDeviceSlug }
)}:
${dialogNoRenames}`,
text: html`<ha-expansion-panel outlined>
<span slot="header"
>${this.hass.localize(
"ui.panel.config.devices.confirm_rename_entity_wont_rename",
{ deviceSlug: oldDeviceSlug, count: dialogNoRenames.length }
)}</span
>
${dialogNoRenames}
</ha-expansion-panel>`,
});
}
}
Expand Down
21 changes: 8 additions & 13 deletions src/panels/config/repairs/ha-config-repairs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { showRepairsIssueDialog } from "./show-repair-issue-dialog";
import {
STATISTIC_TYPES,
StatisticsValidationResult,
updateStatisticsIssues,
} from "../../../data/recorder";

@customElement("ha-config-repairs")
Expand Down Expand Up @@ -144,25 +145,19 @@ class HaConfigRepairs extends LitElement {
issue.translation_key &&
STATISTIC_TYPES.includes(issue.translation_key as any)
) {
const localize =
await this.hass.loadFragmentTranslation("developer-tools");
this.hass.loadFragmentTranslation("developer-tools");
const data = await fetchRepairsIssueData(
this.hass.connection,
issue.domain,
issue.issue_id
);
if ("issue_type" in data.issue_data) {
await fixStatisticsIssue(
this,
this.hass,
localize || this.hass.localize,
{
type: data.issue_data
.issue_type as StatisticsValidationResult["type"],
data: data.issue_data as any,
}
);
this.hass.callWS({ type: "recorder/update_statistics_issues" });
await fixStatisticsIssue(this, {
type: data.issue_data
.issue_type as StatisticsValidationResult["type"],
data: data.issue_data as any,
});
updateStatisticsIssues(this.hass);
}
} else {
showRepairsIssueDialog(this, {
Expand Down
Loading

0 comments on commit fdf9fab

Please sign in to comment.