Skip to content

Commit 0336ce4

Browse files
authored
20250926.0 (#27213)
2 parents bab0391 + 9ba36ab commit 0336ce4

File tree

9 files changed

+131
-47
lines changed

9 files changed

+131
-47
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "home-assistant-frontend"
7-
version = "20250925.1"
7+
version = "20250926.0"
88
license = "Apache-2.0"
99
license-files = ["LICENSE*"]
1010
description = "The Home Assistant frontend"

src/components/ha-selector/ha-selector-number.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,12 @@ export class HaNumberSelector extends LitElement {
8282
labeled
8383
.min=${this.selector.number!.min}
8484
.max=${this.selector.number!.max}
85-
.value=${this.value ?? ""}
85+
.value=${this.value}
8686
.step=${sliderStep}
8787
.disabled=${this.disabled}
8888
.required=${this.required}
8989
@change=${this._handleSliderChange}
90-
.ticks=${this.selector.number?.slider_ticks}
90+
.withMarkers=${this.selector.number?.slider_ticks || false}
9191
>
9292
</ha-slider>
9393
`

src/dialogs/more-info/controls/more-info-media_player.ts

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ class MoreInfoMediaPlayer extends LitElement {
4848

4949
@property({ attribute: false }) public stateObj?: MediaPlayerEntity;
5050

51-
private _formateDuration(duration: number) {
51+
private _formatDuration(duration: number) {
5252
const hours = Math.floor(duration / 3600);
5353
const minutes = Math.floor((duration % 3600) / 60);
54-
const seconds = duration % 60;
54+
const seconds = Math.floor(duration % 60);
5555
return formatDurationDigital(this.hass.locale, {
5656
hours,
5757
minutes,
@@ -260,12 +260,12 @@ class MoreInfoMediaPlayer extends LitElement {
260260
const controls = computeMediaControls(stateObj, true);
261261
const coverUrl = stateObj.attributes.entity_picture || "";
262262
const playerObj = new HassMediaPlayerEntity(this.hass, this.stateObj);
263-
const position = Math.floor(playerObj.currentProgress) || 0;
264-
const duration = stateObj.attributes.media_duration || 0;
265-
const remaining = duration - position;
266-
const durationFormated =
267-
remaining > 0 ? this._formateDuration(remaining) : 0;
268-
const postionFormated = this._formateDuration(position);
263+
264+
const position = Math.max(Math.floor(playerObj.currentProgress || 0), 0);
265+
const duration = Math.max(stateObj.attributes.media_duration || 0, 0);
266+
const remaining = Math.max(duration - position, 0);
267+
const remainingFormatted = this._formatDuration(remaining);
268+
const positionFormatted = this._formatDuration(position);
269269
const primaryTitle = playerObj.primaryTitle;
270270
const secondaryTitle = playerObj.secondaryTitle;
271271
const turnOn = controls?.find((c) => c.action === "turn_on");
@@ -323,11 +323,10 @@ class MoreInfoMediaPlayer extends LitElement {
323323
@change=${this._handleMediaSeekChanged}
324324
?disabled=${!stateActive(stateObj) ||
325325
!supportsFeature(stateObj, MediaPlayerEntityFeature.SEEK)}
326-
></ha-slider>
327-
<div class="position-info-row">
328-
<span class="position-time">${postionFormated}</span>
329-
<span class="duration-time">${durationFormated}</span>
330-
</div>
326+
>
327+
<span slot="reference">${positionFormatted}</span>
328+
<span slot="reference">${remainingFormatted}</span>
329+
</ha-slider>
331330
</div>
332331
`
333332
: nothing}
@@ -548,13 +547,8 @@ class MoreInfoMediaPlayer extends LitElement {
548547
flex-direction: column;
549548
}
550549
551-
.position-info-row {
552-
display: flex;
553-
flex-direction: row;
554-
justify-content: space-between;
550+
.position-bar ha-slider::part(references) {
555551
color: var(--secondary-text-color);
556-
padding: 0 8px;
557-
font-size: var(--ha-font-size-s);
558552
}
559553
560554
.media-info-row {

src/dialogs/tts-try/dialog-tts-try.ts

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { createCloseHeading } from "../../components/ha-dialog";
88
import "../../components/ha-textarea";
99
import type { HaTextArea } from "../../components/ha-textarea";
1010
import { convertTextToSpeech } from "../../data/tts";
11+
import { haStyleDialog } from "../../resources/styles";
1112
import type { HomeAssistant } from "../../types";
1213
import { showAlertDialog } from "../generic/show-dialog-box";
1314
import type { TTSTryDialogParams } from "./show-dialog-tts-try";
@@ -149,21 +150,24 @@ export class TTSTryDialog extends LitElement {
149150
});
150151
}
151152

152-
static styles = css`
153-
ha-dialog {
154-
--mdc-dialog-max-width: 500px;
155-
}
156-
ha-textarea,
157-
ha-select {
158-
width: 100%;
159-
}
160-
ha-select {
161-
margin-top: 8px;
162-
}
163-
.loading {
164-
height: 36px;
165-
}
166-
`;
153+
static styles = [
154+
haStyleDialog,
155+
css`
156+
ha-dialog {
157+
--mdc-dialog-max-width: 500px;
158+
}
159+
ha-textarea,
160+
ha-select {
161+
width: 100%;
162+
}
163+
ha-select {
164+
margin-top: 8px;
165+
}
166+
.loading {
167+
height: 36px;
168+
}
169+
`,
170+
];
167171
}
168172

