Skip to content

Commit a34bf32

Browse files
authored
Merge branch 'dev' into map-card-editor
2 parents 6baf7a8 + 29b3303 commit a34bf32

File tree

65 files changed

+2295
-2292
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+2295
-2292
lines changed

demo/src/configs/sections/entities.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ export const demoEntitiesSections: DemoConfig["entities"] = (localize) =>
141141
},
142142
},
143143
"device_tracker.car": {
144-
entity_id: "sensor.outdoor_humidity",
144+
entity_id: "device_tracker.car",
145145
state: "not_home",
146146
attributes: {
147147
friendly_name: "Car",
@@ -199,7 +199,7 @@ export const demoEntitiesSections: DemoConfig["entities"] = (localize) =>
199199
},
200200
},
201201
"binary_sensor.kitchen_motion": {
202-
entity_id: "light.kitchen_motion",
202+
entity_id: "binary_sensor.kitchen_motion",
203203
state: "on",
204204
attributes: {
205205
device_class: "motion",
@@ -335,7 +335,7 @@ export const demoEntitiesSections: DemoConfig["entities"] = (localize) =>
335335
},
336336
},
337337
"sensor.rain": {
338-
entity_id: "sensor.moon_phase",
338+
entity_id: "sensor.rain",
339339
state: "7.2",
340340
attributes: {
341341
state_class: "total_increasing",
@@ -565,7 +565,7 @@ export const demoEntitiesSections: DemoConfig["entities"] = (localize) =>
565565
},
566566
},
567567
"update.home_assistant_core_update": {
568-
entity_id: "update.home_assistant_supervisor_update",
568+
entity_id: "update.home_assistant_core_update",
569569
state: "off",
570570
attributes: {
571571
auto_update: false,

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@
3737
"@codemirror/view": "6.39.16",
3838
"@date-fns/tz": "1.4.1",
3939
"@egjs/hammerjs": "2.0.17",
40-
"@formatjs/intl-datetimeformat": "7.2.4",
41-
"@formatjs/intl-displaynames": "7.2.1",
40+
"@formatjs/intl-datetimeformat": "7.2.5",
41+
"@formatjs/intl-displaynames": "7.2.2",
4242
"@formatjs/intl-durationformat": "0.10.1",
4343
"@formatjs/intl-getcanonicallocales": "3.2.1",
44-
"@formatjs/intl-listformat": "8.2.1",
44+
"@formatjs/intl-listformat": "8.2.2",
4545
"@formatjs/intl-locale": "5.2.1",
46-
"@formatjs/intl-numberformat": "9.2.2",
47-
"@formatjs/intl-pluralrules": "6.2.2",
48-
"@formatjs/intl-relativetimeformat": "12.2.2",
46+
"@formatjs/intl-numberformat": "9.2.3",
47+
"@formatjs/intl-pluralrules": "6.2.3",
48+
"@formatjs/intl-relativetimeformat": "12.2.3",
4949
"@fullcalendar/core": "6.1.20",
5050
"@fullcalendar/daygrid": "6.1.20",
5151
"@fullcalendar/interaction": "6.1.20",
@@ -209,7 +209,7 @@
209209
"rspack-manifest-plugin": "5.2.1",
210210
"serve": "14.2.6",
211211
"sinon": "21.0.2",
212-
"tar": "7.5.10",
212+
"tar": "7.5.11",
213213
"terser-webpack-plugin": "5.3.17",
214214
"ts-lit-plugin": "2.0.2",
215215
"typescript": "5.9.3",

src/common/datetime/calc_date_range.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,13 @@ export const calcDateRange = (
9393
];
9494
case "now-12m":
9595
return [
96-
calcDate(today, subMonths, hass.locale, hass.config, 12),
97-
calcDate(today, subMonths, hass.locale, hass.config, 0),
96+
calcDate(
97+
today,
98+
(date) => subMonths(startOfMonth(date), 11),
99+
hass.locale,
100+
hass.config
101+
),
102+
calcDate(today, endOfMonth, hass.locale, hass.config),
98103
];
99104
case "now-1h":
100105
return [

src/common/datetime/format_date.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,21 @@ const formatDateMonthMem = memoizeOne(
166166
})
167167
);
168168

169+
// Aug
170+
export const formatDateMonthShort = (
171+
dateObj: Date,
172+
locale: FrontendLocaleData,
173+
config: HassConfig
174+
) => formatDateMonthShortMem(locale, config.time_zone).format(dateObj);
175+
176+
const formatDateMonthShortMem = memoizeOne(
177+
(locale: FrontendLocaleData, serverTimeZone: string) =>
178+
new Intl.DateTimeFormat(locale.language, {
179+
month: "short",
180+
timeZone: resolveTimeZone(locale.time_zone, serverTimeZone),
181+
})
182+
);
183+
169184
// 2021
170185
export const formatDateYear = (
171186
dateObj: Date,

src/components/entity/state-badge.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import { iconColorCSS } from "../../common/style/icon_color_css";
1515
import { cameraUrlWithWidthHeight } from "../../data/camera";
1616
import { CLIMATE_HVAC_ACTION_TO_MODE } from "../../data/climate";
1717
import type { HomeAssistant } from "../../types";
18-
import { addBrandsAuth } from "../../util/brands-url";
1918
import "../ha-state-icon";
2019

2120
@customElement("state-badge")
@@ -141,7 +140,6 @@ export class StateBadge extends LitElement {
141140
if (this.hass) {
142141
imageUrl = this.hass.hassUrl(imageUrl);
143142
}
144-
imageUrl = addBrandsAuth(imageUrl, this.hass?.auth.data.hassUrl);
145143
if (domain === "camera") {
146144
imageUrl = cameraUrlWithWidthHeight(imageUrl, 80, 80);
147145
}

src/components/ha-slider.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ export class HaSlider extends Slider {
6161
width: 200px;
6262
}
6363
64+
/* Expand slider touch target to 32px */
65+
#slider {
66+
padding-block: 14px;
67+
margin-block: -14px;
68+
}
69+
6470
#thumb {
6571
border: none;
6672
background-color: var(--ha-slider-thumb-color, var(--primary-color));

src/data/backup_manager.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export type CreateBackupStage =
1313
| "app_repositories"
1414
| "apps"
1515
| "await_app_restarts"
16+
| "cleaning_up"
1617
| "docker_config"
1718
| "finishing_file"
1819
| "folders"

src/data/energy.ts

Lines changed: 54 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,19 @@ import { calcDateRange } from "../common/datetime/calc_date_range";
4040
import type { DateRange } from "../common/datetime/calc_date_range";
4141
import { formatNumber } from "../common/number/format_number";
4242

43-
const energyCollectionKeys: (string | undefined)[] = [];
43+
export const ENERGY_COLLECTION_KEY_PREFIX = "energy_";
44+
45+
// All collection keys created this session
46+
const energyCollectionKeys = new Set<string | undefined>();
47+
48+
// Validate that a string is a valid energy collection key.
49+
export function validateEnergyCollectionKey(key: string | undefined) {
50+
if (!key?.startsWith(ENERGY_COLLECTION_KEY_PREFIX)) {
51+
throw new Error(
52+
`Collection keys must start with ${ENERGY_COLLECTION_KEY_PREFIX}.`
53+
);
54+
}
55+
}
4456

4557
export const emptyGridSourceEnergyPreference =
4658
(): GridSourceTypeEnergyPreference => ({
@@ -693,17 +705,20 @@ export interface EnergyCollection extends Collection<EnergyData> {
693705
clearPrefs(): void;
694706
setPeriod(newStart: Date, newEnd?: Date): void;
695707
setCompare(compare: CompareMode): void;
708+
isActive(): boolean;
696709
_refreshTimeout?: number;
697710
_updatePeriodTimeout?: number;
698711
_active: number;
699712
}
700713

701714
const clearEnergyCollectionPreferences = (hass: HomeAssistant) => {
702715
energyCollectionKeys.forEach((key) => {
703-
const energyCollection = getEnergyDataCollection(hass, { key });
704-
energyCollection.clearPrefs();
705-
if (energyCollection._active) {
706-
energyCollection.refresh();
716+
const energyCollection = findEnergyDataCollection(hass, key);
717+
if (energyCollection) {
718+
energyCollection.clearPrefs();
719+
if (energyCollection.isActive()) {
720+
energyCollection.refresh();
721+
}
707722
}
708723
});
709724
};
@@ -730,23 +745,47 @@ const scheduleHourlyRefresh = (collection: EnergyCollection) => {
730745
}
731746
};
732747

733-
export const getEnergyDataCollection = (
748+
const convertCollectionKeyToConnection = (
734749
hass: HomeAssistant,
735-
options: { prefs?: EnergyPreferences; key?: string } = {}
736-
): EnergyCollection => {
750+
collectionKey: string | undefined
751+
): [string, string | undefined] => {
737752
let key = "_energy";
738-
if (options.key) {
739-
if (!options.key.startsWith("energy_")) {
740-
throw new Error("Key need to start with energy_");
741-
}
742-
key = `_${options.key}`;
753+
if (collectionKey) {
754+
validateEnergyCollectionKey(collectionKey);
755+
key = `_${collectionKey}`;
756+
} else if (hass.panelUrl) {
757+
const defaultKey = ENERGY_COLLECTION_KEY_PREFIX + hass.panelUrl;
758+
key = `_${defaultKey}`;
759+
collectionKey = defaultKey;
743760
}
761+
return [key, collectionKey];
762+
};
763+
764+
const findEnergyDataCollection = (
765+
hass: HomeAssistant,
766+
collectionKey: string | undefined
767+
): EnergyCollection | undefined => {
768+
// Lookup the connection key and default key name
769+
const [key, _collectionKey] = convertCollectionKeyToConnection(
770+
hass,
771+
collectionKey
772+
);
773+
return (hass.connection as any)[key];
774+
};
744775

776+
export const getEnergyDataCollection = (
777+
hass: HomeAssistant,
778+
options: { prefs?: EnergyPreferences; key?: string } = {}
779+
): EnergyCollection => {
780+
const [key, collectionKey] = convertCollectionKeyToConnection(
781+
hass,
782+
options.key
783+
);
745784
if ((hass.connection as any)[key]) {
746785
return (hass.connection as any)[key];
747786
}
748787

749-
energyCollectionKeys.push(options.key);
788+
energyCollectionKeys.add(collectionKey);
750789

751790
const collection = getCollection<EnergyData>(
752791
hass.connection,
@@ -832,6 +871,7 @@ export const getEnergyDataCollection = (
832871
};
833872
scheduleUpdatePeriod();
834873

874+
collection.isActive = () => !!collection._active;
835875
collection.clearPrefs = () => {
836876
collection.prefs = undefined;
837877
};

src/data/zwave_js.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,17 +1053,6 @@ export const setZWaveJSLogLevel = (
10531053
config: { level },
10541054
});
10551055

1056-
export interface ZWaveJSIntegrationSettings {
1057-
installer_mode: boolean;
1058-
}
1059-
1060-
export const fetchZwaveIntegrationSettings = (
1061-
hass: HomeAssistant
1062-
): Promise<ZWaveJSIntegrationSettings> =>
1063-
hass.callWS({
1064-
type: "zwave_js/get_integration_settings",
1065-
});
1066-
10671056
export const cancelSecureBootstrapS2 = (
10681057
hass: HomeAssistant,
10691058
entry_id: string

src/dialogs/more-info/components/more-info-control-style.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ export const moreInfoControlStyle = css`
1212
display: flex;
1313
flex-direction: column;
1414
align-items: center;
15+
justify-content: center;
16+
flex: 1;
1517
}
1618
1719
.controls:not(:last-child) {

0 commit comments

Comments
 (0)