Compare commits

..

3 Commits

Author SHA1 Message Date
Paulus Schoutsen
8882624618 Merge pull request #11867 from home-assistant/dev 2022-02-26 13:41:41 -08:00
Paulus Schoutsen
ffac3d055e Merge pull request #11848 from home-assistant/dev 2022-02-24 16:37:06 -08:00
Paulus Schoutsen
09f8f816d1 Merge pull request #11809 from home-assistant/dev (#11809)
* Fix config card rtl issues

* Remove optional field from ha-form schema type (#11538)

* Add entity id autocompletion to YAML code editors (#11099)

* Add selectors to ha-form (#11534)

* Allow translate gas total (#11547)

* Migrate combobox to mwc (#11546)

* New date picker (#11555)

* Link via device on device page (#11554)

Co-authored-by: Zack Barett <arnett.zackary@gmail.com>

* Add integration_discovery to discovery sources (#11564)

* Remember filter between navigation (#11565)

* Convert selectors to MWC (#11543)

* Covert area picker to combo-box (#11562)

* Convert entity picker to ha-combo (#11560)

* Convert entity picker to ha-combo

* Update ha-entity-picker.ts

* Handle empty better

* Clear value when no device/area/entity

* Update links on info page (#11590)

* Migrate (input) select entities to mwc (#11591)

* Convert HaFormSchemas to use selectors (#11589)

* Fix number selector (#11585)

* Convert entity-attribute picker to ha-combo-box (#11587)

* Convert icon picker to ha-combobox (#11586)

Co-authored-by: Zack <zackbarett@hey.com>

* Convert area-devices picker (#11588)

* Convert device automation picker to mwc (#11592)

Co-authored-by: Zack <zackbarett@hey.com>

* Fix clearing device in device action (#11594)

* dark mode fixes (#11595)

* Only show stable add-ons in the store if not advanced mode (#11596)

* Convert Automation Action Choose to HA Form (#11597)

* Convert Auatomation Action Choose to HA Form

* remove log

* Remove Import

* Replace checkboxes in list items with `check-list-item` (#11610)

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>

* Make textarea grow on input (#11618)

* Update lit-virtualizer (#11623)

* Convert time inputs to Lit + mwc (#11609)

* Set initial focus for device, area, and entity dialogs (#11622)

* Add aria-label to table headers with no title (#11503)

* Add loadCardHelpers to cast scope (#11616)

* Update code editor to material 3 look (#11628)

* Set button role on button card and handle enter and space (#11627)

* Only load ha-selector when needed (#11630)

* Fix service control for older browsers (#11629)

* Migrate a bunch of paper-dropdowns (#11626)

* Merged too fast for Bram :) Code improv (#11632)

* Add support for opening camera media source (#11633)

Co-authored-by: Zack Barett <zackbarett@hey.com>

* Create error when trying to backup wile system in freeze (#11634)

Co-authored-by: Bram Kragten <mail@bramkragten.nl>

* Add missing type to create device automation/script heading (#11635)

Co-authored-by: Bram Kragten <mail@bramkragten.nl>

* Generate random webhook_id and add copy button (#11568)

Co-authored-by: Bram Kragten <mail@bramkragten.nl>
Co-authored-by: Zack Barett <zackbarett@hey.com>
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>

* Migrate search bar to mwc (#11637)

* fix data-table row handlers (#11638)

* Bunch of fixes and cleanup (#11636)

* State Trigger -> HA Form (#11631)

Co-authored-by: Bram Kragten <mail@bramkragten.nl>

* Allow uploading media (#11615)

* Allow uploading media

* Update path

* Use current item we already have

* Update src/panels/media-browser/ha-panel-media-browser.ts

Co-authored-by: Bram Kragten <mail@bramkragten.nl>

* Use alert dialog and use button for add media

Co-authored-by: Bram Kragten <mail@bramkragten.nl>

* Add Attribute Picker as a selector - add to state trigger (#11641)

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>

* Time Pattern to HA Form (#11648)

* MQTT Trigger to Ha-Form (#11643)

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>

* Convert Sun to Ha Form (#11647)

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>

* Geo Location Trigger to HA - Form (#11644)

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>

* HA Trigger to HA Form (#11645)

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>

* Make HA Form set required to false for selectors (#11649)

* Fix Lovelace Empty Menu when not advanced or admin (#11660)

* Add support for media player assumed state (#11642)

* Improve search and filters on mobile + fix close button in search field (#11662)

Co-authored-by: Zack <zackbarett@hey.com>

* Allow adding Zigbee/Zwave device (#11650)

* Numerical State to HA-Form (#11646)

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>

* Filter fixes (#11664)

* Add WORKSPACE_DIRECTORY environment variable to devcontainer and script.core (#11477)

Co-authored-by: Joakim Sørensen <hi@ludeeus.dev>

* hotfix history view on missing state (#11663)

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>

* Improve robustness of hls media player (#11672)

* Revert compute state display show empty string as unknown (#11677)

* Set initial focus for some more dialogs (#11676)

* Limit types of media that can be uploaded to local media (#11683)

* Don't show toggle always on more info (#11640)

* Add TTS to media browser (#11679)

* Omit Device info and actions for connected controller nodes (#11673)

* Script Editor to Ha Form (#11601)

Co-authored-by: Bram Kragten <mail@bramkragten.nl>

* Another round of paper-dropdown -> mwc-select conversion (#11674)

* Another round of paper-dropdown -> mwc-select conversion

* ha-pick-language-row -> Lit

* Update hui-view-editor.ts

* Cleanup imports

* hassio

* Add explicit imports

* hassio fixes (#11688)

* Dont exclude domain for area and device (#11689)

* Try to keep the browsing stack when changing players in media panel (#11681)

* Allow uploading multiple files (#11687)

* Bumped version to 20220214.0

* Group helpers not in an area in a single card (#11690)

* Improve `stripPrefixFromEntityName` to handle colon and space separator (#11691)

* Display transmitted messages in MQTT debug info dialog (#11531)

* Latest paper-dropdown -> mwc-select conversion (#11692)

* This adds back mobile click accessibility (#11693)

* Updated text part 2 (#11686)

Co-authored-by: Zack Barett <zackbarett@hey.com>

* Set initial focus for lovelace dialogs (#11667)

Co-authored-by: Bram Kragten <mail@bramkragten.nl>

* Migrate all lovelace elements to mwc (#11695)

Co-authored-by: Zack Barett <zackbarett@hey.com>

* Fix import

* Clean up some imports (#11696)

* Convert triple dots to single char in translations (#11697)

* Fixes remote icon state color (#11698)

* Convert scene action to service call (#11705)

* Convert scene action to service call

* fix describeAction

* rename to metadata

* Update script.ts

* Fix mode selection in automation editor (#11707)

* Remove duplicate gallery page (#11711)

* Add bottom padding to config links list with safe-area-inset-bottom (#11704)

* Bump hls.js to v1.1.5 (#11712)

* Make zwave_js config panel inclusion state aware (#11556)

Co-authored-by: Bram Kragten <mail@bramkragten.nl>

* Fix mwc-select in lovelace editors (#11708)

* Add signed add-on capability and adjust max rating (#11703)

* Add support for removing config entry from a device

* Tweak

* Fix lint error

* Tweak

* Prettier

* Add play media action (#11702)

Co-authored-by: Zack Barett <zackbarett@hey.com>
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>

* Debounce refresh the cloud status if Google events happen (#11721)

* Remove custom MQTT delete device button (#11724)

* Apply suggestions from code review

Co-authored-by: Bram Kragten <mail@bramkragten.nl>

* Update src/panels/config/devices/ha-config-device-page.ts

Co-authored-by: Bram Kragten <mail@bramkragten.nl>

* Correct typing

* Prettier

* Remove useless Array.isArray check

* Remove custom Tasmota delete device button (#11725)

* Automation Conditions to conversion to ha-form or mwc (#11727)

* Set initial focus for energy dialogs (#11730)

* Entity Settings Page to MWC 3 (#11694)

* Show why relayer is reconnecting (#11732)

* Change words for trigger condition (#11733)

* Update media player more info (#11734)

* Pass hass to ha-form to enable selectors (#11739)

* Bumped version to 20220220.0

* Add link to the selector docs

* TTS form no longer showed due to import oopsie (#11742)

* Improve logo rendering for playing media in browser (#11741)

* Fix media upload on iOS (#11740)

* Handle inifinity media duration (#11749)

* Show when media is being loaded (#11750)

* Lovelace Entity Card Editor to Ha Form - Adds Theme Selector and HaFormColumn (#11731)

Co-authored-by: Bram Kragten <mail@bramkragten.nl>

* Set initial focus for supervisor dialogs (#11710)

* Convert Automation Actions to mwc/ha-form + other automation items (#11753)

* Selector: remove text value when not required and empty (#11754)

* Convert date-range-picker to mwc (#11755)

* Radio Browser is now added during onboarding (#11756)

* Add support for the media browser My link (#11757)

* Show Home Assistant when creating partial backup (#11758)

* Fix zwave migration (#11751)

* Allow config entries to be reloaded when they are in setup_retry state (#11759)

* Area Card Editor to Ha Form (#11762)

* Fix WebRTC player stream playback when disconnected/connected (#11764)

* set theme to undefined when no theme (#11765)

* Paper input migrations (#11766)

* Only show description when set (#11772)

* Thermostat Editor to HA - Form (#11763)

* Thermostat - Ha Form

* Update hui-thermostat-card-editor.ts

Co-authored-by: Bram Kragten <mail@bramkragten.nl>

* Alarm Card Editor to HA Form (#11760)

* Move to ha-form

* Update hui-alarm-panel-card-editor.ts

Co-authored-by: Bram Kragten <mail@bramkragten.nl>

* Change icons for cover with device_class curtain (#11752)

Co-authored-by: Bram Kragten <mail@bramkragten.nl>

* no need for memoize

* Include scoped custom element polyfill (#11776)

* Show triggered in automation editor (#11771)

Co-authored-by: Bram Kragten <mail@bramkragten.nl>

* Allow changing volume media player entity (#11781)

Co-authored-by: Zack Barett <zackbarett@hey.com>

* Add community section (#11779)

* Bumped version to 20220222.0

* Fix State Condition 'For' Data (#11782)

* entities card editor to MWC (#11785)

* Fix ripple corner radius for button card (#11780)

* Condition Card Editor to MWC (#11783)

* Show number of hidden items (#11786)

* Put volume slider in the middle of the button (#11788)

* Add media management dialog (#11787)

Co-authored-by: Bram Kragten <mail@bramkragten.nl>

* Convert alarm control panel more info (#11791)

* Convert alarm control panel more info

* Update more-info-alarm_control_panel.ts

* Update src/dialogs/more-info/controls/more-info-alarm_control_panel.ts

* Apply suggestions from code review

Co-authored-by: Zack Barett <zackbarett@hey.com>

* import

Co-authored-by: Zack Barett <zackbarett@hey.com>

* Migrate more-info configurator (#11792)

* Migrate more-info configurator

* Update more-info-configurator.ts

* Update src/dialogs/more-info/controls/more-info-configurator.ts

* Update src/dialogs/more-info/controls/more-info-configurator.ts

Co-authored-by: Zack Barett <zackbarett@hey.com>

* Import

Co-authored-by: Zack Barett <zackbarett@hey.com>

* Convert more info lock (#11794)

* Add Margin to Tip (#11790)

Co-authored-by: Bram Kragten <mail@bramkragten.nl>

* Dont render double label on number selector (#11796)

* Input conversion in dev tools (#11795)

* Gauge Editor to Ha Form (#11793)

* Stop spinning when opening media in dialog (#11800)

* Fix Entities picker (#11802)

* Migrate single textfields (#11799)

* Migrate single textfields

* Update ha-config-name-form.ts

* Update dialog-area-registry-detail.ts

* Update manual-automation-editor.ts

* Update manual-automation-editor.ts

* required to number selector fix script

* review

* change repository url and project description (#11801)

* Calendar card to HA Form (#11784)

* Graph Footer to MWC (#11803)

* History Graph Editor to ha form (#11797)

* Glance editor to ha-form (#11804)

* Grid Card to HA Form (#11798)

* Button editor to ha-form (#11808)

* Bumped version to 20220223.0

* mwc-select -> ha-select (#11806)

Co-authored-by: Yosi Levy <yosilevy@gmail.com>
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
Co-authored-by: Yosi Levy <37745463+yosilevy@users.noreply.github.com>
Co-authored-by: Kuba Wolanin <hi@kubawolanin.com>
Co-authored-by: Franck Nijhof <git@frenck.dev>
Co-authored-by: Zack Barett <arnett.zackary@gmail.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
Co-authored-by: Zack <zackbarett@hey.com>
Co-authored-by: Joakim Sørensen <ludeeus@ludeeus.dev>
Co-authored-by: Steve Repsher <steverep@users.noreply.github.com>
Co-authored-by: Patrick ZAJDA <patrick@zajda.fr>
Co-authored-by: Thomas Lovén <thomasloven@gmail.com>
Co-authored-by: Eric Severance <esev@esev.com>
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
Co-authored-by: Shay Levy <levyshay1@gmail.com>
Co-authored-by: Michael <35783820+mib1185@users.noreply.github.com>
Co-authored-by: Joakim Sørensen <hi@ludeeus.dev>
Co-authored-by: lintaba <lintaba@gmail.com>
Co-authored-by: Allen Porter <allen@thebends.org>
Co-authored-by: kpine <keith.pine@gmail.com>
Co-authored-by: Brandon Rothweiler <brandonrothweiler@gmail.com>
Co-authored-by: Erik Montnemery <erik@montnemery.com>
Co-authored-by: Matthias de Baat <matthias.debaat@nabucasa.com>
Co-authored-by: Philip Allgaier <mail@spacegaier.de>
Co-authored-by: Josh McCarty <josh@joshmccarty.com>
Co-authored-by: uvjustin <46082645+uvjustin@users.noreply.github.com>
Co-authored-by: Raman Gupta <7243222+raman325@users.noreply.github.com>
Co-authored-by: Pascal Winters <pascal@famwinters.com>
Co-authored-by: Robin Wittebol <robinwittebol@live.nl>
Co-authored-by: Tomasz <t.jagusz@gmail.com>
2022-02-23 11:11:41 -08:00
42 changed files with 267 additions and 640 deletions

View File

@@ -279,7 +279,7 @@ class DemoHaSelector extends LitElement implements ProvideHassElement {
can_play: true,
can_expand: false,
children_media_class: null,
thumbnail: "https://brands.home-assistant.io/_/image/logo.png",
thumbnail: null,
},
{
title: "movie.mp4",

View File

@@ -110,6 +110,8 @@ class HassioAddonStore extends LitElement {
<div class="search">
<search-input
.hass=${this.hass}
no-label-float
no-underline
.filter=${this._filter}
@value-changed=${this._filterChanged}
></search-input>

View File

@@ -80,6 +80,8 @@ class HassioHardwareDialog extends LitElement {
></ha-icon-button>
<search-input
.hass=${this.hass}
dialogInitialFocus
no-label-float
.filter=${this._filter}
@value-changed=${this._handleSearchChange}
.label=${this._dialogParams.supervisor.localize(

View File

@@ -106,9 +106,6 @@ class HassioRepositoriesDialog extends LitElement {
</paper-item-body>
<div class="delete">
<ha-icon-button
.label=${this._dialogParams!.supervisor.localize(
"dialog.repositories.remove"
)}
.disabled=${usedRepositories.includes(repo.slug)}
.slug=${repo.slug}
.path=${usedRepositories.includes(repo.slug)

View File

@@ -1,12 +1,9 @@
// Compat needs to be first import
import "../../src/resources/compatibility";
import { setCancelSyntheticClickEvents } from "@polymer/polymer/lib/utils/settings";
import "../../src/resources/roboto";
import "../../src/resources/safari-14-attachshadow-patch";
import "./hassio-main";
setCancelSyntheticClickEvents(false);
const styleEl = document.createElement("style");
styleEl.innerHTML = `
body {

View File

@@ -45,6 +45,7 @@ import { showAlertDialog } from "../../../src/dialogs/generic/show-dialog-box";
import "../../../src/layouts/hass-loading-screen";
import "../../../src/layouts/hass-subpage";
import "../../../src/layouts/hass-tabs-subpage";
import { SUPERVISOR_UPDATE_NAMES } from "../../../src/panels/config/dashboard/ha-config-updates";
import { HomeAssistant, Route } from "../../../src/types";
import { addonArchIsSupported, extractChangelog } from "../util/addon";
@@ -56,12 +57,6 @@ declare global {
type updateType = "os" | "supervisor" | "core" | "addon";
const SUPERVISOR_UPDATE_NAMES = {
core: "Home Assistant Core",
os: "Home Assistant Operating System",
supervisor: "Home Assistant Supervisor",
};
const changelogUrl = (
entry: updateType,
version: string

View File

@@ -1,6 +1,6 @@
[metadata]
name = home-assistant-frontend
version = 20220301.0
version = 20220226.0
author = The Home Assistant Authors
author_email = hello@home-assistant.io
license = Apache-2.0

View File

@@ -115,9 +115,6 @@ class DateRangePickerElement extends WrappedElement {
color: var(--primary-text-color);
min-width: initial !important;
}
.daterangepicker:before {
display: none;
}
.daterangepicker:after {
border-bottom: 6px solid var(--card-background-color);
}

View File

@@ -51,11 +51,10 @@ export class HaEntitySelector extends SubscribeMixin(LitElement) {
private _filterEntities = (entity: HassEntity): boolean => {
if (this.selector.entity?.domain) {
const filterDomain = this.selector.entity.domain;
const filterDomainIsArray = Array.isArray(filterDomain);
const entityDomain = computeStateDomain(entity);
if (
(filterDomainIsArray && !filterDomain.includes(entityDomain)) ||
(!filterDomainIsArray && entityDomain !== filterDomain)
(Array.isArray(filterDomain) && !filterDomain.includes(entityDomain)) ||
entityDomain !== filterDomain
) {
return false;
}

View File

@@ -12,7 +12,6 @@ import {
} from "../../data/media-player";
import type { MediaSelector, MediaSelectorValue } from "../../data/selector";
import type { HomeAssistant } from "../../types";
import { brandsUrl, extractDomainFromBrandUrl } from "../../util/brands-url";
import "../ha-alert";
import "../ha-form/ha-form";
import type { HaFormSchema } from "../ha-form/types";
@@ -51,18 +50,6 @@ export class HaMediaSelector extends LitElement {
getSignedPath(this.hass, thumbnail).then((signedPath) => {
this._thumbnailUrl = signedPath.path;
});
} else if (
thumbnail &&
thumbnail.startsWith("https://brands.home-assistant.io")
) {
// The backend is not aware of the theme used by the users,
// so we rewrite the URL to show a proper icon
this._thumbnailUrl = brandsUrl({
domain: extractDomainFromBrandUrl(thumbnail),
type: "icon",
useFallback: true,
darkOptimized: this.hass.themes?.darkMode,
});
} else {
this._thumbnailUrl = thumbnail;
}

View File

@@ -42,7 +42,9 @@ export class HaTab extends LitElement {
@keydown=${this._handleKeyDown}
>
${this.narrow ? html`<slot name="icon"></slot>` : ""}
<span class="name">${this.name}</span>
${!this.narrow || this.active
? html`<span class="name">${this.name}</span>`
: ""}
${this._shouldRenderRipple ? html`<mwc-ripple></mwc-ripple>` : ""}
</div>
`;

View File

@@ -34,24 +34,23 @@ import {
MediaPickedEvent,
MediaPlayerBrowseAction,
} from "../../data/media-player";
import { browseLocalMediaPlayer } from "../../data/media_source";
import { isTTSMediaSource } from "../../data/tts";
import { showAlertDialog } from "../../dialogs/generic/show-dialog-box";
import { installResizeObserver } from "../../panels/lovelace/common/install-resize-observer";
import { haStyle } from "../../resources/styles";
import type { HomeAssistant } from "../../types";
import { brandsUrl, extractDomainFromBrandUrl } from "../../util/brands-url";
import { documentationUrl } from "../../util/documentation-url";
import "../entity/ha-entity-picker";
import "../ha-button-menu";
import "../ha-card";
import type { HaCard } from "../ha-card";
import "../ha-circular-progress";
import "../ha-fab";
import "../ha-icon-button";
import "../ha-svg-icon";
import "./ha-browse-media-tts";
import "../ha-fab";
import { browseLocalMediaPlayer } from "../../data/media_source";
import { isTTSMediaSource } from "../../data/tts";
import type { TtsMediaPickedEvent } from "./ha-browse-media-tts";
import "./ha-browse-media-tts";
declare global {
interface HASSDomEvents {
@@ -682,17 +681,6 @@ export class HaMediaPlayerBrowse extends LitElement {
// Thumbnails served by local API require authentication
const signedPath = await getSignedPath(this.hass, thumbnailUrl);
thumbnailUrl = signedPath.path;
} else if (
thumbnailUrl.startsWith("https://brands.home-assistant.io")
) {
// The backend is not aware of the theme used by the users,
// so we rewrite the URL to show a proper icon
thumbnailUrl = brandsUrl({
domain: extractDomainFromBrandUrl(thumbnailUrl),
type: "icon",
useFallback: true,
darkOptimized: this.hass.themes?.darkMode,
});
}
thumbnailCard.style.backgroundImage = `url(${thumbnailUrl})`;
observer.unobserve(thumbnailCard); // loaded, so no need to observe anymore

View File

@@ -1,4 +1,3 @@
import { HassEntity } from "home-assistant-js-websocket";
import { HomeAssistant } from "../types";
export interface InputDateTime {
@@ -18,19 +17,6 @@ export interface InputDateTimeMutableParams {
has_date: boolean;
}
export const stateToIsoDateString = (entityState: HassEntity) =>
`${entityState.attributes.year || "1970"}-${String(
entityState.attributes.month || "01"
).padStart(2, "0")}-${String(entityState.attributes.day || "01").padStart(
2,
"0"
)}T${String(entityState.attributes.hour || "00").padStart(2, "0")}:${String(
entityState.attributes.minute || "00"
).padStart(2, "0")}:${String(entityState.attributes.second || "00").padStart(
2,
"0"
)}`;
export const setInputDateTimeValue = (
hass: HomeAssistant,
entityId: string,

View File

@@ -0,0 +1,58 @@
import { HomeAssistant } from "../../types";
interface SupervisorBaseAvailableUpdates {
panel_path?: string;
update_type?: string;
version_latest?: string;
}
interface SupervisorAddonAvailableUpdates
extends SupervisorBaseAvailableUpdates {
update_type?: "addon";
icon?: string;
name?: string;
}
interface SupervisorCoreAvailableUpdates
extends SupervisorBaseAvailableUpdates {
update_type?: "core";
}
interface SupervisorOsAvailableUpdates extends SupervisorBaseAvailableUpdates {
update_type?: "os";
}
interface SupervisorSupervisorAvailableUpdates
extends SupervisorBaseAvailableUpdates {
update_type?: "supervisor";
}
export type SupervisorAvailableUpdates =
| SupervisorAddonAvailableUpdates
| SupervisorCoreAvailableUpdates
| SupervisorOsAvailableUpdates
| SupervisorSupervisorAvailableUpdates;
export interface SupervisorAvailableUpdatesResponse {
available_updates: SupervisorAvailableUpdates[];
}
export const fetchSupervisorAvailableUpdates = async (
hass: HomeAssistant
): Promise<SupervisorAvailableUpdates[]> =>
(
await hass.callWS<SupervisorAvailableUpdatesResponse>({
type: "supervisor/api",
endpoint: "/available_updates",
method: "get",
})
).available_updates;
export const refreshSupervisorAvailableUpdates = async (
hass: HomeAssistant
): Promise<void> =>
hass.callWS<void>({
type: "supervisor/api",
endpoint: "/refresh_updates",
method: "post",
});

View File

@@ -1,37 +0,0 @@
import { HomeAssistant } from "../types";
export interface UpdateDescription {
identifier: string;
name: string;
domain: string;
current_version: string;
available_version: string;
changelog_content: string | null;
changelog_url: string | null;
icon_url: string | null;
supports_backup: boolean;
}
export interface SkipUpdateParams {
domain: string;
version: string;
identifier: string;
}
export interface PerformUpdateParams extends SkipUpdateParams {
backup?: boolean;
}
export const fetchUpdateInfo = (
hass: HomeAssistant
): Promise<UpdateDescription[]> => hass.callWS({ type: "update/info" });
export const skipUpdate = (
hass: HomeAssistant,
params: SkipUpdateParams
): Promise<void> => hass.callWS({ type: "update/skip", ...params });
export const performUpdate = (
hass: HomeAssistant,
params: PerformUpdateParams
): Promise<void> => hass.callWS({ type: "update/update", ...params });

View File

@@ -117,17 +117,13 @@ class DataEntryFlowDialog extends LitElement {
);
} catch (err: any) {
this.closeDialog();
let message = err.message || err.body || "Unknown error";
if (typeof message !== "string") {
message = JSON.stringify(message);
}
showAlertDialog(this, {
title: this.hass.localize(
"ui.panel.config.integrations.config_flow.error"
),
text: `${this.hass.localize(
"ui.panel.config.integrations.config_flow.could_not_load"
)}: ${message}`,
)}: ${err.message || err.body}`,
});
return;
}

View File

@@ -4,10 +4,7 @@ import { customElement, property } from "lit/decorators";
import "../../../components/ha-date-input";
import "../../../components/ha-time-input";
import { UNAVAILABLE_STATES, UNKNOWN } from "../../../data/entity";
import {
setInputDateTimeValue,
stateToIsoDateString,
} from "../../../data/input_datetime";
import { setInputDateTimeValue } from "../../../data/input_datetime";
import type { HomeAssistant } from "../../../types";
@customElement("more-info-input_datetime")
@@ -27,7 +24,7 @@ class MoreInfoInputDatetime extends LitElement {
? html`
<ha-date-input
.locale=${this.hass.locale}
.value=${stateToIsoDateString(this.stateObj)}
.value=${`${this.stateObj.attributes.year}-${this.stateObj.attributes.month}-${this.stateObj.attributes.day}`}
.disabled=${UNAVAILABLE_STATES.includes(this.stateObj.state)}
@value-changed=${this._dateChanged}
>

View File

@@ -86,11 +86,11 @@ export class QuickBar extends LitElement {
@state() private _search = "";
@state() private _open = false;
@state() private _opened = false;
@state() private _commandMode = false;
@state() private _opened = false;
@state() private _done = false;
@state() private _narrow = false;
@@ -109,12 +109,12 @@ export class QuickBar extends LitElement {
"all and (max-width: 450px), all and (max-height: 500px)"
).matches;
this._initializeItemsIfNeeded();
this._open = true;
this._opened = true;
}
public closeDialog() {
this._open = false;
this._opened = false;
this._done = false;
this._focusSet = false;
this._filter = "";
this._search = "";
@@ -133,7 +133,7 @@ export class QuickBar extends LitElement {
);
protected render() {
if (!this._open) {
if (!this._opened) {
return html``;
}
@@ -218,26 +218,24 @@ export class QuickBar extends LitElement {
`
: html`
<mwc-list>
${this._opened
? html`<lit-virtualizer
scroller
@keydown=${this._handleListItemKeyDown}
@rangechange=${this._handleRangeChanged}
@click=${this._handleItemClick}
class="ha-scrollbar"
style=${styleMap({
height: this._narrow
? "calc(100vh - 56px)"
: `${Math.min(
items.length * (this._commandMode ? 56 : 72) + 26,
500
)}px`,
})}
.items=${items}
.renderItem=${this._renderItem}
>
</lit-virtualizer>`
: ""}
<lit-virtualizer
scroller
@keydown=${this._handleListItemKeyDown}
@rangechange=${this._handleRangeChanged}
@click=${this._handleItemClick}
class="ha-scrollbar"
style=${styleMap({
height: this._narrow
? "calc(100vh - 56px)"
: `${Math.min(
items.length * (this._commandMode ? 56 : 72) + 26,
this._done ? 500 : 0
)}px`,
})}
.items=${items}
.renderItem=${this._renderItem}
>
</lit-virtualizer>
</mwc-list>
`}
${this._hint ? html`<div class="hint">${this._hint}</div>` : ""}
@@ -254,7 +252,9 @@ export class QuickBar extends LitElement {
}
private _handleOpened() {
this._opened = true;
this.updateComplete.then(() => {
this._done = true;
});
}
private async _handleRangeChanged(e) {
@@ -454,10 +454,9 @@ export class QuickBar extends LitElement {
}
private _handleItemClick(ev) {
const listItem = ev.target.closest("mwc-list-item");
this.processItemAndCloseDialog(
listItem.item,
Number(listItem.getAttribute("index"))
(ev.target as any).item,
Number((ev.target as HTMLElement).getAttribute("index"))
);
}

View File

@@ -1,211 +0,0 @@
import "@material/mwc-button/mwc-button";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { customElement, property, state } from "lit/decorators";
import { fireEvent } from "../../common/dom/fire_event";
import { computeRTL } from "../../common/util/compute_rtl";
import "../../components/ha-alert";
import "../../components/ha-checkbox";
import "../../components/ha-circular-progress";
import { createCloseHeading } from "../../components/ha-dialog";
import "../../components/ha-faded";
import "../../components/ha-formfield";
import "../../components/ha-icon-button";
import "../../components/ha-markdown";
import {
performUpdate,
skipUpdate,
UpdateDescription,
} from "../../data/update";
import { haStyleDialog } from "../../resources/styles";
import type { HomeAssistant } from "../../types";
import { UpdateDialogParams } from "./show-ha-update-dialog";
@customElement("ha-update-dialog")
export class HaUpdateDialog extends LitElement {
@property({ attribute: false }) public hass!: HomeAssistant;
@state() private _opened = false;
@state() private _updating = false;
@state() private _error?: string;
@state() private _update!: UpdateDescription;
_refreshCallback!: () => void;
public async showDialog(dialogParams: UpdateDialogParams): Promise<void> {
this._opened = true;
this._update = dialogParams.update;
this._refreshCallback = dialogParams.refreshCallback;
}
public async closeDialog(): Promise<void> {
this._opened = false;
fireEvent(this, "dialog-closed", { dialog: this.localName });
}
protected render(): TemplateResult {
if (!this._opened) {
return html``;
}
return html`
<ha-dialog
open
@closed=${this.closeDialog}
scrimClickAction
.heading=${createCloseHeading(
this.hass,
this.hass.localize("ui.panel.config.updates.dialog.title", {
name: this._update.name,
})
)}
>
<div>
${this._error
? html`<ha-alert alert-type="error" .rtl=${computeRTL(this.hass)}>
${this._error}
</ha-alert>`
: ""}
${!this._updating
? html`
${this._update.changelog_content
? html`
<ha-faded>
<ha-markdown .content=${this._update.changelog_content}>
</ha-markdown>
</ha-faded>
`
: ""}
${this._update.changelog_url
? html`<a href=${this._update.changelog_url} target="_blank">
Full changelog
</a> `
: ""}
<p>
${this.hass.localize(
"ui.panel.config.updates.dialog.description",
{
name: this._update.name,
version: this._update.current_version,
newest_version: this._update.available_version,
}
)}
</p>
${this._update.supports_backup
? html`
<ha-formfield
.label=${this.hass.localize(
"ui.panel.config.updates.dialog.create_backup"
)}
>
<ha-checkbox checked></ha-checkbox>
</ha-formfield>
`
: ""}
`
: html`<ha-circular-progress alt="Updating" size="large" active>
</ha-circular-progress>
<p class="progress-text">
${this.hass.localize(
"ui.panel.config.updates.dialog.updating",
{
name: this._update.name,
version: this._update.available_version,
}
)}
</p>`}
</div>
${!this._updating
? html`
<mwc-button slot="secondaryAction" @click=${this._skipUpdate}>
${this.hass.localize("ui.common.skip")}
</mwc-button>
<mwc-button
.disabled=${this._updating}
slot="primaryAction"
@click=${this._performUpdate}
>
${this.hass.localize("ui.panel.config.updates.dialog.update")}
</mwc-button>
`
: ""}
</ha-dialog>
`;
}
get _shouldCreateBackup(): boolean {
if (!this._update.supports_backup) {
return false;
}
const checkbox = this.shadowRoot?.querySelector("ha-checkbox");
if (checkbox) {
return checkbox.checked;
}
return true;
}
private async _performUpdate() {
this._error = undefined;
this._updating = true;
try {
await performUpdate(this.hass, {
domain: this._update.domain,
identifier: this._update.identifier,
version: this._update.available_version,
backup: this._shouldCreateBackup,
});
} catch (err: any) {
this._error = err.message;
this._updating = false;
return;
}
this._updating = false;
this._refreshCallback();
this.closeDialog();
}
private async _skipUpdate() {
this._error = undefined;
try {
await skipUpdate(this.hass, {
domain: this._update.domain,
identifier: this._update.identifier,
version: this._update.available_version,
});
} catch (err: any) {
this._error = err.message;
return;
}
this._refreshCallback();
this.closeDialog();
}
static get styles(): CSSResultGroup {
return [
haStyleDialog,
css`
ha-circular-progress {
display: block;
margin: 32px;
text-align: center;
}
.progress-text {
text-align: center;
}
ha-markdown {
padding-bottom: 8px;
}
`,
];
}
}
declare global {
interface HTMLElementTagNameMap {
"ha-update-dialog": HaUpdateDialog;
}
}

View File

@@ -1,18 +0,0 @@
import { fireEvent } from "../../common/dom/fire_event";
import { UpdateDescription } from "../../data/update";
export interface UpdateDialogParams {
update: UpdateDescription;
refreshCallback: () => void;
}
export const showUpdateDialog = (
element: HTMLElement,
dialogParams: UpdateDialogParams
): void => {
fireEvent(element, "show-dialog", {
dialogTag: "ha-update-dialog",
dialogImport: () => import("./ha-update-dialog"),
dialogParams,
});
};

View File

@@ -13,9 +13,6 @@ export const SubscribeMixin = <T extends Constructor<ReactiveElement>>(
class SubscribeClass extends superClass {
@property({ attribute: false }) public hass?: HomeAssistant;
// we wait with subscribing till these properties are set on the host element
protected hassSubscribeRequiredHostProps?: string[];
private __unsubs?: Array<UnsubscribeFunc | Promise<UnsubscribeFunc>>;
public connectedCallback() {
@@ -42,16 +39,6 @@ export const SubscribeMixin = <T extends Constructor<ReactiveElement>>(
super.updated(changedProps);
if (changedProps.has("hass")) {
this.__checkSubscribed();
return;
}
if (!this.hassSubscribeRequiredHostProps) {
return;
}
for (const key of changedProps.keys()) {
if (this.hassSubscribeRequiredHostProps.includes(key as string)) {
this.__checkSubscribed();
return;
}
}
}
@@ -65,10 +52,7 @@ export const SubscribeMixin = <T extends Constructor<ReactiveElement>>(
if (
this.__unsubs !== undefined ||
!(this as unknown as Element).isConnected ||
this.hass === undefined ||
this.hassSubscribeRequiredHostProps?.some(
(prop) => this[prop] === undefined
)
this.hass === undefined
) {
return;
}

View File

@@ -26,6 +26,10 @@ import "../../../components/ha-menu-button";
import "../../../components/ha-button-menu";
import "../../../components/ha-svg-icon";
import { CloudStatus } from "../../../data/cloud";
import {
refreshSupervisorAvailableUpdates,
SupervisorAvailableUpdates,
} from "../../../data/supervisor/root";
import { showQuickBar } from "../../../dialogs/quick-bar/show-dialog-quick-bar";
import "../../../layouts/ha-app-layout";
import { haStyle } from "../../../resources/styles";
@@ -34,11 +38,10 @@ import "../ha-config-section";
import { configSections } from "../ha-panel-config";
import "./ha-config-navigation";
import "./ha-config-updates";
import { showAlertDialog } from "../../../dialogs/generic/show-dialog-box";
import { documentationUrl } from "../../../util/documentation-url";
import { UpdateDescription } from "../../../data/update";
import { fireEvent } from "../../../common/dom/fire_event";
import { computeRTL } from "../../../common/util/compute_rtl";
import { showAlertDialog } from "../../../dialogs/generic/show-dialog-box";
import { showToast } from "../../../util/toast";
import { documentationUrl } from "../../../util/documentation-url";
const randomTip = (hass: HomeAssistant) => {
const weighted: string[] = [];
@@ -111,12 +114,14 @@ class HaConfigDashboard extends LitElement {
@property() public cloudStatus?: CloudStatus;
// null means not available
@property() public updates?: UpdateDescription[] | null;
@property() public supervisorUpdates?: SupervisorAvailableUpdates[] | null;
@property() public showAdvanced!: boolean;
@state() private _tip?: string;
private _notifyUpdates = false;
protected render(): TemplateResult {
return html`
<ha-app-layout>
@@ -128,7 +133,6 @@ class HaConfigDashboard extends LitElement {
></ha-menu-button>
<div main-title>${this.hass.localize("panel.config")}</div>
<ha-icon-button
.label=${this.hass.localize("ui.dialogs.quick-bar.title")}
.path=${mdiMagnify}
@click=${this._showQuickBar}
></ha-icon-button>
@@ -155,53 +159,50 @@ class HaConfigDashboard extends LitElement {
.isWide=${this.isWide}
full-width
>
${this.updates === undefined
? html`<ha-alert .rtl=${computeRTL(this.hass)}>
${this.hass.localize(
"ui.panel.config.updates.checking_updates"
)}
</ha-alert>`
: this.updates?.length
? html`<ha-card>
<ha-config-updates
.hass=${this.hass}
.narrow=${this.narrow}
.updates=${this.updates}
></ha-config-updates>
</ha-card>`
: ""}
<ha-card>
${this.narrow && this.updates?.length
? html`<div class="title">
${this.hass.localize("panel.config")}
</div>`
: ""}
${this.cloudStatus && isComponentLoaded(this.hass, "cloud")
? html`
${this.supervisorUpdates === undefined
? // Hide everything until updates loaded
html``
: html`${this.supervisorUpdates?.length
? html`<ha-card>
<ha-config-updates
.hass=${this.hass}
.narrow=${this.narrow}
.supervisorUpdates=${this.supervisorUpdates}
></ha-config-updates>
</ha-card>`
: ""}
<ha-card>
${this.narrow && this.supervisorUpdates?.length
? html`<div class="title">
${this.hass.localize("panel.config")}
</div>`
: ""}
${this.cloudStatus && isComponentLoaded(this.hass, "cloud")
? html`
<ha-config-navigation
.hass=${this.hass}
.narrow=${this.narrow}
.showAdvanced=${this.showAdvanced}
.pages=${[
{
component: "cloud",
path: "/config/cloud",
name: "Home Assistant Cloud",
info: this.cloudStatus,
iconPath: mdiCloudLock,
iconColor: "#3B808E",
},
]}
></ha-config-navigation>
`
: ""}
<ha-config-navigation
.hass=${this.hass}
.narrow=${this.narrow}
.showAdvanced=${this.showAdvanced}
.pages=${[
{
component: "cloud",
path: "/config/cloud",
name: "Home Assistant Cloud",
info: this.cloudStatus,
iconPath: mdiCloudLock,
iconColor: "#3B808E",
},
]}
.pages=${configSections.dashboard}
></ha-config-navigation>
`
: ""}
<ha-config-navigation
.hass=${this.hass}
.narrow=${this.narrow}
.showAdvanced=${this.showAdvanced}
.pages=${configSections.dashboard}
></ha-config-navigation>
</ha-card>
</ha-card>`}
<div class="tips">
<ha-svg-icon .path=${mdiLightbulbOutline}></ha-svg-icon>
<span class="tip-word">Tip!</span>
@@ -218,6 +219,22 @@ class HaConfigDashboard extends LitElement {
if (!this._tip && changedProps.has("hass")) {
this._tip = randomTip(this.hass);
}
if (!changedProps.has("supervisorUpdates") || !this._notifyUpdates) {
return;
}
this._notifyUpdates = false;
if (this.supervisorUpdates?.length) {
showToast(this, {
message: this.hass.localize(
"ui.panel.config.updates.updates_refreshed"
),
});
} else {
showToast(this, {
message: this.hass.localize("ui.panel.config.updates.no_new_updates"),
});
}
}
private _showQuickBar(): void {
@@ -230,16 +247,18 @@ class HaConfigDashboard extends LitElement {
private async _handleMenuAction(ev: CustomEvent<ActionDetail>) {
switch (ev.detail.index) {
case 0:
if (isComponentLoaded(this.hass, "update")) {
fireEvent(this, "ha-refresh-updates");
if (isComponentLoaded(this.hass, "hassio")) {
this._notifyUpdates = true;
await refreshSupervisorAvailableUpdates(this.hass);
fireEvent(this, "ha-refresh-supervisor");
return;
}
showAlertDialog(this, {
title: this.hass.localize(
"ui.panel.config.updates.update_not_loaded.title"
"ui.panel.config.updates.check_unavailable.title"
),
text: this.hass.localize(
"ui.panel.config.updates.update_not_loaded.description"
"ui.panel.config.updates.check_unavailable.description"
),
warning: true,
});

View File

@@ -1,48 +1,21 @@
import "@material/mwc-button/mwc-button";
import { mdiPackageVariant } from "@mdi/js";
import "@polymer/paper-item/paper-icon-item";
import "@polymer/paper-item/paper-item-body";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { customElement, property, state } from "lit/decorators";
import memoizeOne from "memoize-one";
import { fireEvent } from "../../../common/dom/fire_event";
import "../../../components/ha-alert";
import "../../../components/ha-icon-next";
import "../../../components/ha-logo-svg";
import "../../../components/ha-svg-icon";
import { UpdateDescription } from "../../../data/update";
import { showUpdateDialog } from "../../../dialogs/update-dialog/show-ha-update-dialog";
import { SupervisorAvailableUpdates } from "../../../data/supervisor/root";
import { HomeAssistant } from "../../../types";
import { brandsUrl } from "../../../util/brands-url";
import "../../../components/ha-icon-next";
const sortUpdates = memoizeOne((a: UpdateDescription, b: UpdateDescription) => {
if (a.domain === "hassio" && b.domain === "hassio") {
if (a.identifier === "core") {
return -1;
}
if (b.identifier === "core") {
return 1;
}
if (a.identifier === "supervisor") {
return -1;
}
if (b.identifier === "supervisor") {
return 1;
}
if (a.identifier === "os") {
return -1;
}
if (b.identifier === "os") {
return 1;
}
}
if (a.domain === "hassio") {
return -1;
}
if (b.domain === "hassio") {
return 1;
}
return a.name.toUpperCase() < b.name.toUpperCase() ? -1 : 1;
});
export const SUPERVISOR_UPDATE_NAMES = {
core: "Home Assistant Core",
os: "Home Assistant Operating System",
supervisor: "Home Assistant Supervisor",
};
@customElement("ha-config-updates")
class HaConfigUpdates extends LitElement {
@@ -51,62 +24,62 @@ class HaConfigUpdates extends LitElement {
@property({ type: Boolean }) public narrow!: boolean;
@property({ attribute: false })
public updates?: UpdateDescription[] | null;
public supervisorUpdates?: SupervisorAvailableUpdates[] | null;
@state() private _showAll = false;
protected render(): TemplateResult {
if (!this.updates?.length) {
if (!this.supervisorUpdates?.length) {
return html``;
}
// Make sure the first updates shown are for the Supervisor
const sortedUpdates = this.updates.sort((a, b) => sortUpdates(a, b));
const updates =
this._showAll || sortedUpdates.length <= 3
? sortedUpdates
: sortedUpdates.slice(0, 2);
this._showAll || this.supervisorUpdates.length <= 3
? this.supervisorUpdates
: this.supervisorUpdates.slice(0, 2);
return html`
<div class="title">
${this.hass.localize("ui.panel.config.updates.title", {
count: sortedUpdates.length,
count: this.supervisorUpdates.length,
})}
</div>
${updates.map(
(update) => html`
<paper-icon-item @click=${this._showUpdate} .update=${update}>
<span slot="item-icon" class="icon">
<img
src=${update.icon_url ||
brandsUrl({
domain: update.domain,
type: "icon",
useFallback: true,
darkOptimized: this.hass.themes?.darkMode,
})}
/>
</span>
<paper-item-body two-line>
${update.name}
<div secondary>
${this.hass.localize(
"ui.panel.config.updates.version_available",
{
version_available: update.available_version,
}
)}
</div>
</paper-item-body>
</paper-icon-item>
<a href="/hassio${update.panel_path}">
<paper-icon-item>
<span slot="item-icon" class="icon">
${update.update_type === "addon"
? update.icon
? html`<img src="/api/hassio${update.icon}" />`
: html`<ha-svg-icon
.path=${mdiPackageVariant}
></ha-svg-icon>`
: html`<ha-logo-svg></ha-logo-svg>`}
</span>
<paper-item-body two-line>
${update.update_type === "addon"
? update.name
: SUPERVISOR_UPDATE_NAMES[update.update_type!]}
<div secondary>
${this.hass.localize(
"ui.panel.config.updates.version_available",
{
version_available: update.version_latest,
}
)}
</div>
</paper-item-body>
${!this.narrow ? html`<ha-icon-next></ha-icon-next>` : ""}
</paper-icon-item>
</a>
`
)}
${!this._showAll && this.updates.length >= 4
${!this._showAll && this.supervisorUpdates.length >= 4
? html`
<button class="show-more" @click=${this._showAllClicked}>
${this.hass.localize("ui.panel.config.updates.more_updates", {
count: this.updates!.length - updates.length,
count: this.supervisorUpdates!.length - updates.length,
})}
</button>
`
@@ -118,14 +91,6 @@ class HaConfigUpdates extends LitElement {
this._showAll = true;
}
private _showUpdate(ev) {
const update = ev.currentTarget.update as UpdateDescription;
showUpdateDialog(this, {
update,
refreshCallback: () => fireEvent(this, "ha-refresh-updates"),
});
}
static get styles(): CSSResultGroup[] {
return [
css`
@@ -174,9 +139,6 @@ class HaConfigUpdates extends LitElement {
outline: none;
text-decoration: underline;
}
paper-icon-item {
cursor: pointer;
}
`,
];
}

View File

@@ -86,7 +86,6 @@ export class EnergyDeviceSettings extends LitElement {
: device.stat_consumption}</span
>
<ha-icon-button
.label=${this.hass.localize("ui.common.delete")}
@click=${this._deleteDevice}
.device=${device}
.path=${mdiDelete}

View File

@@ -27,18 +27,20 @@ import { customElement, property, state } from "lit/decorators";
import { isComponentLoaded } from "../../common/config/is_component_loaded";
import { listenMediaQuery } from "../../common/dom/media_query";
import { CloudStatus, fetchCloudStatus } from "../../data/cloud";
import { fetchUpdateInfo, UpdateDescription } from "../../data/update";
import {
fetchSupervisorAvailableUpdates,
SupervisorAvailableUpdates,
} from "../../data/supervisor/root";
import "../../layouts/hass-loading-screen";
import { HassRouterPage, RouterOptions } from "../../layouts/hass-router-page";
import { PageNavigation } from "../../layouts/hass-tabs-subpage";
import { HomeAssistant, Route } from "../../types";
import { showToast } from "../../util/toast";
declare global {
// for fire event
interface HASSDomEvents {
"ha-refresh-cloud-status": undefined;
"ha-refresh-updates": undefined;
"ha-refresh-supervisor": undefined;
}
}
@@ -405,7 +407,7 @@ class HaPanelConfig extends HassRouterPage {
@state() private _cloudStatus?: CloudStatus;
@state() private _updates?: UpdateDescription[] | null;
@state() private _supervisorUpdates?: SupervisorAvailableUpdates[] | null;
private _listeners: Array<() => void> = [];
@@ -441,18 +443,18 @@ class HaPanelConfig extends HassRouterPage {
}
});
}
if (isComponentLoaded(this.hass, "update")) {
this._loadUpdates();
this.addEventListener("ha-refresh-updates", () => {
this._loadUpdates();
if (isComponentLoaded(this.hass, "hassio")) {
this._loadSupervisorUpdates();
this.addEventListener("ha-refresh-supervisor", () => {
this._loadSupervisorUpdates();
});
this.addEventListener("connection-status", (ev) => {
if (ev.detail === "connected") {
this._loadUpdates();
this._loadSupervisorUpdates();
}
});
} else {
this._updates = null;
this._supervisorUpdates = null;
}
this.addEventListener("ha-refresh-cloud-status", () =>
this._updateCloudStatus()
@@ -484,7 +486,7 @@ class HaPanelConfig extends HassRouterPage {
isWide,
narrow: this.narrow,
cloudStatus: this._cloudStatus,
updates: this._updates,
supervisorUpdates: this._supervisorUpdates,
});
} else {
el.route = this.routeTail;
@@ -493,7 +495,7 @@ class HaPanelConfig extends HassRouterPage {
el.isWide = isWide;
el.narrow = this.narrow;
el.cloudStatus = this._cloudStatus;
el.updates = this._updates;
el.supervisorUpdates = this._supervisorUpdates;
}
}
@@ -512,33 +514,13 @@ class HaPanelConfig extends HassRouterPage {
}
}
private async _loadUpdates(): Promise<void> {
const _showToast = this._updates !== undefined;
if (_showToast) {
showToast(this, {
message: this.hass.localize("ui.panel.config.updates.checking_updates"),
});
}
private async _loadSupervisorUpdates(): Promise<void> {
try {
this._updates = await fetchUpdateInfo(this.hass);
this._supervisorUpdates = await fetchSupervisorAvailableUpdates(
this.hass
);
} catch (err) {
this._updates = null;
}
if (_showToast) {
if (this._updates?.length) {
showToast(this, {
message: this.hass.localize(
"ui.panel.config.updates.updates_refreshed"
),
});
} else {
showToast(this, {
message: this.hass.localize("ui.panel.config.updates.no_new_updates"),
});
}
this._supervisorUpdates = null;
}
}
}

View File

@@ -144,6 +144,8 @@ export class ZHANetworkVisualizationPage extends LitElement {
<div slot="header">
<search-input
.hass=${this.hass}
no-label-float
no-underline
class="header"
@value-changed=${this._handleSearchChange}
.filter=${this._filter}
@@ -159,6 +161,8 @@ export class ZHANetworkVisualizationPage extends LitElement {
${!this.narrow
? html`<search-input
.hass=${this.hass}
no-label-float
no-underline
@value-changed=${this._handleSearchChange}
.filter=${this._filter}
.label=${this.hass.localize(

View File

@@ -43,6 +43,8 @@ export class HaConfigLogs extends LitElement {
<div slot="header">
<search-input
class="header"
no-label-float
no-underline
@value-changed=${this._filterChanged}
.hass=${this.hass}
.filter=${this._filter}
@@ -53,6 +55,9 @@ export class HaConfigLogs extends LitElement {
: html`
<div class="search">
<search-input
autofocus
no-label-float
no-underline
@value-changed=${this._filterChanged}
.hass=${this.hass}
.filter=${this._filter}

View File

@@ -32,8 +32,6 @@ class HuiEnergyCarbonGaugeCard
@state() private _data?: EnergyData;
protected hassSubscribeRequiredHostProps = ["_config"];
public getCardSize(): number {
return 4;
}

View File

@@ -49,8 +49,6 @@ export class HuiEnergyDevicesGraphCard
@query("ha-chart-base") private _chart?: HaChartBase;
protected hassSubscribeRequiredHostProps = ["_config"];
public hassSubscribe(): UnsubscribeFunc[] {
return [
getEnergyDataCollection(this.hass, {

View File

@@ -43,8 +43,6 @@ class HuiEnergyDistrubutionCard
@state() private _data?: EnergyData;
protected hassSubscribeRequiredHostProps = ["_config"];
public setConfig(config: EnergyDistributionCardConfig): void {
this._config = config;
}

View File

@@ -62,8 +62,6 @@ export class HuiEnergyGasGraphCard
@state() private _unit?: string;
protected hassSubscribeRequiredHostProps = ["_config"];
public hassSubscribe(): UnsubscribeFunc[] {
return [
getEnergyDataCollection(this.hass, {

View File

@@ -35,8 +35,6 @@ class HuiEnergyGridGaugeCard
@state() private _data?: EnergyData;
protected hassSubscribeRequiredHostProps = ["_config"];
public hassSubscribe(): UnsubscribeFunc[] {
return [
getEnergyDataCollection(this.hass!, {

View File

@@ -30,8 +30,6 @@ class HuiEnergySolarGaugeCard
@state() private _data?: EnergyData;
protected hassSubscribeRequiredHostProps = ["_config"];
public hassSubscribe(): UnsubscribeFunc[] {
return [
getEnergyDataCollection(this.hass!, {

View File

@@ -61,8 +61,6 @@ export class HuiEnergySolarGraphCard
@state() private _end = endOfToday();
protected hassSubscribeRequiredHostProps = ["_config"];
public hassSubscribe(): UnsubscribeFunc[] {
return [
getEnergyDataCollection(this.hass, {

View File

@@ -45,8 +45,6 @@ export class HuiEnergySourcesTableCard
@state() private _data?: EnergyData;
protected hassSubscribeRequiredHostProps = ["_config"];
public hassSubscribe(): UnsubscribeFunc[] {
return [
getEnergyDataCollection(this.hass, {

View File

@@ -50,8 +50,6 @@ export class HuiEnergyUsageGraphCard
@state() private _end = endOfToday();
protected hassSubscribeRequiredHostProps = ["_config"];
public hassSubscribe(): UnsubscribeFunc[] {
return [
getEnergyDataCollection(this.hass, {

View File

@@ -9,10 +9,7 @@ import {
import { customElement, property, state } from "lit/decorators";
import "../../../components/ha-date-input";
import { UNAVAILABLE_STATES, UNKNOWN } from "../../../data/entity";
import {
setInputDateTimeValue,
stateToIsoDateString,
} from "../../../data/input_datetime";
import { setInputDateTimeValue } from "../../../data/input_datetime";
import type { HomeAssistant } from "../../../types";
import { hasConfigOrEntityChanged } from "../common/has-changed";
import "../components/hui-generic-entity-row";
@@ -68,7 +65,7 @@ class HuiInputDatetimeEntityRow extends LitElement implements LovelaceRow {
.label=${stateObj.attributes.has_time ? name : undefined}
.locale=${this.hass.locale}
.disabled=${UNAVAILABLE_STATES.includes(stateObj.state)}
.value=${stateToIsoDateString(stateObj)}
.value=${`${stateObj.attributes.year}-${stateObj.attributes.month}-${stateObj.attributes.day}`}
@value-changed=${this._dateChanged}
>
</ha-date-input>

View File

@@ -9,8 +9,6 @@ import {
import { ResolvedMediaSource } from "../../data/media_source";
import { HomeAssistant } from "../../types";
export const ERR_UNSUPPORTED_MEDIA = "Unsupported Media";
export class BrowserMediaPlayer {
private player: HTMLAudioElement;
@@ -27,9 +25,6 @@ export class BrowserMediaPlayer {
private onChange: () => void
) {
const player = new Audio(this.resolved.url);
if (player.canPlayType(resolved.mime_type) === "") {
throw new Error(ERR_UNSUPPORTED_MEDIA);
}
player.autoplay = true;
player.volume = volume;
player.addEventListener("play", this._handleChange);

View File

@@ -49,13 +49,9 @@ import {
SUPPORT_VOLUME_SET,
} from "../../data/media-player";
import { ResolvedMediaSource } from "../../data/media_source";
import { showAlertDialog } from "../../dialogs/generic/show-dialog-box";
import type { HomeAssistant } from "../../types";
import "../lovelace/components/hui-marquee";
import {
BrowserMediaPlayer,
ERR_UNSUPPORTED_MEDIA,
} from "./browser-media-player";
import { BrowserMediaPlayer } from "./browser-media-player";
declare global {
interface HASSDomEvents {
@@ -129,25 +125,13 @@ export class BarMediaPlayer extends LitElement {
throw Error("Only browser supported");
}
this._tearDownBrowserPlayer();
try {
this._browserPlayer = new BrowserMediaPlayer(
this.hass,
item,
resolved,
this._browserPlayerVolume,
() => this.requestUpdate("_browserPlayer")
);
} catch (err: any) {
if (err.message === ERR_UNSUPPORTED_MEDIA) {
showAlertDialog(this, {
text: this.hass.localize(
"ui.components.media-browser.media_not_supported"
),
});
} else {
throw err;
}
}
this._browserPlayer = new BrowserMediaPlayer(
this.hass,
item,
resolved,
this._browserPlayerVolume,
() => this.requestUpdate("_browserPlayer")
);
this._newMediaExpected = false;
}

View File

@@ -27,10 +27,7 @@ import {
MediaPickedEvent,
MediaPlayerItem,
} from "../../data/media-player";
import {
ResolvedMediaSource,
resolveMediaSource,
} from "../../data/media_source";
import { resolveMediaSource } from "../../data/media_source";
import "../../layouts/ha-app-layout";
import { haStyle } from "../../resources/styles";
import type { HomeAssistant, Route } from "../../types";
@@ -227,19 +224,11 @@ class PanelMediaBrowser extends LitElement {
}
this._player.showResolvingNewMediaPicked();
let resolvedUrl: ResolvedMediaSource;
try {
resolvedUrl = await resolveMediaSource(this.hass, item.media_content_id);
} catch (err: any) {
showAlertDialog(this, {
title: this.hass.localize(
"ui.components.media-browser.media_browsing_error"
),
text: err.message,
});
this._player.hideResolvingNewMediaPicked();
return;
}
const resolvedUrl = await resolveMediaSource(
this.hass,
item.media_content_id
);
if (resolvedUrl.mime_type.startsWith("audio/")) {
this._player.playItem(item, resolvedUrl);

View File

@@ -1047,27 +1047,18 @@
"learn_more": "Learn more"
},
"updates": {
"update_not_loaded": {
"check_unavailable": {
"title": "Unable to check for updates",
"description": "You need to enable the update integrtion to be able to check and install updates from the Home Assistant user interface."
"description": "You need to run the Home Assistant operating system to be able to check and install updates from the Home Assistant user interface."
},
"check_updates": "Check for updates",
"checking_updates": "Checking for available updates",
"no_new_updates": "No new updates found",
"updates_refreshed": "Updates refreshed",
"title": "{count} {count, plural,\n one {update}\n other {updates}\n}",
"unable_to_fetch": "Unable to load updates",
"version_available": "Version {version_available} is available",
"more_updates": "+{count} updates",
"show": "show",
"dialog": {
"title": "[%key:supervisor::update_available::update_name%]",
"create_backup": "[%key:supervisor::update_available::create_backup%]",
"open_changelog": "Open changelog",
"updating": "[%key:supervisor::update_available::updating%]",
"update": "[%key:supervisor::common::update%]",
"description": "[%key:supervisor::update_available::description%]"
}
"show": "show"
},
"areas": {
"caption": "Areas",

View File

@@ -9,5 +9,3 @@ export const brandsUrl = (options: BrandsOptions): string =>
`https://brands.home-assistant.io/${options.useFallback ? "_/" : ""}${
options.domain
}/${options.darkOptimized ? "dark_" : ""}${options.type}.png`;
export const extractDomainFromBrandUrl = (url: string) => url.split("/")[4];