169173
declare global {

src/panels/config/energy/ha-config-energy.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ class HaConfigEnergy extends LitElement {
213213
this.hass.states[key],
214214
])
215215
),
216+
issues: this._validationResult,
216217
};
217218
const json = JSON.stringify(data, null, 2);
218219
const blob = new Blob([json], { type: "application/json" });

src/panels/lovelace/card-features/hui-water-heater-operation-modes-card-feature.ts

Lines changed: 68 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,32 @@
1+
import { mdiWaterBoiler } from "@mdi/js";
12
import type { PropertyValues, TemplateResult } from "lit";
23
import { html, LitElement } from "lit";
3-
import { customElement, property, state } from "lit/decorators";
4+
import { customElement, property, query, state } from "lit/decorators";
45
import { styleMap } from "lit/directives/style-map";
6+
import { stopPropagation } from "../../../common/dom/stop_propagation";
57
import { computeDomain } from "../../../common/entity/compute_domain";
68
import { stateColorCss } from "../../../common/entity/state_color";
7-
import "../../../components/ha-control-button";
8-
import "../../../components/ha-control-button-group";
99
import "../../../components/ha-control-select";
1010
import type { ControlSelectOption } from "../../../components/ha-control-select";
11-
import "../../../components/ha-control-slider";
12-
import { UNAVAILABLE } from "../../../data/entity";
11+
import "../../../components/ha-control-select-menu";
12+
import type { HaControlSelectMenu } from "../../../components/ha-control-select-menu";
13+
import "../../../components/ha-list-item";
1314
import type {
1415
OperationMode,
1516
WaterHeaterEntity,
1617
} from "../../../data/water_heater";
1718
import {
18-
compareWaterHeaterOperationMode,
1919
computeOperationModeIcon,
20+
compareWaterHeaterOperationMode,
2021
} from "../../../data/water_heater";
22+
import { UNAVAILABLE } from "../../../data/entity";
2123
import type { HomeAssistant } from "../../../types";
2224
import type { LovelaceCardFeature, LovelaceCardFeatureEditor } from "../types";
2325
import { cardFeatureStyles } from "./common/card-feature-styles";
2426
import { filterModes } from "./common/filter-modes";
2527
import type {
26-
LovelaceCardFeatureContext,
2728
WaterHeaterOperationModesCardFeatureConfig,
29+
LovelaceCardFeatureContext,
2830
} from "./types";
2931

