Compare commits

...

18 Commits

Author SHA1 Message Date
Zack
728ea265e2 Colors 2022-01-24 09:44:30 -06:00
Zack Barett
d859b61365 Update src/translations/en.json
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2022-01-21 17:07:03 -06:00
Zack Barett
50bf69860f Move Developer Tools to Settings 2022-01-21 21:45:40 +00:00
Paulus Schoutsen
cf527e4bc2 Hide download diagnostics if config entry is not loaded (#11383) 2022-01-21 09:41:02 -08:00
Matthias de Baat
197b581e8e Adding results of the Configuration menu user test (#11381)
* Adding results of the Configuration menu user test

* Update title

* Add sidebar entry

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2022-01-21 08:39:17 -08:00
Paulus Schoutsen
f75bf1f676 Check for updates in add-on store (#11382) 2022-01-21 08:16:45 -08:00
Allen Porter
28df79cfda Enable/Disable LL-HLS support based on http/2 availability (#11372)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
Co-authored-by: Philip Allgaier <philip.allgaier@gmx.de>
2022-01-21 08:06:00 -08:00
Zack Barett
3bf19883a8 Fix Date Time Helper (#11367) 2022-01-21 08:36:39 -06:00
Zack Barett
303e065433 Media Browser Bar (#11369)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2022-01-20 14:37:30 -08:00
Joakim Sørensen
7ad0b37a9e Use backend logic for partial backup while updating (#11364) 2022-01-20 10:12:52 -08:00
Joakim Sørensen
930c7e4afa Add backup size to backup table (#11365) 2022-01-20 10:08:53 -06:00
Paulus Schoutsen
81faae6f74 Allow downloading device diagnostics (#11370) 2022-01-19 20:48:24 -08:00
Philip Allgaier
f7fc83ac12 Add space between number input field and unit (#11366) 2022-01-19 12:46:38 -08:00
Paulus Schoutsen
21a099ee9f Clean up users table (#11333)
* Clean up users table

* Add decicated icon for data tables

* Change tooltip and icons

* Only use icons for narrow view

* Shorten headers

* Add chips to the user detail dialog

* Lint

* Hide system badge on mobile
2022-01-19 12:28:13 -08:00
Paulus Schoutsen
7d1ce1b240 Allow creating automation from TTS try dialog (#11161) 2022-01-19 11:32:24 -06:00
Matthias de Baat
d1f1309198 Added examples and corrected some text (#11156) 2022-01-19 09:02:22 -08:00
Philip Allgaier
68dd818f7a Translate "No integration" in device dashboard table (#11362) 2022-01-19 08:57:46 -08:00
Paulus Schoutsen
50bea33a19 Localize config flow title (#11358) 2022-01-18 14:18:22 -08:00
33 changed files with 1392 additions and 522 deletions

View File

@@ -36,6 +36,10 @@ module.exports = [
category: "misc",
header: "Miscelaneous",
},
{
category: "user-test",
header: "User Tests",
},
{
category: "design.home-assistant.io",
header: "Design Documentation",

View File

@@ -5,15 +5,23 @@ title: Alerts
# Alert `<ha-alert>`
The alert offers four severity levels that set a distinctive icon and color.
<ha-alert alert-type="error">This is an error alert — check it out!</ha-alert>
<ha-alert alert-type="error">
This is an error alert — check it out!
</ha-alert>
<ha-alert alert-type="warning">This is an warning alert — check it out!</ha-alert>
<ha-alert alert-type="warning">
This is an warning alert — check it out!
</ha-alert>
<ha-alert alert-type="info">This is an info alert — check it out!</ha-alert>
<ha-alert alert-type="info">
This is an info alert — check it out!
</ha-alert>
<ha-alert alert-type="success">This is an success alert — check it out!</ha-alert>
<ha-alert alert-type="success">
This is an success alert — check it out!
</ha-alert>
**Note:** This component is by [MUI](https://mui.com/components/alert/) and is not documented in the [Material Design guidelines](https://material.io).
**Note:** This component is by <a href="https://mui.com/components/alert/" rel="noopener noreferrer" target="_blank">MUI</a> and is not documented in the <a href="https://material.io" rel="noopener noreferrer" target="_blank">Material Design guidelines</a>.
1. [Guidelines](#guidelines)
2. [Implementation](#implementation)
@@ -21,8 +29,8 @@ The alert offers four severity levels that set a distinctive icon and color.
### Resources
| Type | Link | Status |
|----------------|----------------------------------|-----------|
| Design | [Home Assistant DesignKit](https://www.figma.com/community/file/967153512097289521/Home-Assistant-DesignKit) (Figma) | Available |
| Implementation | [Web Component](https://github.com/home-assistant/frontend/blob/dev/src/components/ha-alert.ts) (GitHub) | Available |
| Design | <a href="https://www.figma.com/community/file/967153512097289521/Home-Assistant-DesignKit" rel="noopener noreferrer" target="_blank">Home Assistant DesignKit</a> (Figma) | Available |
| Implementation | <a href="https://github.com/home-assistant/frontend/blob/dev/src/components/ha-alert.ts" rel="noopener noreferrer" target="_blank">Web Component</a> (GitHub) | Available |
## Guidelines
### Usage
@@ -64,78 +72,93 @@ Actions must have a tab index of 0 so that they can be reached by keyboard-only
### Example Usage
**Alert type**
<ha-alert alert-type="error">This is an error alert — check it out!</ha-alert>
<ha-alert alert-type="error">
This is an error alert — check it out!
</ha-alert>
<ha-alert alert-type="warning">This is an warning alert — check it out!</ha-alert>
<ha-alert alert-type="warning">
This is an warning alert — check it out!
</ha-alert>
<ha-alert alert-type="info">This is an info alert — check it out!</ha-alert>
<ha-alert alert-type="info">
This is an info alert — check it out!
</ha-alert>
<ha-alert alert-type="success">This is an success alert — check it out!</ha-alert>
<ha-alert alert-type="success">
This is an success alert — check it out!
</ha-alert>
```html
<ha-alert alert-type="error">This is an error alert — check it out!</ha-alert>
<ha-alert alert-type="warning">This is a warning alert — check it out!</ha-alert>
<ha-alert alert-type="info">This is an info alert — check it out!</ha-alert>
<ha-alert alert-type="success">This is a success alert — check it out!</ha-alert>
<ha-alert alert-type="error">
This is an error alert — check it out!
</ha-alert>
<ha-alert alert-type="warning">
This is a warning alert — check it out!
</ha-alert>
<ha-alert alert-type="info">
This is an info alert — check it out!
</ha-alert>
<ha-alert alert-type="success">
This is a success alert — check it out!
</ha-alert>
```
**Title**
The `title ` option should not be used without a description.
<ha-alert alert-type="error" title="Error">
This is an error alert — <strong>check it out!</strong>
</ha-alert>
<ha-alert alert-type="warning">
<title>Warning</title>
This is an warning alert — <strong>check it out!</strong>
</ha-alert>
<ha-alert alert-type="info">
<title>Info</title>
This is an info alert — <strong>check it out!</strong>
</ha-alert>
<ha-alert alert-type="success">
<title>Success </title>
This is an success alert — <strong>check it out!</strong>
<ha-alert alert-type="success" title="Success">
This is an success alert — check it out!
</ha-alert>
```html
<ha-alert alert-type="error" title="Error">
This is an error alert — <strong>check it out!</strong>
</ha-alert>
<ha-alert alert-type="warning">
<title>Warning</title>
This is an warning alert — <strong>check it out!</strong>
</ha-alert>
<ha-alert alert-type="info">
<title>Info</title>
This is an info alert — <strong>check it out!</strong>
</ha-alert>
<ha-alert alert-type="success">
<title>Success </title>
This is an success alert — <strong>check it out!</strong>
<ha-alert alert-type="success" title="Success">
This is an success alert — check it out!
</ha-alert>
```
**Dismissable**
*Documentation coming soon*
<ha-alert alert-type="success" dismissable>
This is an success alert — check it out!
</ha-alert>
```html
<ha-alert alert-type="success" dismissable>
This is an success alert — check it out!
</ha-alert>
```
**Slotted action**
<ha-alert alert-type="success">
This is an success alert — check it out!
<mwc-button slot="action" label="Undo"></mwc-button>
</ha-alert>
```html
<ha-alert alert-type="success">
This is an success alert — check it out!
<mwc-button slot="action" label="Undo"></mwc-button>
</ha-alert>
```
**Slotted icon**
*Documentation coming soon*
**Slotted action**
*Documentation coming soon*
**Right to left**
*Documentation coming soon*
<ha-alert alert-type="success" rtl>
This is an info alert — check it out!
</ha-alert>
```html
<ha-alert alert-type="success" rtl>
This is an info alert — check it out!
</ha-alert>
```
### API
**Properties/Attributes**

View File

@@ -0,0 +1,202 @@
---
title: "User Test: Configuration menu"
---
# User Test: Configuration menu (10-17 January, 2022)
At the end of last year, we created one Configuration menu by merging Supervisor. In the next iteration, we want to organize our menu by creating logical grouping and combining duplicated features. We are conducting this test to see if we are on the right track.
* Anyone could join
* Respondents recruited on Twitter, Reddit and Home Assistant Forum
* This test is open for 10 days
* UsabilityHub for user test
* Figma for prototype
* 6 questions
* 3 tasks
* Due to some limitations by UsabilityHub, it only worked on desktop
# Results
915 respondents took part in this test and they gave 407 comments. In general there isnt a significant difference between:
* How long a respondent has been using Home Assistant
* Installation method
* How many visits to its Home Assistant in the past 3 months
* Home Assistant expertise
## Overall menu change
This prototype organized our menu by creating logical grouping and combining duplicated features. What do people think of this change?
### Stats
* 2% (21) Like extremely
* 30% (276) Like very much
* 53% (481) Neutral
* 12% (108) Dislike very much
* 3% (26) Dislike extremely
*3 respondents passed*
### Comments summary
**Like**
* Clean and decluttered
* Style looks better
* Faster to use
* Merging Supervisor into different pages
* Moving Developer tools to Settings
**Dislike**
* Moving Developer tools to Settings
* More clicks for scripts and helpers
* Too many changes at once causes a high learning curve
* Removing the word `Integrations` makes it harder to find them
* Difference between `Addons` and `Services` is a bit subtle
* No clear distinction between `Developer` and `System`
* Material Design got the Google image
**Suggestions**
* More top level menu items for example logs.
* What are settings and what not? Maybe better to name it `Configuration`
* Devices are a first-class citizen in the domain of Home Assistant, and so shouldn't be tucked away in "Settings"
* Rename Developer tools (or make it only for Home Assistant developers)
* Separate administration (for instance creating users / adding lights etc) from development activities (creating automations and scripts)
* Search Bar in Settings
* Feature to put menu items in sidebar
* Unification of add-ons and integrations
* Adding New hints to show what changed
* Give `About` a less prominent size
* Accordion view option which puts every tab below
* Dev mode and a Prod Mode
* Always show config menu (on bigger screens)
### Conclusion
We should keep our focus on organizing our menu by creating logical grouping and combining duplicated features. With these changes we make more people happy:
* Reconsider putting `Logs` as a top-level menu item
* Add a search bar
* Use the word `Integrations` with `Devices & Services`
* Moving `Developer tools` to `Settings` is a good idea
* Rename `Developer tools` to for example `Tools`
* Add `New` explanation popups to what has changed
* We could rename `Configuration` to `Settings`
* Give `About` a less prominent size
## Helpers
In Home Assistant you can create toggles, text fields, number sliders, timers and counters. Also known as `Helpers`. Where should they be placed?
### Stats
* 78% (709) respondents are using helpers. They use it for:
* 92% (645) automations and scenes
* 62% (422) dashboards
* 43% (296) virtual devices
### Comments summary
Some respondents commented that they think `Helpers` shouldnt be listed under `Automations & Services`. Although almost all respondents use it for that specific purpose.
### Conclusion
Helpers is, in addition to `Automations & Services`, also partly seen as virtual devices and dashboard entities.
* We might consider promoting them in their own top-level menu item
* Rename `Helpers` to something with `controls`
## Add person
The first task in this user test was to add a person. Since this has not changed in the current menu structure, this should be an easy assignment. How do people experience the navigation to this feature?
### Stats
95% reached the goal screen and 98% marked the task as completed. There were 18 common paths.
After the task we asked how easy it was to add a person.
* 41% (378) Extremely easy
* 48% (440) Fairly easy
* 7% (67) Neutral
* 2% (19) Somewhat difficult
* 1% (11) Very difficult
### Comments summary
*No mentionable comments *
### Conclusion
This test showed that the current navigation design works.
## YAML
In Home Assistant you can make configuration changes in YAML files. To make these changes take effect you have to reload your YAML in the UI or do a restart. How are people doing this and can they find it in this new design?
### Stats
83% reached the goal screen and 87% marked the task as completed. There were 59 common paths.
After the task we asked how easy it was to reload the YAML changes.
* 4% (40) Extremely easy
* 22% (204) Fairly easy
* 20% (179) Neutral
* 37% (336) Somewhat difficult
* 17% (156) Very difficult
And we asked if they have seen that we've moved some functionality from current `Server Controls` to `Developer Tools`.
* 57% (517) Yes
* 43% (398) No
### Comments summary
**Like**
* YAML in Developer tools
**Dislike**
* Hidden restart and reload
* YAML in Developer Tools
* Combining `Developer tools` with `Server management`
* Reload Home Assistant button isn't clear what it does
* Reload/restart Home Assistant in Developer Tools
**Suggestions**
* Reload all YAML button
* Dev mode and a Prod Mode
* Show restart/reload as buttons in System instead of overflow menu
* Explain that you can reload YAML when you want to restart your system
* YAML reloading under System
### Conclusion
This test showed two different kinds of user groups: UI and YAML users.
* Moving `Developer tools` to `Settings` is a good idea
* YAML users want reload YAML and Home Assistant restart in `System`
* Move the restart and reload button to the `System` page from the overflow menu
* Add suggestion to reload YAML when a user wants to restart
* Add reload all YAML button
## Logs
### Stats
70% reached the goal screen and 77% marked the task as completed. There were 48 common paths.
After the task we asked to find out why your Elgato light isn't working.
* 6% (57) Extremely easy
* 28% (254) Fairly easy
* 21% (188) Neutral
* 21% (196) Somewhat difficult
* 24% (220) Very difficult
### Comments summary
**Suggestions**
* Log errors on the integration page
* Problem solving center
### Conclusion
Although this test shows that a large number of respondents manage to complete the task, they find it difficult to find out the light isnt working.
* Add logs errors/warnings to the integration page
* Reconsider putting `Logs` as a top-level menu item
## Learnings for next user test
* Explain that topic is closed for comments so that you can do this test without any influence
* Mobile test should work on mobile
* Testing on an iPad got some bugs
* People like doing these kind of test and we should do them more often

View File

@@ -95,7 +95,7 @@ class HassioAddonStore extends LitElement {
${this.supervisor.localize("store.repositories")}
</mwc-list-item>
<mwc-list-item>
${this.supervisor.localize("common.reload")}
${this.supervisor.localize("store.check_updates")}
</mwc-list-item>
${this.hass.userData?.showAdvanced &&
atLeastVersion(this.hass.config.version, 0, 117)

View File

@@ -119,7 +119,7 @@ export class HassioBackups extends LitElement {
private _columns = memoizeOne(
(narrow: boolean): DataTableColumnContainer => ({
name: {
title: this.supervisor?.localize("backup.name") || "",
title: this.supervisor.localize("backup.name"),
sortable: true,
filterable: true,
grows: true,
@@ -127,8 +127,16 @@ export class HassioBackups extends LitElement {
html`${entry || backup.slug}
<div class="secondary">${backup.secondary}</div>`,
},
size: {
title: this.supervisor.localize("backup.size"),
width: "15%",
hidden: narrow,
filterable: true,
sortable: true,
template: (entry: number) => Math.ceil(entry * 10) / 10 + " MB",
},
date: {
title: this.supervisor?.localize("backup.created") || "",
title: this.supervisor.localize("backup.created"),
width: "15%",
direction: "desc",
hidden: narrow,
@@ -188,11 +196,11 @@ export class HassioBackups extends LitElement {
slot="trigger"
></ha-icon-button>
<mwc-list-item>
${this.supervisor?.localize("common.reload")}
${this.supervisor.localize("common.reload")}
</mwc-list-item>
${atLeastVersion(this.hass.config.version, 0, 116)
? html`<mwc-list-item>
${this.supervisor?.localize("backup.upload_backup")}
${this.supervisor.localize("backup.upload_backup")}
</mwc-list-item>`
: ""}
</ha-button-menu>

View File

@@ -29,10 +29,6 @@ import {
HassioAddonDetails,
updateHassioAddon,
} from "../../../src/data/hassio/addon";
import {
createHassioPartialBackup,
HassioPartialBackupCreateParams,
} from "../../../src/data/hassio/backup";
import {
extractApiErrorMessage,
ignoreSupervisorError,
@@ -103,7 +99,7 @@ class UpdateAvailableCard extends LitElement {
@state() private _addonInfo?: HassioAddonDetails;
@state() private _action: "backup" | "update" | null = null;
@state() private _updating = false;
@state() private _error?: string;
@@ -138,7 +134,7 @@ class UpdateAvailableCard extends LitElement {
name: this._name,
})}
</p>`
: this._action === null
: !this._updating
? html`
${this._changelogContent
? html`
@@ -172,18 +168,13 @@ class UpdateAvailableCard extends LitElement {
: html`<ha-circular-progress alt="Updating" size="large" active>
</ha-circular-progress>
<p class="progress-text">
${this._action === "update"
? this.supervisor.localize("update_available.updating", {
name: this._name,
version: this._version_latest,
})
: this.supervisor.localize(
"update_available.creating_backup",
{ name: this._name }
)}
${this.supervisor.localize("update_available.updating", {
name: this._name,
version: this._version_latest,
})}
</p>`}
</div>
${this._version !== this._version_latest && this._action === null
${this._version !== this._version_latest && !this._updating
? html`
<div class="card-actions">
${changelog
@@ -319,37 +310,16 @@ class UpdateAvailableCard extends LitElement {
private async _update() {
this._error = undefined;
if (this._shouldCreateBackup) {
let backupArgs: HassioPartialBackupCreateParams;
if (this._updateType === "addon") {
backupArgs = {
name: `addon_${this.addonSlug}_${this._version}`,
addons: [this.addonSlug!],
homeassistant: false,
};
} else {
backupArgs = {
name: `${this._updateType}_${this._version}`,
folders: ["homeassistant"],
homeassistant: true,
};
}
this._action = "backup";
try {
await createHassioPartialBackup(this.hass, backupArgs);
} catch (err: any) {
this._error = extractApiErrorMessage(err);
this._action = null;
return;
}
}
this._action = "update";
this._updating = true;
try {
if (this._updateType === "addon") {
await updateHassioAddon(this.hass, this.addonSlug!);
await updateHassioAddon(
this.hass,
this.addonSlug!,
this._shouldCreateBackup
);
} else if (this._updateType === "core") {
await updateCore(this.hass);
await updateCore(this.hass, this._shouldCreateBackup);
} else if (this._updateType === "os") {
await updateOS(this.hass);
} else if (this._updateType === "supervisor") {
@@ -358,11 +328,12 @@ class UpdateAvailableCard extends LitElement {
} catch (err: any) {
if (this.hass.connection.connected && !ignoreSupervisorError(err)) {
this._error = extractApiErrorMessage(err);
this._action = null;
this._updating = false;
return;
}
}
fireEvent(this, "update-complete");
this._updating = false;
}
static get styles(): CSSResultGroup {

View File

@@ -0,0 +1,64 @@
import { css, html, LitElement, PropertyValues, TemplateResult } from "lit";
import { customElement, property, state } from "lit/decorators";
import "../ha-svg-icon";
@customElement("ha-data-table-icon")
class HaDataTableIcon extends LitElement {
@property() public tooltip!: string;
@property() public path!: string;
@state() private _hovered = false;
protected render(): TemplateResult {
return html`
${this._hovered ? html`<div>${this.tooltip}</div>` : ""}
<ha-svg-icon .path=${this.path}></ha-svg-icon>
`;
}
protected override firstUpdated(changedProps: PropertyValues): void {
super.firstUpdated(changedProps);
const show = () => {
this._hovered = true;
};
const hide = () => {
this._hovered = false;
};
this.addEventListener("mouseenter", show);
this.addEventListener("focus", show);
this.addEventListener("mouseleave", hide);
this.addEventListener("blur", hide);
this.addEventListener("tap", hide);
}
static get styles() {
return css`
:host {
display: inline-block;
position: relative;
}
ha-svg-icon {
color: var(--secondary-text-color);
}
div {
position: absolute;
right: 28px;
z-index: 1002;
outline: none;
font-size: 10px;
line-height: 1;
background-color: var(--paper-tooltip-background, #616161);
color: var(--paper-tooltip-text-color, white);
padding: 8px;
border-radius: 2px;
}
`;
}
}
declare global {
interface HTMLElementTagNameMap {
"ha-data-table-icon": HaDataTableIcon;
}
}

View File

@@ -56,8 +56,8 @@ export interface SortingChangedEvent {
export type SortingDirection = "desc" | "asc" | null;
export interface DataTableColumnContainer {
[key: string]: DataTableColumnData;
export interface DataTableColumnContainer<T = any> {
[key: string]: DataTableColumnData<T>;
}
export interface DataTableSortColumnData {
@@ -68,10 +68,10 @@ export interface DataTableSortColumnData {
direction?: SortingDirection;
}
export interface DataTableColumnData extends DataTableSortColumnData {
export interface DataTableColumnData<T = any> extends DataTableSortColumnData {
title: TemplateResult | string;
type?: "numeric" | "icon" | "icon-button" | "overflow-menu";
template?: <T>(data: any, row: T) => TemplateResult | string;
template?: (data: any, row: T) => TemplateResult | string;
width?: string;
maxWidth?: string;
grows?: boolean;

View File

@@ -48,8 +48,11 @@ class HaHLSPlayer extends LitElement {
private _exoPlayer = false;
private static streamCount = 0;
public connectedCallback() {
super.connectedCallback();
HaHLSPlayer.streamCount += 1;
if (this.hasUpdated) {
this._startHls();
}
@@ -57,6 +60,7 @@ class HaHLSPlayer extends LitElement {
public disconnectedCallback() {
super.disconnectedCallback();
HaHLSPlayer.streamCount -= 1;
this._cleanUp();
}
@@ -186,6 +190,28 @@ class HaHLSPlayer extends LitElement {
});
};
private _isLLHLSSupported(): boolean {
// LL-HLS keeps multiple requests in flight, which can run into browser limitations without
// an http/2 proxy to pipeline requests. However, a small number of streams active at
// once should be OK.
// The stream count may be incremented multiple times before this function is called to check
// the count e.g. when loading a page with many streams on it. The race can work in our favor
// so we now have a better idea on if we'll use too many browser connections later.
if (HaHLSPlayer.streamCount <= 2) {
return true;
}
if (
!("performance" in window) ||
performance.getEntriesByType("resource").length === 0
) {
return false;
}
const perfEntry = performance.getEntriesByType(
"resource"
)[0] as PerformanceResourceTiming;
return "nextHopProtocol" in perfEntry && perfEntry.nextHopProtocol === "h2";
}
private async _renderHLSPolyfill(
videoEl: HTMLVideoElement,
Hls: typeof HlsType,
@@ -197,6 +223,7 @@ class HaHLSPlayer extends LitElement {
manifestLoadingTimeOut: 30000,
levelLoadingTimeOut: 30000,
maxLiveSyncPlaybackRate: 2,
lowLatencyMode: this._isLLHLSSupported(),
});
this._hlsPolyfillInstance = hls;
hls.attachMedia(videoEl);

View File

@@ -8,7 +8,6 @@ import {
mdiClose,
mdiCog,
mdiFormatListBulletedType,
mdiHammer,
mdiLightningBolt,
mdiMenu,
mdiMenuOpen,
@@ -57,7 +56,7 @@ import "./ha-menu-button";
import "./ha-svg-icon";
import "./user/ha-user-badge";
const SHOW_AFTER_SPACER = ["config", "developer-tools"];
const SHOW_AFTER_SPACER = ["config"];
const SUPPORT_SCROLL_IF_NEEDED = "scrollIntoViewIfNeeded" in document.body;
@@ -66,14 +65,12 @@ const SORT_VALUE_URL_PATHS = {
map: 2,
logbook: 3,
history: 4,
"developer-tools": 9,
config: 11,
};
const PANEL_ICONS = {
calendar: mdiCalendar,
config: mdiCog,
"developer-tools": mdiHammer,
energy: mdiLightningBolt,
history: mdiChartBox,
logbook: mdiFormatListBulletedType,
@@ -1033,19 +1030,6 @@ class HaSidebar extends LitElement {
white-space: nowrap;
}
.dev-tools {
display: flex;
flex-direction: row;
justify-content: space-between;
padding: 0 8px;
width: 256px;
box-sizing: border-box;
}
.dev-tools a {
color: var(--sidebar-icon-color);
}
.tooltip {
display: none;
position: absolute;

View File

@@ -413,32 +413,34 @@ export class HaMediaPlayerBrowse extends LitElement {
let parentProm: Promise<MediaPlayerItem> | undefined;
// See if we can take loading shortcuts if navigating to parent or child
if (
// Check if we navigated to a child
oldNavigateIds &&
this.navigateIds.length > oldNavigateIds.length &&
oldNavigateIds.every((oldVal, idx) => {
const curVal = this.navigateIds[idx];
return (
curVal.media_content_id === oldVal.media_content_id &&
curVal.media_content_type === oldVal.media_content_type
);
})
) {
parentProm = Promise.resolve(oldCurrentItem!);
} else if (
// Check if we navigated to a parent
oldNavigateIds &&
this.navigateIds.length < oldNavigateIds.length &&
this.navigateIds.every((curVal, idx) => {
const oldVal = oldNavigateIds[idx];
return (
curVal.media_content_id === oldVal.media_content_id &&
curVal.media_content_type === oldVal.media_content_type
);
})
) {
currentProm = Promise.resolve(oldParentItem!);
if (!changedProps.has("entityId")) {
if (
// Check if we navigated to a child
oldNavigateIds &&
this.navigateIds.length > oldNavigateIds.length &&
oldNavigateIds.every((oldVal, idx) => {
const curVal = this.navigateIds[idx];
return (
curVal.media_content_id === oldVal.media_content_id &&
curVal.media_content_type === oldVal.media_content_type
);
})
) {
parentProm = Promise.resolve(oldCurrentItem!);
} else if (
// Check if we navigated to a parent
oldNavigateIds &&
this.navigateIds.length < oldNavigateIds.length &&
this.navigateIds.every((curVal, idx) => {
const oldVal = oldNavigateIds[idx];
return (
curVal.media_content_id === oldVal.media_content_id &&
curVal.media_content_type === oldVal.media_content_type
);
})
) {
currentProm = Promise.resolve(oldParentItem!);
}
}
// Fetch current
if (!currentProm) {
@@ -710,7 +712,7 @@ export class HaMediaPlayerBrowse extends LitElement {
right: 0;
left: 0;
z-index: 5;
padding: 20px 24px 10px;
padding: 20px 24px 10px 32px;
}
.header_button {
@@ -809,8 +811,7 @@ export class HaMediaPlayerBrowse extends LitElement {
minmax(var(--media-browse-item-size, 175px), 0.1fr)
);
grid-gap: 16px;
padding: 0px 24px;
margin: 8px 0px;
padding: 8px;
}
:host([dialog]) .children {

View File

@@ -114,5 +114,8 @@ export const localizeConfigFlowTitle = (
args.push(key);
args.push(placeholders[key]);
});
return localize(`component.${flow.handler}.config.flow_title`, ...args);
return localize(`component.${flow.handler}.config.flow_title`, ...args) ||
"name" in placeholders
? placeholders.name
: domainToName(localize, flow.handler);
};

View File

@@ -1,9 +1,10 @@
import { HomeAssistant } from "../types";
interface DiagnosticInfo {
export interface DiagnosticInfo {
domain: string;
handlers: {
config_entry: boolean;
device: boolean;
};
}
@@ -14,5 +15,19 @@ export const fetchDiagnosticHandlers = (
type: "diagnostics/list",
});
export const fetchDiagnosticHandler = (
hass: HomeAssistant,
domain: string
): Promise<DiagnosticInfo> =>
hass.callWS<DiagnosticInfo>({
type: "diagnostics/get",
domain,
});
export const getConfigEntryDiagnosticsDownloadUrl = (entry_id: string) =>
`/api/diagnostics/config_entry/${entry_id}`;
export const getDeviceDiagnosticsDownloadUrl = (
entry_id: string,
device_id: string
) => `/api/diagnostics/config_entry/${entry_id}/device/${device_id}`;

View File

@@ -302,7 +302,8 @@ export const installHassioAddon = async (
export const updateHassioAddon = async (
hass: HomeAssistant,
slug: string
slug: string,
backup: boolean
): Promise<void> => {
if (atLeastVersion(hass.config.version, 2021, 2, 4)) {
await hass.callWS({
@@ -310,11 +311,13 @@ export const updateHassioAddon = async (
endpoint: `/store/addons/${slug}/update`,
method: "post",
timeout: null,
data: { backup },
});
} else {
await hass.callApi<HassioResponse<void>>(
"POST",
`hassio/addons/${slug}/update`
`hassio/addons/${slug}/update`,
{ backup }
);
}
};

View File

@@ -20,6 +20,7 @@ export interface HassioBackup {
slug: string;
date: string;
name: string;
size: number;
type: "full" | "partial";
protected: boolean;
content: BackupContent;

View File

@@ -320,3 +320,16 @@ export const computeMediaControls = (
return buttons.length > 0 ? buttons : undefined;
};
export const formatMediaTime = (seconds: number): string => {
if (!seconds) {
return "";
}
let secondsString = new Date(seconds * 1000).toISOString();
secondsString =
seconds > 3600
? secondsString.substring(11, 16)
: secondsString.substring(14, 19);
return secondsString.replace(/^0+/, "").padStart(4, "0");
};

View File

@@ -6,15 +6,18 @@ export const restartCore = async (hass: HomeAssistant) => {
await hass.callService("homeassistant", "restart");
};
export const updateCore = async (hass: HomeAssistant) => {
export const updateCore = async (hass: HomeAssistant, backup: boolean) => {
if (atLeastVersion(hass.config.version, 2021, 2, 4)) {
await hass.callWS({
type: "supervisor/api",
endpoint: "/core/update",
method: "post",
timeout: null,
data: { backup },
});
} else {
await hass.callApi<HassioResponse<void>>("POST", `hassio/core/update`);
await hass.callApi<HassioResponse<void>>("POST", `hassio/core/update`, {
backup,
});
}
};

View File

@@ -1,3 +1,9 @@
import {
mdiCrownCircleOutline,
mdiAlphaSCircleOutline,
mdiHomeCircleOutline,
mdiCancel,
} from "@mdi/js";
import { HomeAssistant } from "../types";
import { Credential } from "./auth";
@@ -73,7 +79,36 @@ export const computeUserInitials = (name: string) => {
.split(" ")
.slice(0, 3)
// Of each word, take first letter
.map((s) => s.substr(0, 1))
.map((s) => s.substring(0, 1))
.join("")
);
};
const OWNER_ICON = mdiCrownCircleOutline;
const SYSTEM_ICON = mdiAlphaSCircleOutline;
const LOCAL_ICON = mdiHomeCircleOutline;
const DISABLED_ICON = mdiCancel;
export const computeUserBadges = (
hass: HomeAssistant,
user: User,
includeSystem: boolean
) => {
const labels: [string, string][] = [];
const translate = (key) => hass.localize(`ui.panel.config.users.${key}`);
if (user.is_owner) {
labels.push([OWNER_ICON, translate("is_owner")]);
}
if (includeSystem && user.system_generated) {
labels.push([SYSTEM_ICON, translate("is_system")]);
}
if (user.local_only) {
labels.push([LOCAL_ICON, translate("is_local")]);
}
if (!user.is_active) {
labels.push([DISABLED_ICON, translate("is_not_active")]);
}
return labels;
};

View File

@@ -1,10 +1,9 @@
import "@material/mwc-button";
import { mdiPlayCircleOutline } from "@mdi/js";
import { mdiPlayCircleOutline, mdiRobot } from "@mdi/js";
import "@polymer/paper-input/paper-textarea";
import type { PaperTextareaElement } from "@polymer/paper-input/paper-textarea";
import "@polymer/paper-item/paper-item";
import "@polymer/paper-listbox/paper-listbox";
import type { PaperListboxElement } from "@polymer/paper-listbox/paper-listbox";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { customElement, property, state, query } from "lit/decorators";
import { LocalStorage } from "../../../../common/decorators/local-storage";
@@ -14,6 +13,7 @@ import { computeStateName } from "../../../../common/entity/compute_state_name";
import { supportsFeature } from "../../../../common/entity/supports-feature";
import { createCloseHeading } from "../../../../components/ha-dialog";
import "../../../../components/ha-paper-dropdown-menu";
import { showAutomationEditor } from "../../../../data/automation";
import { SUPPORT_PLAY_MEDIA } from "../../../../data/media-player";
import { convertTextToSpeech } from "../../../../data/tts";
import { showAlertDialog } from "../../../../dialogs/generic/show-dialog-box";
@@ -29,13 +29,11 @@ export class DialogTryTts extends LitElement {
@state() private _params?: TryTtsDialogParams;
@query("#target") private _targetInput?: PaperListboxElement;
@query("#message") private _messageInput?: PaperTextareaElement;
@LocalStorage("cloudTtsTryMessage") private _message?: string;
@LocalStorage("cloudTtsTryMessage") private _message!: string;
@LocalStorage("cloudTtsTryTarget") private _target?: string;
@LocalStorage("cloudTtsTryTarget") private _target!: string;
public showDialog(params: TryTtsDialogParams) {
this._params = params;
@@ -50,6 +48,7 @@ export class DialogTryTts extends LitElement {
if (!this._params) {
return html``;
}
const target = this._target || "browser";
return html`
<ha-dialog
open
@@ -83,7 +82,8 @@ export class DialogTryTts extends LitElement {
id="target"
slot="dropdown-content"
attr-for-selected="item-value"
.selected=${this._target || "browser"}
.selected=${target}
@selected-changed=${this._handleTargetChanged}
>
<paper-item item-value="browser">
${this.hass.localize(
@@ -108,42 +108,70 @@ export class DialogTryTts extends LitElement {
</div>
<mwc-button
slot="primaryAction"
.label=${this.hass.localize(
"ui.panel.config.cloud.account.tts.dialog.play"
)}
@click=${this._playExample}
.disabled=${this._loadingExample}
>
<ha-svg-icon .path=${mdiPlayCircleOutline}></ha-svg-icon>
&nbsp;${this.hass.localize(
"ui.panel.config.cloud.account.tts.dialog.play"
<ha-svg-icon slot="icon" .path=${mdiPlayCircleOutline}></ha-svg-icon>
</mwc-button>
<mwc-button
slot="secondaryAction"
.disabled=${target === "browser"}
.label=${this.hass.localize(
"ui.panel.config.cloud.account.tts.dialog.create_automation"
)}
@click=${this._createAutomation}
>
<ha-svg-icon slot="icon" .path=${mdiRobot}></ha-svg-icon>
</mwc-button>
</ha-dialog>
`;
}
private async _playExample() {
const target = String(this._targetInput?.selected);
const message = this._messageInput?.value;
private _handleTargetChanged(ev) {
this._target = ev.detail.value;
this.requestUpdate("_target");
}
if (!message || !target) {
private async _playExample() {
const message = this._messageInput?.value;
if (!message) {
return;
}
this._message = message;
this._target = target;
if (target === "browser") {
if (this._target === "browser") {
// We create the audio element here + do a play, because iOS requires it to be done by user action
const audio = new Audio();
audio.play();
this._playBrowser(message, audio);
} else {
this.hass.callService("tts", "cloud_say", {
entity_id: target,
entity_id: this._target,
message,
});
}
}
private _createAutomation() {
const message = this._messageInput!.value!;
this._message = message;
showAutomationEditor({
action: [
{
service: "tts.cloud_say",
data: {
entity_id: this._target,
message: message,
},
},
],
});
this.closeDialog();
}
private async _playBrowser(message: string, audio: HTMLAudioElement) {
this._loadingExample = true;

View File

@@ -3,6 +3,7 @@ import "@polymer/paper-tooltip/paper-tooltip";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { customElement, property, state } from "lit/decorators";
import { ifDefined } from "lit/directives/if-defined";
import { until } from "lit/directives/until";
import memoizeOne from "memoize-one";
import { isComponentLoaded } from "../../../common/config/is_component_loaded";
import { computeDomain } from "../../../common/entity/compute_domain";
@@ -17,6 +18,7 @@ import "../../../components/ha-icon-button";
import "../../../components/ha-icon-next";
import "../../../components/ha-svg-icon";
import { AreaRegistryEntry } from "../../../data/area_registry";
import { getSignedPath } from "../../../data/auth";
import {
ConfigEntry,
disableConfigEntry,
@@ -27,6 +29,11 @@ import {
DeviceRegistryEntry,
updateDeviceRegistryEntry,
} from "../../../data/device_registry";
import {
fetchDiagnosticHandler,
getDeviceDiagnosticsDownloadUrl,
getConfigEntryDiagnosticsDownloadUrl,
} from "../../../data/diagnostics";
import {
EntityRegistryEntry,
findBatteryChargingEntity,
@@ -44,6 +51,7 @@ import "../../../layouts/hass-tabs-subpage";
import { haStyle } from "../../../resources/styles";
import { HomeAssistant, Route } from "../../../types";
import { brandsUrl } from "../../../util/brands-url";
import { fileDownload } from "../../../util/file_download";
import "../ha-config-section";
import { configSections } from "../ha-panel-config";
import "./device-detail/ha-device-entities-card";
@@ -82,6 +90,10 @@ export class HaConfigDevicePage extends LitElement {
@state() private _related?: RelatedResult;
@state() private _diagnosticDownloadLinks?: Promise<
(TemplateResult | string)[]
>;
private _device = memoizeOne(
(
deviceId: string,
@@ -91,10 +103,8 @@ export class HaConfigDevicePage extends LitElement {
);
private _integrations = memoizeOne(
(device: DeviceRegistryEntry, entries: ConfigEntry[]): string[] =>
entries
.filter((entry) => device.config_entries.includes(entry.entry_id))
.map((entry) => entry.domain)
(device: DeviceRegistryEntry, entries: ConfigEntry[]): ConfigEntry[] =>
entries.filter((entry) => device.config_entries.includes(entry.entry_id))
);
private _entities = memoizeOne(
@@ -165,6 +175,65 @@ export class HaConfigDevicePage extends LitElement {
findBatteryChargingEntity(this.hass, entities)
);
public willUpdate(changedProps) {
super.willUpdate(changedProps);
if (
changedProps.has("deviceId") ||
changedProps.has("devices") ||
changedProps.has("deviceId") ||
changedProps.has("entries")
) {
this._diagnosticDownloadLinks = undefined;
}
if (
this._diagnosticDownloadLinks ||
!this.devices ||
!this.deviceId ||
!this.entries
) {
return;
}
this._diagnosticDownloadLinks = this._renderDiagnosticButtons();
}
private async _renderDiagnosticButtons(): Promise<
(TemplateResult | string)[]
> {
const result: TemplateResult[] = [];
const device = this._device(this.deviceId, this.devices);
if (!device) {
return result;
}
return Promise.all(
this._integrations(device, this.entries)
.filter((entry) => entry.state === "loaded")
.map(async (entry) => {
const info = await fetchDiagnosticHandler(this.hass, entry.domain);
if (!info.handlers.device && !info.handlers.config_entry) {
return "";
}
const link = info.handlers.device
? getDeviceDiagnosticsDownloadUrl(entry.entry_id, this.deviceId)
: getConfigEntryDiagnosticsDownloadUrl(entry.entry_id);
return html`
<a href=${link} @click=${this._signUrl}>
<mwc-button>
${this.hass.localize(
`ui.panel.config.devices.download_diagnostics`
)}
</mwc-button>
</a>
`;
})
);
}
protected firstUpdated(changedProps) {
super.firstUpdated(changedProps);
loadDeviceRegistryDetailDialog();
@@ -214,6 +283,66 @@ export class HaConfigDevicePage extends LitElement {
? device.configuration_url!.replace("homeassistant://", "/")
: device.configuration_url;
const deviceInfo: TemplateResult[] = [];
if (device.disabled_by) {
deviceInfo.push(
html`
<ha-alert alert-type="warning">
${this.hass.localize(
"ui.panel.config.devices.enabled_cause",
"cause",
this.hass.localize(
`ui.panel.config.devices.disabled_by.${device.disabled_by}`
)
)}
</ha-alert>
${device.disabled_by === "user"
? html` <div class="card-actions" slot="actions">
<mwc-button unelevated @click=${this._enableDevice}>
${this.hass.localize("ui.common.enable")}
</mwc-button>
</div>`
: ""}
`
);
}
const deviceActions: TemplateResult[] = [];
if (configurationUrl) {
deviceActions.push(html`
<a
href=${configurationUrl}
rel="noopener noreferrer"
.target=${configurationUrlIsHomeAssistant ? "_self" : "_blank"}
>
<mwc-button>
${this.hass.localize(
`ui.panel.config.devices.open_configuration_url_${
device.entry_type || "device"
}`
)}
<ha-svg-icon
.path=${mdiOpenInNew}
slot="trailingIcon"
></ha-svg-icon>
</mwc-button>
</a>
`);
}
this._renderIntegrationInfo(
device,
integrations,
deviceInfo,
deviceActions
);
if (this._diagnosticDownloadLinks) {
deviceActions.push(html`${until(this._diagnosticDownloadLinks)}`);
}
return html`
<hass-tabs-subpage
.hass=${this.hass}
@@ -291,7 +420,7 @@ export class HaConfigDevicePage extends LitElement {
? html`
<img
src=${brandsUrl({
domain: integrations[0],
domain: integrations[0].domain,
type: "logo",
darkOptimized: this.hass.themes?.darkMode,
})}
@@ -312,56 +441,16 @@ export class HaConfigDevicePage extends LitElement {
.devices=${this.devices}
.device=${device}
>
${
device.disabled_by
? html`
<ha-alert alert-type="warning">
${this.hass.localize(
"ui.panel.config.devices.enabled_cause",
"cause",
this.hass.localize(
`ui.panel.config.devices.disabled_by.${device.disabled_by}`
)
)}
</ha-alert>
${device.disabled_by === "user"
? html` <div class="card-actions" slot="actions">
<mwc-button unelevated @click=${this._enableDevice}>
${this.hass.localize("ui.common.enable")}
</mwc-button>
</div>`
: ""}
`
: html``
}
${
configurationUrl
? html`
<div class="card-actions" slot="actions">
<a
href=${configurationUrl}
rel="noopener noreferrer"
.target=${configurationUrlIsHomeAssistant
? "_self"
: "_blank"}
>
<mwc-button>
${this.hass.localize(
`ui.panel.config.devices.open_configuration_url_${
device.entry_type || "device"
}`
)}
<ha-svg-icon
.path=${mdiOpenInNew}
slot="trailingIcon"
></ha-svg-icon>
</mwc-button>
</a>
</div>
`
: ""
}
${this._renderIntegrationInfo(device, integrations)}
${deviceInfo}
${
deviceActions.length
? html`
<div class="card-actions" slot="actions">
${deviceActions}
</div>
`
: ""
}
</ha-device-info-card>
</div>
<div class="column">
@@ -648,85 +737,84 @@ export class HaConfigDevicePage extends LitElement {
private _renderIntegrationInfo(
device,
integrations: string[]
integrations: ConfigEntry[],
deviceInfo: TemplateResult[],
deviceActions: TemplateResult[]
): TemplateResult[] {
const domains = integrations.map((int) => int.domain);
const templates: TemplateResult[] = [];
if (integrations.includes("mqtt")) {
if (domains.includes("mqtt")) {
import(
"./device-detail/integration-elements/mqtt/ha-device-actions-mqtt"
);
templates.push(html`
<div class="card-actions" slot="actions">
<ha-device-actions-mqtt
.hass=${this.hass}
.device=${device}
></ha-device-actions-mqtt>
</div>
deviceActions.push(html`
<ha-device-actions-mqtt
.hass=${this.hass}
.device=${device}
></ha-device-actions-mqtt>
`);
}
if (integrations.includes("ozw")) {
if (domains.includes("ozw")) {
import("./device-detail/integration-elements/ozw/ha-device-actions-ozw");
import("./device-detail/integration-elements/ozw/ha-device-info-ozw");
templates.push(html`
deviceInfo.push(html`
<ha-device-info-ozw
.hass=${this.hass}
.device=${device}
></ha-device-info-ozw>
<div class="card-actions" slot="actions">
<ha-device-actions-ozw
.hass=${this.hass}
.device=${device}
></ha-device-actions-ozw>
</div>
`);
deviceActions.push(html`
<ha-device-actions-ozw
.hass=${this.hass}
.device=${device}
></ha-device-actions-ozw>
`);
}
if (integrations.includes("tasmota")) {
if (domains.includes("tasmota")) {
import(
"./device-detail/integration-elements/tasmota/ha-device-actions-tasmota"
);
templates.push(html`
<div class="card-actions" slot="actions">
<ha-device-actions-tasmota
.hass=${this.hass}
.device=${device}
></ha-device-actions-tasmota>
</div>
deviceActions.push(html`
<ha-device-actions-tasmota
.hass=${this.hass}
.device=${device}
></ha-device-actions-tasmota>
`);
}
if (integrations.includes("zha")) {
if (domains.includes("zha")) {
import("./device-detail/integration-elements/zha/ha-device-actions-zha");
import("./device-detail/integration-elements/zha/ha-device-info-zha");
templates.push(html`
deviceInfo.push(html`
<ha-device-info-zha
.hass=${this.hass}
.device=${device}
></ha-device-info-zha>
<div class="card-actions" slot="actions">
<ha-device-actions-zha
.hass=${this.hass}
.device=${device}
></ha-device-actions-zha>
</div>
`);
deviceActions.push(html`
<ha-device-actions-zha
.hass=${this.hass}
.device=${device}
></ha-device-actions-zha>
`);
}
if (integrations.includes("zwave_js")) {
if (domains.includes("zwave_js")) {
import(
"./device-detail/integration-elements/zwave_js/ha-device-info-zwave_js"
);
import(
"./device-detail/integration-elements/zwave_js/ha-device-actions-zwave_js"
);
templates.push(html`
deviceInfo.push(html`
<ha-device-info-zwave_js
.hass=${this.hass}
.device=${device}
></ha-device-info-zwave_js>
<div class="card-actions" slot="actions">
<ha-device-actions-zwave_js
.hass=${this.hass}
.device=${device}
></ha-device-actions-zwave_js>
</div>
`);
deviceActions.push(html`
<ha-device-actions-zwave_js
.hass=${this.hass}
.device=${device}
></ha-device-actions-zwave_js>
`);
}
return templates;
@@ -866,6 +954,16 @@ export class HaConfigDevicePage extends LitElement {
});
}
private async _signUrl(ev) {
const anchor = ev.target.closest("a");
ev.preventDefault();
const signedUrl = await getSignedPath(
this.hass,
anchor.getAttribute("href")
);
fileDownload(signedUrl.path);
}
static get styles(): CSSResultGroup {
return [
haStyle,

View File

@@ -207,7 +207,9 @@ export class HaConfigDeviceDashboard extends LitElement {
entryLookup[entId].domain
)
.join(", ")
: "No integration",
: this.hass.localize(
"ui.panel.config.devices.data_table.no_integration"
),
battery_entity: [
this._batteryEntity(device.id, deviceEntityLookup),
this._batteryChargingEntity(device.id, deviceEntityLookup),

View File

@@ -4,6 +4,7 @@ import {
mdiCellphoneCog,
mdiCog,
mdiDevices,
mdiHammer,
mdiHomeAssistant,
mdiInformation,
mdiLightningBolt,
@@ -72,7 +73,7 @@ export const configSections: { [name: string]: PageNavigation[] } = {
path: "/hassio",
translationKey: "supervisor",
iconPath: mdiHomeAssistant,
iconColor: "#4084CD",
iconColor: "#F1C447",
component: "hassio",
},
{
@@ -116,6 +117,12 @@ export const configSections: { [name: string]: PageNavigation[] } = {
iconColor: "#4A5963",
core: true,
},
{
path: "/developer-tools",
translationKey: "developer_tools",
iconPath: mdiHammer,
iconColor: "#4084CD",
},
],
devices: [
{

View File

@@ -2,13 +2,13 @@ import "@polymer/paper-input/paper-input";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { customElement, property, state } from "lit/decorators";
import { fireEvent } from "../../../../common/dom/fire_event";
import "../../../../components/ha-formfield";
import "../../../../components/ha-icon-picker";
import "../../../../components/ha-radio";
import type { HaRadio } from "../../../../components/ha-radio";
import { InputDateTime } from "../../../../data/input_datetime";
import { haStyle } from "../../../../resources/styles";
import { HomeAssistant } from "../../../../types";
import "../../../../components/ha-formfield";
import "../../../../components/ha-radio";
import type { HaRadio } from "../../../../components/ha-radio";
@customElement("ha-input_datetime-form")
class HaInputDateTimeForm extends LitElement {
@@ -35,6 +35,8 @@ class HaInputDateTimeForm extends LitElement {
: item.has_time
? "time"
: "date";
this._item.has_date =
!item.has_date && !item.has_time ? true : item.has_date;
} else {
this._name = "";
this._icon = "";

View File

@@ -362,7 +362,7 @@ export class HaIntegrationCard extends LitElement {
)}
</mwc-list-item>`
: ""}
${this.supportsDiagnostics
${this.supportsDiagnostics && item.state === "loaded"
? html`<a
href=${getConfigEntryDiagnosticsDownloadUrl(item.entry_id)}
target="_blank"

View File

@@ -3,13 +3,18 @@ import "@polymer/paper-input/paper-input";
import "@polymer/paper-tooltip/paper-tooltip";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { customElement, property, state } from "lit/decorators";
import { computeRTLDirection } from "../../../common/util/compute_rtl";
import { createCloseHeading } from "../../../components/ha-dialog";
import "../../../components/ha-formfield";
import "../../../components/ha-help-tooltip";
import "../../../components/ha-chip-set";
import "../../../components/ha-chip";
import "../../../components/ha-svg-icon";
import "../../../components/ha-switch";
import { adminChangePassword } from "../../../data/auth";
import {
computeUserBadges,
SYSTEM_GROUP_ID_ADMIN,
SYSTEM_GROUP_ID_USER,
} from "../../../data/user";
@@ -55,6 +60,7 @@ class DialogUserDetail extends LitElement {
return html``;
}
const user = this._params.entry;
const badges = computeUserBadges(this.hass, user, true);
return html`
<ha-dialog
open
@@ -71,26 +77,20 @@ class DialogUserDetail extends LitElement {
${this.hass.localize("ui.panel.config.users.editor.username")}:
${user.username}
</div>
<div>
${user.is_owner
? html`
<span class="state"
>${this.hass.localize(
"ui.panel.config.users.editor.owner"
)}</span
>
`
: ""}
${user.system_generated
? html`
<span class="state">
${this.hass.localize(
"ui.panel.config.users.editor.system_generated"
)}
</span>
`
: ""}
</div>
${badges.length === 0
? ""
: html`
<ha-chip-set>
${badges.map(
([icon, label]) => html`
<ha-chip hasIcon>
<ha-svg-icon slot="icon" .path=${icon}></ha-svg-icon>
${label}
</ha-chip>
`
)}
</ha-chip-set>
`}
<div class="form">
<paper-input
.value=${this._name}
@@ -321,6 +321,9 @@ class DialogUserDetail extends LitElement {
.secondary {
color: var(--secondary-text-color);
}
ha-chip-set {
display: block;
}
.state {
background-color: rgba(var(--rgb-primary-text-color), 0.15);
border-radius: 16px;

View File

@@ -3,13 +3,22 @@ import { html, LitElement, PropertyValues } from "lit";
import { customElement, property } from "lit/decorators";
import memoizeOne from "memoize-one";
import { HASSDomEvent } from "../../../common/dom/fire_event";
import { LocalizeFunc } from "../../../common/translations/localize";
import {
DataTableColumnContainer,
RowClickedEvent,
} from "../../../components/data-table/ha-data-table";
import "../../../components/data-table/ha-data-table-icon";
import "../../../components/ha-fab";
import "../../../components/ha-help-tooltip";
import "../../../components/ha-svg-icon";
import { deleteUser, fetchUsers, updateUser, User } from "../../../data/user";
import {
computeUserBadges,
deleteUser,
fetchUsers,
updateUser,
User,
} from "../../../data/user";
import { showConfirmationDialog } from "../../../dialogs/generic/show-dialog-box";
import "../../../layouts/hass-tabs-subpage-data-table";
import { HomeAssistant, Route } from "../../../types";
@@ -30,23 +39,21 @@ export class HaConfigUsers extends LitElement {
@property() public route!: Route;
private _columns = memoizeOne(
(narrow: boolean, _language): DataTableColumnContainer => {
const columns: DataTableColumnContainer = {
(narrow: boolean, localize: LocalizeFunc): DataTableColumnContainer => {
const columns: DataTableColumnContainer<User> = {
name: {
title: this.hass.localize(
"ui.panel.config.users.picker.headers.name"
),
title: localize("ui.panel.config.users.picker.headers.name"),
sortable: true,
filterable: true,
width: "25%",
direction: "asc",
grows: true,
template: (name, user: any) =>
template: (name, user) =>
narrow
? html` ${name}<br />
<div class="secondary">
${user.username} |
${this.hass.localize(`groups.${user.group_ids[0]}`)}
${user.username ? `${user.username} |` : ""}
${localize(`groups.${user.group_ids[0]}`)}
</div>`
: html` ${name ||
this.hass!.localize(
@@ -54,31 +61,22 @@ export class HaConfigUsers extends LitElement {
)}`,
},
username: {
title: this.hass.localize(
"ui.panel.config.users.picker.headers.username"
),
title: localize("ui.panel.config.users.picker.headers.username"),
sortable: true,
filterable: true,
width: "20%",
direction: "asc",
hidden: narrow,
template: (username) => html`
${username ||
this.hass!.localize("ui.panel.config.users.editor.unnamed_user")}
`,
template: (username) => html` ${username || "-"} `,
},
group_ids: {
title: this.hass.localize(
"ui.panel.config.users.picker.headers.group"
),
title: localize("ui.panel.config.users.picker.headers.group"),
sortable: true,
filterable: true,
width: "20%",
direction: "asc",
hidden: narrow,
template: (groupIds) => html`
${this.hass.localize(`groups.${groupIds[0]}`)}
`,
template: (groupIds) => html` ${localize(`groups.${groupIds[0]}`)} `,
},
is_active: {
title: this.hass.localize(
@@ -88,6 +86,7 @@ export class HaConfigUsers extends LitElement {
sortable: true,
filterable: true,
width: "80px",
hidden: narrow,
template: (is_active) =>
is_active
? html`<ha-svg-icon .path=${mdiCheck}></ha-svg-icon>`
@@ -100,7 +99,8 @@ export class HaConfigUsers extends LitElement {
type: "icon",
sortable: true,
filterable: true,
width: "160px",
width: "80px",
hidden: narrow,
template: (generated) =>
generated
? html`<ha-svg-icon .path=${mdiCheck}></ha-svg-icon>`
@@ -113,10 +113,29 @@ export class HaConfigUsers extends LitElement {
type: "icon",
sortable: true,
filterable: true,
width: "160px",
width: "80px",
hidden: narrow,
template: (local) =>
local ? html`<ha-svg-icon .path=${mdiCheck}></ha-svg-icon>` : "",
},
icons: {
title: "",
type: "icon",
sortable: false,
filterable: false,
width: "104px",
hidden: !narrow,
template: (_, user) => {
const badges = computeUserBadges(this.hass, user, false);
return html`${badges.map(
([icon, tooltip]) =>
html`<ha-data-table-icon
.path=${icon}
.tooltip=${tooltip}
></ha-data-table-icon>`
)}`;
},
},
};
return columns;
@@ -136,7 +155,7 @@ export class HaConfigUsers extends LitElement {
.route=${this.route}
backPath="/config"
.tabs=${configSections.persons}
.columns=${this._columns(this.narrow, this.hass.language)}
.columns=${this._columns(this.narrow, this.hass.localize)}
.data=${this._users}
@row-click=${this._editUser}
hasFab

View File

@@ -120,8 +120,11 @@ class HuiInputNumberEntityRow extends LitElement implements LovelaceRow {
type="number"
@change=${this._selectedValueChanged}
id="input"
></paper-input>
${stateObj.attributes.unit_of_measurement}
>
<span slot="suffix">
${stateObj.attributes.unit_of_measurement}
</span>
</paper-input>
</div>
`}
</hui-generic-entity-row>

View File

@@ -0,0 +1,496 @@
import "@material/mwc-button/mwc-button";
import "@material/mwc-linear-progress/mwc-linear-progress";
import type { LinearProgress } from "@material/mwc-linear-progress/mwc-linear-progress";
import "@material/mwc-list/mwc-list-item";
import {
mdiChevronDown,
mdiMonitor,
mdiPause,
mdiPlay,
mdiPlayPause,
mdiStop,
} from "@mdi/js";
import {
css,
CSSResultGroup,
html,
LitElement,
PropertyValues,
TemplateResult,
} from "lit";
import { customElement, property, query, state } from "lit/decorators";
import { computeDomain } from "../../common/entity/compute_domain";
import { computeStateDomain } from "../../common/entity/compute_state_domain";
import { computeStateName } from "../../common/entity/compute_state_name";
import { domainIcon } from "../../common/entity/domain_icon";
import { supportsFeature } from "../../common/entity/supports-feature";
import { navigate } from "../../common/navigate";
import "../../components/ha-button-menu";
import "../../components/ha-icon-button";
import { UNAVAILABLE_STATES } from "../../data/entity";
import {
BROWSER_PLAYER,
computeMediaControls,
computeMediaDescription,
formatMediaTime,
getCurrentProgress,
MediaPlayerEntity,
SUPPORT_BROWSE_MEDIA,
SUPPORT_PAUSE,
SUPPORT_PLAY,
SUPPORT_STOP,
} from "../../data/media-player";
import type { HomeAssistant } from "../../types";
import "../lovelace/components/hui-marquee";
@customElement("ha-bar-media-player")
class BarMediaPlayer extends LitElement {
@property({ attribute: false }) public hass!: HomeAssistant;
@property({ attribute: false }) public entityId!: string;
@property({ type: Boolean, reflect: true })
public narrow!: boolean;
@query("mwc-linear-progress") private _progressBar?: LinearProgress;
@query("#CurrentProgress") private _currentProgress?: HTMLElement;
@state() private _marqueeActive = false;
private _progressInterval?: number;
public connectedCallback(): void {
super.connectedCallback();
const stateObj = this._stateObj;
if (!stateObj) {
return;
}
if (
!this._progressInterval &&
this._showProgressBar &&
stateObj.state === "playing"
) {
this._progressInterval = window.setInterval(
() => this._updateProgressBar(),
1000
);
}
}
public disconnectedCallback(): void {
if (this._progressInterval) {
clearInterval(this._progressInterval);
this._progressInterval = undefined;
}
}
protected render(): TemplateResult {
const choosePlayerElement = html`
<div
class="choose-player ${this.entityId === BROWSER_PLAYER
? "browser"
: ""}"
>
<ha-button-menu corner="BOTTOM_START">
${this.narrow
? html`
<ha-icon-button
slot="trigger"
.path=${this._stateObj
? domainIcon(computeDomain(this.entityId), this._stateObj)
: mdiMonitor}
></ha-icon-button>
`
: html`
<mwc-button
slot="trigger"
.label=${this.narrow
? ""
: `${
this._stateObj
? computeStateName(this._stateObj)
: BROWSER_PLAYER
}
`}
>
<ha-svg-icon
slot="icon"
.path=${this._stateObj
? domainIcon(computeDomain(this.entityId), this._stateObj)
: mdiMonitor}
></ha-svg-icon>
<ha-svg-icon
slot="trailingIcon"
.path=${mdiChevronDown}
></ha-svg-icon>
</mwc-button>
`}
<mwc-list-item .player=${BROWSER_PLAYER} @click=${this._selectPlayer}
>${this.hass.localize(
"ui.components.media-browser.web-browser"
)}</mwc-list-item
>
${this._mediaPlayerEntities.map(
(source) => html`
<mwc-list-item
?selected=${source.entity_id === this.entityId}
.disabled=${UNAVAILABLE_STATES.includes(source.state)}
.player=${source.entity_id}
@click=${this._selectPlayer}
>${computeStateName(source)}</mwc-list-item
>
`
)}
</ha-button-menu>
</div>
`;
if (!this._stateObj) {
return choosePlayerElement;
}
const stateObj = this._stateObj;
const controls = !this.narrow
? computeMediaControls(stateObj)
: (stateObj.state === "playing" &&
(supportsFeature(stateObj, SUPPORT_PAUSE) ||
supportsFeature(stateObj, SUPPORT_STOP))) ||
((stateObj.state === "paused" || stateObj.state === "idle") &&
supportsFeature(stateObj, SUPPORT_PLAY)) ||
(stateObj.state === "on" &&
(supportsFeature(stateObj, SUPPORT_PLAY) ||
supportsFeature(stateObj, SUPPORT_PAUSE)))
? [
{
icon:
stateObj.state === "on"
? mdiPlayPause
: stateObj.state !== "playing"
? mdiPlay
: supportsFeature(stateObj, SUPPORT_PAUSE)
? mdiPause
: mdiStop,
action:
stateObj.state !== "playing"
? "media_play"
: supportsFeature(stateObj, SUPPORT_PAUSE)
? "media_pause"
: "media_stop",
},
]
: [{}];
const mediaDescription = computeMediaDescription(stateObj);
const mediaDuration = formatMediaTime(stateObj!.attributes.media_duration!);
return html`
<div class="info">
${this._image
? html`<img src=${this.hass.hassUrl(this._image)} />`
: stateObj.state === "off" || stateObj.state !== "playing"
? html`<div class="blank-image"></div>`
: ""}
<div class="media-info">
<hui-marquee
.text=${stateObj.attributes.media_title ||
mediaDescription ||
this.hass.localize(`ui.card.media_player.nothing_playing`)}
.active=${this._marqueeActive}
@mouseover=${this._marqueeMouseOver}
@mouseleave=${this._marqueeMouseLeave}
></hui-marquee>
<span class="secondary">
${stateObj.attributes.media_title ? mediaDescription : ""}
</span>
</div>
</div>
<div class="controls-progress">
<div class="controls">
${controls!.map(
(control) => html`
<ha-icon-button
.label=${this.hass.localize(
`ui.card.media_player.${control.action}`
)}
.path=${control.icon}
action=${control.action}
@click=${this._handleClick}
>
</ha-icon-button>
`
)}
</div>
${this.narrow
? html`<mwc-linear-progress></mwc-linear-progress>`
: html`
<div class="progress">
<div id="CurrentProgress"></div>
<mwc-linear-progress wide></mwc-linear-progress>
<div>${mediaDuration}</div>
</div>
`}
</div>
${choosePlayerElement}
`;
}
protected updated(changedProps: PropertyValues) {
if (!this.hass || !this._stateObj || !changedProps.has("hass")) {
return;
}
const stateObj = this._stateObj;
this._updateProgressBar();
if (
!this._progressInterval &&
this._showProgressBar &&
stateObj.state === "playing"
) {
this._progressInterval = window.setInterval(
() => this._updateProgressBar(),
1000
);
} else if (
this._progressInterval &&
(!this._showProgressBar || stateObj.state !== "playing")
) {
clearInterval(this._progressInterval);
this._progressInterval = undefined;
}
}
private get _stateObj(): MediaPlayerEntity | undefined {
return this.hass!.states[this.entityId] as MediaPlayerEntity;
}
private get _showProgressBar() {
if (!this.hass) {
return false;
}
const stateObj = this._stateObj;
if (!stateObj) {
return false;
}
return (
(stateObj.state === "playing" || stateObj.state === "paused") &&
"media_duration" in stateObj.attributes &&
"media_position" in stateObj.attributes
);
}
private get _image() {
if (!this.hass) {
return undefined;
}
const stateObj = this._stateObj;
if (!stateObj) {
return undefined;
}
return (
stateObj.attributes.entity_picture_local ||
stateObj.attributes.entity_picture
);
}
private get _mediaPlayerEntities() {
return Object.values(this.hass!.states).filter((entity) => {
if (
computeStateDomain(entity) === "media_player" &&
supportsFeature(entity, SUPPORT_BROWSE_MEDIA)
) {
return true;
}
return false;
});
}
private _updateProgressBar(): void {
if (this._progressBar && this._stateObj?.attributes.media_duration) {
const currentProgress = getCurrentProgress(this._stateObj);
this._progressBar.progress =
currentProgress / this._stateObj!.attributes.media_duration;
if (this._currentProgress) {
this._currentProgress.innerHTML = formatMediaTime(currentProgress);
}
}
}
private _handleClick(e: MouseEvent): void {
const action = (e.currentTarget! as HTMLElement).getAttribute("action")!;
this.hass!.callService("media_player", action, {
entity_id: this.entityId,
});
}
private _marqueeMouseOver(): void {
if (!this._marqueeActive) {
this._marqueeActive = true;
}
}
private _marqueeMouseLeave(): void {
if (this._marqueeActive) {
this._marqueeActive = false;
}
}
private _selectPlayer(ev: CustomEvent): void {
const entityId = (ev.currentTarget as any).player;
navigate(`/media-browser/${entityId}`, { replace: true });
}
static get styles(): CSSResultGroup {
return css`
:host {
display: flex;
min-height: 100px;
background: var(
--ha-card-background,
var(--card-background-color, white)
);
border-top: 1px solid var(--divider-color);
}
mwc-linear-progress {
width: 100%;
padding: 0 4px;
--mdc-theme-primary: var(--secondary-text-color);
}
mwc-button[slot="trigger"] {
--mdc-theme-primary: var(--primary-text-color);
--mdc-icon-size: 36px;
}
.info {
flex: 1;
display: flex;
align-items: center;
width: 100%;
margin-right: 16px;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
}
.secondary,
.progress {
color: var(--secondary-text-color);
}
.choose-player {
flex: 1;
display: flex;
justify-content: flex-end;
align-items: center;
padding: 16px;
}
.controls-progress {
flex: 2;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
}
.progress {
display: flex;
width: 100%;
align-items: center;
}
mwc-linear-progress[wide] {
margin: 0 4px;
}
.media-info {
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
padding-left: 16px;
width: 100%;
}
hui-marquee {
font-size: 1.2em;
margin: 0px 0 4px;
}
img {
max-height: 100px;
}
.blank-image {
height: 100px;
width: 100px;
background-color: var(--divider-color);
}
ha-button-menu mwc-button {
line-height: 1;
}
:host([narrow]) {
min-height: 80px;
max-height: 80px;
}
:host([narrow]) .controls-progress {
flex: unset;
min-width: 48px;
}
:host([narrow]) .controls {
display: flex;
}
:host([narrow]) .choose-player {
padding-left: 0;
min-width: 48px;
flex: unset;
justify-content: center;
}
:host([narrow]) .choose-player.browser {
justify-content: flex-end;
width: 100%;
}
:host([narrow]) img {
max-height: 80px;
}
:host([narrow]) .blank-image {
height: 80px;
width: 80px;
}
:host([narrow]) mwc-linear-progress {
padding: 0;
position: absolute;
top: -4px;
left: 0;
}
`;
}
}
declare global {
interface HTMLElementTagNameMap {
"ha-bar-media-player": BarMediaPlayer;
}
}

View File

@@ -11,22 +11,16 @@ import {
import { customElement, property } from "lit/decorators";
import { LocalStorage } from "../../common/decorators/local-storage";
import { HASSDomEvent } from "../../common/dom/fire_event";
import { computeStateDomain } from "../../common/entity/compute_state_domain";
import { supportsFeature } from "../../common/entity/supports-feature";
import { navigate } from "../../common/navigate";
import "../../components/ha-menu-button";
import "../../components/media-player/ha-media-player-browse";
import type { MediaPlayerItemId } from "../../components/media-player/ha-media-player-browse";
import {
BROWSER_PLAYER,
MediaPickedEvent,
SUPPORT_BROWSE_MEDIA,
} from "../../data/media-player";
import { BROWSER_PLAYER, MediaPickedEvent } from "../../data/media-player";
import "../../layouts/ha-app-layout";
import { haStyle } from "../../resources/styles";
import type { HomeAssistant, Route } from "../../types";
import "./ha-bar-media-player";
import { showWebBrowserPlayMediaDialog } from "./show-media-player-dialog";
import { showSelectMediaPlayerDialog } from "./show-select-media-source-dialog";
@customElement("ha-panel-media-browser")
class PanelMediaBrowser extends LitElement {
@@ -48,17 +42,6 @@ class PanelMediaBrowser extends LitElement {
private _entityId = BROWSER_PLAYER;
protected render(): TemplateResult {
const stateObj = this._entityId
? this.hass.states[this._entityId]
: undefined;
const title =
this._entityId === BROWSER_PLAYER
? `${this.hass.localize("ui.components.media-browser.web-browser")}`
: stateObj?.attributes.friendly_name
? `${stateObj?.attributes.friendly_name}`
: undefined;
return html`
<ha-app-layout>
<app-header fixed slot="header">
@@ -73,23 +56,22 @@ class PanelMediaBrowser extends LitElement {
"ui.components.media-browser.media-player-browser"
)}
</div>
<div class="secondary-text">${title || ""}</div>
</div>
<mwc-button @click=${this._showSelectMediaPlayerDialog}>
${this.hass.localize("ui.components.media-browser.choose_player")}
</mwc-button>
</app-toolbar>
</app-header>
<div class="content">
<ha-media-player-browse
.hass=${this.hass}
.entityId=${this._entityId}
.navigateIds=${this._navigateIds}
@media-picked=${this._mediaPicked}
@media-browsed=${this._mediaBrowsed}
></ha-media-player-browse>
</div>
<ha-media-player-browse
.hass=${this.hass}
.entityId=${this._entityId}
.navigateIds=${this._navigateIds}
@media-picked=${this._mediaPicked}
@media-browsed=${this._mediaBrowsed}
></ha-media-player-browse>
</ha-app-layout>
<ha-bar-media-player
.hass=${this.hass}
.entityId=${this._entityId}
.narrow=${this.narrow}
></ha-bar-media-player>
`;
}
@@ -129,15 +111,6 @@ class PanelMediaBrowser extends LitElement {
];
}
private _showSelectMediaPlayerDialog(): void {
showSelectMediaPlayerDialog(this, {
mediaSources: this._mediaPlayerEntities,
sourceSelectedCallback: (entityId) => {
navigate(`/media-browser/${entityId}`, { replace: true });
},
});
}
private _mediaBrowsed(ev) {
if (ev.detail.back) {
history.back();
@@ -179,19 +152,6 @@ class PanelMediaBrowser extends LitElement {
});
}
private get _mediaPlayerEntities() {
return Object.values(this.hass!.states).filter((entity) => {
if (
computeStateDomain(entity) === "media_player" &&
supportsFeature(entity, SUPPORT_BROWSE_MEDIA)
) {
return true;
}
return false;
});
}
static get styles(): CSSResultGroup {
return [
haStyle,
@@ -199,21 +159,20 @@ class PanelMediaBrowser extends LitElement {
:host {
--mdc-theme-primary: var(--app-header-text-color);
}
ha-media-player-browse {
height: calc(100vh - var(--header-height));
height: calc(100vh - (100px + var(--header-height)));
}
:host([narrow]) app-toolbar mwc-button {
width: 65px;
:host([narrow]) ha-media-player-browse {
height: calc(100vh - (80px + var(--header-height)));
}
.heading {
overflow: hidden;
white-space: nowrap;
margin-top: 4px;
}
.heading .secondary-text {
font-size: 14px;
overflow: hidden;
text-overflow: ellipsis;
ha-bar-media-player {
position: absolute;
bottom: 0;
left: 0;
right: 0;
}
`,
];

View File

@@ -1,98 +0,0 @@
import "@material/mwc-list/mwc-list";
import "@material/mwc-list/mwc-list-item";
import "@polymer/paper-item/paper-item";
import "@polymer/paper-listbox/paper-listbox";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { customElement, property } from "lit/decorators";
import { fireEvent } from "../../common/dom/fire_event";
import { computeStateName } from "../../common/entity/compute_state_name";
import { stringCompare } from "../../common/string/compare";
import { createCloseHeading } from "../../components/ha-dialog";
import { UNAVAILABLE_STATES } from "../../data/entity";
import { BROWSER_PLAYER } from "../../data/media-player";
import { haStyleDialog } from "../../resources/styles";
import type { HomeAssistant } from "../../types";
import type { SelectMediaPlayerDialogParams } from "./show-select-media-source-dialog";
@customElement("hui-dialog-select-media-player")
export class HuiDialogSelectMediaPlayer extends LitElement {
@property({ attribute: false }) public hass!: HomeAssistant;
@property({ attribute: false })
private _params?: SelectMediaPlayerDialogParams;
public showDialog(params: SelectMediaPlayerDialogParams): void {
this._params = params;
}
public closeDialog() {
this._params = undefined;
fireEvent(this, "dialog-closed", { dialog: this.localName });
}
protected render(): TemplateResult {
if (!this._params) {
return html``;
}
return html`
<ha-dialog
open
hideActions
.heading=${createCloseHeading(
this.hass,
this.hass.localize(`ui.components.media-browser.choose_player`)
)}
@closed=${this.closeDialog}
>
<mwc-list>
<mwc-list-item .player=${BROWSER_PLAYER} @click=${this._selectPlayer}
>${this.hass.localize(
"ui.components.media-browser.web-browser"
)}</mwc-list-item
>
${this._params.mediaSources
.sort((a, b) =>
stringCompare(computeStateName(a), computeStateName(b))
)
.map(
(source) => html`
<mwc-list-item
.disabled=${UNAVAILABLE_STATES.includes(source.state)}
.player=${source.entity_id}
@click=${this._selectPlayer}
>${computeStateName(source)}</mwc-list-item
>
`
)}
</mwc-list>
</ha-dialog>
`;
}
private _selectPlayer(ev: CustomEvent): void {
const entityId = (ev.currentTarget as any).player;
this._params!.sourceSelectedCallback(entityId);
this.closeDialog();
}
static get styles(): CSSResultGroup {
return [
haStyleDialog,
css`
ha-dialog {
--dialog-content-padding: 0 24px 20px;
}
mwc-list-item[disabled] {
--mdc-theme-text-primary-on-background: var(--disabled-text-color);
}
`,
];
}
}
declare global {
interface HTMLElementTagNameMap {
"hui-dialog-select-media-player": HuiDialogSelectMediaPlayer;
}
}

View File

@@ -1,18 +0,0 @@
import { HassEntity } from "home-assistant-js-websocket";
import { fireEvent } from "../../common/dom/fire_event";
export interface SelectMediaPlayerDialogParams {
mediaSources: HassEntity[];
sourceSelectedCallback: (entityId: string) => void;
}
export const showSelectMediaPlayerDialog = (
element: HTMLElement,
selectMediaPlayereDialogParams: SelectMediaPlayerDialogParams
): void => {
fireEvent(element, "show-dialog", {
dialogTag: "hui-dialog-select-media-player",
dialogImport: () => import("./hui-dialog-select-media-player"),
dialogParams: selectMediaPlayereDialogParams,
});
};

View File

@@ -67,10 +67,10 @@ class StateCardInputNumber extends mixinBehaviors(
on-click="stopPropagation"
hidden="[[hiddenbox]]"
>
<span slot="suffix">
[[stateObj.attributes.unit_of_measurement]]
</span>
</paper-input>
<div class="state" hidden="[[hiddenbox]]">
[[stateObj.attributes.unit_of_measurement]]
</div>
<div
id="sliderstate"
class="state sliderstate"

View File

@@ -203,7 +203,8 @@
"media_volume_down": "Volume down",
"media_volume_mute": "Volume mute",
"media_volume_unmute": "Volume unmute",
"text_to_speak": "Text to speak"
"text_to_speak": "Text to speak",
"nothing_playing": "Nothing Playing"
},
"persistent_notification": {
"dismiss": "Dismiss"
@@ -986,6 +987,10 @@
"settings": {
"title": "Settings",
"description": "Basic settings, server controls, logs and info"
},
"developer_tools": {
"title": "Developer Tools",
"description": "Tools to help create automations and scripts"
}
},
"common": {
@@ -2075,7 +2080,8 @@
"example_message": "Hello {name}, you can play any text on any supported media player!",
"target": "Target",
"target_browser": "Browser",
"play": "Play"
"play": "Play",
"create_automation": "Create Automation"
}
},
"remote": {
@@ -2203,6 +2209,7 @@
"enabled_description": "Disabled devices will not be shown and entities belonging to the device will be disabled and not added to Home Assistant.",
"open_configuration_url_device": "Visit device",
"open_configuration_url_service": "Visit service",
"download_diagnostics": "Download diagnostics",
"automation": {
"automations": "Automations",
"no_automations": "No automations",
@@ -2265,7 +2272,8 @@
"area": "Area",
"integration": "Integration",
"battery": "Battery",
"no_devices": "No devices"
"no_devices": "No devices",
"no_integration": "No integration"
},
"delete": "Delete",
"confirm_delete": "Are you sure you want to delete this device?",
@@ -2516,15 +2524,18 @@
"caption": "Users",
"description": "Manage the Home Assistant user accounts",
"users_privileges_note": "The user group feature is a work in progress. The user will be unable to administer the instance via the UI. We're still auditing all management API endpoints to ensure that they correctly limit access to administrators.",
"is_not_active": "Disabled",
"is_system": "System user",
"is_local": "Local user",
"is_owner": "Owner",
"picker": {
"headers": {
"name": "Display name",
"username": "Username",
"group": "Group",
"system": "System generated",
"system": "System",
"is_active": "Active",
"is_owner": "Owner",
"local": "Local only"
"local": "Local"
},
"add_user": "Add user"
},
@@ -2545,9 +2556,9 @@
"group": "Group",
"active": "Active",
"local_only": "Can only log in from the local network",
"system_generated": "System generated",
"system_generated_users_not_removable": "Unable to remove system generated users.",
"system_generated_users_not_editable": "Unable to update system generated users.",
"system_generated": "System user",
"system_generated_users_not_removable": "Unable to remove system users.",
"system_generated_users_not_editable": "Unable to update system users.",
"unnamed_user": "Unnamed User",
"confirm_user_deletion": "Are you sure you want to delete {name}?",
"active_tooltip": "Controls if user can login"
@@ -4290,7 +4301,6 @@
"create_backup": "Create backup before updating",
"description": "You have {version} installed. Click update to update to version {newest_version}",
"updating": "Updating {name} to version {version}",
"creating_backup": "Creating backup of {name}",
"no_update": "No update available for {name}"
},
"confirm": {
@@ -4314,7 +4324,8 @@
"missing_addons": "Missing add-ons? Enable advanced mode in your user profile page",
"no_results_found": "No results found in {repository}.",
"registries": "Registries",
"repositories": "Repositories"
"repositories": "Repositories",
"check_updates": "Check for updates"
},
"panel": {
"addons": "Add-ons",
@@ -4439,6 +4450,7 @@
"partial_backup": "Partial backup",
"addons": "Add-ons",
"folders": "Folders",
"size": "Size",
"password": "Backup password",
"confirm_password": "Confirm backup password",
"password_protection": "Password protection",