mirror of
https://github.com/home-assistant/frontend.git
synced 2026-11-16 09:52:59 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8823dce36c |
No files matched your search
@@ -18,7 +18,7 @@ workflows:
|
||||
- 'actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9'
|
||||
'.github/workflows/codeql-analysis.yaml':
|
||||
- 'actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1'
|
||||
- 'github/codeql-action@33d7b85da1a04171e211befe2c739303b9a4c066'
|
||||
- 'github/codeql-action@9b3254085494b55a0f7c4c2b3d2d52cc712ce370'
|
||||
'.github/workflows/copilot-setup-steps.yml':
|
||||
- 'actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9'
|
||||
- 'actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1'
|
||||
@@ -151,9 +151,9 @@ dependencies:
|
||||
commit: 'sha1-89ae32b08ed1a541efecbab17912962a5e38981c'
|
||||
owner_id: 7513068
|
||||
repo_id: 113918130
|
||||
'github/codeql-action@33d7b85da1a04171e211befe2c739303b9a4c066':
|
||||
ref: 'v4.39.3'
|
||||
commit: 'sha1-33d7b85da1a04171e211befe2c739303b9a4c066'
|
||||
'github/codeql-action@9b3254085494b55a0f7c4c2b3d2d52cc712ce370':
|
||||
ref: 'v4.39.1'
|
||||
commit: 'sha1-9b3254085494b55a0f7c4c2b3d2d52cc712ce370'
|
||||
owner_id: 9919
|
||||
repo_id: 259445878
|
||||
'home-assistant/actions@86d4564712fa02543c808e3a693dd04f9d3f8361':
|
||||
|
||||
@@ -32,12 +32,12 @@ jobs:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@33d7b85da1a04171e211befe2c739303b9a4c066 # v4.39.3
|
||||
uses: github/codeql-action/init@9b3254085494b55a0f7c4c2b3d2d52cc712ce370 # v4.39.1
|
||||
with:
|
||||
languages: javascript-typescript
|
||||
build-mode: none
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@33d7b85da1a04171e211befe2c739303b9a4c066 # v4.39.3
|
||||
uses: github/codeql-action/analyze@9b3254085494b55a0f7c4c2b3d2d52cc712ce370 # v4.39.1
|
||||
with:
|
||||
category: "/language:javascript-typescript"
|
||||
@@ -157,99 +157,6 @@ async function pollProcess(lokaliseApi, projectId, processId) {
|
||||
}
|
||||
/* eslint-enable no-await-in-loop */
|
||||
|
||||
const DRAFTS_ACCEPTED_KEYS = [
|
||||
// Written per language rather than translated from English, so an English edit doesn't make them outdated
|
||||
"ui.components.rooms.keywords",
|
||||
];
|
||||
|
||||
async function exportTranslations(lokaliseApi, projectId) {
|
||||
const exportProcess = await lokaliseApi.files().async_download(projectId, {
|
||||
format: "json",
|
||||
original_filenames: false,
|
||||
replace_breaks: false,
|
||||
json_unescaped_slashes: true,
|
||||
export_empty_as: "skip",
|
||||
filter_data: ["verified"],
|
||||
});
|
||||
|
||||
const finishedProcess = await pollProcess(
|
||||
lokaliseApi,
|
||||
projectId,
|
||||
exportProcess.process_id
|
||||
);
|
||||
|
||||
const bundleUrl = finishedProcess.details.download_url;
|
||||
|
||||
console.log(`Downloading translations from: ${bundleUrl}`);
|
||||
|
||||
const response = await fetch(bundleUrl);
|
||||
|
||||
if (response.status !== 200 && response.status !== 0) {
|
||||
throw new Error(response.statusText);
|
||||
}
|
||||
|
||||
console.log(`Extracting translations...`);
|
||||
|
||||
const contents = await JSZip.loadAsync(await response.arrayBuffer());
|
||||
|
||||
const files = {};
|
||||
await Promise.all(
|
||||
Object.keys(contents.files).map(async (filename) => {
|
||||
const file = contents.file(filename);
|
||||
if (!file) {
|
||||
// no file, probably a directory
|
||||
return;
|
||||
}
|
||||
files[filename.split("/").splice(-1)[0]] = await file.async("string");
|
||||
})
|
||||
);
|
||||
return files;
|
||||
}
|
||||
|
||||
async function fetchDrafts(lokaliseApi, projectId) {
|
||||
const english = JSON.parse(
|
||||
await fs.readFile("src/translations/en.json", { encoding })
|
||||
);
|
||||
const keyNames = DRAFTS_ACCEPTED_KEYS.flatMap((key) => {
|
||||
const keys = key.split(".");
|
||||
const drafts = keys.reduce((obj, part) => obj?.[part], english) ?? {};
|
||||
return Object.keys(drafts).map((name) => [...keys, name].join("::"));
|
||||
});
|
||||
if (!keyNames.length) {
|
||||
return [];
|
||||
}
|
||||
const { items } = await lokaliseApi.keys().list({
|
||||
project_id: projectId,
|
||||
filter_keys: keyNames.join(","),
|
||||
include_translations: 1,
|
||||
limit: keyNames.length,
|
||||
});
|
||||
return items.flatMap((key) =>
|
||||
key.translations
|
||||
.filter(({ translation }) => translation)
|
||||
.map(({ language_iso, translation }) => ({
|
||||
filename: `${language_iso}.json`,
|
||||
path: key.key_name.web.split("::"),
|
||||
translation,
|
||||
}))
|
||||
);
|
||||
}
|
||||
|
||||
function acceptDrafts(files, drafts) {
|
||||
const data = {};
|
||||
drafts.forEach(({ filename, path: keyPath, translation }) => {
|
||||
data[filename] ??= files[filename] ? JSON.parse(files[filename]) : {};
|
||||
const parent = keyPath.slice(0, -1).reduce((obj, part) => {
|
||||
obj[part] ??= {};
|
||||
return obj[part];
|
||||
}, data[filename]);
|
||||
parent[keyPath.at(-1)] = translation;
|
||||
});
|
||||
Object.entries(data).forEach(([filename, content]) => {
|
||||
files[filename] = JSON.stringify(content, null, 2);
|
||||
});
|
||||
}
|
||||
|
||||
gulp.task("fetch-lokalise", async function () {
|
||||
let apiKey;
|
||||
try {
|
||||
@@ -286,24 +193,52 @@ gulp.task("fetch-lokalise", async function () {
|
||||
await Promise.all(
|
||||
projects.map(async ([project, projectId]) => {
|
||||
try {
|
||||
const [files, drafts] = await Promise.all([
|
||||
exportTranslations(lokaliseApi, projectId),
|
||||
project === "frontend"
|
||||
? fetchDrafts(lokaliseApi, projectId)
|
||||
: undefined,
|
||||
]);
|
||||
if (drafts) {
|
||||
acceptDrafts(files, drafts);
|
||||
const exportProcess = await lokaliseApi
|
||||
.files()
|
||||
.async_download(projectId, {
|
||||
format: "json",
|
||||
original_filenames: false,
|
||||
replace_breaks: false,
|
||||
json_unescaped_slashes: true,
|
||||
export_empty_as: "skip",
|
||||
filter_data: ["verified"],
|
||||
});
|
||||
|
||||
const finishedProcess = await pollProcess(
|
||||
lokaliseApi,
|
||||
projectId,
|
||||
exportProcess.process_id
|
||||
);
|
||||
|
||||
const bundleUrl = finishedProcess.details.download_url;
|
||||
|
||||
console.log(`Downloading translations from: ${bundleUrl}`);
|
||||
|
||||
const response = await fetch(bundleUrl);
|
||||
|
||||
if (response.status !== 200 && response.status !== 0) {
|
||||
throw new Error(response.statusText);
|
||||
}
|
||||
|
||||
console.log(`Extracting translations...`);
|
||||
|
||||
const contents = await JSZip.loadAsync(await response.arrayBuffer());
|
||||
|
||||
await mkdirPromise;
|
||||
await Promise.all(
|
||||
Object.entries(files).map(([filename, content]) =>
|
||||
fs.writeFile(path.join(inDir, project, filename), content, {
|
||||
flag: "w",
|
||||
encoding,
|
||||
})
|
||||
)
|
||||
Object.keys(contents.files).map(async (filename) => {
|
||||
const file = contents.file(filename);
|
||||
if (!file) {
|
||||
// no file, probably a directory
|
||||
return;
|
||||
}
|
||||
const content = await file.async("nodebuffer");
|
||||
await fs.writeFile(
|
||||
path.join(inDir, project, filename.split("/").splice(-1)[0]),
|
||||
content,
|
||||
{ flag: "w", encoding }
|
||||
);
|
||||
})
|
||||
);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
|
||||
@@ -28,7 +28,7 @@ class HcLaunchScreen extends LitElement {
|
||||
:host {
|
||||
display: block;
|
||||
height: 100vh;
|
||||
background-color: var(--primary-background-color, #f2f4f9);
|
||||
background-color: #f2f4f9;
|
||||
font-size: var(--ha-font-size-2xl);
|
||||
}
|
||||
.container {
|
||||
@@ -44,7 +44,7 @@ class HcLaunchScreen extends LitElement {
|
||||
object-fit: cover;
|
||||
}
|
||||
.status {
|
||||
color: var(--primary-text-color, #1d2126);
|
||||
color: #1d2126;
|
||||
}
|
||||
`;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import type {
|
||||
import type { MockHomeAssistant } from "../../../src/fake_data/provide_hass";
|
||||
|
||||
export const mockEnergy = (hass: MockHomeAssistant) => {
|
||||
const prefs: EnergyPreferences = {
|
||||
hass.mockWS("energy/get_prefs", (): EnergyPreferences => ({
|
||||
energy_sources: [
|
||||
{
|
||||
type: "grid",
|
||||
@@ -48,23 +48,6 @@ export const mockEnergy = (hass: MockHomeAssistant) => {
|
||||
stat_energy_to: "sensor.battery_input",
|
||||
stat_rate: "sensor.power_battery",
|
||||
},
|
||||
{
|
||||
type: "battery",
|
||||
name: "Powerwall",
|
||||
stat_energy_from_grid: "sensor.powerwall_from_grid",
|
||||
stat_energy_from_solar: "sensor.powerwall_from_solar",
|
||||
stat_energy_to_home: "sensor.powerwall_to_home",
|
||||
stat_energy_to_grid: "sensor.powerwall_to_grid",
|
||||
stat_rate: "sensor.powerwall_power",
|
||||
power_config: {
|
||||
stat_rate_from_grid: "sensor.powerwall_power_from_grid",
|
||||
stat_rate_from_solar: "sensor.powerwall_power_from_solar",
|
||||
stat_rate_to_home: "sensor.powerwall_power_to_home",
|
||||
stat_rate_to_grid: "sensor.powerwall_power_to_grid",
|
||||
},
|
||||
stat_soc: "sensor.powerwall_battery_level",
|
||||
capacity: 13.5,
|
||||
},
|
||||
{
|
||||
type: "gas",
|
||||
stat_energy_from: "sensor.energy_gas",
|
||||
@@ -122,17 +105,16 @@ export const mockEnergy = (hass: MockHomeAssistant) => {
|
||||
stat_consumption: "sensor.gas_heat_pump",
|
||||
},
|
||||
],
|
||||
};
|
||||
hass.mockWS("energy/get_prefs", (): EnergyPreferences => prefs);
|
||||
}));
|
||||
hass.mockWS("energy/info", (): EnergyInfo => ({
|
||||
cost_sensors: {},
|
||||
solar_forecast_domains: [],
|
||||
}));
|
||||
hass.mockWS("energy/validate", () => ({
|
||||
energy_sources: prefs.energy_sources.map(() => []),
|
||||
device_consumption: prefs.device_consumption.map(() => []),
|
||||
device_consumption_water: prefs.device_consumption_water.map(() => []),
|
||||
device_consumption_gas: prefs.device_consumption_gas.map(() => []),
|
||||
energy_sources: Array.from({ length: 6 }, () => []),
|
||||
device_consumption: Array.from({ length: 6 }, () => []),
|
||||
device_consumption_water: Array.from({ length: 2 }, () => []),
|
||||
device_consumption_gas: Array.from({ length: 2 }, () => []),
|
||||
}));
|
||||
hass.mockWS(
|
||||
"energy/fossil_energy_consumption",
|
||||
|
||||
@@ -1,30 +1,3 @@
|
||||
// Live power of the battery measured per direction, in W
|
||||
const powerwallPower = {
|
||||
from_grid: 50,
|
||||
from_solar: 150,
|
||||
to_home: 0,
|
||||
to_grid: 0,
|
||||
};
|
||||
|
||||
const powerEntity = (entityId: string, power: number) => ({
|
||||
entity_id: entityId,
|
||||
state: String(power),
|
||||
attributes: {
|
||||
state_class: "measurement",
|
||||
unit_of_measurement: "W",
|
||||
},
|
||||
});
|
||||
|
||||
const powerwallEnergyEntity = (entityId: string, friendlyName: string) => ({
|
||||
entity_id: entityId,
|
||||
state: "2",
|
||||
attributes: {
|
||||
last_reset: "1970-01-01T00:00:00:00+00",
|
||||
friendly_name: friendlyName,
|
||||
unit_of_measurement: "kWh",
|
||||
},
|
||||
});
|
||||
|
||||
export const energyEntities = () =>
|
||||
Object.values({
|
||||
"sensor.grid_fossil_fuel_percentage": {
|
||||
@@ -61,31 +34,6 @@ export const energyEntities = () =>
|
||||
unit_of_measurement: "kWh",
|
||||
},
|
||||
},
|
||||
"sensor.powerwall_from_grid": powerwallEnergyEntity(
|
||||
"sensor.powerwall_from_grid",
|
||||
"Powerwall charged from grid"
|
||||
),
|
||||
"sensor.powerwall_from_solar": powerwallEnergyEntity(
|
||||
"sensor.powerwall_from_solar",
|
||||
"Powerwall charged from solar"
|
||||
),
|
||||
"sensor.powerwall_to_home": powerwallEnergyEntity(
|
||||
"sensor.powerwall_to_home",
|
||||
"Powerwall discharged to home"
|
||||
),
|
||||
"sensor.powerwall_to_grid": powerwallEnergyEntity(
|
||||
"sensor.powerwall_to_grid",
|
||||
"Powerwall discharged to grid"
|
||||
),
|
||||
"sensor.powerwall_battery_level": {
|
||||
entity_id: "sensor.powerwall_battery_level",
|
||||
state: "62",
|
||||
attributes: {
|
||||
device_class: "battery",
|
||||
friendly_name: "Powerwall battery level",
|
||||
unit_of_measurement: "%",
|
||||
},
|
||||
},
|
||||
"sensor.energy_consumption_tarif_1": {
|
||||
entity_id: "sensor.energy_consumption_tarif_1",
|
||||
state: "88.6",
|
||||
@@ -186,29 +134,6 @@ export const energyEntities = () =>
|
||||
unit_of_measurement: "W",
|
||||
},
|
||||
},
|
||||
"sensor.powerwall_power_from_grid": powerEntity(
|
||||
"sensor.powerwall_power_from_grid",
|
||||
powerwallPower.from_grid
|
||||
),
|
||||
"sensor.powerwall_power_from_solar": powerEntity(
|
||||
"sensor.powerwall_power_from_solar",
|
||||
powerwallPower.from_solar
|
||||
),
|
||||
"sensor.powerwall_power_to_home": powerEntity(
|
||||
"sensor.powerwall_power_to_home",
|
||||
powerwallPower.to_home
|
||||
),
|
||||
"sensor.powerwall_power_to_grid": powerEntity(
|
||||
"sensor.powerwall_power_to_grid",
|
||||
powerwallPower.to_grid
|
||||
),
|
||||
"sensor.powerwall_power": powerEntity(
|
||||
"sensor.powerwall_power",
|
||||
powerwallPower.to_home +
|
||||
powerwallPower.to_grid -
|
||||
powerwallPower.from_grid -
|
||||
powerwallPower.from_solar
|
||||
),
|
||||
"sensor.energy_gas_cost": {
|
||||
entity_id: "sensor.energy_gas_cost",
|
||||
state: "2",
|
||||
|
||||
@@ -351,26 +351,6 @@ const statisticsFunctions: Record<
|
||||
const derivedCosts: Record<string, { source: string; price: number }> = {
|
||||
"sensor.energy_water_cost": { source: "sensor.energy_water", price: 0.004 },
|
||||
};
|
||||
// Battery directions as a share of the meter the energy also passes, so they
|
||||
// never exceed it
|
||||
const derivedBatteryFlows: Record<string, { source: string; share: number }> = {
|
||||
"sensor.powerwall_from_grid": {
|
||||
source: "sensor.energy_consumption_tarif_1",
|
||||
share: 0.4,
|
||||
},
|
||||
"sensor.powerwall_from_solar": {
|
||||
source: "sensor.solar_production",
|
||||
share: 0.3,
|
||||
},
|
||||
"sensor.powerwall_to_home": {
|
||||
source: "sensor.energy_consumption_tarif_2",
|
||||
share: 0.5,
|
||||
},
|
||||
"sensor.powerwall_to_grid": {
|
||||
source: "sensor.energy_production_tarif_2",
|
||||
share: 0.3,
|
||||
},
|
||||
};
|
||||
|
||||
export const mockRecorder = (mockHass: MockHomeAssistant) => {
|
||||
mockHass.mockWS(
|
||||
@@ -395,22 +375,15 @@ export const mockRecorder = (mockHass: MockHomeAssistant) => {
|
||||
return cache[id];
|
||||
};
|
||||
|
||||
const scaleStats = (source: string, factor: number) => {
|
||||
let sum = 0;
|
||||
return getStats(source).map((statistic) => {
|
||||
const change = statistic.change! * factor;
|
||||
sum += change;
|
||||
return { ...statistic, change, state: sum, sum };
|
||||
});
|
||||
};
|
||||
|
||||
statistic_ids.forEach((id: string) => {
|
||||
if (id in derivedCosts) {
|
||||
const { source, price } = derivedCosts[id];
|
||||
statistics[id] = scaleStats(source, price);
|
||||
} else if (id in derivedBatteryFlows) {
|
||||
const { source, share } = derivedBatteryFlows[id];
|
||||
statistics[id] = scaleStats(source, share);
|
||||
let cost = 0;
|
||||
statistics[id] = getStats(source).map((statistic) => {
|
||||
const change = statistic.change! * price;
|
||||
cost += change;
|
||||
return { ...statistic, change, state: cost, sum: cost };
|
||||
});
|
||||
} else if (id in statisticsFunctions) {
|
||||
statistics[id] = getStats(id);
|
||||
} else {
|
||||
|
||||
@@ -117,17 +117,11 @@ shared slots/attributes below.
|
||||
|
||||
**Attributes**
|
||||
|
||||
| Name | Type | Default | Description |
|
||||
| ---------------------- | ------- | ------- | -------------------------------------------------- |
|
||||
| `headline` | String | — | Primary text. Overridden by the slot. |
|
||||
| `supporting-text` | String | — | Secondary text. Overridden by the slot. |
|
||||
| `wrap-headline` | Boolean | `false` | Wrap the headline instead of truncating it. |
|
||||
| `wrap-supporting-text` | Boolean | `false` | Wrap the supporting text instead of truncating it. |
|
||||
| `disabled` | Boolean | `false` | Dims the row and blocks pointer events. |
|
||||
|
||||
The headline and the supporting text stay on one line and are truncated with an
|
||||
ellipsis by default. Set `wrap-headline` or `wrap-supporting-text` on rows whose
|
||||
text has to stay readable in full, like settings with a description.
|
||||
| Name | Type | Default | Description |
|
||||
| ----------------- | ------- | ------- | --------------------------------------- |
|
||||
| `headline` | String | — | Primary text. Overridden by the slot. |
|
||||
| `supporting-text` | String | — | Secondary text. Overridden by the slot. |
|
||||
| `disabled` | Boolean | `false` | Dims the row and blocks pointer events. |
|
||||
|
||||
**CSS parts**
|
||||
|
||||
|
||||
@@ -191,20 +191,6 @@ export class DemoHaList extends LitElement {
|
||||
<ha-list-item-base headline="Disabled row" disabled>
|
||||
<ha-svg-icon slot="start" .path=${mdiHome}></ha-svg-icon>
|
||||
</ha-list-item-base>
|
||||
<ha-list-item-base
|
||||
headline="Truncated by default, a long headline stays on one line and ends with an ellipsis"
|
||||
supporting-text="Long supporting text is truncated as well, so every row in the list keeps the same height"
|
||||
>
|
||||
<ha-svg-icon slot="start" .path=${mdiHome}></ha-svg-icon>
|
||||
</ha-list-item-base>
|
||||
<ha-list-item-base
|
||||
wrap-headline
|
||||
wrap-supporting-text
|
||||
headline="With wrap-headline, a long headline wraps onto as many lines as it needs"
|
||||
supporting-text="With wrap-supporting-text, long supporting text wraps too, which suits settings with a description"
|
||||
>
|
||||
<ha-svg-icon slot="start" .path=${mdiHome}></ha-svg-icon>
|
||||
</ha-list-item-base>
|
||||
</ha-list-base>
|
||||
</ha-card>
|
||||
|
||||
|
||||
+30
-30
@@ -40,7 +40,7 @@
|
||||
"license": "Apache-2.0",
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "8.1.2",
|
||||
"@babel/runtime": "8.1.0",
|
||||
"@braintree/sanitize-url": "7.1.2",
|
||||
"@codemirror/autocomplete": "6.20.4",
|
||||
"@codemirror/commands": "6.11.1",
|
||||
@@ -48,21 +48,21 @@
|
||||
"@codemirror/lang-python": "6.2.1",
|
||||
"@codemirror/lang-yaml": "6.1.3",
|
||||
"@codemirror/language": "6.13.1",
|
||||
"@codemirror/lint": "6.9.8",
|
||||
"@codemirror/lint": "6.9.7",
|
||||
"@codemirror/search": "6.7.2",
|
||||
"@codemirror/state": "6.7.6",
|
||||
"@codemirror/view": "6.43.15",
|
||||
"@date-fns/tz": "1.5.0",
|
||||
"@egjs/hammerjs": "2.0.17",
|
||||
"@formatjs/intl-datetimeformat": "8.0.3",
|
||||
"@formatjs/intl-displaynames": "8.0.2",
|
||||
"@formatjs/intl-durationformat": "0.12.4",
|
||||
"@formatjs/intl-getcanonicallocales": "3.3.1",
|
||||
"@formatjs/intl-listformat": "9.0.2",
|
||||
"@formatjs/intl-locale": "5.4.3",
|
||||
"@formatjs/intl-numberformat": "10.0.3",
|
||||
"@formatjs/intl-pluralrules": "7.0.3",
|
||||
"@formatjs/intl-relativetimeformat": "13.0.2",
|
||||
"@formatjs/intl-datetimeformat": "8.0.2",
|
||||
"@formatjs/intl-displaynames": "8.0.1",
|
||||
"@formatjs/intl-durationformat": "0.12.3",
|
||||
"@formatjs/intl-getcanonicallocales": "3.3.0",
|
||||
"@formatjs/intl-listformat": "9.0.1",
|
||||
"@formatjs/intl-locale": "5.4.2",
|
||||
"@formatjs/intl-numberformat": "10.0.2",
|
||||
"@formatjs/intl-pluralrules": "7.0.2",
|
||||
"@formatjs/intl-relativetimeformat": "13.0.1",
|
||||
"@home-assistant/webawesome": "3.14.0-ha.2",
|
||||
"@lezer/common": "1.5.5",
|
||||
"@lezer/highlight": "1.2.5",
|
||||
@@ -77,9 +77,9 @@
|
||||
"@mdi/svg": "7.4.47",
|
||||
"@replit/codemirror-indentation-markers": "6.5.3",
|
||||
"@swc/helpers": "0.5.24",
|
||||
"@tsparticles/engine": "4.5.4",
|
||||
"@tsparticles/preset-links": "4.5.4",
|
||||
"@versatiles/style": "9.1.0",
|
||||
"@tsparticles/engine": "4.5.3",
|
||||
"@tsparticles/preset-links": "4.5.3",
|
||||
"@versatiles/style": "9.0.0",
|
||||
"@vibrant/color": "4.0.4",
|
||||
"@vvo/tzdb": "6.204.0",
|
||||
"@webcomponents/scoped-custom-element-registry": "0.0.10",
|
||||
@@ -97,19 +97,19 @@
|
||||
"echarts": "6.1.0",
|
||||
"echarts-extension-chart2music": "0.1.1",
|
||||
"element-internals-polyfill": "3.0.2",
|
||||
"fullcalendar": "7.1.5",
|
||||
"fullcalendar": "7.1.4",
|
||||
"fuse.js": "7.5.0",
|
||||
"hls.js": "1.7.4",
|
||||
"home-assistant-js-websocket": "9.8.1",
|
||||
"idb-keyval": "6.3.0",
|
||||
"intl-messageformat": "12.1.5",
|
||||
"intl-messageformat": "12.1.4",
|
||||
"js-yaml": "5.5.0",
|
||||
"leaflet": "1.9.4",
|
||||
"leaflet.markercluster": "1.5.3",
|
||||
"lit": "3.3.3",
|
||||
"lit-html": "3.3.3",
|
||||
"maplibre-gl": "6.18.0",
|
||||
"marked": "18.2.0",
|
||||
"maplibre-gl": "6.17.0",
|
||||
"marked": "18.1.3",
|
||||
"memoize-one": "6.0.0",
|
||||
"nanoid": "6.0.2",
|
||||
"node-vibrant": "4.0.4",
|
||||
@@ -136,12 +136,12 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@ampproject/remapping": "2.3.0",
|
||||
"@babel/core": "8.1.2",
|
||||
"@babel/core": "8.1.0",
|
||||
"@babel/helper-compilation-targets": "8.0.7",
|
||||
"@babel/helper-define-polyfill-provider": "1.0.0",
|
||||
"@babel/plugin-transform-class-properties": "8.0.1",
|
||||
"@babel/plugin-transform-private-methods": "8.0.1",
|
||||
"@babel/plugin-transform-runtime": "8.1.2",
|
||||
"@babel/plugin-transform-runtime": "8.0.6",
|
||||
"@babel/preset-env": "8.0.7",
|
||||
"@bundle-stats/plugin-webpack-filter": "4.23.1",
|
||||
"@eslint/js": "10.0.1",
|
||||
@@ -153,7 +153,7 @@
|
||||
"@octokit/rest": "22.0.1",
|
||||
"@playwright/test": "1.65.0",
|
||||
"@rsdoctor/rspack-plugin": "1.6.5",
|
||||
"@rspack/core": "2.3.2",
|
||||
"@rspack/core": "2.3.1",
|
||||
"@rspack/dev-server": "2.2.2",
|
||||
"@types/babel__plugin-transform-runtime": "7.9.5",
|
||||
"@types/chromecast-caf-receiver": "7.0.1",
|
||||
@@ -180,7 +180,7 @@
|
||||
"eslint": "10.14.0",
|
||||
"eslint-config-prettier": "10.1.8",
|
||||
"eslint-import-resolver-webpack": "0.13.11",
|
||||
"eslint-plugin-import-x": "4.18.1",
|
||||
"eslint-plugin-import-x": "4.18.0",
|
||||
"eslint-plugin-lit": "2.3.1",
|
||||
"eslint-plugin-lit-a11y": "5.1.3",
|
||||
"eslint-plugin-unused-imports": "4.4.1",
|
||||
@@ -188,14 +188,14 @@
|
||||
"fancy-log": "2.0.0",
|
||||
"fs-extra": "11.4.1",
|
||||
"generate-license-file": "4.2.5",
|
||||
"glob": "14.0.6",
|
||||
"glob": "14.0.4",
|
||||
"globals": "17.14.0",
|
||||
"gulp": "5.0.1",
|
||||
"gulp-json-transform": "0.5.0",
|
||||
"gulp-rename": "2.1.0",
|
||||
"html-minifier-terser": "7.2.0",
|
||||
"husky": "9.1.7",
|
||||
"jsdom": "31.0.1",
|
||||
"jsdom": "31.0.0",
|
||||
"jszip": "3.10.2",
|
||||
"license-checker-rseidelsohn": "5.0.1",
|
||||
"lightningcss": "1.33.0",
|
||||
@@ -206,24 +206,24 @@
|
||||
"map-stream": "0.0.7",
|
||||
"minify-literals": "2.2.0",
|
||||
"pinst": "3.0.0",
|
||||
"prettier": "3.10.1",
|
||||
"prettier": "3.9.10",
|
||||
"rspack-manifest-plugin": "5.2.2",
|
||||
"serve": "14.2.7",
|
||||
"sinon": "22.1.0",
|
||||
"tar": "7.5.23",
|
||||
"tar": "7.5.22",
|
||||
"terser-webpack-plugin": "5.6.1",
|
||||
"ts-lit-plugin": "2.0.2",
|
||||
"typescript": "6.0.3",
|
||||
"typescript-eslint": "8.72.2",
|
||||
"vite": "8.3.8",
|
||||
"typescript-eslint": "8.72.1",
|
||||
"vite": "8.3.6",
|
||||
"vite-tsconfig-paths": "6.1.1",
|
||||
"vitest": "5.1.0",
|
||||
"webpack-stats-plugin": "1.1.3",
|
||||
"webpackbar": "7.0.0",
|
||||
"workbox-build": "7.4.1"
|
||||
},
|
||||
"packageManager": "pnpm@12.20.0",
|
||||
"packageManager": "pnpm@12.18.0",
|
||||
"volta": {
|
||||
"node": "24.22.3"
|
||||
"node": "24.22.2"
|
||||
}
|
||||
}
|
||||
@@ -53,7 +53,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@custom-elements-manifest/analyzer": "0.11.0",
|
||||
"@rslib/core": "1.0.7",
|
||||
"@rslib/core": "1.0.6",
|
||||
"lit": "3.3.3",
|
||||
"typescript": "6.0.3"
|
||||
}
|
||||
|
||||
Generated
+1014
-1010
File diff suppressed because it is too large.
Load diff
@@ -89,19 +89,10 @@ export class LegendFitController {
|
||||
|
||||
private _fit() {
|
||||
const list = this._element;
|
||||
if (!list) {
|
||||
const rowWidth = list?.getBoundingClientRect().width;
|
||||
if (!list || !rowWidth) {
|
||||
return;
|
||||
}
|
||||
const style = getComputedStyle(list);
|
||||
const rowWidth = parseFloat(style.width);
|
||||
// Bounding rects include transforms, such as a dialog scaling in, which
|
||||
// never resize the list, so measure in layout pixels
|
||||
const scale = list.getBoundingClientRect().width / rowWidth;
|
||||
if (!rowWidth || !scale) {
|
||||
return;
|
||||
}
|
||||
const layoutWidth = (element: Element) =>
|
||||
element.getBoundingClientRect().width / scale;
|
||||
const children = Array.from(list.children);
|
||||
const more = children.find((child) =>
|
||||
child.classList.contains("legend-more")
|
||||
@@ -116,7 +107,9 @@ export class LegendFitController {
|
||||
}
|
||||
this._more = more;
|
||||
}
|
||||
const widths = children.filter((child) => child !== more).map(layoutWidth);
|
||||
const widths = children
|
||||
.filter((child) => child !== more)
|
||||
.map((child) => child.getBoundingClientRect().width);
|
||||
// Values resize the items on every state update. Fitting each item at its
|
||||
// widest since the last resize keeps the more button from flickering.
|
||||
if (rowWidth !== this._rowWidth || widths.length !== this._widths.length) {
|
||||
@@ -129,9 +122,9 @@ export class LegendFitController {
|
||||
}
|
||||
const fit = fitInRows(
|
||||
this._widths,
|
||||
more ? layoutWidth(more) : 0,
|
||||
more?.getBoundingClientRect().width ?? 0,
|
||||
rowWidth,
|
||||
parseFloat(style.columnGap) || 0,
|
||||
parseFloat(getComputedStyle(list).columnGap) || 0,
|
||||
rowWidth < NARROW_WIDTH ? NARROW_MAX_ROWS : MAX_ROWS
|
||||
);
|
||||
if (fit !== this.fit) {
|
||||
|
||||
@@ -76,18 +76,6 @@ export interface NetworkData {
|
||||
|
||||
const PHYSICS_DISABLE_THRESHOLD = 512;
|
||||
|
||||
const LAYOUT_ANIMATION_THRESHOLD = 100;
|
||||
|
||||
// Every event of a change of the legend selection, each with the whole
|
||||
// selection
|
||||
const LEGEND_SELECT_EVENTS = [
|
||||
"legendselectchanged",
|
||||
"legendselected",
|
||||
"legendunselected",
|
||||
"legendselectall",
|
||||
"legendinverseselect",
|
||||
];
|
||||
|
||||
const SELECTED_NODE_MAX_ZOOM = 2;
|
||||
|
||||
// Keeps neighbors clear of the search field, buttons and legend
|
||||
@@ -136,22 +124,8 @@ export class HaNetworkGraph extends LitElement {
|
||||
|
||||
@state() private _showLabels = true;
|
||||
|
||||
// Not reactive: a new series option starts the layout again, so a drop only
|
||||
// reaches the option with the next render
|
||||
private _nodePositions: Record<string, { x: number; y: number }> = {};
|
||||
|
||||
// Dragged nodes stay where they are dropped, the force layout moves the others
|
||||
private _pinnedNodes: string[] = [];
|
||||
|
||||
// Names of the legend categories that are switched off. Not reactive: the
|
||||
// legend lays the graph out itself, only the layout animation threshold
|
||||
// needs a render
|
||||
private _hiddenCategories: string[] = [];
|
||||
|
||||
private _dragNode?: string;
|
||||
|
||||
private _dragMoved = false;
|
||||
|
||||
private _followSelectedNode = false;
|
||||
|
||||
private _followedChart?: EChartsType;
|
||||
@@ -196,15 +170,12 @@ export class HaNetworkGraph extends LitElement {
|
||||
this._showLabels,
|
||||
isMobile,
|
||||
hasHighlightedNodes,
|
||||
this.selectedNode,
|
||||
this._nodePositions,
|
||||
this._pinnedNodes,
|
||||
this._fewVisibleNodes()
|
||||
this.selectedNode
|
||||
)}
|
||||
.options=${this._createOptions(this.data?.categories)}
|
||||
height="100%"
|
||||
.extraComponents=${[GraphChart]}
|
||||
@chart-setup=${this._handleChartSetup}
|
||||
@chart-setup=${this._updateFollowing}
|
||||
>
|
||||
<slot name="search" slot="search"></slot>
|
||||
<slot name="button" slot="button"></slot>
|
||||
@@ -302,10 +273,7 @@ export class HaNetworkGraph extends LitElement {
|
||||
showLabels: boolean,
|
||||
isMobile: boolean,
|
||||
hasHighlightedNodes?: boolean,
|
||||
selectedNode?: string,
|
||||
nodePositions: Record<string, { x: number; y: number }> = {},
|
||||
pinnedNodes: string[] = [],
|
||||
fewVisibleNodes = true
|
||||
selectedNode?: string
|
||||
) => ({
|
||||
id: "network",
|
||||
type: "graph",
|
||||
@@ -343,15 +311,14 @@ export class HaNetworkGraph extends LitElement {
|
||||
repulsion: [400, 600],
|
||||
edgeLength: [200, 350],
|
||||
gravity: 0.05,
|
||||
layoutAnimation: !reducedMotion && fewVisibleNodes,
|
||||
layoutAnimation: !reducedMotion && data.nodes.length < 100,
|
||||
},
|
||||
edgeSymbol: ["none", "arrow"],
|
||||
edgeSymbolSize: 10,
|
||||
data: this._getSeriesData(
|
||||
data.nodes,
|
||||
data.links,
|
||||
nodePositions,
|
||||
pinnedNodes,
|
||||
this._nodePositions,
|
||||
selectedNode
|
||||
),
|
||||
links: data.links.map((link) => ({
|
||||
@@ -367,25 +334,11 @@ export class HaNetworkGraph extends LitElement {
|
||||
deepEqual
|
||||
);
|
||||
|
||||
// The legend leaves the nodes of hidden categories out of the layout
|
||||
private _fewVisibleNodes() {
|
||||
const hidden = this._hiddenCategories;
|
||||
const visibleNodes = hidden.length
|
||||
? this.data.nodes.filter(
|
||||
(node) =>
|
||||
node.category === undefined ||
|
||||
!hidden.includes(this.data.categories?.[node.category]?.name ?? "")
|
||||
).length
|
||||
: this.data.nodes.length;
|
||||
return visibleNodes < LAYOUT_ANIMATION_THRESHOLD;
|
||||
}
|
||||
|
||||
private _getSeriesData = memoizeOne(
|
||||
(
|
||||
nodes: NetworkNode[],
|
||||
links: NetworkLink[],
|
||||
nodePositions: Record<string, { x: number; y: number }>,
|
||||
pinnedNodes: string[],
|
||||
selectedNode?: string
|
||||
) =>
|
||||
this._getPositionedNodes(nodes, links, nodePositions).map((node) => {
|
||||
@@ -402,7 +355,7 @@ export class HaNetworkGraph extends LitElement {
|
||||
? { ...node.itemStyle, borderWidth: 3 }
|
||||
: node.itemStyle || {},
|
||||
label: selected ? { ...node.label, fontWeight: "bold" } : node.label,
|
||||
fixed: node.fixed || pinnedNodes.includes(node.id),
|
||||
fixed: node.fixed,
|
||||
x: node.x,
|
||||
y: node.y,
|
||||
} as NonNullable<GraphSeriesOption["data"]>[number];
|
||||
@@ -562,90 +515,6 @@ export class HaNetworkGraph extends LitElement {
|
||||
}
|
||||
}
|
||||
|
||||
private _handleChartSetup() {
|
||||
const chart = this._baseChart?.chart;
|
||||
chart?.on("mousedown", this._handleNodeMouseDown);
|
||||
chart?.getZr().on("drag", this._handleDrag);
|
||||
chart?.getZr().on("dragend", this._handleDragEnd);
|
||||
for (const event of LEGEND_SELECT_EVENTS) {
|
||||
chart?.on(event, this._handleLegendChange);
|
||||
}
|
||||
const legend = (
|
||||
chart?.getOption() as
|
||||
{ legend?: { selected?: Record<string, boolean> }[] } | undefined
|
||||
)?.legend?.[0];
|
||||
this._setHiddenCategories(legend?.selected ?? {});
|
||||
// A recreated chart, e.g. after a theme change, lacks the drops since the
|
||||
// last render
|
||||
this.requestUpdate();
|
||||
this._updateFollowing();
|
||||
}
|
||||
|
||||
private _handleLegendChange = (params: unknown) => {
|
||||
const fewVisibleNodes = this._fewVisibleNodes();
|
||||
this._setHiddenCategories(
|
||||
(params as { selected: Record<string, boolean> }).selected
|
||||
);
|
||||
if (this._fewVisibleNodes() !== fewVisibleNodes) {
|
||||
// The new series option lays out again from where the nodes are now
|
||||
this._saveNodePositions();
|
||||
this.requestUpdate();
|
||||
}
|
||||
};
|
||||
|
||||
private _setHiddenCategories(selected: Record<string, boolean>) {
|
||||
this._hiddenCategories = Object.keys(selected).filter(
|
||||
(name) => !selected[name]
|
||||
);
|
||||
}
|
||||
|
||||
private _handleNodeMouseDown = (params: {
|
||||
dataType?: string;
|
||||
data?: unknown;
|
||||
}) => {
|
||||
this._dragNode =
|
||||
params.dataType === "node" ? (params.data as NetworkNode).id : undefined;
|
||||
this._dragMoved = false;
|
||||
};
|
||||
|
||||
private _handleDrag = () => {
|
||||
this._dragMoved = true;
|
||||
};
|
||||
|
||||
private _handleDragEnd = () => {
|
||||
const id = this._dragNode;
|
||||
const moved = this._dragMoved;
|
||||
this._dragNode = undefined;
|
||||
this._dragMoved = false;
|
||||
// A click also ends a drag, which releases a pinned node in ECharts
|
||||
if (!id || (!moved && !this._pinnedNodes.includes(id))) {
|
||||
return;
|
||||
}
|
||||
this._pinNodeInChart(id);
|
||||
if (!this._pinnedNodes.includes(id)) {
|
||||
this._pinnedNodes = [...this._pinnedNodes, id];
|
||||
}
|
||||
this._saveNodePositions();
|
||||
};
|
||||
|
||||
// A new series option would start the layout again, so the pin goes into
|
||||
// the running force layout, and into the item option that ECharts lays out
|
||||
// from again, e.g. on a legend change
|
||||
private _pinNodeInChart(id: string) {
|
||||
const series = this._getGraphSeries();
|
||||
const node = series?.getGraph().getNodeById(id);
|
||||
if (!node) {
|
||||
return;
|
||||
}
|
||||
series.forceLayout?.setFixed(node.dataIndex);
|
||||
const [x, y] = node.getLayout();
|
||||
Object.assign(series.getData().getRawDataItem(node.dataIndex), {
|
||||
fixed: true,
|
||||
x,
|
||||
y,
|
||||
});
|
||||
}
|
||||
|
||||
private _updateFollowing() {
|
||||
const chart = this._followSelectedNode ? this._baseChart?.chart : undefined;
|
||||
if (chart !== this._followedChart) {
|
||||
@@ -681,7 +550,10 @@ export class HaNetworkGraph extends LitElement {
|
||||
if (!chart) {
|
||||
return;
|
||||
}
|
||||
const series = this._getGraphSeries(chart);
|
||||
const series: any = chart
|
||||
// @ts-ignore private method but no other way to get the graph positions
|
||||
.getModel()
|
||||
.getSeriesByIndex(0);
|
||||
const node = series?.getGraph().getNodeById(this.selectedNode);
|
||||
const position: number[] | undefined = node?.getLayout();
|
||||
if (!position) {
|
||||
@@ -742,7 +614,6 @@ export class HaNetworkGraph extends LitElement {
|
||||
|
||||
private _togglePhysics() {
|
||||
this._saveNodePositions();
|
||||
this._pinnedNodes = [];
|
||||
this._physicsEnabled = !this._physicsEnabled;
|
||||
}
|
||||
|
||||
@@ -751,28 +622,24 @@ export class HaNetworkGraph extends LitElement {
|
||||
}
|
||||
|
||||
private _saveNodePositions() {
|
||||
// Nodes that are not drawn keep their earlier position
|
||||
const positions = { ...this._nodePositions };
|
||||
this._getGraphSeries()
|
||||
?.getGraph()
|
||||
.eachNode((node: any) => {
|
||||
const layout = node.getLayout();
|
||||
if (layout) {
|
||||
positions[node.id] = {
|
||||
x: layout[0],
|
||||
y: layout[1],
|
||||
};
|
||||
}
|
||||
});
|
||||
this._nodePositions = positions;
|
||||
}
|
||||
|
||||
private _getGraphSeries(chart = this._baseChart?.chart): any {
|
||||
if (!chart || chart.isDisposed()) {
|
||||
return undefined;
|
||||
const positions = {};
|
||||
if (this._baseChart?.chart) {
|
||||
this._baseChart.chart
|
||||
// @ts-ignore private method but no other way to get the graph positions
|
||||
.getModel()
|
||||
.getSeriesByIndex(0)
|
||||
.getGraph()
|
||||
.eachNode((node: any) => {
|
||||
const layout = node.getLayout();
|
||||
if (layout) {
|
||||
positions[node.id] = {
|
||||
x: layout[0],
|
||||
y: layout[1],
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
// @ts-ignore private method but no other way to get the graph
|
||||
return chart.getModel().getSeriesByIndex(0);
|
||||
this._nodePositions = positions;
|
||||
}
|
||||
|
||||
static styles = css`
|
||||
|
||||
@@ -52,7 +52,7 @@ class StateInfo extends LitElement {
|
||||
${
|
||||
this.inDialog
|
||||
? html`<div class="time-ago">
|
||||
<ha-tooltip for="relative-time" trigger="hover focus click">
|
||||
<ha-tooltip for="relative-time">
|
||||
<div class="row">
|
||||
<span class="column-name">
|
||||
${this._localize(
|
||||
|
||||
@@ -6,7 +6,7 @@ import { repeat } from "lit/directives/repeat";
|
||||
import { styleMap } from "lit/directives/style-map";
|
||||
import memoizeOne from "memoize-one";
|
||||
import { consume } from "../common/decorators/consume";
|
||||
import { fireEvent, type HASSDomEvent } from "../common/dom/fire_event";
|
||||
import { fireEvent } from "../common/dom/fire_event";
|
||||
import { supportsFeature } from "../common/entity/supports-feature";
|
||||
import {
|
||||
CameraEntityFeature,
|
||||
@@ -17,14 +17,8 @@ import {
|
||||
STREAM_TYPE_WEB_RTC,
|
||||
type CameraCapabilities,
|
||||
type CameraEntity,
|
||||
type StreamType,
|
||||
} from "../data/camera";
|
||||
import {
|
||||
MJPEG_STREAM,
|
||||
selectCameraStreams,
|
||||
type CameraStream,
|
||||
type CameraStreamTracks,
|
||||
type CameraStreamType,
|
||||
} from "../data/camera-streams";
|
||||
import {
|
||||
apiContext,
|
||||
configContext,
|
||||
@@ -35,7 +29,14 @@ import "./ha-hls-player";
|
||||
import "./ha-web-rtc-player";
|
||||
import type { HaWebRtcPlayer } from "./ha-web-rtc-player";
|
||||
|
||||
export type { CameraStreamType } from "../data/camera-streams";
|
||||
const MJPEG_STREAM = "mjpeg";
|
||||
|
||||
export type CameraStreamType = StreamType | typeof MJPEG_STREAM;
|
||||
|
||||
interface Stream {
|
||||
type: CameraStreamType;
|
||||
visible: boolean;
|
||||
}
|
||||
|
||||
@customElement("ha-camera-stream")
|
||||
export class HaCameraStream extends LitElement {
|
||||
@@ -77,15 +78,13 @@ export class HaCameraStream extends LitElement {
|
||||
|
||||
@state() private _capabilities?: CameraCapabilities;
|
||||
|
||||
@state() private _hlsStreams?: CameraStreamTracks;
|
||||
@state() private _hlsStreams?: { hasAudio: boolean; hasVideo: boolean };
|
||||
|
||||
@state() private _webRtcStreams?: CameraStreamTracks;
|
||||
@state() private _webRtcStreams?: { hasAudio: boolean; hasVideo: boolean };
|
||||
|
||||
@query("ha-web-rtc-player") private _webRtcPlayer?: HaWebRtcPlayer;
|
||||
|
||||
private _visibleStreamType?: CameraStreamType;
|
||||
|
||||
private _capabilitiesRequest = 0;
|
||||
private _visibleStreamType?: Stream["type"];
|
||||
|
||||
private _thumbnailApi = memoizeOne(
|
||||
(
|
||||
@@ -133,10 +132,6 @@ export class HaCameraStream extends LitElement {
|
||||
public connectedCallback() {
|
||||
super.connectedCallback();
|
||||
this._connected = true;
|
||||
if (this.hasUpdated) {
|
||||
// The players start again when reattached, so their results do as well
|
||||
this._resetStreams();
|
||||
}
|
||||
}
|
||||
|
||||
public disconnectedCallback() {
|
||||
@@ -151,8 +146,9 @@ export class HaCameraStream extends LitElement {
|
||||
capabilities: this._capabilities,
|
||||
});
|
||||
}
|
||||
const streams = this._currentStreams();
|
||||
const visibleStreamType = streams.find((stream) => stream.visible)?.type;
|
||||
const visibleStreamType = this._currentStreams().find(
|
||||
(stream) => stream.visible
|
||||
)?.type;
|
||||
if (visibleStreamType !== this._visibleStreamType) {
|
||||
this._visibleStreamType = visibleStreamType;
|
||||
fireEvent(this, "stream-type-changed", { type: visibleStreamType });
|
||||
@@ -171,7 +167,7 @@ export class HaCameraStream extends LitElement {
|
||||
)}`;
|
||||
}
|
||||
|
||||
private _renderStream(stream: CameraStream) {
|
||||
private _renderStream(stream: Stream) {
|
||||
if (!this.stateObj) {
|
||||
return nothing;
|
||||
}
|
||||
@@ -233,14 +229,15 @@ export class HaCameraStream extends LitElement {
|
||||
return this._streams(
|
||||
this._capabilities?.frontend_stream_types,
|
||||
this._hlsStreams,
|
||||
this._webRtcStreams
|
||||
this._webRtcStreams,
|
||||
this.muted
|
||||
);
|
||||
}
|
||||
|
||||
private async _getCapabilities() {
|
||||
this._capabilities = undefined;
|
||||
this._resetStreams();
|
||||
const request = ++this._capabilitiesRequest;
|
||||
this._hlsStreams = undefined;
|
||||
this._webRtcStreams = undefined;
|
||||
if (!supportsFeature(this.stateObj!, CameraEntityFeature.STREAM)) {
|
||||
this._capabilities = {
|
||||
frontend_stream_types: [],
|
||||
@@ -248,19 +245,10 @@ export class HaCameraStream extends LitElement {
|
||||
};
|
||||
return;
|
||||
}
|
||||
const capabilities = await fetchCameraCapabilities(
|
||||
this._capabilities = await fetchCameraCapabilities(
|
||||
this._api,
|
||||
this.stateObj!.entity_id
|
||||
);
|
||||
if (request !== this._capabilitiesRequest) {
|
||||
return;
|
||||
}
|
||||
this._capabilities = capabilities;
|
||||
}
|
||||
|
||||
private _resetStreams() {
|
||||
this._hlsStreams = undefined;
|
||||
this._webRtcStreams = undefined;
|
||||
}
|
||||
|
||||
private async _getPosterUrl(): Promise<void> {
|
||||
@@ -281,38 +269,89 @@ export class HaCameraStream extends LitElement {
|
||||
fireEvent(this, "load");
|
||||
}
|
||||
|
||||
private _handleHlsStreams(ev: HASSDomEvent<HASSDomEvents["streams"]>) {
|
||||
private _handleHlsStreams(ev: CustomEvent) {
|
||||
this._hlsStreams = ev.detail;
|
||||
}
|
||||
|
||||
private _handleWebRtcStreams(ev: HASSDomEvent<HASSDomEvents["streams"]>) {
|
||||
if (
|
||||
!ev.detail.hasVideo &&
|
||||
!ev.detail.hasAudio &&
|
||||
this._capabilities?.frontend_stream_types.length === 1 &&
|
||||
typeof RTCPeerConnection !== "undefined"
|
||||
) {
|
||||
// Without another stream type, keep the player to show why it failed.
|
||||
// Only a browser without WebRTC falls back to MJPEG.
|
||||
return;
|
||||
}
|
||||
private _handleWebRtcStreams(ev: CustomEvent) {
|
||||
this._webRtcStreams = ev.detail;
|
||||
}
|
||||
|
||||
private _streams = memoizeOne(
|
||||
(
|
||||
supportedTypes?: CameraCapabilities["frontend_stream_types"],
|
||||
hlsStreams?: CameraStreamTracks,
|
||||
webRtcStreams?: CameraStreamTracks
|
||||
): CameraStream[] => {
|
||||
supportedTypes?: StreamType[],
|
||||
hlsStreams?: { hasAudio: boolean; hasVideo: boolean },
|
||||
webRtcStreams?: { hasAudio: boolean; hasVideo: boolean },
|
||||
muted?: boolean
|
||||
): Stream[] => {
|
||||
if (__DEMO__) {
|
||||
return [{ type: MJPEG_STREAM, visible: true }];
|
||||
}
|
||||
return selectCameraStreams({
|
||||
supportedTypes,
|
||||
hlsStreams,
|
||||
webRtcStreams,
|
||||
});
|
||||
if (!supportedTypes) {
|
||||
return [];
|
||||
}
|
||||
if (supportedTypes.length === 0) {
|
||||
// doesn't support any stream type, fallback to mjpeg
|
||||
return [{ type: MJPEG_STREAM, visible: true }];
|
||||
}
|
||||
if (supportedTypes.length === 1) {
|
||||
// only 1 stream type, no need to choose
|
||||
if (
|
||||
(supportedTypes[0] === STREAM_TYPE_HLS &&
|
||||
hlsStreams?.hasVideo === false) ||
|
||||
(supportedTypes[0] === STREAM_TYPE_WEB_RTC &&
|
||||
webRtcStreams?.hasVideo === false)
|
||||
) {
|
||||
// stream failed to load, fallback to mjpeg
|
||||
return [{ type: MJPEG_STREAM, visible: true }];
|
||||
}
|
||||
return [{ type: supportedTypes[0], visible: true }];
|
||||
}
|
||||
if (hlsStreams && webRtcStreams) {
|
||||
// fully loaded
|
||||
if (
|
||||
hlsStreams.hasVideo &&
|
||||
hlsStreams.hasAudio &&
|
||||
!webRtcStreams.hasAudio &&
|
||||
!muted
|
||||
) {
|
||||
// webRTC stream is missing audio and audio is not muted, use HLS
|
||||
return [{ type: STREAM_TYPE_HLS, visible: true }];
|
||||
}
|
||||
if (webRtcStreams.hasVideo) {
|
||||
return [{ type: STREAM_TYPE_WEB_RTC, visible: true }];
|
||||
}
|
||||
// both streams failed to load, fallback to mjpeg
|
||||
return [{ type: MJPEG_STREAM, visible: true }];
|
||||
}
|
||||
|
||||
if (hlsStreams?.hasVideo !== webRtcStreams?.hasVideo) {
|
||||
// one of the two streams is loaded, or errored
|
||||
// choose the one that has video or is still loading
|
||||
if (hlsStreams?.hasVideo) {
|
||||
return [
|
||||
{ type: STREAM_TYPE_HLS, visible: true },
|
||||
{ type: STREAM_TYPE_WEB_RTC, visible: false },
|
||||
];
|
||||
}
|
||||
if (hlsStreams?.hasVideo === false) {
|
||||
return [{ type: STREAM_TYPE_WEB_RTC, visible: true }];
|
||||
}
|
||||
if (webRtcStreams?.hasVideo) {
|
||||
return [
|
||||
{ type: STREAM_TYPE_WEB_RTC, visible: true },
|
||||
{ type: STREAM_TYPE_HLS, visible: false },
|
||||
];
|
||||
}
|
||||
if (webRtcStreams?.hasVideo === false) {
|
||||
return [{ type: STREAM_TYPE_HLS, visible: true }];
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
{ type: STREAM_TYPE_HLS, visible: true },
|
||||
{ type: STREAM_TYPE_WEB_RTC, visible: false },
|
||||
];
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -387,7 +387,7 @@ export class HaControlCircularSlider extends LitElement {
|
||||
}
|
||||
|
||||
private _handleKeyDown(e: KeyboardEvent) {
|
||||
if (this.disabled || !A11Y_KEY_CODES.has(e.code)) return;
|
||||
if (!A11Y_KEY_CODES.has(e.code)) return;
|
||||
e.preventDefault();
|
||||
if (this._lastSlider) {
|
||||
this.shadowRoot?.getElementById(this._lastSlider)?.focus();
|
||||
@@ -439,7 +439,7 @@ export class HaControlCircularSlider extends LitElement {
|
||||
}
|
||||
|
||||
private _handleKeyUp(e: KeyboardEvent) {
|
||||
if (this.disabled || !A11Y_KEY_CODES.has(e.code)) return;
|
||||
if (!A11Y_KEY_CODES.has(e.code)) return;
|
||||
this._activeSlider = (e.currentTarget as any).id as ActiveSlider;
|
||||
e.preventDefault();
|
||||
fireEvent(this, `${this._activeSlider}-changing`, {
|
||||
|
||||
@@ -87,12 +87,11 @@ export class HaFilterCategories extends LitElement {
|
||||
public disconnectedCallback() {
|
||||
super.disconnectedCallback();
|
||||
this._unsubscribeCategories();
|
||||
this._categories = [];
|
||||
}
|
||||
|
||||
protected willUpdate(changedProps: PropertyValues) {
|
||||
super.willUpdate(changedProps);
|
||||
if (changedProps.has("scope") && this.scope !== this._categoriesScope) {
|
||||
if (changedProps.get("scope") !== undefined) {
|
||||
this._categories = [];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,9 +112,6 @@ export class HaGenericPicker extends PickerMixin(LitElement) {
|
||||
|
||||
@property({ type: Boolean, attribute: "no-sort" }) public noSort = false;
|
||||
|
||||
@property({ attribute: "pin-block" })
|
||||
public pinBlock?: "start" | "center" | "end" | "nearest";
|
||||
|
||||
// Skip the "unknown value" highlight and note for a value that is not in the
|
||||
// list but that the value renderer presents on its own.
|
||||
@property({ type: Boolean, attribute: "no-unknown-state" })
|
||||
@@ -350,7 +347,6 @@ export class HaGenericPicker extends PickerMixin(LitElement) {
|
||||
.searchKeys=${this.searchKeys}
|
||||
.customValueLabel=${this.customValueLabel}
|
||||
.noSort=${this.noSort}
|
||||
.pinBlock=${this.pinBlock}
|
||||
></ha-picker-combo-box>
|
||||
`;
|
||||
}
|
||||
|
||||
@@ -26,11 +26,7 @@ export class HaHelpTooltip extends LitElement {
|
||||
protected render(): TemplateResult {
|
||||
return html`
|
||||
<ha-svg-icon id="svg-icon" .path=${mdiHelpCircleOutline}></ha-svg-icon>
|
||||
<ha-tooltip
|
||||
trigger="hover focus click"
|
||||
for="svg-icon"
|
||||
.placement=${this.position}
|
||||
>
|
||||
<ha-tooltip for="svg-icon" .placement=${this.position}>
|
||||
${this.label}
|
||||
</ha-tooltip>
|
||||
`;
|
||||
|
||||
@@ -180,14 +180,13 @@ class HaHLSPlayer extends LitElement {
|
||||
return;
|
||||
}
|
||||
|
||||
const entityId = this.entityid;
|
||||
if (!entityId) {
|
||||
if (!this.entityid) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const { url } = await fetchStreamUrl(
|
||||
{ callWS: this._api.callWS, hassUrl: this._connection.hassUrl },
|
||||
entityId
|
||||
this.entityid
|
||||
);
|
||||
|
||||
this._url = this._connection.hassUrl(url);
|
||||
@@ -199,10 +198,6 @@ class HaHLSPlayer extends LitElement {
|
||||
// eslint-disable-next-line
|
||||
console.error(err);
|
||||
|
||||
if (!this.isConnected || entityId !== this.entityid) {
|
||||
// Removed or switched camera while fetching, the result is outdated
|
||||
return;
|
||||
}
|
||||
fireEvent(this, "streams", { hasAudio: false, hasVideo: false });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,13 @@
|
||||
import type { RenderItemFunction } from "@lit-labs/virtualizer/virtualize";
|
||||
import type { PropertyValues, TemplateResult } from "lit";
|
||||
import type { TemplateResult } from "lit";
|
||||
import { LitElement, css, html } from "lit";
|
||||
import { customElement, property, query, state } from "lit/decorators";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import memoizeOne from "memoize-one";
|
||||
import { consumeLocalize } from "../common/decorators/consume-context-entry";
|
||||
import { fireEvent } from "../common/dom/fire_event";
|
||||
import { caseInsensitiveStringCompare } from "../common/string/compare";
|
||||
import type { LocalizeFunc } from "../common/translations/localize";
|
||||
import { customIcons } from "../data/custom_icons";
|
||||
import type { ValueChangedEvent } from "../types";
|
||||
import "./ha-combo-box-item";
|
||||
import "./ha-generic-picker";
|
||||
import type { HaGenericPicker } from "./ha-generic-picker";
|
||||
import "./ha-icon";
|
||||
import type { PickerComboBoxItem } from "./ha-picker-combo-box";
|
||||
|
||||
@@ -54,17 +50,16 @@ const createIconItem = (icon: IconData, prefix: string): PickerComboBoxItem => {
|
||||
const loadIcons = async () => {
|
||||
ICONS_LOADED = true;
|
||||
|
||||
const sortIcons = (icons: PickerComboBoxItem[]) =>
|
||||
icons.sort((a, b) => caseInsensitiveStringCompare(a.id, b.id));
|
||||
|
||||
const iconList = await import("../../build/mdi/iconList.json");
|
||||
const mdiIcons = iconList.default.map((icon) => createIconItem(icon, "mdi"));
|
||||
ICONS = sortIcons([...mdiIcons]);
|
||||
ICONS = iconList.default.map((icon) => createIconItem(icon, "mdi"));
|
||||
|
||||
const customIconItems = await Promise.all(
|
||||
Object.keys(customIcons).map(loadCustomIconItems)
|
||||
);
|
||||
ICONS = sortIcons([...mdiIcons, ...customIconItems.flat()]);
|
||||
const customIconLoads: Promise<PickerComboBoxItem[]>[] = [];
|
||||
Object.keys(customIcons).forEach((iconSet) => {
|
||||
customIconLoads.push(loadCustomIconItems(iconSet));
|
||||
});
|
||||
(await Promise.all(customIconLoads)).forEach((customIconItems) => {
|
||||
ICONS.push(...customIconItems);
|
||||
});
|
||||
};
|
||||
|
||||
const loadCustomIconItems = async (
|
||||
@@ -86,8 +81,8 @@ const loadCustomIconItems = async (
|
||||
|
||||
const rowRenderer: RenderItemFunction<PickerComboBoxItem> = (item) => html`
|
||||
<ha-combo-box-item>
|
||||
<ha-icon .icon=${item.icon ?? item.id} slot="start"></ha-icon>
|
||||
${item.icon ?? item.id}
|
||||
<ha-icon .icon=${item.id} slot="start"></ha-icon>
|
||||
${item.id}
|
||||
</ha-combo-box-item>
|
||||
`;
|
||||
|
||||
@@ -109,32 +104,12 @@ export class HaIconPicker extends LitElement {
|
||||
|
||||
@property({ type: Boolean }) public invalid = false;
|
||||
|
||||
@property({ attribute: false }) public suggestedIcons?: string[];
|
||||
|
||||
@state() @consumeLocalize() private _localize!: LocalizeFunc;
|
||||
|
||||
@query("ha-generic-picker") private _picker?: HaGenericPicker;
|
||||
|
||||
private _getIconPickerItems = () =>
|
||||
this._itemsWithSuggestions(ICONS, this.suggestedIcons, this._localize);
|
||||
|
||||
protected updated(changedProps: PropertyValues) {
|
||||
super.updated(changedProps);
|
||||
if (changedProps.has("suggestedIcons") || changedProps.has("_localize")) {
|
||||
this._picker?.refreshItems();
|
||||
}
|
||||
}
|
||||
private _getIconPickerItems = (): PickerComboBoxItem[] => ICONS;
|
||||
|
||||
protected render(): TemplateResult {
|
||||
return html`
|
||||
<ha-generic-picker
|
||||
allow-custom-value
|
||||
no-sort
|
||||
.pinBlock=${
|
||||
this.value && this.suggestedIcons?.includes(this.value)
|
||||
? "end"
|
||||
: undefined
|
||||
}
|
||||
.getItems=${this._getIconPickerItems}
|
||||
.helper=${this.helper}
|
||||
.disabled=${this.disabled}
|
||||
@@ -153,35 +128,15 @@ export class HaIconPicker extends LitElement {
|
||||
`;
|
||||
}
|
||||
|
||||
private _itemsWithSuggestions = memoizeOne(
|
||||
(
|
||||
icons: PickerComboBoxItem[],
|
||||
suggestedIcons: string[] | undefined,
|
||||
localize: LocalizeFunc
|
||||
): (PickerComboBoxItem | string)[] => {
|
||||
if (!suggestedIcons?.length) {
|
||||
return icons;
|
||||
}
|
||||
const suggested = new Set(suggestedIcons);
|
||||
return [
|
||||
localize("ui.components.icon_picker.suggested"),
|
||||
...suggestedIcons.map((icon) => ({ id: icon, primary: icon, icon })),
|
||||
localize("ui.components.icon_picker.all_icons"),
|
||||
...icons.filter((item) => !suggested.has(item.id)),
|
||||
];
|
||||
}
|
||||
);
|
||||
|
||||
// Filter can take a significant chunk of frame (up to 3-5 ms)
|
||||
private _filterIcons = memoizeOne(
|
||||
(
|
||||
filter: string,
|
||||
filteredItems: PickerComboBoxItem[],
|
||||
_allItems: PickerComboBoxItem[]
|
||||
allItems: PickerComboBoxItem[]
|
||||
): PickerComboBoxItem[] => {
|
||||
const normalizedFilter = filter.toLowerCase().replace(/\s+/g, "-");
|
||||
// The full list also holds the suggestions and their section titles
|
||||
const iconItems = ICONS.length ? ICONS : filteredItems;
|
||||
const iconItems = allItems?.length ? allItems : filteredItems;
|
||||
|
||||
if (!normalizedFilter.length) {
|
||||
return iconItems;
|
||||
@@ -220,7 +175,8 @@ export class HaIconPicker extends LitElement {
|
||||
protected firstUpdated() {
|
||||
if (!ICONS_LOADED) {
|
||||
loadIcons().then(() => {
|
||||
this._picker?.refreshItems();
|
||||
this._getIconPickerItems = (): PickerComboBoxItem[] => ICONS;
|
||||
this.requestUpdate();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,10 +32,6 @@ export class HaMarqueeText extends LitElement {
|
||||
|
||||
private _pauseTimeout?: number;
|
||||
|
||||
private get _animationFactor() {
|
||||
return document.dir === "rtl" ? -1 : 1;
|
||||
}
|
||||
|
||||
protected firstUpdated(changedProps: PropertyValues<this>) {
|
||||
super.firstUpdated(changedProps);
|
||||
|
||||
@@ -121,7 +117,7 @@ export class HaMarqueeText extends LitElement {
|
||||
reachedEnd = true;
|
||||
}
|
||||
}
|
||||
this._textSpan.style.transform = `translateX(${this._position * this._animationFactor}px)`;
|
||||
this._textSpan.style.transform = `translateX(${this._position}px)`;
|
||||
if (reachedEnd) {
|
||||
this._pauseTimeout = window.setTimeout(() => {
|
||||
this._pauseTimeout = undefined;
|
||||
|
||||
@@ -201,9 +201,6 @@ export class HaPickerComboBox extends ScrollableFadeMixin(LitElement) {
|
||||
|
||||
@property({ type: Boolean, attribute: "no-sort" }) public noSort = false;
|
||||
|
||||
@property({ attribute: "pin-block" })
|
||||
public pinBlock?: "start" | "center" | "end" | "nearest";
|
||||
|
||||
@query(".list") private _list?: HaListBase;
|
||||
|
||||
@query("ha-input-search") private _searchFieldElement?: HaInputSearch;
|
||||
@@ -456,7 +453,6 @@ export class HaPickerComboBox extends ScrollableFadeMixin(LitElement) {
|
||||
this.value
|
||||
)}
|
||||
.pinIndex=${this.value ? this._getInitialSelectedIndex() : undefined}
|
||||
.pinBlock=${this.pinBlock ?? "center"}
|
||||
@mousedown=${this._preventBlur}
|
||||
@focus=${this._focusList}
|
||||
@blur=${this._resetSelectedItem}
|
||||
@@ -689,11 +685,6 @@ export class HaPickerComboBox extends ScrollableFadeMixin(LitElement) {
|
||||
fireEvent(this, "index-selected", { index, item, newTab });
|
||||
}
|
||||
|
||||
// Fuse indexes every row as text when the first one is a section title
|
||||
private _searchableItems = memoizeOne((items: PickerComboBoxItem[]) =>
|
||||
items.filter((item) => typeof item !== "string")
|
||||
);
|
||||
|
||||
private _fuseIndex = memoizeOne(
|
||||
(states: PickerComboBoxItem[], searchKeys?: FuseWeightedKey[]) =>
|
||||
Fuse.createIndex(searchKeys || DEFAULT_SEARCH_KEYS, states)
|
||||
@@ -717,11 +708,10 @@ export class HaPickerComboBox extends ScrollableFadeMixin(LitElement) {
|
||||
return;
|
||||
}
|
||||
|
||||
const searchableItems = this._searchableItems(this._allItems);
|
||||
const index = this._fuseIndex(searchableItems, this.searchKeys);
|
||||
const index = this._fuseIndex(this._allItems, this.searchKeys);
|
||||
|
||||
let filteredItems = multiTermSortedSearch<PickerComboBoxItem>(
|
||||
searchableItems,
|
||||
this._allItems,
|
||||
searchString,
|
||||
(item) => item.id,
|
||||
index
|
||||
|
||||
@@ -465,13 +465,10 @@ export class HaServiceControl extends LitElement {
|
||||
serviceData?.flatFields.some((field) => showOptionalToggle(field))
|
||||
);
|
||||
|
||||
// Actions that can never have targets get null, like template targets
|
||||
const targetEntities =
|
||||
serviceData &&
|
||||
("target" in serviceData ||
|
||||
serviceData.flatFields.some((field) => field.key === "entity_id"))
|
||||
? this._getTargetedEntities(serviceData.target, this._value)
|
||||
: null;
|
||||
const targetEntities = this._getTargetedEntities(
|
||||
serviceData?.target,
|
||||
this._value
|
||||
);
|
||||
|
||||
const domain = this._value?.action
|
||||
? computeDomain(this._value.action)
|
||||
|
||||
@@ -24,23 +24,8 @@ import { showToast } from "../util/toast";
|
||||
|
||||
const HIDDEN_CLEANUP_DELAY = 60000;
|
||||
|
||||
// How long the backend gets to answer the offer, it has to connect to the camera
|
||||
const ANSWER_TIMEOUT = 20000;
|
||||
|
||||
// How long finding a network path gets after the answer. Browsers can take
|
||||
// minutes to give up on their own, or never do.
|
||||
const ICE_TIMEOUT = 30000;
|
||||
|
||||
// How often a stream that lost its connection or got a backend error is
|
||||
// started again. A new connection that gets no answer or finds no path is not
|
||||
// retried, as a retry would most likely end the same way.
|
||||
const MAX_RETRIES = 1;
|
||||
|
||||
// Gives the backend time to tear down the failed session before the next one
|
||||
const RETRY_DELAY = 1000;
|
||||
|
||||
interface WebRtcPlayerError {
|
||||
type: "not_supported" | "start_failed" | "connect_failed" | "no_connection";
|
||||
type: "not_supported" | "start_failed" | "connect_failed";
|
||||
message?: string;
|
||||
}
|
||||
|
||||
@@ -114,7 +99,7 @@ export class HaWebRtcPlayer extends LitElement {
|
||||
if (this._microphoneDenied) {
|
||||
return "denied";
|
||||
}
|
||||
if (this._microphoneConnecting || this._retryMicrophoneTrack) {
|
||||
if (this._microphoneConnecting) {
|
||||
return "connecting";
|
||||
}
|
||||
return this._localReturnAudioTrack ? "on" : "off";
|
||||
@@ -125,17 +110,11 @@ export class HaWebRtcPlayer extends LitElement {
|
||||
}
|
||||
|
||||
public async toggleMicrophone() {
|
||||
if (
|
||||
this._localReturnAudioTrack ||
|
||||
this._microphoneConnecting ||
|
||||
this._retryMicrophoneTrack
|
||||
) {
|
||||
if (this._localReturnAudioTrack || this._microphoneConnecting) {
|
||||
// Stop (not disable) so the browser releases the microphone, also cancels connecting
|
||||
this._microphoneRequest++;
|
||||
this._localReturnAudioTrack?.stop();
|
||||
this._localReturnAudioTrack = undefined;
|
||||
this._retryMicrophoneTrack?.stop();
|
||||
this._retryMicrophoneTrack = undefined;
|
||||
this._microphoneConnecting = false;
|
||||
this._fireMicrophoneChanged();
|
||||
await this._microphoneSender?.replaceTrack(null).catch(() => undefined);
|
||||
@@ -218,18 +197,6 @@ export class HaWebRtcPlayer extends LitElement {
|
||||
|
||||
private _cleanUpCount = 0;
|
||||
|
||||
private _connectTimeout?: number;
|
||||
|
||||
private _retryTimeout?: number;
|
||||
|
||||
private _retryMicrophoneTrack?: MediaStreamTrack;
|
||||
|
||||
private _retries = 0;
|
||||
|
||||
// The stream showed video since it was started, so a lost connection is
|
||||
// worth a retry
|
||||
private _hasPlayed = false;
|
||||
|
||||
private _handleVisibilityChange = () => {
|
||||
if (document.pictureInPictureElement) {
|
||||
// video is playing in picture-in-picture mode, don't do anything
|
||||
@@ -245,7 +212,7 @@ export class HaWebRtcPlayer extends LitElement {
|
||||
clearTimeout(this._hiddenCleanupTimeout);
|
||||
this._hiddenCleanupTimeout = undefined;
|
||||
} else {
|
||||
this._restartWebRtc();
|
||||
this._startWebRtc();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -286,7 +253,7 @@ export class HaWebRtcPlayer extends LitElement {
|
||||
public override connectedCallback() {
|
||||
super.connectedCallback();
|
||||
if (this.hasUpdated && this.entityid) {
|
||||
this._restartWebRtc();
|
||||
this._startWebRtc();
|
||||
}
|
||||
document.addEventListener("visibilitychange", this._handleVisibilityChange);
|
||||
}
|
||||
@@ -307,13 +274,6 @@ export class HaWebRtcPlayer extends LitElement {
|
||||
if (!changedProperties.has("entityid")) {
|
||||
return;
|
||||
}
|
||||
this._restartWebRtc();
|
||||
}
|
||||
|
||||
/** Starts a new stream, not a retry of the current one. */
|
||||
private _restartWebRtc() {
|
||||
this._retries = 0;
|
||||
this._hasPlayed = false;
|
||||
this._startWebRtc();
|
||||
}
|
||||
|
||||
@@ -455,7 +415,7 @@ export class HaWebRtcPlayer extends LitElement {
|
||||
while (this._candidatesList.length) {
|
||||
const candidate = this._candidatesList.pop();
|
||||
if (candidate) {
|
||||
candidates += `a=${candidate.candidate}\r\n`;
|
||||
candidates += `a=${candidate}\r\n`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -463,8 +423,6 @@ export class HaWebRtcPlayer extends LitElement {
|
||||
|
||||
this._logEvent("start webRtcOffer", offer_sdp);
|
||||
|
||||
this._startConnectTimeout(ANSWER_TIMEOUT);
|
||||
|
||||
this._unsub = webRtcOffer(
|
||||
this._connection,
|
||||
this.entityid,
|
||||
@@ -485,61 +443,11 @@ export class HaWebRtcPlayer extends LitElement {
|
||||
"ice connection state change",
|
||||
this._peerConnection?.iceConnectionState
|
||||
);
|
||||
const iceState = this._peerConnection?.iceConnectionState;
|
||||
if (iceState === "connected" || iceState === "completed") {
|
||||
clearTimeout(this._connectTimeout);
|
||||
this._connectTimeout = undefined;
|
||||
} else if (iceState === "failed") {
|
||||
// An ICE restart needs a new offer, which the backend answers from a new
|
||||
// peer that can't continue this connection, so start a new one instead.
|
||||
this._retryOrFail({ type: "no_connection" });
|
||||
if (this._peerConnection?.iceConnectionState === "failed") {
|
||||
this._peerConnection.restartIce();
|
||||
}
|
||||
};
|
||||
|
||||
private _startConnectTimeout(timeout: number) {
|
||||
clearTimeout(this._connectTimeout);
|
||||
this._connectTimeout = window.setTimeout(() => {
|
||||
this._connectTimeout = undefined;
|
||||
this._logEvent("connect timeout");
|
||||
this._retryOrFail({ type: "no_connection" });
|
||||
}, timeout);
|
||||
}
|
||||
|
||||
private _retryOrFail(error: WebRtcPlayerError) {
|
||||
if (
|
||||
this._retries >= MAX_RETRIES ||
|
||||
// No answer or no path for a stream that never played, a retry would
|
||||
// most likely end the same way
|
||||
(error.type === "no_connection" && !this._hasPlayed) ||
|
||||
// A microphone connect the user started is handled by starting again
|
||||
// without the microphone. A retry keeps the microphone of the stream.
|
||||
(this._localReturnAudioTrack &&
|
||||
this._microphoneConnecting &&
|
||||
this._retries === 0)
|
||||
) {
|
||||
this._failStart(error);
|
||||
return;
|
||||
}
|
||||
this._retries++;
|
||||
this._logEvent("retry", this._retries, error);
|
||||
// Keep showing the last frame instead of the poster while starting again
|
||||
this._captureReconnectFrame();
|
||||
// Taken out before the clean up, so a running microphone is not stopped
|
||||
const microphoneTrack = this._localReturnAudioTrack;
|
||||
this._localReturnAudioTrack = undefined;
|
||||
this._cleanUp();
|
||||
if (microphoneTrack) {
|
||||
this._retryMicrophoneTrack = microphoneTrack;
|
||||
this._fireMicrophoneChanged();
|
||||
}
|
||||
this._retryTimeout = window.setTimeout(() => {
|
||||
this._retryTimeout = undefined;
|
||||
const track = this._retryMicrophoneTrack;
|
||||
this._retryMicrophoneTrack = undefined;
|
||||
this._startWebRtc(track);
|
||||
}, RETRY_DELAY);
|
||||
}
|
||||
|
||||
private async _handleOfferEvent(
|
||||
peerConnection: RTCPeerConnection,
|
||||
event: WebRtcOfferEvent
|
||||
@@ -562,10 +470,6 @@ export class HaWebRtcPlayer extends LitElement {
|
||||
this._candidatesList = [];
|
||||
}
|
||||
if (event.type === "answer") {
|
||||
const iceState = peerConnection.iceConnectionState;
|
||||
if (iceState !== "connected" && iceState !== "completed") {
|
||||
this._startConnectTimeout(ICE_TIMEOUT);
|
||||
}
|
||||
this._logEvent("answer", event.answer);
|
||||
|
||||
this._handleAnswer(peerConnection, event);
|
||||
@@ -591,8 +495,7 @@ export class HaWebRtcPlayer extends LitElement {
|
||||
}
|
||||
}
|
||||
if (event.type === "error") {
|
||||
// Often temporary, like the backend still closing the previous session
|
||||
this._retryOrFail({ type: "start_failed", message: event.message });
|
||||
this._failStart({ type: "start_failed", message: event.message });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -684,13 +587,8 @@ export class HaWebRtcPlayer extends LitElement {
|
||||
}
|
||||
|
||||
private _failStart(error: WebRtcPlayerError) {
|
||||
// The camera can reject the microphone, keep the video running without it.
|
||||
// After retries it is the connection that failed, not the microphone.
|
||||
if (
|
||||
this._localReturnAudioTrack &&
|
||||
this._microphoneConnecting &&
|
||||
this._retries === 0
|
||||
) {
|
||||
// The camera can reject the microphone, keep the video running without it
|
||||
if (this._localReturnAudioTrack && this._microphoneConnecting) {
|
||||
showToast(this, {
|
||||
message: this._localize(
|
||||
"ui.components.web-rtc-player.microphone_connect_failed",
|
||||
@@ -701,19 +599,12 @@ export class HaWebRtcPlayer extends LitElement {
|
||||
return;
|
||||
}
|
||||
this._error = error;
|
||||
this._reconnectPoster = undefined;
|
||||
this._cleanUp();
|
||||
// Tell the camera stream this player has no video, so it can fall back
|
||||
fireEvent(this, "streams", { hasAudio: false, hasVideo: false });
|
||||
}
|
||||
|
||||
private _cleanUp() {
|
||||
this._cleanUpCount++;
|
||||
this._microphoneRequest++;
|
||||
clearTimeout(this._connectTimeout);
|
||||
this._connectTimeout = undefined;
|
||||
clearTimeout(this._retryTimeout);
|
||||
this._retryTimeout = undefined;
|
||||
if (this._remoteStream) {
|
||||
this._remoteStream.getTracks().forEach((track) => {
|
||||
track.stop();
|
||||
@@ -721,15 +612,9 @@ export class HaWebRtcPlayer extends LitElement {
|
||||
|
||||
this._remoteStream = undefined;
|
||||
}
|
||||
if (
|
||||
this._localReturnAudioTrack ||
|
||||
this._microphoneConnecting ||
|
||||
this._retryMicrophoneTrack
|
||||
) {
|
||||
if (this._localReturnAudioTrack || this._microphoneConnecting) {
|
||||
this._localReturnAudioTrack?.stop();
|
||||
this._localReturnAudioTrack = undefined;
|
||||
this._retryMicrophoneTrack?.stop();
|
||||
this._retryMicrophoneTrack = undefined;
|
||||
this._microphoneConnecting = false;
|
||||
this._fireMicrophoneChanged();
|
||||
}
|
||||
@@ -781,8 +666,6 @@ export class HaWebRtcPlayer extends LitElement {
|
||||
|
||||
this._logEvent("loadedData", data);
|
||||
this._stopTimer();
|
||||
this._retries = 0;
|
||||
this._hasPlayed = true;
|
||||
|
||||
// Without a track the microphone is still waiting for permission
|
||||
if (this._microphoneConnecting && this._localReturnAudioTrack) {
|
||||
|
||||
@@ -34,8 +34,6 @@ import type { HASSDomTargetEvent } from "../../common/dom/fire_event";
|
||||
*
|
||||
* @attr {string} headline - Primary text. Overridden by the `headline` slot.
|
||||
* @attr {string} supporting-text - Secondary text. Overridden by the `supporting-text` slot.
|
||||
* @attr {boolean} wrap-headline - Wraps the headline onto multiple lines instead of truncating it.
|
||||
* @attr {boolean} wrap-supporting-text - Wraps the supporting text onto multiple lines instead of truncating it.
|
||||
* @attr {boolean} disabled - Dims the row and blocks pointer events.
|
||||
*/
|
||||
@customElement("ha-row-item")
|
||||
@@ -45,12 +43,6 @@ export class HaRowItem extends LitElement {
|
||||
@property({ type: String, attribute: "supporting-text" })
|
||||
public supportingText?: string;
|
||||
|
||||
@property({ type: Boolean, reflect: true, attribute: "wrap-headline" })
|
||||
public wrapHeadline = false;
|
||||
|
||||
@property({ type: Boolean, reflect: true, attribute: "wrap-supporting-text" })
|
||||
public wrapSupportingText = false;
|
||||
|
||||
@property({ type: Boolean, reflect: true }) public disabled = false;
|
||||
|
||||
protected readonly _slotController = new HasSlotController(
|
||||
@@ -200,10 +192,6 @@ export class HaRowItem extends LitElement {
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
:host([wrap-headline]) .headline,
|
||||
:host([wrap-supporting-text]) .supporting {
|
||||
white-space: normal;
|
||||
}
|
||||
`;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,128 +0,0 @@
|
||||
import type { CSSResultGroup, TemplateResult } from "lit";
|
||||
import { css, html, nothing } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import { HaListItemButton } from "../item/ha-list-item-button";
|
||||
import "./ha-media-browser-thumbnail";
|
||||
|
||||
/**
|
||||
* @element ha-media-player-browse-list-item
|
||||
* @extends {HaListItemButton}
|
||||
*
|
||||
* @summary
|
||||
* Row of the media browser list. Always reserves a graphic next to the title
|
||||
* so titles line up, and shows a thumbnail with an optional play button over
|
||||
* it. Without `interactive` the row is plain text, used for the "not shown"
|
||||
* row. The row is rendered inside the shadow root of `ha-list-virtualized`, so
|
||||
* it carries its own styles.
|
||||
*
|
||||
* @slot start - Play or pick button, shown over the thumbnail.
|
||||
* @slot headline - Title of the row.
|
||||
*
|
||||
* @csspart start - The graphic container.
|
||||
*
|
||||
* @attr {string} thumbnail - URL of the thumbnail. Shown inside the graphic.
|
||||
*/
|
||||
@customElement("ha-media-player-browse-list-item")
|
||||
export class HaMediaPlayerBrowseListItem extends HaListItemButton {
|
||||
@property() public thumbnail?: string;
|
||||
|
||||
// The "not shown" row is plain text, not a button
|
||||
protected override _renderControl(content: TemplateResult): TemplateResult {
|
||||
if (!this.interactive) {
|
||||
return content;
|
||||
}
|
||||
return super._renderControl(content);
|
||||
}
|
||||
|
||||
// Always reserve the graphic, so titles line up across rows
|
||||
protected override _renderStart(): TemplateResult {
|
||||
return html`<div part="start" class="start">
|
||||
<div class="graphic">
|
||||
${
|
||||
this.thumbnail
|
||||
? html`<ha-media-browser-thumbnail
|
||||
.url=${this.thumbnail}
|
||||
></ha-media-browser-thumbnail>`
|
||||
: nothing
|
||||
}
|
||||
<slot name="start"></slot>
|
||||
</div>
|
||||
</div>`;
|
||||
}
|
||||
|
||||
static styles: CSSResultGroup = [
|
||||
HaListItemButton.styles,
|
||||
css`
|
||||
:host {
|
||||
direction: var(--direction);
|
||||
--ha-row-item-padding-block: 0;
|
||||
--ha-row-item-min-height: 48px;
|
||||
}
|
||||
|
||||
:host(.show-images) {
|
||||
--ha-row-item-padding-block: var(--ha-space-1);
|
||||
--ha-row-item-min-height: 64px;
|
||||
}
|
||||
|
||||
:host(.not-shown) {
|
||||
font-style: italic;
|
||||
color: var(--secondary-text-color);
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
::slotted(ha-svg-icon) {
|
||||
color: var(--secondary-text-color);
|
||||
}
|
||||
|
||||
.graphic {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border-radius: var(--ha-border-radius-sm);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
:host(.show-images) .graphic {
|
||||
width: 56px;
|
||||
height: 56px;
|
||||
}
|
||||
|
||||
ha-media-browser-thumbnail {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
}
|
||||
|
||||
::slotted(.play) {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
margin: auto;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
opacity: 0;
|
||||
transition: all 0.5s;
|
||||
background-color: rgba(var(--rgb-card-background-color), 0.5);
|
||||
border-radius: var(--ha-border-radius-circle);
|
||||
--ha-icon-button-size: 40px;
|
||||
}
|
||||
|
||||
:host(:hover) ::slotted(.play) {
|
||||
opacity: 1;
|
||||
color: var(--primary-text-color);
|
||||
}
|
||||
|
||||
::slotted(.play.show) {
|
||||
opacity: 1;
|
||||
background-color: transparent;
|
||||
}
|
||||
`,
|
||||
];
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
"ha-media-player-browse-list-item": HaMediaPlayerBrowseListItem;
|
||||
}
|
||||
}
|
||||
@@ -77,6 +77,7 @@ import "../ha-svg-icon";
|
||||
import "../ha-tooltip";
|
||||
import "../input/ha-input-search";
|
||||
import type { HaInputSearch } from "../input/ha-input-search";
|
||||
import { HaListItemButton } from "../item/ha-list-item-button";
|
||||
import "../list/ha-list-virtualized";
|
||||
import type {
|
||||
HaListVirtualized,
|
||||
@@ -87,7 +88,6 @@ import type { ManualMediaPickedEvent } from "./ha-browse-media-manual";
|
||||
import "./ha-browse-media-tts";
|
||||
import type { TtsMediaPickedEvent } from "./ha-browse-media-tts";
|
||||
import "./ha-media-browser-thumbnail";
|
||||
import "./ha-media-player-browse-list-item";
|
||||
|
||||
declare global {
|
||||
interface HASSDomEvents {
|
||||
@@ -120,6 +120,105 @@ type MediaBrowseListRow =
|
||||
count: number;
|
||||
});
|
||||
|
||||
@customElement("ha-media-player-browse-list-item")
|
||||
export class HaMediaPlayerBrowseListItem extends HaListItemButton {
|
||||
@property() public thumbnail?: string;
|
||||
|
||||
// The "not shown" row is plain text, not a button
|
||||
protected override _renderControl(content: TemplateResult): TemplateResult {
|
||||
if (!this.interactive) {
|
||||
return content;
|
||||
}
|
||||
return super._renderControl(content);
|
||||
}
|
||||
|
||||
// Always reserve the graphic, so titles line up across rows
|
||||
protected override _renderStart(): TemplateResult {
|
||||
return html`<div part="start" class="start">
|
||||
<div class="graphic">
|
||||
${
|
||||
this.thumbnail
|
||||
? html`<ha-media-browser-thumbnail
|
||||
.url=${this.thumbnail}
|
||||
></ha-media-browser-thumbnail>`
|
||||
: nothing
|
||||
}
|
||||
<slot name="start"></slot>
|
||||
</div>
|
||||
</div>`;
|
||||
}
|
||||
|
||||
static styles: CSSResultGroup = [
|
||||
HaListItemButton.styles,
|
||||
css`
|
||||
:host {
|
||||
direction: var(--direction);
|
||||
--ha-row-item-padding-block: 0;
|
||||
--ha-row-item-min-height: 48px;
|
||||
}
|
||||
|
||||
:host(.show-images) {
|
||||
--ha-row-item-padding-block: var(--ha-space-1);
|
||||
--ha-row-item-min-height: 64px;
|
||||
}
|
||||
|
||||
:host(.not-shown) {
|
||||
font-style: italic;
|
||||
color: var(--secondary-text-color);
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
::slotted(ha-svg-icon) {
|
||||
color: var(--secondary-text-color);
|
||||
}
|
||||
|
||||
.graphic {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border-radius: var(--ha-border-radius-sm);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
:host(.show-images) .graphic {
|
||||
width: 56px;
|
||||
height: 56px;
|
||||
}
|
||||
|
||||
ha-media-browser-thumbnail {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
}
|
||||
|
||||
::slotted(.play) {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
margin: auto;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
opacity: 0;
|
||||
transition: all 0.5s;
|
||||
background-color: rgba(var(--rgb-card-background-color), 0.5);
|
||||
border-radius: var(--ha-border-radius-circle);
|
||||
--ha-icon-button-size: 40px;
|
||||
}
|
||||
|
||||
:host(:hover) ::slotted(.play) {
|
||||
opacity: 1;
|
||||
color: var(--primary-text-color);
|
||||
}
|
||||
|
||||
::slotted(.play.show) {
|
||||
opacity: 1;
|
||||
background-color: transparent;
|
||||
}
|
||||
`,
|
||||
];
|
||||
}
|
||||
|
||||
/** Folders with at least this many items get a filter field when their source cannot search. */
|
||||
const FILTER_MIN_CHILDREN = 10;
|
||||
|
||||
@@ -1846,5 +1945,6 @@ export class HaMediaPlayerBrowse extends LitElement {
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
"ha-media-player-browse": HaMediaPlayerBrowse;
|
||||
"ha-media-player-browse-list-item": HaMediaPlayerBrowseListItem;
|
||||
}
|
||||
}
|
||||
@@ -112,7 +112,7 @@ export class HaTracePathDetails extends LitElement {
|
||||
initialValue: {
|
||||
options: [],
|
||||
showIndices: false,
|
||||
select: () => true,
|
||||
select: () => undefined,
|
||||
fixDuplicateIds: async () => undefined,
|
||||
updateTriggerId: () => false,
|
||||
},
|
||||
|
||||
@@ -123,7 +123,7 @@ export const setProtectedAlarmControlPanelMode = async (
|
||||
(mode === "disarmed" && stateObj.attributes.code_format)
|
||||
) {
|
||||
const entry = await getExtendedEntityRegistryEntry(
|
||||
hass.callWS,
|
||||
hass,
|
||||
stateObj.entity_id
|
||||
).catch(() => undefined);
|
||||
const defaultCode = entry?.options?.alarm_control_panel?.default_code;
|
||||
|
||||
@@ -1,201 +0,0 @@
|
||||
import type { LocalizeFunc } from "../common/translations/localize";
|
||||
|
||||
export const ROOM_ICONS = {
|
||||
living_room: [
|
||||
"mdi:sofa",
|
||||
"mdi:sofa-single",
|
||||
"mdi:television",
|
||||
"mdi:fireplace",
|
||||
"mdi:floor-lamp",
|
||||
],
|
||||
bedroom: ["mdi:bed", "mdi:bed-king", "mdi:bed-double", "mdi:lamp"],
|
||||
kids_room: ["mdi:teddy-bear", "mdi:toy-brick", "mdi:bunk-bed", "mdi:cradle"],
|
||||
kitchen: [
|
||||
"mdi:stove",
|
||||
"mdi:fridge",
|
||||
"mdi:countertop",
|
||||
"mdi:chef-hat",
|
||||
"mdi:pot-steam",
|
||||
"mdi:coffee-maker",
|
||||
],
|
||||
dining_room: [
|
||||
"mdi:silverware-fork-knife",
|
||||
"mdi:table-chair",
|
||||
"mdi:table-furniture",
|
||||
"mdi:glass-wine",
|
||||
],
|
||||
bathroom: [
|
||||
"mdi:shower",
|
||||
"mdi:bathtub",
|
||||
"mdi:shower-head",
|
||||
"mdi:toothbrush",
|
||||
"mdi:hair-dryer",
|
||||
],
|
||||
toilet: ["mdi:toilet", "mdi:paper-roll"],
|
||||
office: [
|
||||
"mdi:desk",
|
||||
"mdi:laptop",
|
||||
"mdi:monitor",
|
||||
"mdi:chair-rolling",
|
||||
"mdi:bookshelf",
|
||||
],
|
||||
laundry_room: [
|
||||
"mdi:washing-machine",
|
||||
"mdi:tumble-dryer",
|
||||
"mdi:iron",
|
||||
"mdi:hanger",
|
||||
],
|
||||
hallway: ["mdi:door", "mdi:door-open", "mdi:coat-rack", "mdi:key"],
|
||||
stairs: ["mdi:stairs", "mdi:stairs-up", "mdi:stairs-down"],
|
||||
garage: ["mdi:garage", "mdi:garage-variant", "mdi:car", "mdi:tools"],
|
||||
garden: [
|
||||
"mdi:flower",
|
||||
"mdi:tree",
|
||||
"mdi:grass",
|
||||
"mdi:sprout",
|
||||
"mdi:watering-can",
|
||||
"mdi:greenhouse",
|
||||
],
|
||||
terrace: [
|
||||
"mdi:balcony",
|
||||
"mdi:grill",
|
||||
"mdi:umbrella-outline",
|
||||
"mdi:coach-lamp",
|
||||
"mdi:patio-heater",
|
||||
],
|
||||
basement: [
|
||||
"mdi:home-floor-negative-1",
|
||||
"mdi:stairs-down",
|
||||
"mdi:water-boiler",
|
||||
],
|
||||
attic: ["mdi:home-roof", "mdi:package-variant-closed"],
|
||||
storage: ["mdi:archive", "mdi:package-variant-closed", "mdi:warehouse"],
|
||||
utility_room: [
|
||||
"mdi:water-boiler",
|
||||
"mdi:heat-pump",
|
||||
"mdi:server-network",
|
||||
"mdi:flash",
|
||||
],
|
||||
pool: ["mdi:pool", "mdi:swim"],
|
||||
media_room: [
|
||||
"mdi:theater",
|
||||
"mdi:projector",
|
||||
"mdi:television",
|
||||
"mdi:movie-open",
|
||||
],
|
||||
game_room: [
|
||||
"mdi:gamepad-variant",
|
||||
"mdi:billiards",
|
||||
"mdi:cards-playing",
|
||||
"mdi:dice-multiple",
|
||||
],
|
||||
music_room: ["mdi:piano", "mdi:guitar-acoustic", "mdi:music"],
|
||||
library: ["mdi:bookshelf", "mdi:book-open-variant", "mdi:library"],
|
||||
bar: [
|
||||
"mdi:glass-cocktail",
|
||||
"mdi:glass-mug-variant",
|
||||
"mdi:bottle-wine",
|
||||
"mdi:beer",
|
||||
],
|
||||
dressing_room: [
|
||||
"mdi:hanger",
|
||||
"mdi:wardrobe",
|
||||
"mdi:tshirt-crew",
|
||||
"mdi:shoe-heel",
|
||||
],
|
||||
workshop: ["mdi:tools", "mdi:hammer-wrench", "mdi:toolbox", "mdi:saw-blade"],
|
||||
server_room: ["mdi:server-network", "mdi:server", "mdi:router-network"],
|
||||
safe_room: ["mdi:shield-home", "mdi:shield-lock", "mdi:safe"],
|
||||
prayer_room: ["mdi:hands-pray", "mdi:meditation", "mdi:candle"],
|
||||
sauna: ["mdi:spa", "mdi:hot-tub", "mdi:thermometer-high"],
|
||||
outdoor_kitchen: ["mdi:grill", "mdi:grill-outline", "mdi:pizza"],
|
||||
driveway: ["mdi:road-variant", "mdi:car", "mdi:gate"],
|
||||
} as const satisfies Record<string, readonly string[]>;
|
||||
|
||||
export type RoomType = keyof typeof ROOM_ICONS;
|
||||
|
||||
type RoomKeywords = Partial<Record<RoomType, string[]>>;
|
||||
|
||||
export const ROOM_TYPES = Object.keys(ROOM_ICONS) as RoomType[];
|
||||
|
||||
export const isRoomType = (value: string): value is RoomType =>
|
||||
(ROOM_TYPES as string[]).includes(value);
|
||||
|
||||
// Languages written without spaces between words
|
||||
const NO_WORD_SPACING =
|
||||
/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Thai}]/u;
|
||||
|
||||
const normalizeRoomText = (text: string): string =>
|
||||
text
|
||||
.normalize("NFD")
|
||||
.replace(/\p{M}/gu, "")
|
||||
.toLowerCase()
|
||||
.replace(/['’]/g, "")
|
||||
.replace(/[^\p{L}\p{N}]+/gu, " ")
|
||||
.trim();
|
||||
|
||||
interface RoomMatch {
|
||||
room: RoomType;
|
||||
start: number;
|
||||
end: number;
|
||||
}
|
||||
|
||||
const findMatches = (name: string, keywords: RoomKeywords): RoomMatch[] => {
|
||||
const text = ` ${normalizeRoomText(name)} `;
|
||||
const candidates: RoomMatch[] = [];
|
||||
for (const room of ROOM_TYPES) {
|
||||
for (const keyword of keywords[room] ?? []) {
|
||||
const phrase = normalizeRoomText(keyword);
|
||||
if (!phrase) {
|
||||
continue;
|
||||
}
|
||||
const needle = NO_WORD_SPACING.test(phrase) ? phrase : ` ${phrase} `;
|
||||
const start = text.indexOf(needle);
|
||||
if (start !== -1) {
|
||||
candidates.push({ room, start, end: start + needle.length });
|
||||
}
|
||||
}
|
||||
}
|
||||
// The longest phrase wins, so "guest bedroom" is not also read as "bedroom"
|
||||
candidates.sort((a, b) => b.end - b.start - (a.end - a.start));
|
||||
const kept: RoomMatch[] = [];
|
||||
for (const match of candidates) {
|
||||
const overlaps = kept.some(
|
||||
(other) => match.start < other.end - 1 && other.start < match.end - 1
|
||||
);
|
||||
if (!overlaps) {
|
||||
kept.push(match);
|
||||
}
|
||||
}
|
||||
return kept.sort((a, b) => a.start - b.start);
|
||||
};
|
||||
|
||||
const matchRoomTypes = (
|
||||
names: string[],
|
||||
keywords: RoomKeywords
|
||||
): RoomType[] => {
|
||||
const rooms = new Set<RoomType>();
|
||||
for (const name of names) {
|
||||
for (const match of findMatches(name, keywords)) {
|
||||
rooms.add(match.room);
|
||||
}
|
||||
}
|
||||
return [...rooms];
|
||||
};
|
||||
|
||||
const roomIconSuggestions = (rooms: RoomType[]): string[] => [
|
||||
...new Set(rooms.flatMap((room) => ROOM_ICONS[room])),
|
||||
];
|
||||
|
||||
export const getAreaIconSuggestions = (
|
||||
names: string[],
|
||||
localize: LocalizeFunc
|
||||
): string[] => {
|
||||
const keywords: RoomKeywords = Object.fromEntries(
|
||||
ROOM_TYPES.map((room) => [
|
||||
room,
|
||||
localize(`ui.components.rooms.keywords.${room}`).split("|"),
|
||||
])
|
||||
);
|
||||
return roomIconSuggestions(matchRoomTypes(names, keywords));
|
||||
};
|
||||
@@ -1,80 +0,0 @@
|
||||
export const STREAM_TYPE_HLS = "hls";
|
||||
export const STREAM_TYPE_WEB_RTC = "web_rtc";
|
||||
|
||||
export type StreamType = typeof STREAM_TYPE_HLS | typeof STREAM_TYPE_WEB_RTC;
|
||||
|
||||
export const MJPEG_STREAM = "mjpeg";
|
||||
|
||||
export type CameraStreamType = StreamType | typeof MJPEG_STREAM;
|
||||
|
||||
export interface CameraStream {
|
||||
type: CameraStreamType;
|
||||
visible: boolean;
|
||||
}
|
||||
|
||||
/** What a player reported, `hasVideo: false` means it failed to load. */
|
||||
export interface CameraStreamTracks {
|
||||
hasAudio: boolean;
|
||||
hasVideo: boolean;
|
||||
}
|
||||
|
||||
export interface CameraStreamSelectionOptions {
|
||||
supportedTypes?: StreamType[];
|
||||
hlsStreams?: CameraStreamTracks;
|
||||
webRtcStreams?: CameraStreamTracks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decides which players are rendered and which one is shown. Hidden players
|
||||
* are still loading in the background.
|
||||
*/
|
||||
export const selectCameraStreams = ({
|
||||
supportedTypes,
|
||||
hlsStreams,
|
||||
webRtcStreams,
|
||||
}: CameraStreamSelectionOptions): CameraStream[] => {
|
||||
if (!supportedTypes) {
|
||||
return [];
|
||||
}
|
||||
if (supportedTypes.length === 0) {
|
||||
// doesn't support any stream type, fallback to mjpeg
|
||||
return [{ type: MJPEG_STREAM, visible: true }];
|
||||
}
|
||||
if (supportedTypes.length === 1) {
|
||||
// only 1 stream type, no need to choose
|
||||
if (
|
||||
(supportedTypes[0] === STREAM_TYPE_HLS &&
|
||||
hlsStreams?.hasVideo === false) ||
|
||||
(supportedTypes[0] === STREAM_TYPE_WEB_RTC &&
|
||||
webRtcStreams?.hasVideo === false)
|
||||
) {
|
||||
// stream failed to load, fallback to mjpeg
|
||||
return [{ type: MJPEG_STREAM, visible: true }];
|
||||
}
|
||||
return [{ type: supportedTypes[0], visible: true }];
|
||||
}
|
||||
|
||||
const hlsFailed = hlsStreams?.hasVideo === false;
|
||||
|
||||
if (webRtcStreams?.hasVideo) {
|
||||
// WebRTC is preferred whenever it plays, it has the lowest latency
|
||||
return [{ type: STREAM_TYPE_WEB_RTC, visible: true }];
|
||||
}
|
||||
|
||||
if (webRtcStreams?.hasVideo === false) {
|
||||
if (hlsFailed) {
|
||||
// both streams failed to load, fallback to mjpeg
|
||||
return [{ type: MJPEG_STREAM, visible: true }];
|
||||
}
|
||||
return [{ type: STREAM_TYPE_HLS, visible: true }];
|
||||
}
|
||||
|
||||
// WebRTC is still loading
|
||||
if (hlsFailed) {
|
||||
return [{ type: STREAM_TYPE_WEB_RTC, visible: true }];
|
||||
}
|
||||
return [
|
||||
{ type: STREAM_TYPE_HLS, visible: true },
|
||||
{ type: STREAM_TYPE_WEB_RTC, visible: false },
|
||||
];
|
||||
};
|
||||
+4
-6
@@ -7,15 +7,13 @@ import { timeCacheEntityPromiseFunc } from "../common/util/time-cache-entity-pro
|
||||
import type { HomeAssistant, HomeAssistantApi } from "../types";
|
||||
import { fileDownload } from "../util/file_download";
|
||||
import { getSignedPath } from "./auth";
|
||||
import type { StreamType } from "./camera-streams";
|
||||
|
||||
export const CAMERA_ORIENTATIONS = [1, 2, 3, 4, 6, 8];
|
||||
|
||||
export {
|
||||
STREAM_TYPE_HLS,
|
||||
STREAM_TYPE_WEB_RTC,
|
||||
type StreamType,
|
||||
} from "./camera-streams";
|
||||
export const STREAM_TYPE_HLS = "hls";
|
||||
export const STREAM_TYPE_WEB_RTC = "web_rtc";
|
||||
|
||||
export type StreamType = typeof STREAM_TYPE_HLS | typeof STREAM_TYPE_WEB_RTC;
|
||||
|
||||
export { CameraEntityFeature } from "./feature/camera_entity_feature";
|
||||
|
||||
|
||||
+48
-323
@@ -97,6 +97,13 @@ export const emptyHomeEnergyPreference =
|
||||
stat_energy_to: "",
|
||||
});
|
||||
|
||||
export const emptyBatteryEnergyPreference =
|
||||
(): BatterySourceTypeEnergyPreference => ({
|
||||
type: "battery",
|
||||
stat_energy_from: "",
|
||||
stat_energy_to: "",
|
||||
});
|
||||
|
||||
export const emptyGasEnergyPreference = (): GasSourceTypeEnergyPreference => ({
|
||||
type: "gas",
|
||||
stat_energy_from: "",
|
||||
@@ -183,125 +190,16 @@ export interface HomeSourceTypeEnergyPreference {
|
||||
name?: string;
|
||||
}
|
||||
|
||||
export interface BatteryTotalsSourceTypeEnergyPreference {
|
||||
export interface BatterySourceTypeEnergyPreference {
|
||||
type: "battery";
|
||||
stat_energy_from: string; // out of the battery
|
||||
stat_energy_to: string; // into the battery
|
||||
stat_energy_from: string;
|
||||
stat_energy_to: string;
|
||||
stat_rate?: string; // always available if power_config is set
|
||||
power_config?: PowerConfig;
|
||||
stat_soc?: string;
|
||||
capacity?: number; // usable capacity in kWh, used to weight the combined SOC
|
||||
name?: string;
|
||||
}
|
||||
|
||||
// Non-negative power sensors, any subset
|
||||
export interface BatteryDirectionsPowerConfig {
|
||||
stat_rate_from_grid?: string; // grid → battery
|
||||
stat_rate_from_solar?: string; // solar → battery
|
||||
stat_rate_to_home?: string; // battery → home
|
||||
stat_rate_to_grid?: string; // battery → grid
|
||||
}
|
||||
|
||||
// A missing direction is 0. At least one charge and one discharge direction is
|
||||
// required, so getBatteryEnergyStatIds never returns an empty list.
|
||||
export interface BatteryDirectionsSourceTypeEnergyPreference {
|
||||
type: "battery";
|
||||
stat_energy_from?: undefined;
|
||||
stat_energy_to?: undefined;
|
||||
stat_energy_from_grid?: string; // grid → battery
|
||||
stat_energy_from_solar?: string; // solar → battery
|
||||
stat_energy_to_home?: string; // battery → home
|
||||
stat_energy_to_grid?: string; // battery → grid
|
||||
// Net power generated from power_config, + discharge and − charge
|
||||
stat_rate?: string;
|
||||
power_config?: BatteryDirectionsPowerConfig;
|
||||
stat_soc?: string;
|
||||
capacity?: number;
|
||||
name?: string;
|
||||
}
|
||||
|
||||
export type BatterySourceTypeEnergyPreference =
|
||||
| BatteryTotalsSourceTypeEnergyPreference
|
||||
| BatteryDirectionsSourceTypeEnergyPreference;
|
||||
|
||||
export interface BatteryFlowStatIds {
|
||||
grid_to_battery?: string;
|
||||
solar_to_battery?: string;
|
||||
battery_to_home?: string;
|
||||
battery_to_grid?: string;
|
||||
}
|
||||
|
||||
export const BATTERY_FLOW_KEYS = [
|
||||
"grid_to_battery",
|
||||
"solar_to_battery",
|
||||
"battery_to_home",
|
||||
"battery_to_grid",
|
||||
] as const satisfies readonly (keyof BatteryFlowStatIds)[];
|
||||
|
||||
export const isBatteryDirections = (
|
||||
source: BatterySourceTypeEnergyPreference
|
||||
): source is BatteryDirectionsSourceTypeEnergyPreference => {
|
||||
const directions = source as BatteryDirectionsSourceTypeEnergyPreference;
|
||||
return !!(
|
||||
directions.stat_energy_from_grid ||
|
||||
directions.stat_energy_from_solar ||
|
||||
directions.stat_energy_to_home ||
|
||||
directions.stat_energy_to_grid
|
||||
);
|
||||
};
|
||||
|
||||
/** The direction statistics, or undefined for a battery configured with totals. */
|
||||
export const getBatteryFlowStatIds = (
|
||||
source: BatterySourceTypeEnergyPreference
|
||||
): BatteryFlowStatIds | undefined =>
|
||||
isBatteryDirections(source)
|
||||
? {
|
||||
grid_to_battery: source.stat_energy_from_grid || undefined,
|
||||
solar_to_battery: source.stat_energy_from_solar || undefined,
|
||||
battery_to_home: source.stat_energy_to_home || undefined,
|
||||
battery_to_grid: source.stat_energy_to_grid || undefined,
|
||||
}
|
||||
: undefined;
|
||||
|
||||
/** The direction power sensors, or undefined for a battery configured with totals. */
|
||||
export const getBatteryFlowPowerIds = (
|
||||
source: BatterySourceTypeEnergyPreference
|
||||
): BatteryFlowStatIds | undefined =>
|
||||
isBatteryDirections(source)
|
||||
? {
|
||||
grid_to_battery: source.power_config?.stat_rate_from_grid || undefined,
|
||||
solar_to_battery:
|
||||
source.power_config?.stat_rate_from_solar || undefined,
|
||||
battery_to_home: source.power_config?.stat_rate_to_home || undefined,
|
||||
battery_to_grid: source.power_config?.stat_rate_to_grid || undefined,
|
||||
}
|
||||
: undefined;
|
||||
|
||||
/** Statistics whose sum is the energy going into and coming out of the battery. */
|
||||
export const getBatteryEnergyStatIds = (
|
||||
source: BatterySourceTypeEnergyPreference
|
||||
): { charge: string[]; discharge: string[] } => {
|
||||
if (!isBatteryDirections(source)) {
|
||||
return {
|
||||
charge: [source.stat_energy_to],
|
||||
discharge: [source.stat_energy_from],
|
||||
};
|
||||
}
|
||||
const ids = (...stats: (string | undefined)[]) =>
|
||||
stats.filter((id): id is string => !!id);
|
||||
return {
|
||||
charge: ids(source.stat_energy_from_grid, source.stat_energy_from_solar),
|
||||
discharge: ids(source.stat_energy_to_home, source.stat_energy_to_grid),
|
||||
};
|
||||
};
|
||||
|
||||
/** Identifies a battery in page keys and lookups. */
|
||||
export const getBatteryPrimaryStat = (
|
||||
source: BatterySourceTypeEnergyPreference
|
||||
): string => {
|
||||
const { charge, discharge } = getBatteryEnergyStatIds(source);
|
||||
return discharge[0] ?? charge[0] ?? "";
|
||||
};
|
||||
export interface GasSourceTypeEnergyPreference {
|
||||
type: "gas";
|
||||
|
||||
@@ -494,28 +392,6 @@ export const computeEnergyLabel = (
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Name that cards show as "<name> charged" and "<name> discharged". Unnamed
|
||||
* batteries configured with totals are labelled by each statistic instead.
|
||||
*/
|
||||
export const getBatteryName = (
|
||||
states: HomeAssistant["states"],
|
||||
formatEntityName: HomeAssistant["formatEntityName"],
|
||||
source: BatterySourceTypeEnergyPreference,
|
||||
statsMetadata?: Record<string, StatisticsMetaData>
|
||||
): string | undefined => {
|
||||
if (source.name || !isBatteryDirections(source)) {
|
||||
return source.name;
|
||||
}
|
||||
const primary = getBatteryPrimaryStat(source);
|
||||
return computeEnergyLabel(
|
||||
states,
|
||||
formatEntityName,
|
||||
primary,
|
||||
statsMetadata?.[primary]
|
||||
);
|
||||
};
|
||||
|
||||
export const computeEnergyStatisticArea = (
|
||||
registries: HomeAssistantRegistries,
|
||||
statisticId: string
|
||||
@@ -676,8 +552,8 @@ export const getReferencedStatisticIds = (
|
||||
}
|
||||
|
||||
if (source.type === "battery") {
|
||||
const { charge, discharge } = getBatteryEnergyStatIds(source);
|
||||
statIDs.push(...discharge, ...charge);
|
||||
statIDs.push(source.stat_energy_from);
|
||||
statIDs.push(source.stat_energy_to);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1761,8 +1637,7 @@ const getEnergyGasUnit = (
|
||||
return [source.stat_energy_to];
|
||||
}
|
||||
if (source.type === "battery") {
|
||||
const { charge, discharge } = getBatteryEnergyStatIds(source);
|
||||
return [...discharge, ...charge];
|
||||
return [source.stat_energy_from, source.stat_energy_to];
|
||||
}
|
||||
if (source.type === "grid") {
|
||||
return [source.stat_energy_from, source.stat_energy_to].filter(
|
||||
@@ -1835,14 +1710,6 @@ export interface EnergySumData {
|
||||
from_battery?: Record<number, number>;
|
||||
solar?: Record<number, number>;
|
||||
home?: Record<number, number>;
|
||||
// Set together, only when a battery has direction statistics
|
||||
grid_to_battery?: Record<number, number>;
|
||||
solar_to_battery?: Record<number, number>;
|
||||
battery_to_home?: Record<number, number>;
|
||||
battery_to_grid?: Record<number, number>;
|
||||
// Charge and discharge of the batteries configured with totals
|
||||
to_battery_totals?: Record<number, number>;
|
||||
from_battery_totals?: Record<number, number>;
|
||||
total: {
|
||||
to_grid?: number;
|
||||
from_grid?: number;
|
||||
@@ -1850,12 +1717,6 @@ export interface EnergySumData {
|
||||
from_battery?: number;
|
||||
solar?: number;
|
||||
home?: number;
|
||||
grid_to_battery?: number;
|
||||
solar_to_battery?: number;
|
||||
battery_to_home?: number;
|
||||
battery_to_grid?: number;
|
||||
to_battery_totals?: number;
|
||||
from_battery_totals?: number;
|
||||
};
|
||||
timestamps: number[];
|
||||
}
|
||||
@@ -1897,10 +1758,14 @@ const getSummedDataPartial = (
|
||||
data: EnergyData,
|
||||
compare?: boolean
|
||||
): EnergySumData => {
|
||||
const statIds: Partial<
|
||||
Record<Exclude<keyof EnergySumData, "total" | "timestamps">, string[]>
|
||||
> = {};
|
||||
const batteries: BatterySourceTypeEnergyPreference[] = [];
|
||||
const statIds: {
|
||||
to_grid?: string[];
|
||||
from_grid?: string[];
|
||||
solar?: string[];
|
||||
to_battery?: string[];
|
||||
from_battery?: string[];
|
||||
home?: string[];
|
||||
} = {};
|
||||
|
||||
for (const source of data.prefs.energy_sources) {
|
||||
if (source.type === "solar") {
|
||||
@@ -1918,14 +1783,12 @@ const getSummedDataPartial = (
|
||||
}
|
||||
|
||||
if (source.type === "battery") {
|
||||
batteries.push(source);
|
||||
const { charge, discharge } = getBatteryEnergyStatIds(source);
|
||||
if (statIds.to_battery) {
|
||||
statIds.to_battery.push(...charge);
|
||||
statIds.from_battery!.push(...discharge);
|
||||
statIds.to_battery.push(source.stat_energy_to);
|
||||
statIds.from_battery!.push(source.stat_energy_from);
|
||||
} else {
|
||||
statIds.to_battery = [...charge];
|
||||
statIds.from_battery = [...discharge];
|
||||
statIds.to_battery = [source.stat_energy_to];
|
||||
statIds.from_battery = [source.stat_energy_from];
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@@ -1951,23 +1814,6 @@ const getSummedDataPartial = (
|
||||
}
|
||||
}
|
||||
|
||||
if (batteries.some(isBatteryDirections)) {
|
||||
for (const key of BATTERY_FLOW_KEYS) {
|
||||
statIds[key] = batteries.flatMap(
|
||||
(battery) => getBatteryFlowStatIds(battery)?.[key] ?? []
|
||||
);
|
||||
}
|
||||
const totalsBatteries = batteries.filter(
|
||||
(battery) => !isBatteryDirections(battery)
|
||||
);
|
||||
statIds.to_battery_totals = totalsBatteries.flatMap(
|
||||
(battery) => getBatteryEnergyStatIds(battery).charge
|
||||
);
|
||||
statIds.from_battery_totals = totalsBatteries.flatMap(
|
||||
(battery) => getBatteryEnergyStatIds(battery).discharge
|
||||
);
|
||||
}
|
||||
|
||||
const summedData: EnergySumData = { total: {}, timestamps: [] };
|
||||
const timestamps = new Set<number>();
|
||||
Object.entries(statIds).forEach(([key, subStatIds]) => {
|
||||
@@ -2038,12 +1884,11 @@ const computeConsumptionDataPartial = (
|
||||
},
|
||||
};
|
||||
|
||||
const measured = BATTERY_FLOW_KEYS.some((key) => data[key]);
|
||||
const fromGrid = data.from_grid;
|
||||
const toGrid = data.to_grid;
|
||||
const solarData = data.solar;
|
||||
const toBattery = measured ? data.to_battery_totals : data.to_battery;
|
||||
const fromBattery = measured ? data.from_battery_totals : data.from_battery;
|
||||
const toBattery = data.to_battery;
|
||||
const fromBattery = data.from_battery;
|
||||
const total = outData.total;
|
||||
|
||||
data.timestamps.forEach((t) => {
|
||||
@@ -2058,25 +1903,13 @@ const computeConsumptionDataPartial = (
|
||||
used_total,
|
||||
solar_to_battery,
|
||||
solar_to_grid,
|
||||
} = computeConsumptionSingle(
|
||||
{
|
||||
from_grid: fromGrid && (fromGrid[t] ?? 0),
|
||||
to_grid: toGrid && (toGrid[t] ?? 0),
|
||||
solar: solarData && (solarData[t] ?? 0),
|
||||
to_battery: toBattery && (toBattery[t] ?? 0),
|
||||
from_battery: fromBattery && (fromBattery[t] ?? 0),
|
||||
},
|
||||
measured
|
||||
? {
|
||||
measured: {
|
||||
grid_to_battery: data.grid_to_battery?.[t] ?? 0,
|
||||
solar_to_battery: data.solar_to_battery?.[t] ?? 0,
|
||||
battery_to_home: data.battery_to_home?.[t] ?? 0,
|
||||
battery_to_grid: data.battery_to_grid?.[t] ?? 0,
|
||||
},
|
||||
}
|
||||
: undefined
|
||||
);
|
||||
} = computeConsumptionSingle({
|
||||
from_grid: fromGrid && (fromGrid[t] ?? 0),
|
||||
to_grid: toGrid && (toGrid[t] ?? 0),
|
||||
solar: solarData && (solarData[t] ?? 0),
|
||||
to_battery: toBattery && (toBattery[t] ?? 0),
|
||||
from_battery: fromBattery && (fromBattery[t] ?? 0),
|
||||
});
|
||||
|
||||
const usedTotal = hasHome ? Math.max(homeUsed, 0) : used_total;
|
||||
outData.used_total[t] = usedTotal;
|
||||
@@ -2100,15 +1933,13 @@ const computeConsumptionDataPartial = (
|
||||
return outData;
|
||||
};
|
||||
|
||||
interface ConsumptionInput {
|
||||
export const computeConsumptionSingle = (data: {
|
||||
from_grid: number | undefined;
|
||||
to_grid: number | undefined;
|
||||
solar: number | undefined;
|
||||
to_battery: number | undefined;
|
||||
from_battery: number | undefined;
|
||||
}
|
||||
|
||||
interface ConsumptionResult {
|
||||
}): {
|
||||
grid_to_battery: number;
|
||||
battery_to_grid: number;
|
||||
solar_to_battery: number;
|
||||
@@ -2117,12 +1948,7 @@ interface ConsumptionResult {
|
||||
used_grid: number;
|
||||
used_battery: number;
|
||||
used_total: number;
|
||||
}
|
||||
|
||||
const inferConsumption = (
|
||||
data: ConsumptionInput,
|
||||
usedTotal?: number
|
||||
): ConsumptionResult => {
|
||||
} => {
|
||||
let to_grid = Math.max(data.to_grid || 0, 0);
|
||||
let to_battery = Math.max(data.to_battery || 0, 0);
|
||||
let solar = Math.max(data.solar || 0, 0);
|
||||
@@ -2130,12 +1956,11 @@ const inferConsumption = (
|
||||
let from_battery = Math.max(data.from_battery || 0, 0);
|
||||
|
||||
const used_total =
|
||||
usedTotal ??
|
||||
(from_grid || 0) +
|
||||
(solar || 0) +
|
||||
(from_battery || 0) -
|
||||
(to_grid || 0) -
|
||||
(to_battery || 0);
|
||||
(solar || 0) +
|
||||
(from_battery || 0) -
|
||||
(to_grid || 0) -
|
||||
(to_battery || 0);
|
||||
|
||||
let grid_to_battery = 0;
|
||||
|
||||
@@ -2203,70 +2028,6 @@ const inferConsumption = (
|
||||
};
|
||||
};
|
||||
|
||||
export type MeasuredBatteryFlows = Record<
|
||||
(typeof BATTERY_FLOW_KEYS)[number],
|
||||
number | undefined
|
||||
>;
|
||||
|
||||
/**
|
||||
* Splits the energy or power of one period into flows. Batteries with
|
||||
* direction statistics pass them in `measured`, and `to_battery` and
|
||||
* `from_battery` then only hold the batteries configured with totals.
|
||||
* Measured flows are kept as they are; only the rest is estimated. Leave a
|
||||
* meter undefined when it isn't configured, rather than 0.
|
||||
*/
|
||||
export const computeConsumptionSingle = (
|
||||
data: ConsumptionInput,
|
||||
options?: { measured?: MeasuredBatteryFlows; used_total?: number }
|
||||
): ConsumptionResult => {
|
||||
const measured = options?.measured;
|
||||
if (!measured) {
|
||||
return inferConsumption(data, options?.used_total);
|
||||
}
|
||||
const clamp = (value: number | undefined) => Math.max(value || 0, 0);
|
||||
const gridToBattery = clamp(measured.grid_to_battery);
|
||||
const solarToBattery = clamp(measured.solar_to_battery);
|
||||
const batteryToHome = clamp(measured.battery_to_home);
|
||||
const batteryToGrid = clamp(measured.battery_to_grid);
|
||||
const fromGrid = clamp(data.from_grid);
|
||||
const toGrid = clamp(data.to_grid);
|
||||
const solar = clamp(data.solar);
|
||||
// A flow without a configured meter never passed one, so it stays out of
|
||||
// the home load
|
||||
const metered = (meter: number | undefined, flow: number) =>
|
||||
meter === undefined ? 0 : flow;
|
||||
const toBattery =
|
||||
clamp(data.to_battery) +
|
||||
metered(data.from_grid, gridToBattery) +
|
||||
metered(data.solar, solarToBattery);
|
||||
const fromBattery =
|
||||
clamp(data.from_battery) +
|
||||
batteryToHome +
|
||||
metered(data.to_grid, batteryToGrid);
|
||||
const usedTotal =
|
||||
options.used_total ?? fromGrid + solar + fromBattery - toGrid - toBattery;
|
||||
|
||||
// Only what the measured flows leave over is estimated
|
||||
const inferred = inferConsumption(
|
||||
{
|
||||
from_grid: Math.max(fromGrid - gridToBattery, 0),
|
||||
to_grid: Math.max(toGrid - batteryToGrid, 0),
|
||||
solar: Math.max(solar - solarToBattery, 0),
|
||||
to_battery: data.to_battery,
|
||||
from_battery: data.from_battery,
|
||||
},
|
||||
Math.max(usedTotal - batteryToHome, 0)
|
||||
);
|
||||
return {
|
||||
...inferred,
|
||||
grid_to_battery: inferred.grid_to_battery + gridToBattery,
|
||||
solar_to_battery: inferred.solar_to_battery + solarToBattery,
|
||||
battery_to_grid: inferred.battery_to_grid + batteryToGrid,
|
||||
used_battery: inferred.used_battery + batteryToHome,
|
||||
used_total: usedTotal,
|
||||
};
|
||||
};
|
||||
|
||||
export const formatConsumptionShort = (
|
||||
locale: HomeAssistant["locale"],
|
||||
consumption: number | null,
|
||||
@@ -2756,54 +2517,18 @@ export const downloadEnergyData = (
|
||||
grid_productions_cost
|
||||
);
|
||||
|
||||
const batteries = energy_sources.filter(
|
||||
(s): s is BatterySourceTypeEnergyPreference => s.type === "battery"
|
||||
);
|
||||
const battery_ins: string[] = [];
|
||||
const battery_outs: string[] = [];
|
||||
const battery_flows: Record<keyof BatteryFlowStatIds, string[]> = {
|
||||
grid_to_battery: [],
|
||||
solar_to_battery: [],
|
||||
battery_to_home: [],
|
||||
battery_to_grid: [],
|
||||
};
|
||||
batteries.forEach((source) => {
|
||||
const flows = getBatteryFlowStatIds(source);
|
||||
if (!flows) {
|
||||
const { charge, discharge } = getBatteryEnergyStatIds(source);
|
||||
battery_ins.push(...charge);
|
||||
battery_outs.push(...discharge);
|
||||
return;
|
||||
}
|
||||
BATTERY_FLOW_KEYS.forEach((key) => {
|
||||
if (flows[key]) {
|
||||
battery_flows[key].push(flows[key]);
|
||||
}
|
||||
energy_sources
|
||||
.filter((s) => s.type === "battery")
|
||||
.forEach((source) => {
|
||||
source = source as BatterySourceTypeEnergyPreference;
|
||||
battery_ins.push(source.stat_energy_to);
|
||||
battery_outs.push(source.stat_energy_from);
|
||||
});
|
||||
});
|
||||
|
||||
printCategory("battery_in", battery_ins, electricUnit);
|
||||
printCategory("battery_out", battery_outs, electricUnit);
|
||||
printCategory(
|
||||
"battery_in_from_grid",
|
||||
battery_flows.grid_to_battery,
|
||||
electricUnit
|
||||
);
|
||||
printCategory(
|
||||
"battery_in_from_solar",
|
||||
battery_flows.solar_to_battery,
|
||||
electricUnit
|
||||
);
|
||||
printCategory(
|
||||
"battery_out_to_home",
|
||||
battery_flows.battery_to_home,
|
||||
electricUnit
|
||||
);
|
||||
printCategory(
|
||||
"battery_out_to_grid",
|
||||
battery_flows.battery_to_grid,
|
||||
electricUnit
|
||||
);
|
||||
|
||||
const solar_productions: string[] = [];
|
||||
energy_sources
|
||||
@@ -2920,7 +2645,7 @@ export const downloadEnergyData = (
|
||||
|
||||
const hasSolar = !!solar_productions.length;
|
||||
const hasHome = !!home_consumptions.length;
|
||||
const hasBattery = batteries.length > 0;
|
||||
const hasBattery = !!battery_ins.length;
|
||||
const hasGridReturn = !!grid_productions.length;
|
||||
const hasGridSource = !!grid_consumptions.length;
|
||||
|
||||
|
||||
@@ -266,10 +266,10 @@ export const computeEntityRegistryName = (
|
||||
};
|
||||
|
||||
export const getExtendedEntityRegistryEntry = (
|
||||
callWS: HomeAssistant["callWS"],
|
||||
hass: Pick<HomeAssistant, "callWS">,
|
||||
entityId: string
|
||||
): Promise<ExtEntityRegistryEntry> =>
|
||||
callWS({
|
||||
hass.callWS({
|
||||
type: "config/entity_registry/get",
|
||||
entity_id: entityId,
|
||||
});
|
||||
|
||||
@@ -60,18 +60,3 @@ export const validateHassioSession = async (
|
||||
): Promise<void> => {
|
||||
await hass.callWS({ type: "supervisor/ingress/validate_session", session });
|
||||
};
|
||||
|
||||
// Extends the session, or replaces it with a new one for the app if it has
|
||||
// expired. Returns the session to keep using.
|
||||
export const refreshHassioSession = async (
|
||||
hass: Pick<HomeAssistant, "callWS">,
|
||||
slug: string,
|
||||
session: string
|
||||
): Promise<string> => {
|
||||
try {
|
||||
await validateHassioSession(hass, session);
|
||||
return session;
|
||||
} catch (_err: any) {
|
||||
return createHassioSession(hass, slug);
|
||||
}
|
||||
};
|
||||
+5
-5
@@ -6,7 +6,7 @@ import type { LocalizeFunc } from "../common/translations/localize";
|
||||
import { showEnterCodeDialog } from "../dialogs/enter-code/show-enter-code-dialog";
|
||||
import type { HomeAssistant } from "../types";
|
||||
import { UNAVAILABLE } from "./entity/entity";
|
||||
import { getExtendedEntityRegistryEntry } from "./entity/entity_registry";
|
||||
import type { ExtEntityRegistryEntry } from "./entity/entity_registry";
|
||||
|
||||
export enum LockEntityFeature {
|
||||
OPEN = 1,
|
||||
@@ -88,10 +88,10 @@ export const callProtectedLockService = async (
|
||||
service: ProtectedLockService
|
||||
) => {
|
||||
let code: string | undefined;
|
||||
const lockRegistryEntry = await getExtendedEntityRegistryEntry(
|
||||
callWS,
|
||||
stateObj.entity_id
|
||||
).catch(() => undefined);
|
||||
const lockRegistryEntry = await callWS<ExtEntityRegistryEntry>({
|
||||
type: "config/entity_registry/get",
|
||||
entity_id: stateObj.entity_id,
|
||||
}).catch(() => undefined);
|
||||
const defaultCode = lockRegistryEntry?.options?.lock?.default_code;
|
||||
|
||||
if (stateObj!.attributes.code_format && !defaultCode) {
|
||||
|
||||
+7
-11
@@ -209,15 +209,7 @@ export const watchForNewMatterDevice = (
|
||||
callback: (device: DeviceRegistryEntry) => void
|
||||
): UnsubscribeFunc => {
|
||||
let curMatterDevices: Set<string> | undefined;
|
||||
let unsubDeviceReg: UnsubscribeFunc | undefined;
|
||||
// Callers also unsubscribe after a find. The registry collection counts its
|
||||
// subscribers, so a second unsubscribe would stop its updates for everyone.
|
||||
const unsubscribe = () => {
|
||||
unsubDeviceReg?.();
|
||||
unsubDeviceReg = undefined;
|
||||
curMatterDevices = undefined;
|
||||
};
|
||||
unsubDeviceReg = subscribeDeviceRegistry(hass.connection, (entries) => {
|
||||
const unsubDeviceReg = subscribeDeviceRegistry(hass.connection, (entries) => {
|
||||
if (!curMatterDevices) {
|
||||
curMatterDevices = new Set(
|
||||
Object.values(entries)
|
||||
@@ -234,11 +226,15 @@ export const watchForNewMatterDevice = (
|
||||
!curMatterDevices!.has(device.id)
|
||||
);
|
||||
if (newMatterDevices.length) {
|
||||
unsubscribe();
|
||||
unsubDeviceReg();
|
||||
curMatterDevices = undefined;
|
||||
callback(newMatterDevices[0]);
|
||||
}
|
||||
});
|
||||
return unsubscribe;
|
||||
return () => {
|
||||
unsubDeviceReg();
|
||||
curMatterDevices = undefined;
|
||||
};
|
||||
};
|
||||
|
||||
export const redirectOnNewMatterDevice = (
|
||||
|
||||
@@ -20,7 +20,7 @@ import {
|
||||
registriesContext,
|
||||
uiContext,
|
||||
} from "./context";
|
||||
import type { HomeAssistant, HomeAssistantRegistries } from "../types";
|
||||
import type { HomeAssistant } from "../types";
|
||||
|
||||
/**
|
||||
* Reactive controller that keeps `NavigationPathInfo` in sync with a
|
||||
@@ -45,8 +45,19 @@ export class NavigationPathInfoController extends ContextController {
|
||||
})
|
||||
private _panels?: HomeAssistant["panels"];
|
||||
|
||||
@consumeContext({ context: registriesContext, subscribe: true })
|
||||
private _registries?: HomeAssistantRegistries | null;
|
||||
@consumeContext({
|
||||
context: registriesContext,
|
||||
subscribe: true,
|
||||
transform: ({ areas }) => areas,
|
||||
})
|
||||
private _areas?: HomeAssistant["areas"];
|
||||
|
||||
@consumeContext({
|
||||
context: registriesContext,
|
||||
subscribe: true,
|
||||
transform: ({ devices }) => devices,
|
||||
})
|
||||
private _devices?: HomeAssistant["devices"];
|
||||
|
||||
@consumeContext({
|
||||
context: configContext,
|
||||
@@ -68,8 +79,6 @@ export class NavigationPathInfoController extends ContextController {
|
||||
|
||||
private _path?: string;
|
||||
|
||||
private _resolvedInputs?: unknown[];
|
||||
|
||||
get info(): NavigationPathInfo {
|
||||
return this._info;
|
||||
}
|
||||
@@ -88,31 +97,13 @@ export class NavigationPathInfoController extends ContextController {
|
||||
this._unsubscribe();
|
||||
}
|
||||
|
||||
// The resolved info depends on every consumed value, so re-resolve.
|
||||
protected contextUpdated(): void {
|
||||
const inputs = this._inputs();
|
||||
if (
|
||||
this._resolvedInputs &&
|
||||
inputs.every((value, i) => value === this._resolvedInputs![i])
|
||||
) {
|
||||
return;
|
||||
}
|
||||
this._resolve();
|
||||
}
|
||||
|
||||
private _inputs(): unknown[] {
|
||||
return [
|
||||
this._localize,
|
||||
this._panels,
|
||||
this._registries?.areas,
|
||||
this._registries?.devices,
|
||||
this._config,
|
||||
this._connection,
|
||||
];
|
||||
}
|
||||
|
||||
private _resolve(): void {
|
||||
this._unsubscribe();
|
||||
this._resolvedInputs = this._inputs();
|
||||
|
||||
if (!this._path) {
|
||||
if (this._info !== DEFAULT_NAVIGATION_PATH_INFO) {
|
||||
@@ -125,8 +116,8 @@ export class NavigationPathInfoController extends ContextController {
|
||||
if (
|
||||
!this._localize ||
|
||||
!this._panels ||
|
||||
!this._registries?.areas ||
|
||||
!this._registries.devices ||
|
||||
!this._areas ||
|
||||
!this._devices ||
|
||||
!this._config ||
|
||||
!this._connection
|
||||
) {
|
||||
@@ -137,8 +128,8 @@ export class NavigationPathInfoController extends ContextController {
|
||||
{
|
||||
localize: this._localize,
|
||||
panels: this._panels,
|
||||
areas: this._registries.areas,
|
||||
devices: this._registries.devices,
|
||||
areas: this._areas,
|
||||
devices: this._devices,
|
||||
config: this._config,
|
||||
connection: this._connection,
|
||||
},
|
||||
|
||||
+7
-13
@@ -364,25 +364,19 @@ const getWeatherExtrema = (
|
||||
if (new Date(fc.datetime).getDate() !== today) {
|
||||
break;
|
||||
}
|
||||
if (fc.temperature == null) {
|
||||
continue;
|
||||
}
|
||||
if (tempHigh === undefined || fc.temperature > tempHigh) {
|
||||
if (!tempHigh || fc.temperature > tempHigh) {
|
||||
tempHigh =
|
||||
temperatureFractionDigits === undefined
|
||||
? fc.temperature
|
||||
: round(fc.temperature, temperatureFractionDigits);
|
||||
}
|
||||
if (fc.templow != null && (tempLow === undefined || fc.templow < tempLow)) {
|
||||
if (fc.templow !== undefined && (!tempLow || fc.templow < tempLow)) {
|
||||
tempLow =
|
||||
temperatureFractionDigits === undefined
|
||||
? fc.templow
|
||||
: round(fc.templow, temperatureFractionDigits);
|
||||
}
|
||||
if (
|
||||
fc.templow == null &&
|
||||
(tempLow === undefined || fc.temperature < tempLow)
|
||||
) {
|
||||
if (!fc.templow && (!tempLow || fc.temperature < tempLow)) {
|
||||
tempLow =
|
||||
temperatureFractionDigits === undefined
|
||||
? fc.temperature
|
||||
@@ -390,19 +384,19 @@ const getWeatherExtrema = (
|
||||
}
|
||||
}
|
||||
|
||||
if (tempLow === undefined && tempHigh === undefined) {
|
||||
if (!tempLow && !tempHigh) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return html`
|
||||
${
|
||||
tempHigh !== undefined
|
||||
tempHigh
|
||||
? formatEntityAttributeValue(stateObj, "temperature", tempHigh)
|
||||
: ""
|
||||
}
|
||||
${tempLow !== undefined && tempHigh !== undefined ? " / " : ""}
|
||||
${tempLow && tempHigh ? " / " : ""}
|
||||
${
|
||||
tempLow !== undefined
|
||||
tempLow
|
||||
? formatEntityAttributeValue(stateObj, "temperature", tempLow)
|
||||
: ""
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ export const fetchEntityConfigFlow = async (
|
||||
if (!entities || !(entityId in entities)) {
|
||||
return undefined;
|
||||
}
|
||||
const regEntry = await getExtendedEntityRegistryEntry(api.callWS, entityId);
|
||||
const regEntry = await getExtendedEntityRegistryEntry(api, entityId);
|
||||
if (!regEntry.config_entry_id) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -167,12 +167,16 @@ export class HaMoreInfoFavorites extends LitElement {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: var(--ha-space-4);
|
||||
margin: calc(var(--ha-space-2) * -1);
|
||||
flex-wrap: wrap;
|
||||
max-width: var(--favorite-items-max-width, 250px);
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.container > * {
|
||||
margin: var(--ha-space-2);
|
||||
}
|
||||
|
||||
.favorite {
|
||||
display: block;
|
||||
}
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ export class HaMoreInfoViewVacuumCleanAreasHeaderAction extends LitElement {
|
||||
if (!this.params.entityId || !this.hass.user?.is_admin) return;
|
||||
try {
|
||||
const entry = await getExtendedEntityRegistryEntry(
|
||||
this.hass.callWS,
|
||||
this.hass,
|
||||
this.params.entityId
|
||||
);
|
||||
const areaMapping = entry?.options?.vacuum?.area_mapping;
|
||||
|
||||
@@ -56,10 +56,7 @@ export class HaMoreInfoViewVacuumCleanAreas extends LitElement {
|
||||
|
||||
try {
|
||||
const entry: ExtEntityRegistryEntry =
|
||||
await getExtendedEntityRegistryEntry(
|
||||
this.hass.callWS,
|
||||
this.params.entityId
|
||||
);
|
||||
await getExtendedEntityRegistryEntry(this.hass, this.params.entityId);
|
||||
|
||||
const areaMapping = entry?.options?.vacuum?.area_mapping || {};
|
||||
const mappedAreaIds = new Set(Object.keys(areaMapping));
|
||||
|
||||
@@ -50,7 +50,7 @@ export class HaMoreInfoViewVacuumSegmentMapping extends LitElement {
|
||||
if (!this.params.entityId) return;
|
||||
|
||||
this._entry = await getExtendedEntityRegistryEntry(
|
||||
this.hass.callWS,
|
||||
this.hass,
|
||||
this.params.entityId
|
||||
);
|
||||
|
||||
|
||||
@@ -227,7 +227,7 @@ class MoreInfoWeather extends LitElement {
|
||||
.datetime=${this.stateObj.last_changed}
|
||||
capitalize
|
||||
></ha-relative-time>
|
||||
<ha-tooltip trigger="hover focus click" for="relative-time">
|
||||
<ha-tooltip for="relative-time">
|
||||
<div class="row">
|
||||
<span class="column-name">
|
||||
${this._i18n.localize(
|
||||
|
||||
@@ -217,7 +217,7 @@ export class MoreInfoDialog extends DirtyStateProviderMixin<
|
||||
}
|
||||
try {
|
||||
this._entry = await getExtendedEntityRegistryEntry(
|
||||
this.hass.callWS,
|
||||
this.hass,
|
||||
this._entityId
|
||||
);
|
||||
} catch (_e) {
|
||||
|
||||
@@ -33,11 +33,7 @@ export class HuiPersistentNotificationItem extends LitElement {
|
||||
.datetime=${this.notification.created_at}
|
||||
capitalize
|
||||
></ha-relative-time>
|
||||
<ha-tooltip
|
||||
trigger="hover focus click"
|
||||
for="relative-time"
|
||||
placement="bottom"
|
||||
>
|
||||
<ha-tooltip for="relative-time" placement="bottom">
|
||||
${this._computeTooltip(this.hass, this.notification)}
|
||||
</ha-tooltip>
|
||||
</span>
|
||||
|
||||
@@ -60,25 +60,14 @@
|
||||
/* Margins, not flex `gap` (Safari 14.1). */
|
||||
#ha-launch-screen .ha-launch-screen-actions {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
margin: 0 16px;
|
||||
}
|
||||
#ha-launch-screen .ha-launch-screen-actions label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-top: 8px;
|
||||
padding: 8px 16px;
|
||||
font-size: 14px;
|
||||
cursor: pointer;
|
||||
}
|
||||
#ha-launch-screen .ha-launch-screen-actions input {
|
||||
margin: 0 8px 0 0;
|
||||
accent-color: #009ac7;
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
margin: -4px 16px;
|
||||
}
|
||||
#ha-launch-screen .ha-launch-screen-actions button {
|
||||
margin: 4px;
|
||||
padding: 8px 16px;
|
||||
border: 1px solid currentColor;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 18px;
|
||||
background: none;
|
||||
color: #009ac7;
|
||||
@@ -87,6 +76,9 @@
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
}
|
||||
#ha-launch-screen .ha-launch-screen-actions .ha-launch-screen-continue {
|
||||
border-color: currentColor;
|
||||
}
|
||||
.ohf-logo {
|
||||
margin: 48px 0;
|
||||
display: flex;
|
||||
|
||||
@@ -116,33 +116,30 @@
|
||||
actions.className = "ha-launch-screen-actions";
|
||||
box.appendChild(actions);
|
||||
|
||||
var always = null;
|
||||
var button = document.createElement("button");
|
||||
button.type = "button";
|
||||
button.textContent = "Continue anyway";
|
||||
button.addEventListener("click", function () {
|
||||
try {
|
||||
localStorage.setItem(
|
||||
ACCEPTED_KEY,
|
||||
always && always.checked ? "always" : String(Date.now())
|
||||
);
|
||||
} catch (_err) {
|
||||
// Continue this time only.
|
||||
}
|
||||
box.removeChild(actions);
|
||||
loadApp();
|
||||
});
|
||||
actions.appendChild(button);
|
||||
function addButton(label, value) {
|
||||
var button = document.createElement("button");
|
||||
button.type = "button";
|
||||
button.textContent = label;
|
||||
button.addEventListener("click", function () {
|
||||
try {
|
||||
localStorage.setItem(ACCEPTED_KEY, value());
|
||||
} catch (_err) {
|
||||
// Continue this time only.
|
||||
}
|
||||
box.removeChild(actions);
|
||||
loadApp();
|
||||
});
|
||||
actions.appendChild(button);
|
||||
return button;
|
||||
}
|
||||
|
||||
// From the first reminder on. A checkbox, so it is not chosen by
|
||||
// accident.
|
||||
addButton("Continue anyway", function () {
|
||||
return String(Date.now());
|
||||
}).className = "ha-launch-screen-continue";
|
||||
if (acceptedAt) {
|
||||
var label = document.createElement("label");
|
||||
always = document.createElement("input");
|
||||
always.type = "checkbox";
|
||||
label.appendChild(always);
|
||||
label.appendChild(document.createTextNode("Don't show again"));
|
||||
actions.appendChild(label);
|
||||
addButton("Don't show again", function () {
|
||||
return "always";
|
||||
});
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ import type { IngressAppInfo } from "../../data/hassio/ingress";
|
||||
import {
|
||||
createHassioSession,
|
||||
fetchIngressAppInfo,
|
||||
refreshHassioSession,
|
||||
validateHassioSession,
|
||||
} from "../../data/hassio/ingress";
|
||||
import {
|
||||
showAlertDialog,
|
||||
@@ -60,10 +60,6 @@ class HaPanelApp extends LitElement {
|
||||
|
||||
private _sessionKeepAlive?: number;
|
||||
|
||||
private _session?: { slug: string; session: string };
|
||||
|
||||
private _sessionRefresh?: Promise<void>;
|
||||
|
||||
private _fetchDataTimeout?: number;
|
||||
|
||||
private _autoRetryUntil?: number;
|
||||
@@ -96,22 +92,17 @@ class HaPanelApp extends LitElement {
|
||||
super.connectedCallback();
|
||||
window.addEventListener("message", this._handleIframeMessage);
|
||||
window.addEventListener("resize", this._handleResize);
|
||||
document.addEventListener("visibilitychange", this._handleVisibility);
|
||||
document.addEventListener("resume", this._handleVisibility);
|
||||
}
|
||||
|
||||
public disconnectedCallback() {
|
||||
super.disconnectedCallback();
|
||||
window.removeEventListener("message", this._handleIframeMessage);
|
||||
window.removeEventListener("resize", this._handleResize);
|
||||
document.removeEventListener("visibilitychange", this._handleVisibility);
|
||||
document.removeEventListener("resume", this._handleVisibility);
|
||||
|
||||
if (this._sessionKeepAlive) {
|
||||
clearInterval(this._sessionKeepAlive);
|
||||
this._sessionKeepAlive = undefined;
|
||||
}
|
||||
this._session = undefined;
|
||||
if (this._fetchDataTimeout) {
|
||||
clearTimeout(this._fetchDataTimeout);
|
||||
this._fetchDataTimeout = undefined;
|
||||
@@ -351,51 +342,17 @@ class HaPanelApp extends LitElement {
|
||||
if (this._sessionKeepAlive) {
|
||||
clearInterval(this._sessionKeepAlive);
|
||||
}
|
||||
this._session = { slug: addonSlug, session };
|
||||
this._sessionKeepAlive = window.setInterval(this._refreshSession, 60000);
|
||||
this._sessionKeepAlive = window.setInterval(async () => {
|
||||
try {
|
||||
await validateHassioSession(this.hass, session);
|
||||
} catch (_err: any) {
|
||||
session = await createHassioSession(this.hass, addonSlug);
|
||||
}
|
||||
}, 60000);
|
||||
|
||||
this._addon = addon;
|
||||
}
|
||||
|
||||
// The keep-alive timer does not run while the device sleeps, so the session
|
||||
// may have expired by the time the page is visible again. Refresh it right
|
||||
// away instead of leaving the app unreachable until the next tick.
|
||||
// "resume" only fires in Chromium after a frozen page, other browsers rely
|
||||
// on "visibilitychange".
|
||||
private _handleVisibility = () => {
|
||||
if (!document.hidden) {
|
||||
this._refreshSession();
|
||||
}
|
||||
};
|
||||
|
||||
private _refreshSession = (): Promise<void> => {
|
||||
const current = this._session;
|
||||
if (!current) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
if (this._sessionRefresh) {
|
||||
return this._sessionRefresh;
|
||||
}
|
||||
this._sessionRefresh = refreshHassioSession(
|
||||
this.hass,
|
||||
current.slug,
|
||||
current.session
|
||||
)
|
||||
.then((session) => {
|
||||
// the panel may have switched to another app meanwhile
|
||||
if (this._session === current) {
|
||||
this._session = { slug: current.slug, session };
|
||||
}
|
||||
})
|
||||
.catch((_err: any) => {
|
||||
// Connection to Home Assistant is gone, the next refresh will retry
|
||||
})
|
||||
.finally(() => {
|
||||
this._sessionRefresh = undefined;
|
||||
});
|
||||
return this._sessionRefresh;
|
||||
};
|
||||
|
||||
private async _checkLoaded(ev: Event): Promise<void> {
|
||||
const iframe = ev.target as HTMLIFrameElement;
|
||||
|
||||
|
||||
@@ -816,7 +816,7 @@ class SupervisorAppInfo extends MobileAwareMixin(LitElement) {
|
||||
this._currentAddon.version
|
||||
? html`
|
||||
<wa-divider></wa-divider>
|
||||
<ha-row-item wrap-supporting-text>
|
||||
<ha-row-item>
|
||||
<span slot="headline">
|
||||
${this.i18n.localize(
|
||||
"ui.panel.config.apps.dashboard.option.boot.title"
|
||||
@@ -842,7 +842,7 @@ class SupervisorAppInfo extends MobileAwareMixin(LitElement) {
|
||||
${
|
||||
this._currentAddon.startup !== "once"
|
||||
? html`
|
||||
<ha-row-item wrap-supporting-text>
|
||||
<ha-row-item>
|
||||
<span slot="headline">
|
||||
${this.i18n.localize(
|
||||
"ui.panel.config.apps.dashboard.option.watchdog.title"
|
||||
@@ -867,7 +867,7 @@ class SupervisorAppInfo extends MobileAwareMixin(LitElement) {
|
||||
`
|
||||
: nothing
|
||||
}
|
||||
<ha-row-item wrap-supporting-text>
|
||||
<ha-row-item>
|
||||
<span slot="headline">
|
||||
${this.i18n.localize(
|
||||
"ui.panel.config.apps.dashboard.option.auto_update.title"
|
||||
@@ -893,7 +893,7 @@ class SupervisorAppInfo extends MobileAwareMixin(LitElement) {
|
||||
!this._computeCannotIngressSidebar &&
|
||||
this._currentAddon.ingress
|
||||
? html`
|
||||
<ha-row-item wrap-supporting-text>
|
||||
<ha-row-item>
|
||||
<span slot="headline">
|
||||
${this.i18n.localize(
|
||||
"ui.panel.config.apps.dashboard.option.ingress_panel.title"
|
||||
@@ -923,7 +923,7 @@ class SupervisorAppInfo extends MobileAwareMixin(LitElement) {
|
||||
${
|
||||
this._computeUsesProtectedOptions
|
||||
? html`
|
||||
<ha-row-item wrap-supporting-text>
|
||||
<ha-row-item>
|
||||
<span slot="headline">
|
||||
${this.i18n.localize(
|
||||
"ui.panel.config.apps.dashboard.option.protected.title"
|
||||
@@ -954,7 +954,7 @@ class SupervisorAppInfo extends MobileAwareMixin(LitElement) {
|
||||
${
|
||||
this._currentAddon.version && this._currentAddon.state === "started"
|
||||
? html`<wa-divider></wa-divider>
|
||||
<ha-row-item wrap-supporting-text>
|
||||
<ha-row-item>
|
||||
<span slot="supporting-text">
|
||||
${this.i18n.localize(
|
||||
"ui.panel.config.apps.dashboard.hostname"
|
||||
@@ -1630,6 +1630,10 @@ class SupervisorAppInfo extends MobileAwareMixin(LitElement) {
|
||||
color: var(--ha-color-text-secondary);
|
||||
}
|
||||
|
||||
.controls ha-row-item::part(supporting-text) {
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.controls .content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { CSSResultGroup, PropertyValues } from "lit";
|
||||
import type { CSSResultGroup } from "lit";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { fireEvent } from "../../../common/dom/fire_event";
|
||||
@@ -29,10 +29,6 @@ import type {
|
||||
AreaRegistryEntryMutableParams,
|
||||
} from "../../../data/area/area_registry";
|
||||
import { deleteAreaRegistryEntry } from "../../../data/area/area_registry";
|
||||
import {
|
||||
getAreaIconSuggestions,
|
||||
ROOM_ICONS,
|
||||
} from "../../../data/area_icon_suggestions";
|
||||
import {
|
||||
SENSOR_DEVICE_CLASS_HUMIDITY,
|
||||
SENSOR_DEVICE_CLASS_TEMPERATURE,
|
||||
@@ -100,10 +96,6 @@ class DialogAreaDetail
|
||||
|
||||
@state() private _submitting = false;
|
||||
|
||||
@state() private _suggestedIcons?: string[];
|
||||
|
||||
private _iconFollowsName = false;
|
||||
|
||||
@state() private _open = false;
|
||||
|
||||
@state() private _suggestionInclude: MetadataSuggestionInclude = {
|
||||
@@ -136,7 +128,6 @@ class DialogAreaDetail
|
||||
this._temperatureEntity = null;
|
||||
this._humidityEntity = null;
|
||||
}
|
||||
this._iconFollowsName = !this._params.entry;
|
||||
this._open = true;
|
||||
this._initDirtyTracking({ type: "deep" }, this._currentState());
|
||||
await this.updateComplete;
|
||||
@@ -160,30 +151,6 @@ class DialogAreaDetail
|
||||
return true;
|
||||
}
|
||||
|
||||
protected willUpdate(changedProps: PropertyValues) {
|
||||
super.willUpdate(changedProps);
|
||||
if (changedProps.has("_name") || changedProps.has("_aliases")) {
|
||||
this._updateSuggestedIcons();
|
||||
}
|
||||
}
|
||||
|
||||
private _updateSuggestedIcons() {
|
||||
const icons = getAreaIconSuggestions(
|
||||
[this._name ?? "", ...(this._aliases ?? [])],
|
||||
this.hass.localize
|
||||
);
|
||||
this._suggestedIcons = icons;
|
||||
if (this._iconFollowsName) {
|
||||
const untouched = !this.isDirtyState;
|
||||
this._icon = icons[0] ?? null;
|
||||
if (untouched) {
|
||||
this._initDirtyTracking({ type: "deep" }, this._currentState());
|
||||
} else {
|
||||
this._updateDirtyState(this._currentState());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private _entityName(entityId: string | null): string | null {
|
||||
const stateObj = entityId ? this.hass.states[entityId] : undefined;
|
||||
return stateObj ? this.hass.formatEntityName(stateObj) : null;
|
||||
@@ -226,7 +193,6 @@ class DialogAreaDetail
|
||||
.value=${this._icon}
|
||||
@value-changed=${this._iconChanged}
|
||||
.label=${this.hass.localize("ui.panel.config.areas.editor.icon")}
|
||||
.suggestedIcons=${this._suggestedIcons}
|
||||
></ha-icon-picker>
|
||||
|
||||
<ha-floor-picker
|
||||
@@ -334,7 +300,6 @@ class DialogAreaDetail
|
||||
this._suggestionInclude = {
|
||||
...this._suggestionInclude,
|
||||
name: this._name.trim() === "",
|
||||
room: !this._icon || this._iconFollowsName,
|
||||
};
|
||||
|
||||
return generateMetadataSuggestionTask<{
|
||||
@@ -384,11 +349,6 @@ class DialogAreaDetail
|
||||
this._floor = processed.floor;
|
||||
}
|
||||
|
||||
if (processed.room && (!this._icon || this._iconFollowsName)) {
|
||||
this._icon = ROOM_ICONS[processed.room][0];
|
||||
this._iconFollowsName = false;
|
||||
}
|
||||
|
||||
this._updateDirtyState(this._currentState());
|
||||
}
|
||||
|
||||
@@ -504,7 +464,6 @@ class DialogAreaDetail
|
||||
private _iconChanged(ev) {
|
||||
this._error = undefined;
|
||||
this._icon = ev.detail.value;
|
||||
this._iconFollowsName = false;
|
||||
this._updateDirtyState(this._currentState());
|
||||
}
|
||||
|
||||
|
||||
@@ -6,10 +6,8 @@ import { consume } from "../../../../../common/decorators/consume";
|
||||
import { ensureArray } from "../../../../../common/array/ensure-array";
|
||||
import { fireEvent } from "../../../../../common/dom/fire_event";
|
||||
import { capitalizeFirstLetter } from "../../../../../common/string/capitalize-first-letter";
|
||||
import "../../../../../components/animation/ha-fade-in";
|
||||
import "../../../../../components/ha-alert";
|
||||
import "../../../../../components/ha-button";
|
||||
import "../../../../../components/ha-spinner";
|
||||
import "../../../../../components/ha-svg-icon";
|
||||
import "../../../../../components/ha-trigger-icon";
|
||||
import "../../../../../components/item/ha-list-item-option";
|
||||
@@ -19,7 +17,6 @@ import type { TriggerCondition } from "../../../../../data/automation";
|
||||
import {
|
||||
automationTriggerContext,
|
||||
hasCustomTriggerId,
|
||||
triggerOptionsResolved,
|
||||
type AutomationTriggerContext,
|
||||
type TriggerIdOption,
|
||||
} from "../../trigger/automation-trigger-id";
|
||||
@@ -56,33 +53,16 @@ export class HaTriggerCondition extends LitElement {
|
||||
const selectedIds = (ensureArray(this.condition.id) ?? []).filter(Boolean);
|
||||
const triggerIdOptions = this._triggers?.options ?? [];
|
||||
const missingIds = this._missingIds(this.condition.id, triggerIdOptions);
|
||||
const status = this._triggers?.blueprintStatus;
|
||||
const resolved = triggerOptionsResolved(this._triggers);
|
||||
|
||||
if (!triggerIdOptions.length && !selectedIds.length) {
|
||||
switch (status) {
|
||||
case "loading":
|
||||
return html`<ha-fade-in .delay=${500}>
|
||||
<ha-spinner size="small"></ha-spinner>
|
||||
</ha-fade-in>`;
|
||||
case "failed":
|
||||
return this.hass.localize(
|
||||
"ui.panel.config.automation.editor.conditions.type.trigger.blueprint_triggers_unavailable"
|
||||
);
|
||||
case "loaded":
|
||||
return this.hass.localize(
|
||||
"ui.panel.config.automation.editor.conditions.type.trigger.blueprint_no_trigger_ids"
|
||||
);
|
||||
case undefined:
|
||||
return this.hass.localize(
|
||||
"ui.panel.config.automation.editor.conditions.type.trigger.no_triggers"
|
||||
);
|
||||
}
|
||||
return this.hass.localize(
|
||||
"ui.panel.config.automation.editor.conditions.type.trigger.no_triggers"
|
||||
);
|
||||
}
|
||||
|
||||
return html`
|
||||
${
|
||||
resolved && missingIds.length
|
||||
missingIds.length
|
||||
? html`<ha-alert alert-type="warning">
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.automation.editor.conditions.type.trigger.missing_triggers"
|
||||
@@ -126,13 +106,7 @@ export class HaTriggerCondition extends LitElement {
|
||||
appearance="checkbox"
|
||||
>
|
||||
<span slot="start" class="trigger-row-leading">
|
||||
${
|
||||
this._triggers?.showIndices
|
||||
? html`<span class="trigger-index-badge"
|
||||
>${option.index + 1}</span
|
||||
>`
|
||||
: nothing
|
||||
}
|
||||
<span class="trigger-index-badge">${option.index + 1}</span>
|
||||
<ha-trigger-icon
|
||||
.trigger=${
|
||||
"trigger" in option.trigger ? option.trigger.trigger : ""
|
||||
@@ -145,9 +119,7 @@ export class HaTriggerCondition extends LitElement {
|
||||
)}
|
||||
</span>
|
||||
${
|
||||
option.duplicate ||
|
||||
hasCustomTriggerId(option) ||
|
||||
!this._triggers?.showIndices
|
||||
option.duplicate || hasCustomTriggerId(option)
|
||||
? html`<span
|
||||
slot="supporting-text"
|
||||
class="trigger-id ${option.duplicate ? "duplicate" : ""}"
|
||||
@@ -180,22 +152,14 @@ export class HaTriggerCondition extends LitElement {
|
||||
.disabled=${this.disabled}
|
||||
appearance="checkbox"
|
||||
>
|
||||
${
|
||||
resolved
|
||||
? html`<span slot="start" class="missing-trigger-badge">
|
||||
<ha-svg-icon .path=${mdiLinkVariantOff}></ha-svg-icon>
|
||||
<span class="missing-trigger-id">${id}</span>
|
||||
</span>`
|
||||
: nothing
|
||||
}
|
||||
<span slot="start" class="missing-trigger-badge">
|
||||
<ha-svg-icon .path=${mdiLinkVariantOff}></ha-svg-icon>
|
||||
<span class="missing-trigger-id">${id}</span>
|
||||
</span>
|
||||
<span slot="headline">
|
||||
${
|
||||
resolved
|
||||
? this.hass.localize(
|
||||
"ui.panel.config.automation.editor.conditions.type.trigger.missing_trigger"
|
||||
)
|
||||
: id
|
||||
}
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.automation.editor.conditions.type.trigger.missing_trigger"
|
||||
)}
|
||||
</span>
|
||||
</ha-list-item-option>
|
||||
`
|
||||
@@ -233,7 +197,8 @@ export class HaTriggerCondition extends LitElement {
|
||||
? ids
|
||||
: [...ids, id]
|
||||
: ids.filter((_id) => _id !== id);
|
||||
if (this._triggers?.select(this.condition, selectedIds)) {
|
||||
if (this._triggers) {
|
||||
this._triggers.select(this.condition, selectedIds);
|
||||
return;
|
||||
}
|
||||
fireEvent(this, "value-changed", {
|
||||
|
||||
@@ -146,15 +146,6 @@ export class HaAutomationEditor extends AutomationScriptEditorMixin<AutomationCo
|
||||
this._manualEditor?.resetPastedConfig();
|
||||
this._updateConfig(config);
|
||||
},
|
||||
fetchBlueprintTriggers: async ({ path, input }) => {
|
||||
const result = await substituteBlueprint(
|
||||
this.hass,
|
||||
"automation",
|
||||
path,
|
||||
input || {}
|
||||
);
|
||||
return normalizeAutomationConfig(result.substituted_config).triggers;
|
||||
},
|
||||
});
|
||||
|
||||
private _newAutomationId?: string;
|
||||
|
||||
@@ -3,14 +3,11 @@ import type { LitElement, ReactiveController } from "lit";
|
||||
import memoizeOne from "memoize-one";
|
||||
import type {
|
||||
AutomationConfig,
|
||||
BlueprintAutomationConfig,
|
||||
SidebarConfig,
|
||||
Trigger,
|
||||
TriggerCondition,
|
||||
} from "../../../../data/automation";
|
||||
import { ContextSubscriptionController } from "../../../../common/decorators/consume";
|
||||
import { debounce } from "../../../../common/util/debounce";
|
||||
import { deepEqual } from "../../../../common/util/deep-equal";
|
||||
import type { LocalizeFunc } from "../../../../common/translations/localize";
|
||||
import { internationalizationContext } from "../../../../data/context";
|
||||
import { showConfirmationDialog } from "../../../../dialogs/generic/show-dialog-box";
|
||||
@@ -19,15 +16,12 @@ import {
|
||||
automationTriggerContext,
|
||||
cleanupRemovedGeneratedTriggerReferences,
|
||||
cleanupUnusedGeneratedTriggerIds,
|
||||
getBlueprintTriggerIdOptions,
|
||||
getTriggerIdOptions,
|
||||
getExplicitTriggerIds,
|
||||
isGeneratedTriggerId,
|
||||
makeDuplicateTriggerIdsUnique,
|
||||
replaceLeafTrigger,
|
||||
updateTriggerCondition,
|
||||
type TriggerIdOption,
|
||||
type BlueprintTriggersStatus,
|
||||
} from "./automation-trigger-id";
|
||||
import { preserveAutomationRowKeys } from "../ha-automation-sortable-list-mixin";
|
||||
|
||||
@@ -37,10 +31,6 @@ interface AutomationTriggerControllerOptions {
|
||||
canEdit: () => boolean;
|
||||
/** Apply one complete change through the editor's undo and dirty-state handling. */
|
||||
commit: (config: AutomationConfig) => void;
|
||||
/** Resolve a blueprint automation's triggers, with its inputs substituted. */
|
||||
fetchBlueprintTriggers: (
|
||||
useBlueprint: BlueprintAutomationConfig["use_blueprint"]
|
||||
) => Promise<Trigger | Trigger[] | undefined>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,9 +43,6 @@ interface AutomationTriggerControllerOptions {
|
||||
*
|
||||
* The transformation helpers only change configuration. This controller preserves
|
||||
* the corresponding row keys so an open sidebar continues to track the edited row.
|
||||
*
|
||||
* A blueprint automation has no triggers of its own: options come from the
|
||||
* blueprint's substituted triggers, and conditions in its inputs change themselves.
|
||||
*/
|
||||
export class AutomationTriggerController implements ReactiveController {
|
||||
// Only read in event handlers, so it does not need to rerender the host.
|
||||
@@ -67,18 +54,6 @@ export class AutomationTriggerController implements ReactiveController {
|
||||
// changes, so rendering and selection use the same IDs across host updates.
|
||||
private _getTriggerIdOptions = memoizeOne(getTriggerIdOptions);
|
||||
|
||||
private _getBlueprintTriggerIdOptions = memoizeOne(
|
||||
getBlueprintTriggerIdOptions
|
||||
);
|
||||
|
||||
/** The blueprint use whose triggers were last requested. */
|
||||
private _blueprintRequested?: BlueprintAutomationConfig["use_blueprint"];
|
||||
|
||||
private _blueprintTriggers?: Trigger | Trigger[];
|
||||
|
||||
/** "failed" while required inputs are empty. */
|
||||
private _blueprintStatus: BlueprintTriggersStatus = "loading";
|
||||
|
||||
constructor(
|
||||
private _host: LitElement,
|
||||
private _options: AutomationTriggerControllerOptions
|
||||
@@ -103,39 +78,15 @@ export class AutomationTriggerController implements ReactiveController {
|
||||
_host.addController(this);
|
||||
}
|
||||
|
||||
public hostDisconnected() {
|
||||
this._fetchBlueprintTriggers.cancel();
|
||||
this._blueprintRequested = undefined;
|
||||
}
|
||||
|
||||
/** Publish options before descendants render, including after undo or redo. */
|
||||
public hostUpdate() {
|
||||
const config = this._options.getConfig();
|
||||
if (!config) {
|
||||
return;
|
||||
}
|
||||
let options: TriggerIdOption[];
|
||||
let blueprintStatus: BlueprintTriggersStatus | undefined;
|
||||
let showIndices = this._provider.value.showIndices;
|
||||
if ("use_blueprint" in config && config.use_blueprint) {
|
||||
this._requestBlueprintTriggers(config.use_blueprint);
|
||||
options = this._getBlueprintTriggerIdOptions(this._blueprintTriggers);
|
||||
blueprintStatus = this._blueprintStatus;
|
||||
showIndices = false;
|
||||
} else {
|
||||
options = this._getTriggerIdOptions(config.triggers);
|
||||
}
|
||||
if (
|
||||
options !== this._provider.value.options ||
|
||||
blueprintStatus !== this._provider.value.blueprintStatus ||
|
||||
showIndices !== this._provider.value.showIndices
|
||||
) {
|
||||
this._provider.setValue({
|
||||
...this._provider.value,
|
||||
options,
|
||||
blueprintStatus,
|
||||
showIndices,
|
||||
});
|
||||
const options = this._getTriggerIdOptions(config.triggers);
|
||||
if (options !== this._provider.value.options) {
|
||||
this._provider.setValue({ ...this._provider.value, options });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,54 +138,10 @@ export class AutomationTriggerController implements ReactiveController {
|
||||
return cleaned;
|
||||
}
|
||||
|
||||
/** Request the blueprint's triggers again whenever its path or inputs change. */
|
||||
private _requestBlueprintTriggers(
|
||||
useBlueprint: BlueprintAutomationConfig["use_blueprint"]
|
||||
) {
|
||||
if (deepEqual(useBlueprint, this._blueprintRequested)) {
|
||||
return;
|
||||
}
|
||||
if (useBlueprint.path !== this._blueprintRequested?.path) {
|
||||
this._blueprintTriggers = undefined;
|
||||
}
|
||||
this._blueprintStatus = "loading";
|
||||
this._blueprintRequested = useBlueprint;
|
||||
this._fetchBlueprintTriggers(useBlueprint);
|
||||
}
|
||||
|
||||
private _fetchBlueprintTriggers = debounce(
|
||||
async (useBlueprint: BlueprintAutomationConfig["use_blueprint"]) => {
|
||||
let triggers: Trigger | Trigger[] | undefined;
|
||||
try {
|
||||
triggers = await this._options.fetchBlueprintTriggers(useBlueprint);
|
||||
} catch (_err) {
|
||||
if (useBlueprint === this._blueprintRequested) {
|
||||
this._blueprintStatus = "failed";
|
||||
this._host.requestUpdate();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (useBlueprint !== this._blueprintRequested) {
|
||||
return;
|
||||
}
|
||||
this._blueprintTriggers = triggers;
|
||||
this._blueprintStatus = "loaded";
|
||||
this._host.requestUpdate();
|
||||
},
|
||||
500,
|
||||
true
|
||||
);
|
||||
|
||||
private _selectTriggerIds = (
|
||||
condition: TriggerCondition,
|
||||
ids: string[]
|
||||
): boolean => {
|
||||
private _selectTriggerIds = (condition: TriggerCondition, ids: string[]) => {
|
||||
const config = this._options.getConfig();
|
||||
if (config && "use_blueprint" in config) {
|
||||
return false;
|
||||
}
|
||||
if (!config || !this._options.canEdit()) {
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
const triggers = assignGeneratedTriggerIds(
|
||||
config.triggers,
|
||||
@@ -250,7 +157,6 @@ export class AutomationTriggerController implements ReactiveController {
|
||||
// Generated IDs that no condition or action references are no longer in use.
|
||||
// Strip them so the YAML does not accumulate stale identifiers.
|
||||
this._commit(cleanupUnusedGeneratedTriggerIds(updated));
|
||||
return true;
|
||||
};
|
||||
|
||||
private _fixDuplicateTriggerIds = async () => {
|
||||
|
||||
@@ -38,28 +38,13 @@ export interface TriggerIdOption {
|
||||
duplicate: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether a blueprint's substituted triggers are known. While "loading" or
|
||||
* "failed", options keep the last triggers fetched, if any.
|
||||
*/
|
||||
export type BlueprintTriggersStatus = "loaded" | "loading" | "failed";
|
||||
|
||||
/** Controller-provided options and operations for editors, sidebars, and row summaries. */
|
||||
export interface AutomationTriggerContext {
|
||||
options: TriggerIdOption[];
|
||||
/**
|
||||
* Left out for an automation with its own triggers. Set for a blueprint
|
||||
* automation, whose missing IDs can only be flagged once "loaded".
|
||||
*/
|
||||
blueprintStatus?: BlueprintTriggersStatus;
|
||||
/** True while the user is editing a `triggered_by` condition; trigger rows show their index badges only in this state. */
|
||||
showIndices: boolean;
|
||||
/**
|
||||
* Pass the original condition object so identical conditions remain distinguishable.
|
||||
* Return false when the condition is not one of the automation's conditions, as in
|
||||
* a blueprint automation, whose conditions live in its inputs.
|
||||
*/
|
||||
select: (condition: TriggerCondition, ids: string[]) => boolean;
|
||||
/** Pass the original condition object so identical conditions remain distinguishable. */
|
||||
select: (condition: TriggerCondition, ids: string[]) => void;
|
||||
/** Requests confirmation before migrating duplicate IDs throughout the automation. */
|
||||
fixDuplicateIds: () => Promise<void>;
|
||||
/**
|
||||
@@ -69,13 +54,6 @@ export interface AutomationTriggerContext {
|
||||
updateTriggerId: (original: Trigger, updated: Trigger) => boolean;
|
||||
}
|
||||
|
||||
/** Whether options list every trigger, so an ID not among them is really missing. */
|
||||
export const triggerOptionsResolved = (
|
||||
context: AutomationTriggerContext | undefined
|
||||
): boolean =>
|
||||
context?.blueprintStatus === undefined ||
|
||||
context.blueprintStatus === "loaded";
|
||||
|
||||
export const automationTriggerContext =
|
||||
createContext<AutomationTriggerContext>("automationTriggers");
|
||||
|
||||
@@ -162,27 +140,6 @@ export const getTriggerIdOptions = (
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Build options from a blueprint's substituted triggers. The blueprint owns its
|
||||
* triggers, so only those with a stored ID can be referenced, and triggers sharing
|
||||
* an ID are one option: a condition on that ID matches any of them.
|
||||
*/
|
||||
export const getBlueprintTriggerIdOptions = (
|
||||
triggers: Trigger | Trigger[] | undefined
|
||||
): TriggerIdOption[] => {
|
||||
const options: TriggerIdOption[] = [];
|
||||
const seenIds = new Set<string>();
|
||||
flattenTriggers(triggers).forEach((trigger, index) => {
|
||||
const id = getTriggerId(trigger);
|
||||
if (!id || seenIds.has(id)) {
|
||||
return;
|
||||
}
|
||||
seenIds.add(id);
|
||||
options.push({ id, trigger, index, draft: false, duplicate: false });
|
||||
});
|
||||
return options;
|
||||
};
|
||||
|
||||
/**
|
||||
* Transform leaf triggers recursively, retaining list wrappers and scalar/array shape.
|
||||
* Copy only changed branches; callbacks must return replacements rather than mutate leaves.
|
||||
|
||||
@@ -14,7 +14,6 @@ import type { EntityRegistryEntry } from "../../../../data/entity/entity_registr
|
||||
import type { HomeAssistant } from "../../../../types";
|
||||
import {
|
||||
automationTriggerContext,
|
||||
triggerOptionsResolved,
|
||||
type AutomationTriggerContext,
|
||||
} from "./automation-trigger-id";
|
||||
|
||||
@@ -42,7 +41,6 @@ export class HaAutomationTriggerReferences extends LitElement {
|
||||
const missingIds = selectedIds.filter(
|
||||
(id) => !options.some((option) => option.id === id)
|
||||
);
|
||||
const resolved = triggerOptionsResolved(this._triggers);
|
||||
|
||||
if (options.length && !selectedIds.length) {
|
||||
return html`<span class="trigger-reference no-selection">
|
||||
@@ -89,21 +87,17 @@ export class HaAutomationTriggerReferences extends LitElement {
|
||||
</span>
|
||||
`
|
||||
),
|
||||
missingIds.map((id) =>
|
||||
resolved
|
||||
? html`
|
||||
<span class="trigger-reference missing">
|
||||
<ha-svg-icon .path=${mdiLinkVariantOff}></ha-svg-icon>
|
||||
<span>
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.automation.editor.conditions.type.trigger.missing_trigger"
|
||||
)}
|
||||
</span>
|
||||
</span>
|
||||
`
|
||||
: html`<span class="trigger-reference">
|
||||
<span class="trigger-reference-label">${id}</span>
|
||||
</span>`
|
||||
missingIds.map(
|
||||
() => html`
|
||||
<span class="trigger-reference missing">
|
||||
<ha-svg-icon .path=${mdiLinkVariantOff}></ha-svg-icon>
|
||||
<span>
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.automation.editor.conditions.type.trigger.missing_trigger"
|
||||
)}
|
||||
</span>
|
||||
</span>
|
||||
`
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ class HaBackupConfigAddon extends LitElement {
|
||||
protected render() {
|
||||
return html`
|
||||
<ha-list-base>
|
||||
<ha-list-item-base wrap-headline wrap-supporting-text>
|
||||
<ha-list-item-base>
|
||||
<span slot="headline">
|
||||
${this.hass.localize(
|
||||
`ui.panel.config.backup.schedule.update_preference.label`
|
||||
@@ -55,7 +55,7 @@ class HaBackupConfigAddon extends LitElement {
|
||||
]}
|
||||
></ha-select>
|
||||
</ha-list-item-base>
|
||||
<ha-list-item-base wrap-headline wrap-supporting-text>
|
||||
<ha-list-item-base>
|
||||
<span slot="headline">
|
||||
${this.hass.localize(`ui.panel.config.backup.schedule.retention`)}
|
||||
</span>
|
||||
@@ -113,6 +113,10 @@ class HaBackupConfigAddon extends LitElement {
|
||||
ha-list-base {
|
||||
--ha-row-item-padding-inline: 0;
|
||||
}
|
||||
ha-list-item-base::part(headline),
|
||||
ha-list-item-base::part(supporting-text) {
|
||||
white-space: wrap;
|
||||
}
|
||||
ha-select {
|
||||
min-width: 210px;
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ class HaBackupConfigAgents extends LitElement {
|
||||
!this.cloudStatus.active_subscription;
|
||||
|
||||
return html`
|
||||
<ha-list-item-base wrap-headline wrap-supporting-text>
|
||||
<ha-list-item-base>
|
||||
${this._renderAgentIcon(agentId)}
|
||||
<div slot="headline" class="name">${name}</div>
|
||||
${
|
||||
@@ -248,7 +248,7 @@ class HaBackupConfigAgents extends LitElement {
|
||||
);
|
||||
|
||||
return html`
|
||||
<ha-list-item-base wrap-headline>
|
||||
<ha-list-item-base>
|
||||
${this._renderAgentIcon(agentId)}
|
||||
<div slot="headline" class="name">${name}</div>
|
||||
<ha-icon-button
|
||||
@@ -317,6 +317,10 @@ class HaBackupConfigAgents extends LitElement {
|
||||
--mdc-icon-size: 48px;
|
||||
color: var(--primary-text-color);
|
||||
}
|
||||
ha-list-item-base::part(headline),
|
||||
ha-list-item-base::part(supporting-text) {
|
||||
white-space: wrap;
|
||||
}
|
||||
ha-list-item-base::part(end) {
|
||||
gap: var(--ha-space-2);
|
||||
}
|
||||
|
||||
@@ -239,7 +239,7 @@ class HaBackupConfigData extends LitElement {
|
||||
return html`
|
||||
${this._renderSizeEstimate()}
|
||||
<ha-list-base>
|
||||
<ha-list-item-base wrap-headline wrap-supporting-text>
|
||||
<ha-list-item-base>
|
||||
<ha-svg-icon slot="start" .path=${mdiCog}></ha-svg-icon>
|
||||
<span slot="headline">
|
||||
${this.hass.localize("ui.panel.config.backup.data.ha_settings")}
|
||||
@@ -266,7 +266,7 @@ class HaBackupConfigData extends LitElement {
|
||||
|
||||
${
|
||||
this._showDbOption
|
||||
? html`<ha-list-item-base wrap-headline wrap-supporting-text>
|
||||
? html`<ha-list-item-base>
|
||||
<ha-svg-icon slot="start" .path=${mdiChartBox}></ha-svg-icon>
|
||||
<span slot="headline">
|
||||
${this.hass.localize("ui.panel.config.backup.data.history")}
|
||||
@@ -288,7 +288,7 @@ class HaBackupConfigData extends LitElement {
|
||||
${
|
||||
isHassio
|
||||
? html`
|
||||
<ha-list-item-base wrap-headline wrap-supporting-text>
|
||||
<ha-list-item-base>
|
||||
<ha-svg-icon
|
||||
slot="start"
|
||||
.path=${mdiPlayBoxMultiple}
|
||||
@@ -309,7 +309,7 @@ class HaBackupConfigData extends LitElement {
|
||||
></ha-switch>
|
||||
</ha-list-item-base>
|
||||
|
||||
<ha-list-item-base wrap-headline wrap-supporting-text>
|
||||
<ha-list-item-base>
|
||||
<ha-svg-icon slot="start" .path=${mdiFolder}></ha-svg-icon>
|
||||
<span slot="headline">
|
||||
${this.hass.localize(
|
||||
@@ -332,7 +332,7 @@ class HaBackupConfigData extends LitElement {
|
||||
${
|
||||
this._hasLocalAddons(this._addons)
|
||||
? html`
|
||||
<ha-list-item-base wrap-headline wrap-supporting-text>
|
||||
<ha-list-item-base>
|
||||
<ha-svg-icon
|
||||
slot="start"
|
||||
.path=${mdiFolder}
|
||||
@@ -360,7 +360,7 @@ class HaBackupConfigData extends LitElement {
|
||||
${
|
||||
this._addons.length
|
||||
? html`
|
||||
<ha-list-item-base wrap-headline wrap-supporting-text>
|
||||
<ha-list-item-base>
|
||||
<ha-svg-icon
|
||||
slot="start"
|
||||
.path=${mdiPuzzle}
|
||||
@@ -566,6 +566,10 @@ class HaBackupConfigData extends LitElement {
|
||||
ha-list-base {
|
||||
--ha-row-item-padding-inline: 0;
|
||||
}
|
||||
ha-list-item-base::part(headline),
|
||||
ha-list-item-base::part(supporting-text) {
|
||||
white-space: wrap;
|
||||
}
|
||||
ha-list-item-base::part(start) {
|
||||
color: var(--ha-color-text-secondary);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ class HaBackupConfigEncryptionKey extends LitElement {
|
||||
if (this._value) {
|
||||
return html`
|
||||
<ha-list-base>
|
||||
<ha-list-item-base wrap-headline wrap-supporting-text>
|
||||
<ha-list-item-base>
|
||||
<span slot="headline">
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.backup.encryption_key.download_emergency_kit"
|
||||
@@ -48,7 +48,7 @@ class HaBackupConfigEncryptionKey extends LitElement {
|
||||
)}
|
||||
</ha-button>
|
||||
</ha-list-item-base>
|
||||
<ha-list-item-base wrap-headline wrap-supporting-text>
|
||||
<ha-list-item-base>
|
||||
<span slot="headline">
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.backup.encryption_key.show_encryption_key"
|
||||
@@ -70,7 +70,7 @@ class HaBackupConfigEncryptionKey extends LitElement {
|
||||
)}
|
||||
</ha-button>
|
||||
</ha-list-item-base>
|
||||
<ha-list-item-base wrap-headline wrap-supporting-text>
|
||||
<ha-list-item-base>
|
||||
<span slot="headline">
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.backup.encryption_key.change_encryption_key"
|
||||
@@ -99,7 +99,7 @@ class HaBackupConfigEncryptionKey extends LitElement {
|
||||
|
||||
return html`
|
||||
<ha-list-base>
|
||||
<ha-list-item-base wrap-headline wrap-supporting-text>
|
||||
<ha-list-item-base>
|
||||
<span slot="headline">
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.backup.encryption_key.set_encryption_key"
|
||||
@@ -152,6 +152,10 @@ class HaBackupConfigEncryptionKey extends LitElement {
|
||||
ha-list-base {
|
||||
--ha-row-item-padding-inline: 0;
|
||||
}
|
||||
ha-list-item-base::part(headline),
|
||||
ha-list-item-base::part(supporting-text) {
|
||||
white-space: wrap;
|
||||
}
|
||||
ha-button[size="s"] ha-svg-icon {
|
||||
--mdc-icon-size: 16px;
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ class HaBackupConfigRetention extends LitElement {
|
||||
}
|
||||
|
||||
return html`
|
||||
<ha-list-item-base wrap-headline wrap-supporting-text>
|
||||
<ha-list-item-base>
|
||||
<span slot="headline">
|
||||
${
|
||||
this.headline ??
|
||||
@@ -256,6 +256,11 @@ class HaBackupConfigRetention extends LitElement {
|
||||
ha-row-item::part(end) {
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
ha-list-item-base::part(headline),
|
||||
ha-list-item-base::part(supporting-text) {
|
||||
white-space: wrap;
|
||||
}
|
||||
ha-select {
|
||||
min-width: 210px;
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ class HaBackupConfigSchedule extends LitElement {
|
||||
|
||||
return html`
|
||||
<ha-list-base>
|
||||
<ha-list-item-base wrap-headline wrap-supporting-text>
|
||||
<ha-list-item-base>
|
||||
<span slot="headline">
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.backup.schedule.schedule"
|
||||
@@ -154,7 +154,7 @@ class HaBackupConfigSchedule extends LitElement {
|
||||
)}
|
||||
outlined
|
||||
>
|
||||
<ha-row-item wrap-headline class="days">
|
||||
<ha-row-item class="days">
|
||||
<span slot="headline">
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.backup.schedule.backup_every"
|
||||
@@ -186,7 +186,7 @@ class HaBackupConfigSchedule extends LitElement {
|
||||
(data.recurrence === BackupScheduleRecurrence.CUSTOM_DAYS &&
|
||||
data.days.length > 0)
|
||||
? html`
|
||||
<ha-list-item-base wrap-headline wrap-supporting-text>
|
||||
<ha-list-item-base>
|
||||
<span slot="headline">
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.backup.schedule.time"
|
||||
@@ -231,7 +231,7 @@ class HaBackupConfigSchedule extends LitElement {
|
||||
)}
|
||||
outlined
|
||||
>
|
||||
<ha-row-item wrap-headline wrap-supporting-text>
|
||||
<ha-row-item>
|
||||
<span slot="headline">
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.backup.schedule.custom_time_label"
|
||||
@@ -266,7 +266,7 @@ class HaBackupConfigSchedule extends LitElement {
|
||||
${
|
||||
this.supervisor
|
||||
? html`
|
||||
<ha-list-item-base wrap-headline wrap-supporting-text>
|
||||
<ha-list-item-base>
|
||||
<span slot="headline">
|
||||
${this.hass.localize(
|
||||
`ui.panel.config.backup.schedule.update_preference.label`
|
||||
@@ -415,6 +415,12 @@ class HaBackupConfigSchedule extends LitElement {
|
||||
ha-list-base {
|
||||
--ha-row-item-padding-inline: 0;
|
||||
}
|
||||
ha-row-item::part(headline),
|
||||
ha-row-item::part(supporting-text),
|
||||
ha-list-item-base::part(headline),
|
||||
ha-list-item-base::part(supporting-text) {
|
||||
white-space: wrap;
|
||||
}
|
||||
ha-select {
|
||||
min-width: 210px;
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ class HaBackupOverviewBackups extends LitElement {
|
||||
return html`
|
||||
<ha-backup-summary-card .heading=${heading} .status=${status}>
|
||||
<ha-list-base>
|
||||
<ha-list-item-base wrap-headline>
|
||||
<ha-list-item-base>
|
||||
<ha-svg-icon slot="start" .path=${mdiBackupRestore}></ha-svg-icon>
|
||||
<span slot="headline" class=${headline === null ? "skeleton" : ""}
|
||||
>${headline}</span
|
||||
@@ -74,7 +74,7 @@ class HaBackupOverviewBackups extends LitElement {
|
||||
${
|
||||
description || description === null
|
||||
? html`
|
||||
<ha-list-item-base wrap-headline>
|
||||
<ha-list-item-base>
|
||||
<ha-svg-icon
|
||||
slot="start"
|
||||
.path=${mdiCalendar}
|
||||
@@ -367,6 +367,9 @@ class HaBackupOverviewBackups extends LitElement {
|
||||
ha-list-item-base::part(start) {
|
||||
color: var(--ha-color-text-secondary);
|
||||
}
|
||||
ha-list-item-base::part(headline) {
|
||||
white-space: wrap;
|
||||
}
|
||||
span.skeleton {
|
||||
position: relative;
|
||||
display: block;
|
||||
|
||||
@@ -152,7 +152,7 @@ class HaConfigBackupDetails extends LitElement {
|
||||
${
|
||||
CLOUD_AGENT === this.agentId
|
||||
? html`
|
||||
<ha-row-item wrap-supporting-text>
|
||||
<ha-row-item>
|
||||
<span slot="headline">
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.backup.location.encryption.location_encrypted"
|
||||
@@ -179,7 +179,7 @@ class HaConfigBackupDetails extends LitElement {
|
||||
`
|
||||
: encrypted
|
||||
? html`
|
||||
<ha-row-item wrap-supporting-text>
|
||||
<ha-row-item>
|
||||
<span slot="headline">
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.backup.location.encryption.location_encrypted"
|
||||
@@ -213,7 +213,7 @@ class HaConfigBackupDetails extends LitElement {
|
||||
"ui.panel.config.backup.location.encryption.warning_encryption_turn_off_description"
|
||||
)}
|
||||
</ha-alert>
|
||||
<ha-row-item wrap-supporting-text>
|
||||
<ha-row-item>
|
||||
<span slot="headline">
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.backup.location.encryption.location_unencrypted"
|
||||
@@ -333,7 +333,6 @@ class HaConfigBackupDetails extends LitElement {
|
||||
margin: 0 auto;
|
||||
gap: var(--ha-space-6);
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
.card-content {
|
||||
@@ -365,6 +364,9 @@ class HaConfigBackupDetails extends LitElement {
|
||||
ha-backup-data-picker {
|
||||
display: block;
|
||||
}
|
||||
ha-row-item::part(supporting-text) {
|
||||
white-space: wrap;
|
||||
}
|
||||
.dot {
|
||||
display: block;
|
||||
position: relative;
|
||||
|
||||
@@ -170,7 +170,7 @@ export class CloudRemotePref extends LitElement {
|
||||
>
|
||||
<div class="card-content">
|
||||
<ha-list-base>
|
||||
<ha-list-item-base wrap-supporting-text>
|
||||
<ha-list-item-base>
|
||||
<span slot="headline"
|
||||
>${this.hass.localize(
|
||||
"ui.panel.config.cloud.account.remote.external_activation"
|
||||
@@ -187,7 +187,7 @@ export class CloudRemotePref extends LitElement {
|
||||
@change=${this._toggleAllowRemoteEnabledChanged}
|
||||
></ha-switch>
|
||||
</ha-list-item-base>
|
||||
<ha-list-item-base wrap-supporting-text>
|
||||
<ha-list-item-base>
|
||||
<span slot="headline"
|
||||
>${this.hass.localize(
|
||||
"ui.panel.config.cloud.account.remote.certificate_info"
|
||||
@@ -311,6 +311,9 @@ export class CloudRemotePref extends LitElement {
|
||||
ha-list-base {
|
||||
--ha-row-item-padding-inline: 0;
|
||||
}
|
||||
ha-list-item-base::part(supporting-text) {
|
||||
white-space: normal;
|
||||
}
|
||||
ha-tip {
|
||||
max-width: 600px;
|
||||
margin: 0 auto;
|
||||
|
||||
@@ -199,7 +199,7 @@ export class CloudWebhooks extends LitElement {
|
||||
|
||||
private _renderHookRow(entry: Webhook) {
|
||||
return html`
|
||||
<ha-row-item wrap-headline wrap-supporting-text>
|
||||
<ha-row-item>
|
||||
<span slot="headline"
|
||||
>${entry.name}
|
||||
${
|
||||
@@ -374,6 +374,7 @@ export class CloudWebhooks extends LitElement {
|
||||
}
|
||||
ha-row-item::part(headline),
|
||||
ha-row-item::part(supporting-text) {
|
||||
white-space: wrap;
|
||||
word-break: break-all;
|
||||
}
|
||||
`,
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import { dump } from "js-yaml";
|
||||
import type { AITaskStructure, GenDataTaskResult } from "../../../data/ai_task";
|
||||
import type { RoomType } from "../../../data/area_icon_suggestions";
|
||||
import { isRoomType, ROOM_TYPES } from "../../../data/area_icon_suggestions";
|
||||
import type { HomeAssistant } from "../../../types";
|
||||
import type { SuggestWithAIGenerateTask } from "../../../components/ha-suggest-with-ai-button";
|
||||
import {
|
||||
@@ -16,7 +14,6 @@ export interface MetadataSuggestionResult {
|
||||
category?: string;
|
||||
labels?: string[];
|
||||
floor?: string;
|
||||
room?: RoomType;
|
||||
}
|
||||
|
||||
export type MetadataSuggestionDomain =
|
||||
@@ -28,7 +25,6 @@ export interface MetadataSuggestionInclude {
|
||||
categories?: boolean;
|
||||
labels?: boolean;
|
||||
floor?: boolean;
|
||||
room?: boolean;
|
||||
}
|
||||
|
||||
export const SUGGESTION_INCLUDE_DEFAULT: MetadataSuggestionInclude = {
|
||||
@@ -90,7 +86,6 @@ export async function generateMetadataSuggestionTask<T>(
|
||||
// providers reject a select/enum schema with an empty options list.
|
||||
const includeCategories = categoryOptions.length > 0;
|
||||
const includeFloor = floorOptions.length > 0;
|
||||
const includeRoom = Boolean(include.room) && domain === "area";
|
||||
|
||||
const structure: AITaskStructure = {
|
||||
...(include.name && {
|
||||
@@ -144,20 +139,6 @@ export async function generateMetadataSuggestionTask<T>(
|
||||
},
|
||||
},
|
||||
}),
|
||||
...(includeRoom && {
|
||||
room: {
|
||||
description: `The type of room that best matches the ${domain}`,
|
||||
required: false,
|
||||
selector: {
|
||||
select: {
|
||||
options: ROOM_TYPES.map((room) => ({
|
||||
value: room,
|
||||
label: room.replace(/_/g, " "),
|
||||
})),
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
};
|
||||
|
||||
const requestedParts = [
|
||||
@@ -166,7 +147,6 @@ export async function generateMetadataSuggestionTask<T>(
|
||||
includeCategories ? "a category" : null,
|
||||
include.labels ? "labels" : null,
|
||||
includeFloor ? "a floor" : null,
|
||||
includeRoom ? "a room type" : null,
|
||||
].filter((entry): entry is string => entry !== null);
|
||||
|
||||
const categoryLabels: string[] = [
|
||||
@@ -253,10 +233,6 @@ export async function processMetadataSuggestion(
|
||||
const processed: MetadataSuggestionResult = {
|
||||
name: include.name ? result.data.name : undefined,
|
||||
description: include.description ? result.data.description : undefined,
|
||||
room:
|
||||
include.room && result.data.room && isRoomType(result.data.room)
|
||||
? result.data.room
|
||||
: undefined,
|
||||
};
|
||||
|
||||
// Convert category name to ID
|
||||
|
||||
@@ -16,13 +16,7 @@ import type {
|
||||
EnergyPreferencesValidation,
|
||||
EnergyValidationIssue,
|
||||
} from "../../../../data/energy";
|
||||
import {
|
||||
getBatteryEnergyStatIds,
|
||||
getBatteryFlowStatIds,
|
||||
getBatteryName,
|
||||
getBatteryPrimaryStat,
|
||||
saveEnergyPreferences,
|
||||
} from "../../../../data/energy";
|
||||
import { saveEnergyPreferences } from "../../../../data/energy";
|
||||
import type { StatisticsMetaData } from "../../../../data/recorder";
|
||||
import { getStatisticLabel } from "../../../../data/recorder";
|
||||
import {
|
||||
@@ -120,10 +114,8 @@ export class EnergyBatterySettings extends LitElement {
|
||||
? html`
|
||||
<div class="items">
|
||||
${batterySources.map((source) => {
|
||||
const chargeStat =
|
||||
getBatteryEnergyStatIds(source).charge[0];
|
||||
const toEntityState = this.hass.states[chargeStat];
|
||||
const summary = this._directionsSummary(source);
|
||||
const toEntityState =
|
||||
this.hass.states[source.stat_energy_to];
|
||||
return html`
|
||||
<ha-card outlined>
|
||||
<ha-automation-row
|
||||
@@ -147,20 +139,18 @@ export class EnergyBatterySettings extends LitElement {
|
||||
>${this._sourceName(source)}</span
|
||||
>
|
||||
${
|
||||
summary
|
||||
? html`<span class="label secondary"
|
||||
>${summary}</span
|
||||
source.name
|
||||
? nothing
|
||||
: html`<span class="label secondary"
|
||||
>${getStatisticLabel(
|
||||
this.hass.states,
|
||||
this.hass.formatEntityName,
|
||||
source.stat_energy_to,
|
||||
this.statsMetadata?.[
|
||||
source.stat_energy_to
|
||||
]
|
||||
)}</span
|
||||
>`
|
||||
: source.name
|
||||
? nothing
|
||||
: html`<span class="label secondary"
|
||||
>${getStatisticLabel(
|
||||
this.hass.states,
|
||||
this.hass.formatEntityName,
|
||||
chargeStat,
|
||||
this.statsMetadata?.[chargeStat]
|
||||
)}</span
|
||||
>`
|
||||
}
|
||||
</div>
|
||||
<ha-icon-button
|
||||
@@ -198,52 +188,17 @@ export class EnergyBatterySettings extends LitElement {
|
||||
}
|
||||
|
||||
private _sourceName(source: BatterySourceTypeEnergyPreference) {
|
||||
const primary = getBatteryPrimaryStat(source);
|
||||
return (
|
||||
getBatteryName(
|
||||
this.hass.states,
|
||||
this.hass.formatEntityName,
|
||||
source,
|
||||
this.statsMetadata
|
||||
) ||
|
||||
source.name ||
|
||||
getStatisticLabel(
|
||||
this.hass.states,
|
||||
this.hass.formatEntityName,
|
||||
primary,
|
||||
this.statsMetadata?.[primary]
|
||||
source.stat_energy_from,
|
||||
this.statsMetadata?.[source.stat_energy_from]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private _directionsSummary(
|
||||
source: BatterySourceTypeEnergyPreference
|
||||
): string | undefined {
|
||||
const flows = getBatteryFlowStatIds(source);
|
||||
if (!flows) {
|
||||
return undefined;
|
||||
}
|
||||
const key = "ui.panel.config.energy.battery.summary";
|
||||
const charge =
|
||||
flows.grid_to_battery && flows.solar_to_battery
|
||||
? this.hass.localize(`${key}.charges_from_grid_and_solar`)
|
||||
: flows.grid_to_battery
|
||||
? this.hass.localize(`${key}.charges_from_grid`)
|
||||
: flows.solar_to_battery
|
||||
? this.hass.localize(`${key}.charges_from_solar`)
|
||||
: undefined;
|
||||
const discharge =
|
||||
flows.battery_to_home && flows.battery_to_grid
|
||||
? this.hass.localize(`${key}.discharges_to_home_and_grid`)
|
||||
: flows.battery_to_home
|
||||
? this.hass.localize(`${key}.discharges_to_home`)
|
||||
: flows.battery_to_grid
|
||||
? this.hass.localize(`${key}.discharges_to_grid`)
|
||||
: undefined;
|
||||
return charge && discharge
|
||||
? this.hass.localize(`${key}.directions`, { charge, discharge })
|
||||
: charge || discharge;
|
||||
}
|
||||
|
||||
private _addSource() {
|
||||
this._openEditor();
|
||||
}
|
||||
@@ -260,7 +215,7 @@ export class EnergyBatterySettings extends LitElement {
|
||||
|
||||
private _editorHref(source?: BatterySourceTypeEnergyPreference) {
|
||||
return this.listPath
|
||||
? `${this.listPath}/battery/${source ? encodeURIComponent(getBatteryPrimaryStat(source)) : "new"}`
|
||||
? `${this.listPath}/battery/${source ? encodeURIComponent(source.stat_energy_from) : "new"}`
|
||||
: undefined;
|
||||
}
|
||||
|
||||
@@ -268,20 +223,12 @@ export class EnergyBatterySettings extends LitElement {
|
||||
preferences: EnergyPreferences,
|
||||
source?: BatterySourceTypeEnergyPreference
|
||||
): EnergyEditorConfig {
|
||||
const sources = preferences.energy_sources;
|
||||
return {
|
||||
kind: "battery",
|
||||
params: {
|
||||
statsMetadata: this.statsMetadata,
|
||||
source: source ? { ...source } : undefined,
|
||||
battery_sources: sources.filter(isBatterySource),
|
||||
has_grid_import: sources.some(
|
||||
(src) => src.type === "grid" && !!src.stat_energy_from
|
||||
),
|
||||
has_grid_export: sources.some(
|
||||
(src) => src.type === "grid" && !!src.stat_energy_to
|
||||
),
|
||||
has_solar: sources.some((src) => src.type === "solar"),
|
||||
battery_sources: preferences.energy_sources.filter(isBatterySource),
|
||||
saveCallback: (newSource) => this._saveSource(newSource, source),
|
||||
},
|
||||
};
|
||||
@@ -294,9 +241,9 @@ export class EnergyBatterySettings extends LitElement {
|
||||
return index;
|
||||
}
|
||||
// Saving replaces the preferences, after which only the statistic matches
|
||||
const key = getBatteryPrimaryStat(source);
|
||||
return sources.findIndex(
|
||||
(src) => isBatterySource(src) && getBatteryPrimaryStat(src) === key
|
||||
(src) =>
|
||||
isBatterySource(src) && src.stat_energy_from === source.stat_energy_from
|
||||
);
|
||||
}
|
||||
|
||||
@@ -308,7 +255,7 @@ export class EnergyBatterySettings extends LitElement {
|
||||
}
|
||||
const source = this.preferences.energy_sources.find(
|
||||
(src): src is BatterySourceTypeEnergyPreference =>
|
||||
isBatterySource(src) && getBatteryPrimaryStat(src) === key
|
||||
isBatterySource(src) && src.stat_energy_from === key
|
||||
);
|
||||
return (
|
||||
source &&
|
||||
|
||||
@@ -64,33 +64,9 @@ export function integralUnits(
|
||||
return totalUnits.includes(unit) ? { unit_time: "h" } : undefined;
|
||||
}
|
||||
|
||||
export interface PowerIntegral<
|
||||
Energy extends string = "stat_energy_from" | "stat_energy_to",
|
||||
> extends Omit<IntegralRequest, "name"> {
|
||||
export interface PowerIntegral extends Omit<IntegralRequest, "name"> {
|
||||
/** Energy statistic the helper provides. */
|
||||
energy: Energy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the energy statistics of a source that are not set yet and can be
|
||||
* calculated from the power sensor paired with them.
|
||||
*/
|
||||
export function pendingIntegrals<Energy extends string>(
|
||||
states: HomeAssistant["states"],
|
||||
source: Partial<Record<Energy, string | null>>,
|
||||
pairs: readonly (readonly [Energy, string | undefined])[],
|
||||
totalUnits: string[]
|
||||
): PowerIntegral<Energy>[] {
|
||||
return pairs.flatMap(([energy, rate]) => {
|
||||
if (!rate || source[energy]) {
|
||||
return [];
|
||||
}
|
||||
const units = integralUnits(
|
||||
states[rate]?.attributes.unit_of_measurement,
|
||||
totalUnits
|
||||
);
|
||||
return units ? [{ energy, rate, units }] : [];
|
||||
});
|
||||
energy: "stat_energy_from" | "stat_energy_to";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -108,15 +84,21 @@ export function pendingPowerIntegrals(
|
||||
if (powerType !== "two_sensors") {
|
||||
return [];
|
||||
}
|
||||
return pendingIntegrals(
|
||||
states,
|
||||
source,
|
||||
[
|
||||
["stat_energy_from", powerConfig.stat_rate_from],
|
||||
["stat_energy_to", powerConfig.stat_rate_to],
|
||||
],
|
||||
totalUnits
|
||||
);
|
||||
const rates = {
|
||||
stat_energy_from: powerConfig.stat_rate_from,
|
||||
stat_energy_to: powerConfig.stat_rate_to,
|
||||
};
|
||||
return (["stat_energy_from", "stat_energy_to"] as const).flatMap((energy) => {
|
||||
const rate = rates[energy];
|
||||
if (!rate || source[energy]) {
|
||||
return [];
|
||||
}
|
||||
const units = integralUnits(
|
||||
states[rate]?.attributes.unit_of_measurement,
|
||||
totalUnits
|
||||
);
|
||||
return units ? [{ energy, rate, units }] : [];
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,58 +1,8 @@
|
||||
import type {
|
||||
BatteryDirectionsPowerConfig,
|
||||
BatteryDirectionsSourceTypeEnergyPreference,
|
||||
BatterySourceTypeEnergyPreference,
|
||||
PowerConfig,
|
||||
} from "../../../../data/energy";
|
||||
import {
|
||||
getBatteryEnergyStatIds,
|
||||
isBatteryDirections,
|
||||
} from "../../../../data/energy";
|
||||
import type { PowerConfig } from "../../../../data/energy";
|
||||
import { deepEqual } from "../../../../common/util/deep-equal";
|
||||
|
||||
export type PowerType = "none" | "standard" | "inverted" | "two_sensors";
|
||||
|
||||
export type BatteryMode = "total" | "directions";
|
||||
|
||||
export const BATTERY_DIRECTIONS = [
|
||||
{
|
||||
key: "from_grid",
|
||||
energy: "stat_energy_from_grid",
|
||||
power: "stat_rate_from_grid",
|
||||
charge: true,
|
||||
},
|
||||
{
|
||||
key: "from_solar",
|
||||
energy: "stat_energy_from_solar",
|
||||
power: "stat_rate_from_solar",
|
||||
charge: true,
|
||||
},
|
||||
{
|
||||
key: "to_home",
|
||||
energy: "stat_energy_to_home",
|
||||
power: "stat_rate_to_home",
|
||||
charge: false,
|
||||
},
|
||||
{
|
||||
key: "to_grid",
|
||||
energy: "stat_energy_to_grid",
|
||||
power: "stat_rate_to_grid",
|
||||
charge: false,
|
||||
},
|
||||
] as const satisfies readonly {
|
||||
key: string;
|
||||
energy: keyof BatteryDirectionsSourceTypeEnergyPreference;
|
||||
power: keyof BatteryDirectionsPowerConfig;
|
||||
charge: boolean;
|
||||
}[];
|
||||
|
||||
export type BatteryDirection = (typeof BATTERY_DIRECTIONS)[number];
|
||||
|
||||
export const getBatteryMode = (
|
||||
source?: BatterySourceTypeEnergyPreference
|
||||
): BatteryMode | undefined =>
|
||||
source ? (isBatteryDirections(source) ? "directions" : "total") : undefined;
|
||||
|
||||
/**
|
||||
* Extracts the power type from a PowerConfig object.
|
||||
*/
|
||||
@@ -127,9 +77,18 @@ export function buildPowerExcludeList(
|
||||
sources.forEach((entry) => {
|
||||
if (entry.stat_rate) powerIds.push(entry.stat_rate);
|
||||
if (entry.power_config) {
|
||||
powerIds.push(
|
||||
...Object.values(entry.power_config).filter((id): id is string => !!id)
|
||||
);
|
||||
if (entry.power_config.stat_rate) {
|
||||
powerIds.push(entry.power_config.stat_rate);
|
||||
}
|
||||
if (entry.power_config.stat_rate_inverted) {
|
||||
powerIds.push(entry.power_config.stat_rate_inverted);
|
||||
}
|
||||
if (entry.power_config.stat_rate_from) {
|
||||
powerIds.push(entry.power_config.stat_rate_from);
|
||||
}
|
||||
if (entry.power_config.stat_rate_to) {
|
||||
powerIds.push(entry.power_config.stat_rate_to);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -144,62 +103,22 @@ export function buildPowerExcludeList(
|
||||
return powerIds.filter((id) => !currentPowerIds.includes(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the statistics the other batteries use in either mode. The edited
|
||||
* battery can't reuse them.
|
||||
*/
|
||||
export function buildBatteryExcludeList(
|
||||
sources: BatterySourceTypeEnergyPreference[],
|
||||
current?: BatterySourceTypeEnergyPreference
|
||||
): string[] {
|
||||
const currentIndex = current
|
||||
? sources.findIndex((source) => deepEqual(source, current))
|
||||
: -1;
|
||||
return sources.flatMap((source, index) => {
|
||||
if (index === currentIndex) {
|
||||
return [];
|
||||
}
|
||||
const { charge, discharge } = getBatteryEnergyStatIds(source);
|
||||
return [
|
||||
...charge,
|
||||
...discharge,
|
||||
source.stat_rate,
|
||||
...Object.values(source.power_config ?? {}),
|
||||
].filter((id): id is string => !!id);
|
||||
});
|
||||
}
|
||||
|
||||
const isDirectionPowerConfig = (
|
||||
config: PowerConfig | BatteryDirectionsPowerConfig
|
||||
): config is BatteryDirectionsPowerConfig =>
|
||||
BATTERY_DIRECTIONS.some(
|
||||
({ power }) => !!(config as BatteryDirectionsPowerConfig)[power]
|
||||
);
|
||||
|
||||
/**
|
||||
* Returns the entity id of the power sensor the backend generated for a saved
|
||||
* source, if any. Inverted, two sensor and battery direction configs get such
|
||||
* a helper, its entity id is stored in `stat_rate`. Returns nothing while the
|
||||
* config differs from the saved one, as the helper doesn't match the edited
|
||||
* config yet.
|
||||
* source, if any. Inverted and two sensor configs get such a helper, its entity
|
||||
* id is stored in `stat_rate`. Returns nothing while the config differs from the
|
||||
* saved one, as the helper doesn't match the edited config yet.
|
||||
*/
|
||||
export function getPowerHelperEntityId(
|
||||
source:
|
||||
| {
|
||||
stat_rate?: string;
|
||||
power_config?: PowerConfig | BatteryDirectionsPowerConfig;
|
||||
}
|
||||
| undefined,
|
||||
currentPowerConfig: PowerConfig | BatteryDirectionsPowerConfig
|
||||
source: { stat_rate?: string; power_config?: PowerConfig } | undefined,
|
||||
currentPowerConfig: PowerConfig
|
||||
): string | undefined {
|
||||
if (!source?.stat_rate || !source.power_config) {
|
||||
return undefined;
|
||||
}
|
||||
if (!isDirectionPowerConfig(source.power_config)) {
|
||||
const savedPowerType = getPowerTypeFromConfig(source.power_config);
|
||||
if (savedPowerType !== "inverted" && savedPowerType !== "two_sensors") {
|
||||
return undefined;
|
||||
}
|
||||
const savedPowerType = getPowerTypeFromConfig(source.power_config);
|
||||
if (savedPowerType !== "inverted" && savedPowerType !== "two_sensors") {
|
||||
return undefined;
|
||||
}
|
||||
if (!deepEqual(source.power_config, currentPowerConfig)) {
|
||||
return undefined;
|
||||
|
||||
@@ -40,10 +40,6 @@ export interface EnergyHomeSourceEditorParams {
|
||||
export interface EnergyBatterySourceEditorParams {
|
||||
source?: BatterySourceTypeEnergyPreference;
|
||||
battery_sources: BatterySourceTypeEnergyPreference[];
|
||||
/** The sources a battery measured per direction charges from or discharges to */
|
||||
has_grid_import: boolean;
|
||||
has_grid_export: boolean;
|
||||
has_solar: boolean;
|
||||
statsMetadata?: Record<string, StatisticsMetaData>;
|
||||
saveCallback: (source: BatterySourceTypeEnergyPreference) => Promise<void>;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -77,10 +77,7 @@ export class DialogVacuumSegmentMapping
|
||||
if (!this._params) return;
|
||||
|
||||
const entityId = this._params.entityId;
|
||||
this._entry = await getExtendedEntityRegistryEntry(
|
||||
this.hass.callWS,
|
||||
entityId
|
||||
);
|
||||
this._entry = await getExtendedEntityRegistryEntry(this.hass, entityId);
|
||||
|
||||
if (this._entry?.options?.vacuum) {
|
||||
this._areaMapping = this._entry.options.vacuum.area_mapping || {};
|
||||
|
||||
@@ -542,7 +542,7 @@ export class EntityRegistrySettingsEditor extends LitElement {
|
||||
return html`
|
||||
${
|
||||
!this.hideName && this._device
|
||||
? html`<ha-row-item wrap-supporting-text class="main-entity">
|
||||
? html`<ha-row-item class="main-entity">
|
||||
<span slot="headline"
|
||||
>${this.hass.localize(
|
||||
"ui.dialogs.entity_registry.editor.main_entity",
|
||||
@@ -740,7 +740,7 @@ export class EntityRegistrySettingsEditor extends LitElement {
|
||||
${
|
||||
SWITCH_AS_DOMAINS_INVERT.includes(this._switchAsDomain)
|
||||
? html`
|
||||
<ha-row-item wrap-supporting-text>
|
||||
<ha-row-item>
|
||||
<span slot="headline"
|
||||
>${this.hass.localize(
|
||||
"ui.dialogs.entity_registry.editor.invert.label"
|
||||
@@ -1017,7 +1017,7 @@ export class EntityRegistrySettingsEditor extends LitElement {
|
||||
${
|
||||
this._cameraPrefs
|
||||
? html`
|
||||
<ha-row-item wrap-supporting-text>
|
||||
<ha-row-item>
|
||||
<span slot="headline"
|
||||
>${this.hass.localize(
|
||||
"ui.dialogs.entity_registry.editor.stream.preload_stream"
|
||||
@@ -1035,7 +1035,7 @@ export class EntityRegistrySettingsEditor extends LitElement {
|
||||
@change=${this._handleCameraPrefsChanged}
|
||||
></ha-switch>
|
||||
</ha-row-item>
|
||||
<ha-row-item wrap-supporting-text>
|
||||
<ha-row-item>
|
||||
<span slot="headline"
|
||||
>${this.hass.localize(
|
||||
"ui.dialogs.entity_registry.editor.stream.stream_orientation"
|
||||
@@ -1074,7 +1074,6 @@ export class EntityRegistrySettingsEditor extends LitElement {
|
||||
this.helperConfigEntry.domain !== "switch_as_x"
|
||||
? html`
|
||||
<ha-list-item-button
|
||||
wrap-supporting-text
|
||||
class="menu-item"
|
||||
.disabled=${this.disabled}
|
||||
@click=${this._showOptionsFlow}
|
||||
@@ -1107,7 +1106,6 @@ export class EntityRegistrySettingsEditor extends LitElement {
|
||||
: nothing
|
||||
}
|
||||
<ha-list-item-button
|
||||
wrap-supporting-text
|
||||
class="menu-item"
|
||||
.disabled=${this.disabled}
|
||||
@click=${this._handleVoiceAssistantsClicked}
|
||||
@@ -1136,7 +1134,6 @@ export class EntityRegistrySettingsEditor extends LitElement {
|
||||
supportsFeature(stateObj, VacuumEntityFeature.CLEAN_AREA)
|
||||
? html`
|
||||
<ha-list-item-button
|
||||
wrap-supporting-text
|
||||
class="menu-item"
|
||||
.disabled=${this.disabled}
|
||||
@click=${this._handleVacuumSegmentMappingClicked}
|
||||
@@ -1174,7 +1171,7 @@ export class EntityRegistrySettingsEditor extends LitElement {
|
||||
: nothing
|
||||
}
|
||||
|
||||
<ha-row-item wrap-supporting-text>
|
||||
<ha-row-item>
|
||||
<span slot="headline"
|
||||
>${this.hass.localize(
|
||||
"ui.dialogs.entity_registry.editor.enabled_label"
|
||||
@@ -1214,7 +1211,7 @@ export class EntityRegistrySettingsEditor extends LitElement {
|
||||
: nothing
|
||||
}
|
||||
|
||||
<ha-row-item wrap-supporting-text>
|
||||
<ha-row-item>
|
||||
<span slot="headline"
|
||||
>${this.hass.localize(
|
||||
"ui.dialogs.entity_registry.editor.visible_label"
|
||||
@@ -1236,7 +1233,7 @@ export class EntityRegistrySettingsEditor extends LitElement {
|
||||
${
|
||||
this.entry.device_id
|
||||
? html`
|
||||
<ha-row-item wrap-supporting-text class="device-area">
|
||||
<ha-row-item class="device-area">
|
||||
<span slot="headline"
|
||||
>${this.hass.localize(
|
||||
"ui.dialogs.entity_registry.editor.use_device_area"
|
||||
@@ -2016,6 +2013,11 @@ export class EntityRegistrySettingsEditor extends LitElement {
|
||||
ha-input.entityId ha-icon-button:last-child {
|
||||
margin-inline-start: 0;
|
||||
}
|
||||
|
||||
ha-row-item::part(supporting-text),
|
||||
ha-list-item-button::part(supporting-text) {
|
||||
white-space: normal;
|
||||
}
|
||||
ha-row-item {
|
||||
--ha-row-item-padding-inline: 0;
|
||||
}
|
||||
|
||||
@@ -601,7 +601,7 @@ export class DialogHelperDetail extends DirtyStateProviderMixin<
|
||||
try {
|
||||
// The entity ID usually matches the helper ID, unless it was taken
|
||||
const entry = await getExtendedEntityRegistryEntry(
|
||||
this._api.callWS,
|
||||
this._api,
|
||||
`${domain}.${uniqueId}`
|
||||
).catch(() => undefined);
|
||||
if (entry && isCreated(entry)) {
|
||||
|
||||
+2
-11
@@ -127,8 +127,7 @@ class DialogMatterAddDevice extends LitElement {
|
||||
|
||||
private get _waitForCommissioningFinish(): boolean {
|
||||
// When the app supports reporting Matter commissioning status, defer
|
||||
// advancing past the spinner of its own flow until we receive
|
||||
// matter/commission/finish.
|
||||
// advancing past the spinner until we receive matter/commission/finish.
|
||||
return !!this.hass.auth.external?.config.hasMatterStatusReport;
|
||||
}
|
||||
|
||||
@@ -136,13 +135,7 @@ class DialogMatterAddDevice extends LitElement {
|
||||
if (!this._newDevice) {
|
||||
return;
|
||||
}
|
||||
// Only the app's own flow, started from the "new" step, reports back.
|
||||
// The other steps commission through core or another app.
|
||||
if (
|
||||
this._step === "new" &&
|
||||
this._waitForCommissioningFinish &&
|
||||
!this._commissioningFinished
|
||||
) {
|
||||
if (this._waitForCommissioningFinish && !this._commissioningFinished) {
|
||||
return;
|
||||
}
|
||||
this._step = "device_added";
|
||||
@@ -156,8 +149,6 @@ class DialogMatterAddDevice extends LitElement {
|
||||
if (this._newDevice) {
|
||||
// Device already showed up in the registry — ignore the failure signal
|
||||
// and let the user finish the rename flow.
|
||||
this._commissioningFinished = true;
|
||||
this._maybeShowDeviceAdded();
|
||||
return;
|
||||
}
|
||||
showToast(this, {
|
||||
|
||||
+7
-12
@@ -178,7 +178,6 @@ export class MatterConfigDashboard extends LitElement {
|
||||
)}
|
||||
>
|
||||
<ha-list-item-button
|
||||
wrap-headline
|
||||
href=${`/config/devices/dashboard?historyBack=1&config_entry=${this._configEntry?.entry_id}&status=disabled`}
|
||||
>
|
||||
<ha-svg-icon slot="start" .path=${mdiDevices}></ha-svg-icon>
|
||||
@@ -191,7 +190,6 @@ export class MatterConfigDashboard extends LitElement {
|
||||
<ha-icon-next slot="end"></ha-icon-next>
|
||||
</ha-list-item-button>
|
||||
<ha-list-item-button
|
||||
wrap-headline
|
||||
href=${`/config/entities?historyBack=1&config_entry=${this._configEntry?.entry_id}`}
|
||||
>
|
||||
<ha-svg-icon slot="start" .path=${mdiShape}></ha-svg-icon>
|
||||
@@ -218,11 +216,7 @@ export class MatterConfigDashboard extends LitElement {
|
||||
"ui.panel.config.matter.panel.options_title"
|
||||
)}
|
||||
>
|
||||
<ha-list-item-button
|
||||
wrap-headline
|
||||
wrap-supporting-text
|
||||
href="/config/matter/options"
|
||||
>
|
||||
<ha-list-item-button href="/config/matter/options">
|
||||
<ha-svg-icon slot="start" .path=${mdiTune}></ha-svg-icon>
|
||||
<div slot="headline">
|
||||
${this.hass.localize(
|
||||
@@ -238,11 +232,7 @@ export class MatterConfigDashboard extends LitElement {
|
||||
</ha-list-item-button>
|
||||
${
|
||||
isComponentLoaded(this.hass.config, "thread")
|
||||
? html`<ha-list-item-button
|
||||
wrap-headline
|
||||
wrap-supporting-text
|
||||
href="/config/thread"
|
||||
>
|
||||
? html`<ha-list-item-button href="/config/thread">
|
||||
<ha-svg-icon
|
||||
slot="start"
|
||||
.path=${THREAD_ICON}
|
||||
@@ -309,6 +299,11 @@ export class MatterConfigDashboard extends LitElement {
|
||||
max-width: var(--ha-content-width-narrow);
|
||||
}
|
||||
|
||||
ha-list-item-button::part(headline),
|
||||
ha-list-item-button::part(supporting-text) {
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.nav-card {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ class MatterOptionsPage extends LitElement {
|
||||
}
|
||||
${
|
||||
canCommissionMatterExternal(this.hass)
|
||||
? html`<ha-row-item wrap-headline wrap-supporting-text>
|
||||
? html`<ha-row-item>
|
||||
<span slot="headline">
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.matter.panel.mobile_app_commisioning"
|
||||
@@ -80,7 +80,7 @@ class MatterOptionsPage extends LitElement {
|
||||
</ha-row-item>`
|
||||
: nothing
|
||||
}
|
||||
<ha-row-item wrap-headline wrap-supporting-text>
|
||||
<ha-row-item>
|
||||
<span slot="headline">
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.matter.panel.commission_device"
|
||||
@@ -102,7 +102,7 @@ class MatterOptionsPage extends LitElement {
|
||||
)}
|
||||
</ha-button>
|
||||
</ha-row-item>
|
||||
<ha-row-item wrap-headline wrap-supporting-text>
|
||||
<ha-row-item>
|
||||
<span slot="headline">
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.matter.panel.add_shared_device"
|
||||
@@ -124,7 +124,7 @@ class MatterOptionsPage extends LitElement {
|
||||
)}
|
||||
</ha-button>
|
||||
</ha-row-item>
|
||||
<ha-row-item wrap-headline wrap-supporting-text>
|
||||
<ha-row-item>
|
||||
<span slot="headline">
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.matter.panel.set_wifi_credentials"
|
||||
@@ -146,7 +146,7 @@ class MatterOptionsPage extends LitElement {
|
||||
)}
|
||||
</ha-button>
|
||||
</ha-row-item>
|
||||
<ha-row-item wrap-headline wrap-supporting-text>
|
||||
<ha-row-item>
|
||||
<span slot="headline">
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.matter.panel.set_thread_credentials"
|
||||
@@ -320,6 +320,11 @@ class MatterOptionsPage extends LitElement {
|
||||
max-width: var(--ha-content-width-narrow);
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
ha-row-item::part(headline),
|
||||
ha-row-item::part(supporting-text) {
|
||||
white-space: normal;
|
||||
}
|
||||
`,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -221,7 +221,6 @@ export class MQTTConfigPanel extends LitElement {
|
||||
)}
|
||||
>
|
||||
<ha-list-item-button
|
||||
wrap-headline
|
||||
href=${`/config/devices/dashboard?historyBack=1&config_entry=${this._configEntry?.entry_id}&status=disabled`}
|
||||
>
|
||||
<ha-svg-icon slot="start" .path=${mdiDevices}></ha-svg-icon>
|
||||
@@ -233,7 +232,6 @@ export class MQTTConfigPanel extends LitElement {
|
||||
<ha-icon-next slot="end"></ha-icon-next>
|
||||
</ha-list-item-button>
|
||||
<ha-list-item-button
|
||||
wrap-headline
|
||||
href=${`/config/entities?historyBack=1&config_entry=${this._configEntry?.entry_id}`}
|
||||
>
|
||||
<ha-svg-icon slot="start" .path=${mdiShape}></ha-svg-icon>
|
||||
@@ -255,11 +253,7 @@ export class MQTTConfigPanel extends LitElement {
|
||||
<ha-card class="nav-card">
|
||||
<div class="card-content">
|
||||
<ha-list-base>
|
||||
<ha-list-item-button
|
||||
wrap-headline
|
||||
wrap-supporting-text
|
||||
@click=${this._openOptionFlow}
|
||||
>
|
||||
<ha-list-item-button @click=${this._openOptionFlow}>
|
||||
<ha-svg-icon slot="start" .path=${mdiTune}></ha-svg-icon>
|
||||
<div slot="headline">
|
||||
${this.hass.localize("ui.panel.config.mqtt.option_flow")}
|
||||
@@ -271,11 +265,7 @@ export class MQTTConfigPanel extends LitElement {
|
||||
</div>
|
||||
<ha-icon-next slot="end"></ha-icon-next>
|
||||
</ha-list-item-button>
|
||||
<ha-list-item-button
|
||||
wrap-headline
|
||||
wrap-supporting-text
|
||||
@click=${this._openConfigFlow}
|
||||
>
|
||||
<ha-list-item-button @click=${this._openConfigFlow}>
|
||||
<ha-svg-icon slot="start" .path=${mdiMqttLogo}></ha-svg-icon>
|
||||
<div slot="headline">
|
||||
${this.hass.localize("ui.panel.config.mqtt.config_flow")}
|
||||
@@ -450,6 +440,10 @@ export class MQTTConfigPanel extends LitElement {
|
||||
margin: 0 auto var(--ha-space-4);
|
||||
max-width: var(--ha-content-width-narrow);
|
||||
}
|
||||
ha-list-item-button::part(headline),
|
||||
ha-list-item-button::part(supporting-text) {
|
||||
white-space: normal;
|
||||
}
|
||||
ha-select {
|
||||
width: 96px;
|
||||
margin: 0 8px;
|
||||
|
||||
@@ -225,10 +225,12 @@ class MqttSubscribeCard extends LitElement {
|
||||
|
||||
static styles = css`
|
||||
form {
|
||||
padding: var(--ha-space-4) 0 var(--ha-space-8);
|
||||
padding: var(--ha-space-4);
|
||||
padding-bottom: var(--ha-space-8);
|
||||
}
|
||||
.content_subscribe_panel {
|
||||
max-width: var(--ha-content-width-narrow);
|
||||
margin-top: var(--ha-space-6);
|
||||
max-width: 600px;
|
||||
margin: 0 auto;
|
||||
direction: ltr;
|
||||
}
|
||||
|
||||
+2
-1
@@ -159,7 +159,7 @@ class ThreadNetworkInfoPage extends LitElement {
|
||||
if (value === null) {
|
||||
return nothing;
|
||||
}
|
||||
return html`<ha-list-item-base wrap-supporting-text>
|
||||
return html`<ha-list-item-base>
|
||||
<span slot="headline">${label}</span>
|
||||
<span slot="supporting-text">${value}</span>
|
||||
</ha-list-item-base>`;
|
||||
@@ -180,6 +180,7 @@ class ThreadNetworkInfoPage extends LitElement {
|
||||
|
||||
ha-list-item-base::part(supporting-text) {
|
||||
font-size: var(--ha-font-size-m);
|
||||
white-space: normal;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
`,
|
||||
|
||||
@@ -237,7 +237,6 @@ class ZHAConfigDashboard extends LitElement {
|
||||
)}
|
||||
>
|
||||
<ha-list-item-button
|
||||
wrap-headline
|
||||
href=${`/config/devices/dashboard?historyBack=1&config_entry=${this._configEntry?.entry_id}&status=disabled`}
|
||||
>
|
||||
<ha-svg-icon slot="start" .path=${mdiDevices}></ha-svg-icon>
|
||||
@@ -250,7 +249,6 @@ class ZHAConfigDashboard extends LitElement {
|
||||
<ha-icon-next slot="end"></ha-icon-next>
|
||||
</ha-list-item-button>
|
||||
<ha-list-item-button
|
||||
wrap-headline
|
||||
href=${`/config/entities?historyBack=1&config_entry=${this._configEntry?.entry_id}`}
|
||||
>
|
||||
<ha-svg-icon slot="start" .path=${mdiShape}></ha-svg-icon>
|
||||
@@ -262,7 +260,7 @@ class ZHAConfigDashboard extends LitElement {
|
||||
</div>
|
||||
<ha-icon-next slot="end"></ha-icon-next>
|
||||
</ha-list-item-button>
|
||||
<ha-list-item-button wrap-headline href="/config/zha/groups">
|
||||
<ha-list-item-button href="/config/zha/groups">
|
||||
<ha-svg-icon
|
||||
slot="start"
|
||||
.path=${mdiFolderMultipleOutline}
|
||||
@@ -309,11 +307,7 @@ class ZHAConfigDashboard extends LitElement {
|
||||
"ui.panel.config.zha.configuration_page.options_title"
|
||||
)}
|
||||
>
|
||||
<ha-list-item-button
|
||||
wrap-headline
|
||||
wrap-supporting-text
|
||||
href="/config/zha/options"
|
||||
>
|
||||
<ha-list-item-button href="/config/zha/options">
|
||||
<ha-svg-icon slot="start" .path=${mdiTune}></ha-svg-icon>
|
||||
<div slot="headline">
|
||||
${this.hass.localize(
|
||||
@@ -327,11 +321,7 @@ class ZHAConfigDashboard extends LitElement {
|
||||
</div>
|
||||
<ha-icon-next slot="end"></ha-icon-next>
|
||||
</ha-list-item-button>
|
||||
<ha-list-item-button
|
||||
wrap-headline
|
||||
wrap-supporting-text
|
||||
href="/config/zha/network-info"
|
||||
>
|
||||
<ha-list-item-button href="/config/zha/network-info">
|
||||
<ha-svg-icon
|
||||
slot="start"
|
||||
.path=${mdiInformationOutline}
|
||||
@@ -350,10 +340,7 @@ class ZHAConfigDashboard extends LitElement {
|
||||
</ha-list-item-button>
|
||||
${dynamicSections.map(
|
||||
(section) => html`
|
||||
<ha-list-item-button
|
||||
wrap-headline
|
||||
href=${`/config/zha/section/${section}`}
|
||||
>
|
||||
<ha-list-item-button href=${`/config/zha/section/${section}`}>
|
||||
<ha-svg-icon slot="start" .path=${mdiTune}></ha-svg-icon>
|
||||
<div slot="headline">
|
||||
${
|
||||
@@ -377,7 +364,7 @@ class ZHAConfigDashboard extends LitElement {
|
||||
<ha-card class="nav-card">
|
||||
<div class="card-content">
|
||||
<ha-list-base>
|
||||
<ha-list-item-base wrap-headline wrap-supporting-text>
|
||||
<ha-list-item-base>
|
||||
<span slot="headline">
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.zha.configuration_page.download_backup"
|
||||
@@ -402,7 +389,7 @@ class ZHAConfigDashboard extends LitElement {
|
||||
)}
|
||||
</ha-progress-button>
|
||||
</ha-list-item-base>
|
||||
<ha-list-item-base wrap-headline wrap-supporting-text>
|
||||
<ha-list-item-base>
|
||||
<span slot="headline">
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.zha.configuration_page.migrate_radio"
|
||||
@@ -536,6 +523,13 @@ class ZHAConfigDashboard extends LitElement {
|
||||
max-width: var(--ha-content-width-narrow);
|
||||
}
|
||||
|
||||
ha-list-item-base::part(headline),
|
||||
ha-list-item-base::part(supporting-text),
|
||||
ha-list-item-button::part(headline),
|
||||
ha-list-item-button::part(supporting-text) {
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.nav-card .card-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
@@ -54,7 +54,7 @@ class ZHANetworkInfoPage extends LitElement {
|
||||
${
|
||||
this._networkSettings
|
||||
? html`<ha-list-base>
|
||||
<ha-list-item-base wrap-supporting-text>
|
||||
<ha-list-item-base>
|
||||
<span slot="headline"
|
||||
>${this.hass.localize(
|
||||
"ui.panel.config.zha.configuration_page.channel_label"
|
||||
@@ -74,7 +74,7 @@ class ZHANetworkInfoPage extends LitElement {
|
||||
@click=${this._showChannelMigrationDialog}
|
||||
></ha-icon-button>
|
||||
</ha-list-item-base>
|
||||
<ha-list-item-base wrap-supporting-text>
|
||||
<ha-list-item-base>
|
||||
<span slot="headline">PAN ID</span>
|
||||
<span slot="supporting-text"
|
||||
>${
|
||||
@@ -82,7 +82,7 @@ class ZHANetworkInfoPage extends LitElement {
|
||||
}</span
|
||||
>
|
||||
</ha-list-item-base>
|
||||
<ha-list-item-base wrap-supporting-text>
|
||||
<ha-list-item-base>
|
||||
<span slot="headline">Extended PAN ID</span>
|
||||
<span slot="supporting-text"
|
||||
>${
|
||||
@@ -91,13 +91,13 @@ class ZHANetworkInfoPage extends LitElement {
|
||||
}</span
|
||||
>
|
||||
</ha-list-item-base>
|
||||
<ha-list-item-base wrap-supporting-text>
|
||||
<ha-list-item-base>
|
||||
<span slot="headline">Coordinator IEEE</span>
|
||||
<span slot="supporting-text"
|
||||
>${this._networkSettings.settings.node_info.ieee}</span
|
||||
>
|
||||
</ha-list-item-base>
|
||||
<ha-list-item-base wrap-supporting-text>
|
||||
<ha-list-item-base>
|
||||
<span slot="headline"
|
||||
>${this.hass.localize(
|
||||
"ui.panel.config.zha.configuration_page.radio_type"
|
||||
@@ -107,7 +107,7 @@ class ZHANetworkInfoPage extends LitElement {
|
||||
>${this._networkSettings.radio_type}</span
|
||||
>
|
||||
</ha-list-item-base>
|
||||
<ha-list-item-base wrap-supporting-text>
|
||||
<ha-list-item-base>
|
||||
<span slot="headline"
|
||||
>${this.hass.localize(
|
||||
"ui.panel.config.zha.configuration_page.serial_port"
|
||||
@@ -121,7 +121,7 @@ class ZHANetworkInfoPage extends LitElement {
|
||||
this._networkSettings.device.baudrate &&
|
||||
!this._networkSettings.device.path.startsWith("socket://")
|
||||
? html`
|
||||
<ha-list-item-base wrap-supporting-text>
|
||||
<ha-list-item-base>
|
||||
<span slot="headline"
|
||||
>${this.hass.localize(
|
||||
"ui.panel.config.zha.configuration_page.baudrate"
|
||||
@@ -177,6 +177,7 @@ class ZHANetworkInfoPage extends LitElement {
|
||||
|
||||
ha-list-item-base::part(supporting-text) {
|
||||
font-size: var(--ha-font-size-m);
|
||||
white-space: normal;
|
||||
}
|
||||
`,
|
||||
];
|
||||
|
||||
@@ -116,7 +116,7 @@ class ZHAOptionsPage extends LitElement {
|
||||
this._configuration
|
||||
? html`
|
||||
<ha-list-base>
|
||||
<ha-list-item-base wrap-headline wrap-supporting-text>
|
||||
<ha-list-item-base>
|
||||
<span slot="headline"
|
||||
>${this.hass.localize(
|
||||
"ui.panel.config.zha.configuration_page.enable_identify_on_join_label"
|
||||
@@ -136,7 +136,7 @@ class ZHAOptionsPage extends LitElement {
|
||||
@change=${this._enableIdentifyOnJoinChanged}
|
||||
></ha-switch>
|
||||
</ha-list-item-base>
|
||||
<ha-list-item-base wrap-headline wrap-supporting-text>
|
||||
<ha-list-item-base>
|
||||
<span slot="headline"
|
||||
>${this.hass.localize(
|
||||
"ui.panel.config.zha.configuration_page.default_light_transition_label"
|
||||
@@ -161,7 +161,7 @@ class ZHAOptionsPage extends LitElement {
|
||||
<span slot="end">s</span>
|
||||
</ha-input>
|
||||
</ha-list-item-base>
|
||||
<ha-list-item-base wrap-headline wrap-supporting-text>
|
||||
<ha-list-item-base>
|
||||
<span slot="headline"
|
||||
>${this.hass.localize(
|
||||
"ui.panel.config.zha.configuration_page.enhanced_light_transition_label"
|
||||
@@ -181,7 +181,7 @@ class ZHAOptionsPage extends LitElement {
|
||||
@change=${this._enhancedLightTransitionChanged}
|
||||
></ha-switch>
|
||||
</ha-list-item-base>
|
||||
<ha-list-item-base wrap-headline wrap-supporting-text>
|
||||
<ha-list-item-base>
|
||||
<span slot="headline"
|
||||
>${this.hass.localize(
|
||||
"ui.panel.config.zha.configuration_page.light_transitioning_flag_label"
|
||||
@@ -201,7 +201,7 @@ class ZHAOptionsPage extends LitElement {
|
||||
@change=${this._lightTransitioningFlagChanged}
|
||||
></ha-switch>
|
||||
</ha-list-item-base>
|
||||
<ha-list-item-base wrap-headline wrap-supporting-text>
|
||||
<ha-list-item-base>
|
||||
<span slot="headline"
|
||||
>${this.hass.localize(
|
||||
"ui.panel.config.zha.configuration_page.group_members_assume_state_label"
|
||||
@@ -221,7 +221,7 @@ class ZHAOptionsPage extends LitElement {
|
||||
@change=${this._groupMembersAssumeStateChanged}
|
||||
></ha-switch>
|
||||
</ha-list-item-base>
|
||||
<ha-list-item-base wrap-headline wrap-supporting-text>
|
||||
<ha-list-item-base>
|
||||
<span slot="headline"
|
||||
>${this.hass.localize(
|
||||
"ui.panel.config.zha.configuration_page.consider_unavailable_mains_label"
|
||||
@@ -265,7 +265,7 @@ class ZHAOptionsPage extends LitElement {
|
||||
`
|
||||
: nothing
|
||||
}
|
||||
<ha-list-item-base wrap-headline wrap-supporting-text>
|
||||
<ha-list-item-base>
|
||||
<span slot="headline"
|
||||
>${this.hass.localize(
|
||||
"ui.panel.config.zha.configuration_page.consider_unavailable_battery_label"
|
||||
@@ -309,7 +309,7 @@ class ZHAOptionsPage extends LitElement {
|
||||
`
|
||||
: nothing
|
||||
}
|
||||
<ha-list-item-base wrap-headline wrap-supporting-text>
|
||||
<ha-list-item-base>
|
||||
<span slot="headline"
|
||||
>${this.hass.localize(
|
||||
"ui.panel.config.zha.configuration_page.enable_mains_startup_polling_label"
|
||||
@@ -463,6 +463,11 @@ class ZHAOptionsPage extends LitElement {
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
ha-list-item-base::part(headline),
|
||||
ha-list-item-base::part(supporting-text) {
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
ha-select,
|
||||
ha-input {
|
||||
min-width: 210px;
|
||||
|
||||
+6
-1
@@ -78,7 +78,7 @@ class ZWaveJSControllerStatistics extends SubscribeMixin(LitElement) {
|
||||
|
||||
private _renderStat(key: string) {
|
||||
return html`
|
||||
<ha-list-item-base wrap-headline wrap-supporting-text>
|
||||
<ha-list-item-base>
|
||||
<span slot="headline">
|
||||
${this.hass.localize(
|
||||
`ui.panel.config.zwave_js.dashboard.statistics.${key}.label`
|
||||
@@ -104,6 +104,11 @@ class ZWaveJSControllerStatistics extends SubscribeMixin(LitElement) {
|
||||
max-width: var(--ha-content-width-narrow);
|
||||
}
|
||||
|
||||
ha-list-item-base::part(headline),
|
||||
ha-list-item-base::part(supporting-text) {
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
span[slot="end"] {
|
||||
font-size: 0.95em;
|
||||
color: var(--primary-text-color);
|
||||
|
||||
+5
-4
@@ -50,7 +50,7 @@ class ZWaveJSNetworkInfoPage extends LitElement {
|
||||
${
|
||||
this._network
|
||||
? html`<ha-list-base>
|
||||
<ha-list-item-base wrap-supporting-text>
|
||||
<ha-list-item-base>
|
||||
<span slot="headline">
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.zwave_js.dashboard.home_id"
|
||||
@@ -66,7 +66,7 @@ class ZWaveJSNetworkInfoPage extends LitElement {
|
||||
}
|
||||
</span>
|
||||
</ha-list-item-base>
|
||||
<ha-list-item-base wrap-supporting-text>
|
||||
<ha-list-item-base>
|
||||
<span slot="headline">
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.zwave_js.dashboard.driver_version"
|
||||
@@ -76,7 +76,7 @@ class ZWaveJSNetworkInfoPage extends LitElement {
|
||||
${this._network.client.driver_version}
|
||||
</span>
|
||||
</ha-list-item-base>
|
||||
<ha-list-item-base wrap-supporting-text>
|
||||
<ha-list-item-base>
|
||||
<span slot="headline">
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.zwave_js.dashboard.server_version"
|
||||
@@ -86,7 +86,7 @@ class ZWaveJSNetworkInfoPage extends LitElement {
|
||||
${this._network.client.server_version}
|
||||
</span>
|
||||
</ha-list-item-base>
|
||||
<ha-list-item-base wrap-supporting-text>
|
||||
<ha-list-item-base>
|
||||
<span slot="headline">
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.zwave_js.dashboard.server_url"
|
||||
@@ -120,6 +120,7 @@ class ZWaveJSNetworkInfoPage extends LitElement {
|
||||
|
||||
ha-list-item-base::part(supporting-text) {
|
||||
font-size: var(--ha-font-size-m);
|
||||
white-space: normal;
|
||||
}
|
||||
`,
|
||||
];
|
||||
|
||||
@@ -62,7 +62,7 @@ class ZWaveJSOptionsPage extends LitElement {
|
||||
${
|
||||
this._network
|
||||
? html`<ha-list-base>
|
||||
<ha-list-item-base wrap-headline wrap-supporting-text>
|
||||
<ha-list-item-base>
|
||||
<span slot="headline">
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.zwave_js.common.rebuild_network_routes"
|
||||
@@ -85,7 +85,7 @@ class ZWaveJSOptionsPage extends LitElement {
|
||||
)}
|
||||
</ha-button>
|
||||
</ha-list-item-base>
|
||||
<ha-list-item-base wrap-headline wrap-supporting-text>
|
||||
<ha-list-item-base>
|
||||
<span slot="headline">
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.zwave_js.common.remove_node"
|
||||
@@ -149,6 +149,11 @@ class ZWaveJSOptionsPage extends LitElement {
|
||||
max-width: var(--ha-content-width-narrow);
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
ha-list-item-base::part(headline),
|
||||
ha-list-item-base::part(supporting-text) {
|
||||
white-space: normal;
|
||||
}
|
||||
`,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -64,11 +64,7 @@ class HaConfigSectionNetwork extends LitElement {
|
||||
>
|
||||
${NETWORK_BROWSERS.map(
|
||||
(domain) => html`
|
||||
<ha-list-item-button
|
||||
wrap-headline
|
||||
wrap-supporting-text
|
||||
href="/config/${domain}"
|
||||
>
|
||||
<ha-list-item-button href="/config/${domain}">
|
||||
<div slot="headline">
|
||||
${this.hass.localize(
|
||||
`ui.panel.config.network.discovery.${domain}`
|
||||
@@ -108,6 +104,10 @@ class HaConfigSectionNetwork extends LitElement {
|
||||
display: block;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
.discovery-card ha-list-item-button::part(headline),
|
||||
.discovery-card ha-list-item-button::part(supporting-text) {
|
||||
white-space: normal;
|
||||
}
|
||||
`;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { TemplateResult } from "lit";
|
||||
import { html, LitElement } from "lit";
|
||||
import { css, html, LitElement } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import "../../../../components/item/ha-list-item-base";
|
||||
import "../../../../components/ha-switch";
|
||||
@@ -14,7 +14,7 @@ class HaDebugConnectionRow extends LitElement {
|
||||
|
||||
protected render(): TemplateResult {
|
||||
return html`
|
||||
<ha-list-item-base wrap-headline wrap-supporting-text>
|
||||
<ha-list-item-base>
|
||||
<span slot="headline"
|
||||
>${this.hass.localize(
|
||||
"ui.panel.config.tools.tabs.debug.debug_connection.title"
|
||||
@@ -43,6 +43,13 @@ class HaDebugConnectionRow extends LitElement {
|
||||
setDebugConnection(debugConnection);
|
||||
storeState(this.hass);
|
||||
}
|
||||
|
||||
static styles = css`
|
||||
ha-list-item-base::part(headline),
|
||||
ha-list-item-base::part(supporting-text) {
|
||||
white-space: normal;
|
||||
}
|
||||
`;
|
||||
}
|
||||
|
||||
declare global {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { TemplateResult } from "lit";
|
||||
import { html, LitElement } from "lit";
|
||||
import { css, html, LitElement } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import { storage } from "../../../../common/decorators/storage";
|
||||
import { setViewTransitionDisabled } from "../../../../common/util/view-transition";
|
||||
@@ -17,7 +17,7 @@ class HaDebugDisableViewTransitionRow extends LitElement {
|
||||
|
||||
protected render(): TemplateResult {
|
||||
return html`
|
||||
<ha-list-item-base wrap-headline wrap-supporting-text>
|
||||
<ha-list-item-base>
|
||||
<span slot="headline"
|
||||
>${this.hass.localize(
|
||||
"ui.panel.config.tools.tabs.debug.disable_view_transition.title"
|
||||
@@ -41,6 +41,13 @@ class HaDebugDisableViewTransitionRow extends LitElement {
|
||||
this._disabled = (ev.target as HaSwitch).checked;
|
||||
setViewTransitionDisabled(this._disabled);
|
||||
}
|
||||
|
||||
static styles = css`
|
||||
ha-list-item-base::part(headline),
|
||||
ha-list-item-base::part(supporting-text) {
|
||||
white-space: normal;
|
||||
}
|
||||
`;
|
||||
}
|
||||
|
||||
declare global {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { html, LitElement } from "lit";
|
||||
import { css, html, LitElement } from "lit";
|
||||
import { customElement, state } from "lit/decorators";
|
||||
import { consumeLocalize } from "../../../../common/decorators/consume-context-entry";
|
||||
import { storage } from "../../../../common/decorators/storage";
|
||||
@@ -19,7 +19,7 @@ class HaDebugSafeAreaToolRow extends LitElement {
|
||||
|
||||
protected render() {
|
||||
return html`
|
||||
<ha-list-item-base wrap-headline wrap-supporting-text>
|
||||
<ha-list-item-base>
|
||||
<span slot="headline"
|
||||
>${this._localize(
|
||||
"ui.panel.config.tools.tabs.debug.safe_area_tool.title"
|
||||
@@ -42,6 +42,13 @@ class HaDebugSafeAreaToolRow extends LitElement {
|
||||
private _checkedChanged(ev: Event) {
|
||||
this._enabled = (ev.target as HaSwitch).checked;
|
||||
}
|
||||
|
||||
static styles = css`
|
||||
ha-list-item-base::part(headline),
|
||||
ha-list-item-base::part(supporting-text) {
|
||||
white-space: normal;
|
||||
}
|
||||
`;
|
||||
}
|
||||
|
||||
declare global {
|
||||
|
||||
@@ -99,7 +99,7 @@ class HaPanelDevDebug extends SubscribeMixin(LitElement) {
|
||||
}
|
||||
let entity: ExtEntityRegistryEntry | undefined;
|
||||
try {
|
||||
entity = await getExtendedEntityRegistryEntry(this.hass.callWS, id);
|
||||
entity = await getExtendedEntityRegistryEntry(this.hass, id);
|
||||
} catch {
|
||||
// not in the registry
|
||||
}
|
||||
|
||||
@@ -212,7 +212,7 @@ export class AssistPref extends LitElement {
|
||||
)}
|
||||
<ha-svg-icon slot="start" .path=${mdiPlus}></ha-svg-icon>
|
||||
</ha-button>
|
||||
<ha-row-item wrap-headline wrap-supporting-text>
|
||||
<ha-row-item>
|
||||
<span slot="headline"
|
||||
>${this.hass!.localize(
|
||||
"ui.panel.config.voice_assistants.expose.expose_new_entities"
|
||||
@@ -415,6 +415,10 @@ export class AssistPref extends LitElement {
|
||||
a {
|
||||
color: var(--primary-color);
|
||||
}
|
||||
ha-row-item::part(headline),
|
||||
ha-row-item::part(supporting-text) {
|
||||
white-space: normal;
|
||||
}
|
||||
.header-actions {
|
||||
position: absolute;
|
||||
right: 0px;
|
||||
|
||||
@@ -139,7 +139,7 @@ export class CloudAlexaPref extends LitElement {
|
||||
</ha-alert>`
|
||||
: nothing
|
||||
}
|
||||
<ha-row-item wrap-headline wrap-supporting-text>
|
||||
<ha-row-item>
|
||||
<span slot="headline"
|
||||
>${this.hass!.localize(
|
||||
"ui.panel.config.cloud.account.alexa.expose_new_entities"
|
||||
@@ -160,7 +160,7 @@ export class CloudAlexaPref extends LitElement {
|
||||
${
|
||||
alexa_registered
|
||||
? html`
|
||||
<ha-row-item wrap-headline wrap-supporting-text>
|
||||
<ha-row-item>
|
||||
<span slot="headline"
|
||||
>${this.hass!.localize(
|
||||
"ui.panel.config.cloud.account.alexa.enable_state_reporting"
|
||||
@@ -265,6 +265,10 @@ export class CloudAlexaPref extends LitElement {
|
||||
ha-row-item {
|
||||
--ha-row-item-padding-inline: 0;
|
||||
}
|
||||
ha-row-item::part(headline),
|
||||
ha-row-item::part(supporting-text) {
|
||||
white-space: normal;
|
||||
}
|
||||
.header-actions {
|
||||
position: absolute;
|
||||
right: 24px;
|
||||
|
||||
@@ -138,7 +138,7 @@ export class CloudGooglePref extends LitElement {
|
||||
`
|
||||
: nothing
|
||||
}
|
||||
<ha-row-item wrap-headline wrap-supporting-text>
|
||||
<ha-row-item>
|
||||
<span slot="headline"
|
||||
>${this.hass!.localize(
|
||||
"ui.panel.config.cloud.account.google.expose_new_entities"
|
||||
@@ -183,7 +183,7 @@ export class CloudGooglePref extends LitElement {
|
||||
`
|
||||
: nothing
|
||||
}
|
||||
<ha-row-item wrap-headline wrap-supporting-text>
|
||||
<ha-row-item>
|
||||
<span slot="headline"
|
||||
>${this.hass!.localize(
|
||||
"ui.panel.config.cloud.account.google.enable_state_reporting"
|
||||
@@ -201,7 +201,7 @@ export class CloudGooglePref extends LitElement {
|
||||
></ha-switch>
|
||||
</ha-row-item>
|
||||
|
||||
<ha-row-item wrap-headline wrap-supporting-text>
|
||||
<ha-row-item>
|
||||
<span slot="headline"
|
||||
>${this.hass.localize(
|
||||
"ui.panel.config.cloud.account.google.security_devices"
|
||||
@@ -347,6 +347,10 @@ export class CloudGooglePref extends LitElement {
|
||||
ha-row-item {
|
||||
--ha-row-item-padding-inline: 0;
|
||||
}
|
||||
ha-row-item::part(headline),
|
||||
ha-row-item::part(supporting-text) {
|
||||
white-space: normal;
|
||||
}
|
||||
ha-input {
|
||||
width: 250px;
|
||||
margin-top: 8px;
|
||||
|
||||
@@ -193,7 +193,7 @@ export class EntityVoiceSettings extends SubscribeMixin(LitElement) {
|
||||
const exposedToAssist = this.exposed.conversation;
|
||||
|
||||
return html`
|
||||
<ha-row-item wrap-headline>
|
||||
<ha-row-item>
|
||||
<h3 slot="headline">
|
||||
${this.hass.localize("ui.dialogs.voice-settings.expose_header")}
|
||||
</h3>
|
||||
@@ -227,7 +227,7 @@ export class EntityVoiceSettings extends SubscribeMixin(LitElement) {
|
||||
this._googleEntity?.might_2fa;
|
||||
|
||||
return html`
|
||||
<ha-row-item wrap-headline wrap-supporting-text>
|
||||
<ha-row-item>
|
||||
<voice-assistant-brand-icon
|
||||
slot="start"
|
||||
.voiceAssistantId=${key}
|
||||
@@ -324,7 +324,7 @@ export class EntityVoiceSettings extends SubscribeMixin(LitElement) {
|
||||
)}
|
||||
</ha-alert>`
|
||||
: html`
|
||||
<ha-row-item wrap-headline wrap-supporting-text>
|
||||
<ha-row-item>
|
||||
<span slot="headline">${this._computedName(this.entry)}</span>
|
||||
<span slot="supporting-text">
|
||||
${this.hass.localize(
|
||||
@@ -419,7 +419,7 @@ export class EntityVoiceSettings extends SubscribeMixin(LitElement) {
|
||||
);
|
||||
if (this.entry) {
|
||||
const entry = await getExtendedEntityRegistryEntry(
|
||||
this.hass.callWS,
|
||||
this.hass,
|
||||
this.entityId
|
||||
);
|
||||
fireEvent(this, "entity-entry-updated", entry);
|
||||
@@ -437,7 +437,7 @@ export class EntityVoiceSettings extends SubscribeMixin(LitElement) {
|
||||
exposeEntities(this.hass, assistants, [this.entityId], ev.target.checked);
|
||||
if (this.entry) {
|
||||
const entry = await getExtendedEntityRegistryEntry(
|
||||
this.hass.callWS,
|
||||
this.hass,
|
||||
this.entityId
|
||||
);
|
||||
fireEvent(this, "entity-entry-updated", entry);
|
||||
@@ -457,6 +457,10 @@ export class EntityVoiceSettings extends SubscribeMixin(LitElement) {
|
||||
ha-row-item {
|
||||
--ha-row-item-padding-inline: 0;
|
||||
}
|
||||
ha-row-item::part(headline),
|
||||
ha-row-item::part(supporting-text) {
|
||||
white-space: normal;
|
||||
}
|
||||
img {
|
||||
height: 32px;
|
||||
width: 32px;
|
||||
|
||||
Loaded 100 of 154 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user