3032
export const supportsWaterHeaterOperationModesCardFeature = (
@@ -52,6 +54,9 @@ class HuiWaterHeaterOperationModeCardFeature
5254

5355
@state() _currentOperationMode?: OperationMode;
5456

57+
@query("ha-control-select-menu", true)
58+
private _haSelect?: HaControlSelectMenu;
59+
5560
private get _stateObj() {
5661
if (!this.hass || !this.context || !this.context.entity_id) {
5762
return undefined;
@@ -97,8 +102,23 @@ class HuiWaterHeaterOperationModeCardFeature
97102
}
98103
}
99104

105+
protected updated(changedProps: PropertyValues) {
106+
super.updated(changedProps);
107+
if (this._haSelect && changedProps.has("hass")) {
108+
const oldHass = changedProps.get("hass") as HomeAssistant | undefined;
109+
if (
110+
this.hass &&
111+
this.hass.formatEntityAttributeValue !==
112+
oldHass?.formatEntityAttributeValue
113+
) {
114+
this._haSelect.layoutOptions();
115+
}
116+
}
117+
}
118+
100119
private async _valueChanged(ev: CustomEvent) {
101-
const mode = (ev.detail as any).value as OperationMode;
120+
const mode =
121+
(ev.detail as any).value ?? ((ev.target as any).value as OperationMode);
102122

103123
if (mode === this._stateObj!.state) return;
104124

@@ -143,9 +163,48 @@ class HuiWaterHeaterOperationModeCardFeature
143163
).map<ControlSelectOption>((mode) => ({
144164
value: mode,
145165
label: this.hass!.formatEntityState(this._stateObj!, mode),
146-
path: computeOperationModeIcon(mode as OperationMode),
166+
icon: html`
167+
<ha-svg-icon
168+
slot="graphic"
169+
.path=${computeOperationModeIcon(mode as OperationMode)}
170+
></ha-svg-icon>
171+
`,
147172
}));
148173

174+
if (this._config.style === "dropdown") {
175+
return html`
176+
<ha-control-select-menu
177+
show-arrow
178+
hide-label
179+
.label=${this.hass.localize("ui.card.water_heater.mode")}
180+
.value=${this._currentOperationMode}
181+
.disabled=${this._stateObj.state === UNAVAILABLE}
182+
fixedMenuPosition
183+
naturalMenuWidth
184+
@selected=${this._valueChanged}
185+
@closed=${stopPropagation}
186+
>
187+
${this._currentOperationMode
188+
? html`
189+
<ha-svg-icon
190+
slot="icon"
191+
.path=${computeOperationModeIcon(this._currentOperationMode)}
192+
></ha-svg-icon>
193+
`
194+
: html`
195+
<ha-svg-icon slot="icon" .path=${mdiWaterBoiler}></ha-svg-icon>
196+
`}
197+
${options.map(
198+
(option) => html`
199+
<ha-list-item .value=${option.value} graphic="icon">
200+
${option.icon}${option.label}
201+
</ha-list-item>
202+
`
203+
)}
204+
</ha-control-select-menu>
205+
`;
206+
}
207+
149208
return html`
150209
<ha-control-select
151210
.options=${options}

src/panels/lovelace/card-features/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ export interface ToggleCardFeatureConfig {
140140

141141
export interface WaterHeaterOperationModesCardFeatureConfig {
142142
type: "water-heater-operation-modes";
143+
style?: "dropdown" | "icons";
143144
operation_modes?: OperationMode[];
144145
}
145146

src/panels/lovelace/editor/config-elements/hui-water-heater-operation-modes-card-feature-editor.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import type {
1616
} from "../../card-features/types";
1717
import type { LovelaceCardFeatureEditor } from "../../types";
1818
import { compareWaterHeaterOperationMode } from "../../../../data/water_heater";
19+
import type { LocalizeFunc } from "../../../../common/translations/localize";
1920

2021
type WaterHeaterOperationModesCardFeatureData =
2122
WaterHeaterOperationModesCardFeatureConfig & {
@@ -39,11 +40,27 @@ export class HuiWaterHeaterOperationModesCardFeatureEditor
3940

4041
private _schema = memoizeOne(
4142
(
43+
localize: LocalizeFunc,
4244
formatEntityState: FormatEntityStateFunc,
4345
stateObj: HassEntity | undefined,
4446
customizeModes: boolean
4547
) =>
4648
[
49+
{
50+
name: "style",
51+
selector: {
52+
select: {
53+
multiple: false,
54+
mode: "list",
55+
options: ["dropdown", "icons"].map((mode) => ({
56+
value: mode,
57+
label: localize(
58+
`ui.panel.lovelace.editor.features.types.water-heater-operation-modes.style_list.${mode}`
59+
),
60+
})),
61+
},
62+
},
63+
},
4764
{
4865
name: "customize_modes",
4966
selector: {
@@ -85,11 +102,13 @@ export class HuiWaterHeaterOperationModesCardFeatureEditor
85102
: undefined;
86103

87104
const data: WaterHeaterOperationModesCardFeatureData = {
105+
style: "icons",
88106
...this._config,
89107
customize_modes: this._config.operation_modes !== undefined,
90108
};
91109

92110
const schema = this._schema(
111+
this.hass.localize,
93112
this.hass.formatEntityState,
94113
stateObj,
95114
data.customize_modes
@@ -131,6 +150,7 @@ export class HuiWaterHeaterOperationModesCardFeatureEditor
131150
) => {
132151
switch (schema.name) {
133152
case "operation_modes":
153+
case "style":
134154
case "customize_modes":
135155
return this.hass!.localize(
136156
`ui.panel.lovelace.editor.features.types.water-heater-operation-modes.${schema.name}`

src/translations/en.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8217,7 +8217,12 @@
82178217
"water-heater-operation-modes": {
82188218
"label": "Water heater operation modes",
82198219
"operation_modes": "Operation modes",
8220-
"customize_modes": "Customize operation modes"
8220+
"customize_modes": "Customize operation modes",
8221+
"style": "[%key:ui::panel::lovelace::editor::features::types::climate-preset-modes::style%]",
8222+
"style_list": {
8223+
"dropdown": "[%key:ui::panel::lovelace::editor::features::types::climate-preset-modes::style_list::dropdown%]",
8224+
"icons": "[%key:ui::panel::lovelace::editor::features::types::climate-preset-modes::style_list::icons%]"
8225+
}
82218226
},
82228227
"lawn-mower-commands": {
82238228
"label": "Lawn mower commands",

0 commit comments

Comments
 (0)