mirror of
https://github.com/home-assistant/frontend.git
synced 2025-11-12 20:40:29 +00:00
Compare commits
63 Commits
update-hov
...
feature/ti
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0ce17e3dea | ||
|
|
ef9029829a | ||
|
|
8bc53c61f2 | ||
|
|
711dcdbff0 | ||
|
|
6834e458d7 | ||
|
|
d597239925 | ||
|
|
004b3ce025 | ||
|
|
43e7b55e99 | ||
|
|
ea5fe14a64 | ||
|
|
807fbf8bb6 | ||
|
|
44cd425ce8 | ||
|
|
af01f66329 | ||
|
|
d5892b372c | ||
|
|
8656df6129 | ||
|
|
8c543ee67c | ||
|
|
4789d8c793 | ||
|
|
f08bbe7c1e | ||
|
|
9f1ee988bc | ||
|
|
eba0fa35d3 | ||
|
|
5b8c5375b4 | ||
|
|
bf351d67e9 | ||
|
|
b75fa013d2 | ||
|
|
2601b0d89c | ||
|
|
ef8410e121 | ||
|
|
37610703c8 | ||
|
|
4efd9bba8a | ||
|
|
e1fe7976d8 | ||
|
|
53b96107d9 | ||
|
|
dcbad9e798 | ||
|
|
26b3212c7e | ||
|
|
f3f4bcfe45 | ||
|
|
7cfa9de75f | ||
|
|
b66dc8894d | ||
|
|
14a7813ab0 | ||
|
|
70a2ca281f | ||
|
|
d982f042fc | ||
|
|
e60f9e326b | ||
|
|
ba39d189e7 | ||
|
|
78867b2cd9 | ||
|
|
1dff42dc00 | ||
|
|
0c9b3a0765 | ||
|
|
5a109c0ba8 | ||
|
|
f3b214c30a | ||
|
|
c49d2a0be6 | ||
|
|
c6c3170c1b | ||
|
|
0abb958aea | ||
|
|
9d55843629 | ||
|
|
b70d309297 | ||
|
|
5961b71562 | ||
|
|
6942626f60 | ||
|
|
069c0acdff | ||
|
|
1f0d83190d | ||
|
|
7c6c92c856 | ||
|
|
eff352cde1 | ||
|
|
62a75c188c | ||
|
|
4ffa6b6186 | ||
|
|
25173cf605 | ||
|
|
3277d8e80b | ||
|
|
55864fdc82 | ||
|
|
d4d662ba46 | ||
|
|
3ea5f508bb | ||
|
|
902a5dd678 | ||
|
|
4a3ed62583 |
@@ -5,17 +5,17 @@ const castContext = framework.CastReceiverContext.getInstance();
|
|||||||
const playerManager = castContext.getPlayerManager();
|
const playerManager = castContext.getPlayerManager();
|
||||||
|
|
||||||
playerManager.setMessageInterceptor(
|
playerManager.setMessageInterceptor(
|
||||||
framework.messages.MessageType.LOAD,
|
"LOAD" as framework.messages.MessageType.LOAD,
|
||||||
(loadRequestData) => {
|
(loadRequestData) => {
|
||||||
const media = loadRequestData.media;
|
const media = loadRequestData.media;
|
||||||
// Special handling if it came from Google Assistant
|
// Special handling if it came from Google Assistant
|
||||||
if (media.entity) {
|
if (media.entity) {
|
||||||
media.contentId = media.entity;
|
media.contentId = media.entity;
|
||||||
media.streamType = framework.messages.StreamType.LIVE;
|
media.streamType = "LIVE" as framework.messages.StreamType.LIVE;
|
||||||
media.contentType = "application/vnd.apple.mpegurl";
|
media.contentType = "application/vnd.apple.mpegurl";
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
media.hlsVideoSegmentFormat =
|
media.hlsVideoSegmentFormat =
|
||||||
framework.messages.HlsVideoSegmentFormat.FMP4;
|
"fmp4" as framework.messages.HlsVideoSegmentFormat.FMP4;
|
||||||
}
|
}
|
||||||
return loadRequestData;
|
return loadRequestData;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,8 @@ const playDummyMedia = (viewTitle?: string) => {
|
|||||||
loadRequestData.media.contentId =
|
loadRequestData.media.contentId =
|
||||||
"https://cast.home-assistant.io/images/google-nest-hub.png";
|
"https://cast.home-assistant.io/images/google-nest-hub.png";
|
||||||
loadRequestData.media.contentType = "image/jpeg";
|
loadRequestData.media.contentType = "image/jpeg";
|
||||||
loadRequestData.media.streamType = framework.messages.StreamType.NONE;
|
loadRequestData.media.streamType =
|
||||||
|
"NONE" as framework.messages.StreamType.NONE;
|
||||||
const metadata = new framework.messages.GenericMediaMetadata();
|
const metadata = new framework.messages.GenericMediaMetadata();
|
||||||
metadata.title = viewTitle;
|
metadata.title = viewTitle;
|
||||||
loadRequestData.media.metadata = metadata;
|
loadRequestData.media.metadata = metadata;
|
||||||
@@ -89,7 +90,7 @@ const showMediaPlayer = () => {
|
|||||||
const options = new framework.CastReceiverOptions();
|
const options = new framework.CastReceiverOptions();
|
||||||
options.disableIdleTimeout = true;
|
options.disableIdleTimeout = true;
|
||||||
options.customNamespaces = {
|
options.customNamespaces = {
|
||||||
[CAST_NS]: framework.system.MessageType.JSON,
|
[CAST_NS]: "json" as framework.system.MessageType.JSON,
|
||||||
};
|
};
|
||||||
|
|
||||||
castContext.addCustomMessageListener(
|
castContext.addCustomMessageListener(
|
||||||
@@ -97,9 +98,7 @@ castContext.addCustomMessageListener(
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
(ev: ReceivedMessage<HassMessage>) => {
|
(ev: ReceivedMessage<HassMessage>) => {
|
||||||
// We received a show Lovelace command, stop media from playing, hide media player and show Lovelace controller
|
// We received a show Lovelace command, stop media from playing, hide media player and show Lovelace controller
|
||||||
if (
|
if (playerManager.getPlayerState() !== "IDLE") {
|
||||||
playerManager.getPlayerState() !== framework.messages.PlayerState.IDLE
|
|
||||||
) {
|
|
||||||
playerManager.stop();
|
playerManager.stop();
|
||||||
} else {
|
} else {
|
||||||
showLovelaceController();
|
showLovelaceController();
|
||||||
@@ -113,7 +112,7 @@ castContext.addCustomMessageListener(
|
|||||||
const playerManager = castContext.getPlayerManager();
|
const playerManager = castContext.getPlayerManager();
|
||||||
|
|
||||||
playerManager.setMessageInterceptor(
|
playerManager.setMessageInterceptor(
|
||||||
framework.messages.MessageType.LOAD,
|
"LOAD" as framework.messages.MessageType.LOAD,
|
||||||
(loadRequestData) => {
|
(loadRequestData) => {
|
||||||
if (
|
if (
|
||||||
loadRequestData.media.contentId ===
|
loadRequestData.media.contentId ===
|
||||||
@@ -127,24 +126,23 @@ playerManager.setMessageInterceptor(
|
|||||||
// Special handling if it came from Google Assistant
|
// Special handling if it came from Google Assistant
|
||||||
if (media.entity) {
|
if (media.entity) {
|
||||||
media.contentId = media.entity;
|
media.contentId = media.entity;
|
||||||
media.streamType = framework.messages.StreamType.LIVE;
|
media.streamType = "LIVE" as framework.messages.StreamType.LIVE;
|
||||||
media.contentType = "application/vnd.apple.mpegurl";
|
media.contentType = "application/vnd.apple.mpegurl";
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
media.hlsVideoSegmentFormat =
|
media.hlsVideoSegmentFormat =
|
||||||
framework.messages.HlsVideoSegmentFormat.FMP4;
|
"fmp4" as framework.messages.HlsVideoSegmentFormat.FMP4;
|
||||||
}
|
}
|
||||||
return loadRequestData;
|
return loadRequestData;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
playerManager.addEventListener(
|
playerManager.addEventListener(
|
||||||
framework.events.EventType.MEDIA_STATUS,
|
"MEDIA_STATUS" as framework.events.EventType.MEDIA_STATUS,
|
||||||
(event) => {
|
(event) => {
|
||||||
if (
|
if (
|
||||||
event.mediaStatus?.playerState === framework.messages.PlayerState.IDLE &&
|
event.mediaStatus?.playerState === "IDLE" &&
|
||||||
event.mediaStatus?.idleReason &&
|
event.mediaStatus?.idleReason &&
|
||||||
event.mediaStatus?.idleReason !==
|
event.mediaStatus?.idleReason !== "INTERRUPTED"
|
||||||
framework.messages.IdleReason.INTERRUPTED
|
|
||||||
) {
|
) {
|
||||||
// media finished or stopped, return to default Lovelace
|
// media finished or stopped, return to default Lovelace
|
||||||
showLovelaceController();
|
showLovelaceController();
|
||||||
|
|||||||
@@ -162,7 +162,7 @@
|
|||||||
"@rspack/core": "1.5.1",
|
"@rspack/core": "1.5.1",
|
||||||
"@rspack/dev-server": "1.1.4",
|
"@rspack/dev-server": "1.1.4",
|
||||||
"@types/babel__plugin-transform-runtime": "7.9.5",
|
"@types/babel__plugin-transform-runtime": "7.9.5",
|
||||||
"@types/chromecast-caf-receiver": "6.0.22",
|
"@types/chromecast-caf-receiver": "6.0.24",
|
||||||
"@types/chromecast-caf-sender": "1.0.11",
|
"@types/chromecast-caf-sender": "1.0.11",
|
||||||
"@types/color-name": "2.0.0",
|
"@types/color-name": "2.0.0",
|
||||||
"@types/culori": "4.0.0",
|
"@types/culori": "4.0.0",
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "home-assistant-frontend"
|
name = "home-assistant-frontend"
|
||||||
version = "20250827.0"
|
version = "20250903.0"
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
license-files = ["LICENSE*"]
|
license-files = ["LICENSE*"]
|
||||||
description = "The Home Assistant frontend"
|
description = "The Home Assistant frontend"
|
||||||
|
|||||||
@@ -80,7 +80,18 @@ export class HaAutomationRow extends LitElement {
|
|||||||
ev.key !== " " &&
|
ev.key !== " " &&
|
||||||
!(
|
!(
|
||||||
(this.sortSelected || ev.altKey) &&
|
(this.sortSelected || ev.altKey) &&
|
||||||
|
!(ev.ctrlKey || ev.metaKey) &&
|
||||||
|
!ev.shiftKey &&
|
||||||
(ev.key === "ArrowUp" || ev.key === "ArrowDown")
|
(ev.key === "ArrowUp" || ev.key === "ArrowDown")
|
||||||
|
) &&
|
||||||
|
!(
|
||||||
|
(ev.ctrlKey || ev.metaKey) &&
|
||||||
|
!ev.shiftKey &&
|
||||||
|
!ev.altKey &&
|
||||||
|
(ev.key === "c" ||
|
||||||
|
ev.key === "x" ||
|
||||||
|
ev.key === "Delete" ||
|
||||||
|
ev.key === "Backspace")
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
@@ -101,6 +112,22 @@ export class HaAutomationRow extends LitElement {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ev.ctrlKey || ev.metaKey) {
|
||||||
|
if (ev.key === "c") {
|
||||||
|
fireEvent(this, "copy-row");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (ev.key === "x") {
|
||||||
|
fireEvent(this, "cut-row");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ev.key === "Delete" || ev.key === "Backspace") {
|
||||||
|
fireEvent(this, "delete-row");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.click();
|
this.click();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,6 +159,7 @@ export class HaAutomationRow extends LitElement {
|
|||||||
.expand-button {
|
.expand-button {
|
||||||
transition: transform 150ms cubic-bezier(0.4, 0, 0.2, 1);
|
transition: transform 150ms cubic-bezier(0.4, 0, 0.2, 1);
|
||||||
color: var(--ha-color-on-neutral-quiet);
|
color: var(--ha-color-on-neutral-quiet);
|
||||||
|
margin-left: -8px;
|
||||||
}
|
}
|
||||||
:host([building-block]) .leading-icon-wrapper {
|
:host([building-block]) .leading-icon-wrapper {
|
||||||
background-color: var(--ha-color-fill-neutral-loud-resting);
|
background-color: var(--ha-color-fill-neutral-loud-resting);
|
||||||
@@ -196,5 +224,8 @@ declare global {
|
|||||||
interface HASSDomEvents {
|
interface HASSDomEvents {
|
||||||
"toggle-collapsed": undefined;
|
"toggle-collapsed": undefined;
|
||||||
"stop-sort-selection": undefined;
|
"stop-sort-selection": undefined;
|
||||||
|
"copy-row": undefined;
|
||||||
|
"cut-row": undefined;
|
||||||
|
"delete-row": undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ export class HaBottomSheet extends LitElement {
|
|||||||
|
|
||||||
@state() private _dialogMaxViewpointHeight = 70;
|
@state() private _dialogMaxViewpointHeight = 70;
|
||||||
|
|
||||||
|
@state() private _dialogMinViewpointHeight = 55;
|
||||||
|
|
||||||
@state() private _dialogViewportHeight?: number;
|
@state() private _dialogViewportHeight?: number;
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
@@ -41,6 +43,7 @@ export class HaBottomSheet extends LitElement {
|
|||||||
? `${this._dialogViewportHeight}vh`
|
? `${this._dialogViewportHeight}vh`
|
||||||
: "auto",
|
: "auto",
|
||||||
maxHeight: `${this._dialogMaxViewpointHeight}vh`,
|
maxHeight: `${this._dialogMaxViewpointHeight}vh`,
|
||||||
|
minHeight: `${this._dialogMinViewpointHeight}vh`,
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
<div class="handle-wrapper">
|
<div class="handle-wrapper">
|
||||||
@@ -80,6 +83,7 @@ export class HaBottomSheet extends LitElement {
|
|||||||
this._dialogViewportHeight =
|
this._dialogViewportHeight =
|
||||||
(this._dialog.offsetHeight / window.innerHeight) * 100;
|
(this._dialog.offsetHeight / window.innerHeight) * 100;
|
||||||
this._dialogMaxViewpointHeight = 90;
|
this._dialogMaxViewpointHeight = 90;
|
||||||
|
this._dialogMinViewpointHeight = 20;
|
||||||
} else {
|
} else {
|
||||||
// after close animation is done close dialog element and fire closed event
|
// after close animation is done close dialog element and fire closed event
|
||||||
this._dialog.close();
|
this._dialog.close();
|
||||||
|
|||||||
@@ -159,6 +159,7 @@ export class HaMdDialog extends Dialog {
|
|||||||
--md-dialog-headline-size: var(--ha-font-size-xl);
|
--md-dialog-headline-size: var(--ha-font-size-xl);
|
||||||
--md-dialog-supporting-text-size: var(--ha-font-size-m);
|
--md-dialog-supporting-text-size: var(--ha-font-size-m);
|
||||||
--md-dialog-supporting-text-line-height: var(--ha-line-height-normal);
|
--md-dialog-supporting-text-line-height: var(--ha-line-height-normal);
|
||||||
|
--md-divider-color: var(--divider-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
:host([type="alert"]) {
|
:host([type="alert"]) {
|
||||||
|
|||||||
121
src/components/ha-numeric-arrow-input.ts
Normal file
121
src/components/ha-numeric-arrow-input.ts
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
import { css, html, LitElement } from "lit";
|
||||||
|
import { customElement, property, query } from "lit/decorators";
|
||||||
|
import memoizeOne from "memoize-one";
|
||||||
|
import { mdiMinus, mdiPlus } from "@mdi/js";
|
||||||
|
import { fireEvent } from "../common/dom/fire_event";
|
||||||
|
import type { HaIconButton } from "./ha-icon-button";
|
||||||
|
import "./ha-textfield";
|
||||||
|
import "./ha-icon-button";
|
||||||
|
import { clampValue } from "../data/number";
|
||||||
|
|
||||||
|
@customElement("ha-numeric-arrow-input")
|
||||||
|
export class HaNumericArrowInput extends LitElement {
|
||||||
|
@property({ attribute: false }) public disabled = false;
|
||||||
|
|
||||||
|
@property({ attribute: false }) public required = false;
|
||||||
|
|
||||||
|
@property({ attribute: false }) public min?: number;
|
||||||
|
|
||||||
|
@property({ attribute: false }) public max?: number;
|
||||||
|
|
||||||
|
@property({ attribute: false }) public step?: number;
|
||||||
|
|
||||||
|
@property({ attribute: false }) public padStart?: number;
|
||||||
|
|
||||||
|
@property({ attribute: false }) public labelUp = "Increase";
|
||||||
|
|
||||||
|
@property({ attribute: false }) public labelDown = "Decrease";
|
||||||
|
|
||||||
|
@property({ attribute: false }) public value = 0;
|
||||||
|
|
||||||
|
@query("ha-icon-button[data-direction='up']")
|
||||||
|
private _upButton!: HaIconButton;
|
||||||
|
|
||||||
|
@query("ha-icon-button[data-direction='down']")
|
||||||
|
private _downButton!: HaIconButton;
|
||||||
|
|
||||||
|
private _paddedValue = memoizeOne((value: number, padStart?: number) =>
|
||||||
|
value.toString().padStart(padStart ?? 0, "0")
|
||||||
|
);
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return html`<div
|
||||||
|
class="numeric-arrow-input-container"
|
||||||
|
@keydown=${this._keyDown}
|
||||||
|
>
|
||||||
|
<ha-icon-button
|
||||||
|
data-direction="up"
|
||||||
|
.disabled=${this.disabled}
|
||||||
|
.label=${this.labelUp}
|
||||||
|
.path=${mdiPlus}
|
||||||
|
@click=${this._up}
|
||||||
|
></ha-icon-button>
|
||||||
|
<span class="numeric-arrow-input-value"
|
||||||
|
>${this._paddedValue(this.value, this.padStart)}</span
|
||||||
|
>
|
||||||
|
<ha-icon-button
|
||||||
|
data-direction="down"
|
||||||
|
.disabled=${this.disabled}
|
||||||
|
.label=${this.labelDown}
|
||||||
|
.path=${mdiMinus}
|
||||||
|
@click=${this._down}
|
||||||
|
></ha-icon-button>
|
||||||
|
</div>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
private _keyDown(ev: KeyboardEvent) {
|
||||||
|
if (ev.key === "ArrowUp") {
|
||||||
|
this._upButton.focus();
|
||||||
|
this._up();
|
||||||
|
}
|
||||||
|
if (ev.key === "ArrowDown") {
|
||||||
|
this._downButton.focus();
|
||||||
|
this._down();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private _up() {
|
||||||
|
const newValue = this.value + (this.step ?? 1);
|
||||||
|
fireEvent(
|
||||||
|
this,
|
||||||
|
"value-changed",
|
||||||
|
clampValue({ value: newValue, min: this.min, max: this.max })
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private _down() {
|
||||||
|
const newValue = this.value - (this.step ?? 1);
|
||||||
|
fireEvent(
|
||||||
|
this,
|
||||||
|
"value-changed",
|
||||||
|
clampValue({ value: newValue, min: this.min, max: this.max })
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static styles = css`
|
||||||
|
.numeric-arrow-input-container {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.numeric-arrow-input-container ha-icon-button {
|
||||||
|
--mdc-icon-button-size: 24px;
|
||||||
|
color: var(--secondary-text-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.numeric-arrow-input-value {
|
||||||
|
color: var(--primary-text-color);
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface HTMLElementTagNameMap {
|
||||||
|
"ha-numeric-arrow-input": HaNumericArrowInput;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ import {
|
|||||||
mdiDevices,
|
mdiDevices,
|
||||||
mdiPaletteSwatch,
|
mdiPaletteSwatch,
|
||||||
mdiTextureBox,
|
mdiTextureBox,
|
||||||
|
mdiTransitConnectionVariant,
|
||||||
} from "@mdi/js";
|
} from "@mdi/js";
|
||||||
import type { CSSResultGroup, PropertyValues } from "lit";
|
import type { CSSResultGroup, PropertyValues } from "lit";
|
||||||
import { LitElement, css, html, nothing } from "lit";
|
import { LitElement, css, html, nothing } from "lit";
|
||||||
@@ -266,7 +267,9 @@ export class HaRelatedItems extends LitElement {
|
|||||||
<a href="/config/devices/device/${relatedDeviceId}">
|
<a href="/config/devices/device/${relatedDeviceId}">
|
||||||
<ha-list-item hasMeta graphic="icon">
|
<ha-list-item hasMeta graphic="icon">
|
||||||
<ha-svg-icon
|
<ha-svg-icon
|
||||||
.path=${mdiDevices}
|
.path=${device.entry_type === "service"
|
||||||
|
? mdiTransitConnectionVariant
|
||||||
|
: mdiDevices}
|
||||||
slot="graphic"
|
slot="graphic"
|
||||||
></ha-svg-icon>
|
></ha-svg-icon>
|
||||||
${device.name_by_user || device.name}
|
${device.name_by_user || device.name}
|
||||||
|
|||||||
@@ -15,21 +15,16 @@ declare global {
|
|||||||
"item-added": {
|
"item-added": {
|
||||||
index: number;
|
index: number;
|
||||||
data: any;
|
data: any;
|
||||||
|
item: any;
|
||||||
};
|
};
|
||||||
"item-removed": {
|
"item-removed": {
|
||||||
index: number;
|
index: number;
|
||||||
};
|
};
|
||||||
"drag-start": undefined;
|
"drag-start": undefined;
|
||||||
"drag-end": undefined;
|
"drag-end": undefined;
|
||||||
"item-cloned": HaSortableClonedEventData;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface HaSortableClonedEventData {
|
|
||||||
item: any;
|
|
||||||
clone: any;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type HaSortableOptions = Omit<
|
export type HaSortableOptions = Omit<
|
||||||
SortableInstance.SortableOptions,
|
SortableInstance.SortableOptions,
|
||||||
"onStart" | "onChoose" | "onEnd" | "onUpdate" | "onAdd" | "onRemove"
|
"onStart" | "onChoose" | "onEnd" | "onUpdate" | "onAdd" | "onRemove"
|
||||||
@@ -154,7 +149,6 @@ export class HaSortable extends LitElement {
|
|||||||
onUpdate: this._handleUpdate,
|
onUpdate: this._handleUpdate,
|
||||||
onAdd: this._handleAdd,
|
onAdd: this._handleAdd,
|
||||||
onRemove: this._handleRemove,
|
onRemove: this._handleRemove,
|
||||||
onClone: this._handleClone,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (this.draggableSelector) {
|
if (this.draggableSelector) {
|
||||||
@@ -187,6 +181,7 @@ export class HaSortable extends LitElement {
|
|||||||
fireEvent(this, "item-added", {
|
fireEvent(this, "item-added", {
|
||||||
index: evt.newIndex,
|
index: evt.newIndex,
|
||||||
data: evt.item.sortableData,
|
data: evt.item.sortableData,
|
||||||
|
item: evt.item,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -194,10 +189,6 @@ export class HaSortable extends LitElement {
|
|||||||
fireEvent(this, "item-removed", { index: evt.oldIndex });
|
fireEvent(this, "item-removed", { index: evt.oldIndex });
|
||||||
};
|
};
|
||||||
|
|
||||||
private _handleClone = (evt) => {
|
|
||||||
fireEvent(this, "item-cloned", evt);
|
|
||||||
};
|
|
||||||
|
|
||||||
private _handleEnd = async (evt) => {
|
private _handleEnd = async (evt) => {
|
||||||
fireEvent(this, "drag-end");
|
fireEvent(this, "drag-end");
|
||||||
// put back in original location
|
// put back in original location
|
||||||
|
|||||||
281
src/components/ha-time-picker.ts
Normal file
281
src/components/ha-time-picker.ts
Normal file
@@ -0,0 +1,281 @@
|
|||||||
|
import type { PropertyValues } from "lit";
|
||||||
|
import { css, html, LitElement, nothing } from "lit";
|
||||||
|
import { customElement, property, state } from "lit/decorators";
|
||||||
|
import { clampValue } from "../data/number";
|
||||||
|
import { useAmPm } from "../common/datetime/use_am_pm";
|
||||||
|
import { fireEvent } from "../common/dom/fire_event";
|
||||||
|
import type { FrontendLocaleData } from "../data/translation";
|
||||||
|
import type { HomeAssistant } from "../types";
|
||||||
|
import type { ClampedValue } from "../data/number";
|
||||||
|
import "./ha-base-time-input";
|
||||||
|
import "./ha-button";
|
||||||
|
import "./ha-numeric-arrow-input";
|
||||||
|
|
||||||
|
@customElement("ha-time-picker")
|
||||||
|
export class HaTimePicker extends LitElement {
|
||||||
|
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||||
|
|
||||||
|
@property({ attribute: false }) public locale!: FrontendLocaleData;
|
||||||
|
|
||||||
|
@property({ attribute: false }) public value?: string;
|
||||||
|
|
||||||
|
@property({ attribute: false }) public disabled = false;
|
||||||
|
|
||||||
|
@property({ attribute: false }) public required = false;
|
||||||
|
|
||||||
|
@property({ attribute: false }) public enableSeconds = false;
|
||||||
|
|
||||||
|
@state() private _hours = 0;
|
||||||
|
|
||||||
|
@state() private _minutes = 0;
|
||||||
|
|
||||||
|
@state() private _seconds = 0;
|
||||||
|
|
||||||
|
@state() private _useAmPm = false;
|
||||||
|
|
||||||
|
@state() private _isPm = false;
|
||||||
|
|
||||||
|
protected firstUpdated(changedProperties: PropertyValues) {
|
||||||
|
super.firstUpdated(changedProperties);
|
||||||
|
this._useAmPm = useAmPm(this.locale);
|
||||||
|
|
||||||
|
let hours = NaN;
|
||||||
|
let minutes = NaN;
|
||||||
|
let seconds = NaN;
|
||||||
|
let isPm = false;
|
||||||
|
|
||||||
|
if (this.value) {
|
||||||
|
const parts = this.value?.split(":") || [];
|
||||||
|
minutes = parts[1] ? Number(parts[1]) : 0;
|
||||||
|
seconds = parts[2] ? Number(parts[2]) : 0;
|
||||||
|
const hour24 = parts[0] ? Number(parts[0]) : 0;
|
||||||
|
|
||||||
|
if (this._useAmPm) {
|
||||||
|
if (hour24 === 0) {
|
||||||
|
hours = 12;
|
||||||
|
isPm = false;
|
||||||
|
} else if (hour24 < 12) {
|
||||||
|
hours = hour24;
|
||||||
|
isPm = false;
|
||||||
|
} else if (hour24 === 12) {
|
||||||
|
hours = 12;
|
||||||
|
isPm = true;
|
||||||
|
} else {
|
||||||
|
hours = hour24 - 12;
|
||||||
|
isPm = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
hours = hour24;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this._hours = hours;
|
||||||
|
this._minutes = minutes;
|
||||||
|
this._seconds = seconds;
|
||||||
|
this._isPm = isPm;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected render() {
|
||||||
|
return html`<div class="time-picker-container">
|
||||||
|
<ha-numeric-arrow-input
|
||||||
|
.disabled=${this.disabled}
|
||||||
|
.required=${this.required}
|
||||||
|
.min=${this._useAmPm ? 1 : 0}
|
||||||
|
.max=${this._useAmPm ? 12 : 23}
|
||||||
|
.step=${1}
|
||||||
|
.padStart=${2}
|
||||||
|
.value=${this._hours}
|
||||||
|
@value-changed=${this._hoursChanged}
|
||||||
|
.labelUp=${
|
||||||
|
// TODO: Localize
|
||||||
|
"Increase hours"
|
||||||
|
}
|
||||||
|
.labelDown=${
|
||||||
|
// TODO: Localize
|
||||||
|
"Decrease hours"
|
||||||
|
}
|
||||||
|
></ha-numeric-arrow-input>
|
||||||
|
<span class="time-picker-separator">:</span>
|
||||||
|
<ha-numeric-arrow-input
|
||||||
|
.disabled=${this.disabled}
|
||||||
|
.required=${this.required}
|
||||||
|
.min=${0}
|
||||||
|
.max=${59}
|
||||||
|
.step=${1}
|
||||||
|
.padStart=${2}
|
||||||
|
.labelUp=${
|
||||||
|
// TODO: Localize
|
||||||
|
"Increase minutes"
|
||||||
|
}
|
||||||
|
.labelDown=${
|
||||||
|
// TODO: Localize
|
||||||
|
"Decrease minutes"
|
||||||
|
}
|
||||||
|
.value=${this._minutes}
|
||||||
|
@value-changed=${this._minutesChanged}
|
||||||
|
></ha-numeric-arrow-input>
|
||||||
|
${this.enableSeconds
|
||||||
|
? html`
|
||||||
|
<span class="time-picker-separator">:</span>
|
||||||
|
<ha-numeric-arrow-input
|
||||||
|
.disabled=${this.disabled}
|
||||||
|
.required=${this.required}
|
||||||
|
.min=${0}
|
||||||
|
.max=${59}
|
||||||
|
.step=${1}
|
||||||
|
.padStart=${2}
|
||||||
|
.labelUp=${
|
||||||
|
// TODO: Localize
|
||||||
|
"Increase seconds"
|
||||||
|
}
|
||||||
|
.labelDown=${
|
||||||
|
// TODO: Localize
|
||||||
|
"Decrease seconds"
|
||||||
|
}
|
||||||
|
.value=${this._seconds}
|
||||||
|
@value-changed=${this._secondsChanged}
|
||||||
|
></ha-numeric-arrow-input>
|
||||||
|
`
|
||||||
|
: nothing}
|
||||||
|
${this._useAmPm
|
||||||
|
? html`
|
||||||
|
<ha-button @click=${this._toggleAmPm}>
|
||||||
|
${this._isPm ? "PM" : "AM"}
|
||||||
|
</ha-button>
|
||||||
|
`
|
||||||
|
: nothing}
|
||||||
|
</div>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected updated(changedProperties: PropertyValues) {
|
||||||
|
super.updated(changedProperties);
|
||||||
|
|
||||||
|
if (changedProperties.has("_hours")) {
|
||||||
|
this._timeUpdated();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (changedProperties.has("_minutes")) {
|
||||||
|
this._timeUpdated();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (changedProperties.has("_seconds")) {
|
||||||
|
this._timeUpdated();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (changedProperties.has("_useAmPm")) {
|
||||||
|
this._timeUpdated();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (changedProperties.has("_isPm")) {
|
||||||
|
this._timeUpdated();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private _hoursChanged(ev: CustomEvent<ClampedValue>) {
|
||||||
|
ev.stopPropagation?.();
|
||||||
|
this._hours = ev.detail.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private _minutesChanged(ev: CustomEvent<ClampedValue>) {
|
||||||
|
ev.stopPropagation?.();
|
||||||
|
this._minutes = ev.detail.value;
|
||||||
|
if (ev.detail.clamped) {
|
||||||
|
if (ev.detail.value === 0) {
|
||||||
|
this._hoursChanged({
|
||||||
|
detail: clampValue({
|
||||||
|
value: this._hours - 1,
|
||||||
|
min: this._useAmPm ? 1 : 0,
|
||||||
|
max: this._useAmPm ? 12 : 23,
|
||||||
|
}),
|
||||||
|
} as CustomEvent<ClampedValue>);
|
||||||
|
this._minutes = 59;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ev.detail.value === 59) {
|
||||||
|
this._hoursChanged({
|
||||||
|
detail: clampValue({
|
||||||
|
value: this._hours + 1,
|
||||||
|
min: this._useAmPm ? 1 : 0,
|
||||||
|
max: this._useAmPm ? 12 : 23,
|
||||||
|
}),
|
||||||
|
} as CustomEvent<ClampedValue>);
|
||||||
|
const hourMax = this._useAmPm ? 12 : 23;
|
||||||
|
if (this._hours < hourMax) {
|
||||||
|
this._minutes = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private _secondsChanged(ev: CustomEvent<ClampedValue>) {
|
||||||
|
ev.stopPropagation?.();
|
||||||
|
this._seconds = ev.detail.value;
|
||||||
|
if (ev.detail.clamped) {
|
||||||
|
if (ev.detail.value === 0) {
|
||||||
|
this._minutesChanged({
|
||||||
|
detail: clampValue({ value: this._minutes - 1, min: 0, max: 59 }),
|
||||||
|
} as CustomEvent<ClampedValue>);
|
||||||
|
this._seconds = 59;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ev.detail.value === 59) {
|
||||||
|
this._minutesChanged({
|
||||||
|
detail: clampValue({ value: this._minutes + 1, min: 0, max: 59 }),
|
||||||
|
} as CustomEvent<ClampedValue>);
|
||||||
|
const hourMax = this._useAmPm ? 12 : 23;
|
||||||
|
if (!(this._hours === hourMax && this._minutes === 59)) {
|
||||||
|
this._seconds = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private _toggleAmPm() {
|
||||||
|
this._isPm = !this._isPm;
|
||||||
|
}
|
||||||
|
|
||||||
|
private _timeUpdated() {
|
||||||
|
let hour24 = this._hours;
|
||||||
|
|
||||||
|
if (this._useAmPm) {
|
||||||
|
if (this._hours === 12) {
|
||||||
|
hour24 = this._isPm ? 12 : 0;
|
||||||
|
} else {
|
||||||
|
hour24 = this._isPm ? this._hours + 12 : this._hours;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const timeParts = [
|
||||||
|
hour24.toString().padStart(2, "0"),
|
||||||
|
this._minutes.toString().padStart(2, "0"),
|
||||||
|
this._seconds.toString().padStart(2, "0"),
|
||||||
|
];
|
||||||
|
|
||||||
|
const time = timeParts.join(":");
|
||||||
|
if (time === this.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.value = time;
|
||||||
|
fireEvent(this, "change");
|
||||||
|
fireEvent(this, "value-changed", { value: time });
|
||||||
|
}
|
||||||
|
|
||||||
|
static styles = css`
|
||||||
|
.time-picker-container {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
gap: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.time-picker-separator {
|
||||||
|
color: var(--primary-text-color);
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface HTMLElementTagNameMap {
|
||||||
|
"ha-time-picker": HaTimePicker;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -24,11 +24,14 @@ export interface BluetoothConnectionData extends DataTableRowData {
|
|||||||
source: string;
|
source: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type HaScannerType = "usb" | "uart" | "remote" | "unknown";
|
||||||
|
|
||||||
export interface BluetoothScannerDetails {
|
export interface BluetoothScannerDetails {
|
||||||
source: string;
|
source: string;
|
||||||
connectable: boolean;
|
connectable: boolean;
|
||||||
name: string;
|
name: string;
|
||||||
adapter: string;
|
adapter: string;
|
||||||
|
scanner_type?: HaScannerType;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type BluetoothScannersDetails = Record<string, BluetoothScannerDetails>;
|
export type BluetoothScannersDetails = Record<string, BluetoothScannerDetails>;
|
||||||
@@ -55,6 +58,13 @@ export interface BluetoothAllocationsData {
|
|||||||
allocated: string[];
|
allocated: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface BluetoothScannerState {
|
||||||
|
source: string;
|
||||||
|
adapter: string;
|
||||||
|
current_mode: "active" | "passive" | null;
|
||||||
|
requested_mode: "active" | "passive" | null;
|
||||||
|
}
|
||||||
|
|
||||||
export const subscribeBluetoothScannersDetailsUpdates = (
|
export const subscribeBluetoothScannersDetailsUpdates = (
|
||||||
conn: Connection,
|
conn: Connection,
|
||||||
store: Store<BluetoothScannersDetails>
|
store: Store<BluetoothScannersDetails>
|
||||||
@@ -170,3 +180,20 @@ export const subscribeBluetoothConnectionAllocations = (
|
|||||||
params
|
params
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const subscribeBluetoothScannerState = (
|
||||||
|
conn: Connection,
|
||||||
|
callbackFunction: (scannerState: BluetoothScannerState) => void,
|
||||||
|
configEntryId?: string
|
||||||
|
): Promise<() => Promise<void>> => {
|
||||||
|
const params: { type: string; config_entry_id?: string } = {
|
||||||
|
type: "bluetooth/subscribe_scanner_state",
|
||||||
|
};
|
||||||
|
if (configEntryId) {
|
||||||
|
params.config_entry_id = configEntryId;
|
||||||
|
}
|
||||||
|
return conn.subscribeMessage<BluetoothScannerState>(
|
||||||
|
(scannerState) => callbackFunction(scannerState),
|
||||||
|
params
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|||||||
@@ -97,6 +97,7 @@ export interface DataEntryFlowStepMenu {
|
|||||||
step_id: string;
|
step_id: string;
|
||||||
/** If array, use value to lookup translations in strings.json */
|
/** If array, use value to lookup translations in strings.json */
|
||||||
menu_options: string[] | Record<string, string>;
|
menu_options: string[] | Record<string, string>;
|
||||||
|
sort?: boolean;
|
||||||
description_placeholders?: Record<string, string>;
|
description_placeholders?: Record<string, string>;
|
||||||
translation_domain?: string;
|
translation_domain?: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
export const strokeWidth = 5;
|
export const strokeWidth = 2;
|
||||||
|
|||||||
@@ -12,3 +12,35 @@ export const getNumberDeviceClassConvertibleUnits = (
|
|||||||
type: "number/device_class_convertible_units",
|
type: "number/device_class_convertible_units",
|
||||||
device_class: deviceClass,
|
device_class: deviceClass,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export interface ClampedValue {
|
||||||
|
clamped: boolean;
|
||||||
|
value: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clamp a value between a minimum and maximum value
|
||||||
|
* @param value - The value to clamp
|
||||||
|
* @param min - The minimum value
|
||||||
|
* @param max - The maximum value
|
||||||
|
* @returns The clamped value
|
||||||
|
*/
|
||||||
|
export const clampValue = ({
|
||||||
|
value,
|
||||||
|
min,
|
||||||
|
max,
|
||||||
|
}: {
|
||||||
|
value: number;
|
||||||
|
min?: number;
|
||||||
|
max?: number;
|
||||||
|
}): ClampedValue => {
|
||||||
|
if (max !== undefined && value > max) {
|
||||||
|
return { clamped: true, value: max };
|
||||||
|
}
|
||||||
|
|
||||||
|
if (min !== undefined && value < min) {
|
||||||
|
return { clamped: true, value: min };
|
||||||
|
}
|
||||||
|
|
||||||
|
return { clamped: false, value };
|
||||||
|
};
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import type { Connection } from "home-assistant-js-websocket";
|
|||||||
import { computeStateName } from "../common/entity/compute_state_name";
|
import { computeStateName } from "../common/entity/compute_state_name";
|
||||||
import type { HaDurationData } from "../components/ha-duration-input";
|
import type { HaDurationData } from "../components/ha-duration-input";
|
||||||
import type { HomeAssistant } from "../types";
|
import type { HomeAssistant } from "../types";
|
||||||
|
import { firstWeekday } from "../common/datetime/first_weekday";
|
||||||
|
|
||||||
export interface RecorderInfo {
|
export interface RecorderInfo {
|
||||||
backlog: number | null;
|
backlog: number | null;
|
||||||
@@ -108,7 +109,7 @@ export interface StatisticsValidationResultMeanTypeChanged {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export const VOLUME_UNITS = ["L", "gal", "ft³", "m³", "CCF"] as const;
|
export const VOLUME_UNITS = ["L", "gal", "ft³", "m³", "CCF", "MCF"] as const;
|
||||||
|
|
||||||
export interface StatisticsUnitConfiguration {
|
export interface StatisticsUnitConfiguration {
|
||||||
energy?: "Wh" | "kWh" | "MWh" | "GJ";
|
energy?: "Wh" | "kWh" | "MWh" | "GJ";
|
||||||
@@ -211,7 +212,14 @@ export const fetchStatistic = (
|
|||||||
: period.fixed_period.end,
|
: period.fixed_period.end,
|
||||||
}
|
}
|
||||||
: undefined,
|
: undefined,
|
||||||
calendar: period.calendar,
|
calendar: period.calendar
|
||||||
|
? {
|
||||||
|
...(period.calendar.period === "week"
|
||||||
|
? { first_weekday: firstWeekday(hass.locale).substring(0, 3) }
|
||||||
|
: {}),
|
||||||
|
...period.calendar,
|
||||||
|
}
|
||||||
|
: undefined,
|
||||||
rolling_window: period.rolling_window,
|
rolling_window: period.rolling_window,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -256,6 +256,13 @@ export const showConfigFlowDialog = (
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
renderMenuOptionDescription(hass, step, option) {
|
||||||
|
return hass.localize(
|
||||||
|
`component.${step.translation_domain || step.handler}.config.step.${step.step_id}.menu_option_descriptions.${option}`,
|
||||||
|
step.description_placeholders
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
renderLoadingDescription(hass, reason, handler, step) {
|
renderLoadingDescription(hass, reason, handler, step) {
|
||||||
if (reason !== "loading_flow" && reason !== "loading_step") {
|
if (reason !== "loading_flow" && reason !== "loading_step") {
|
||||||
return "";
|
return "";
|
||||||
|
|||||||
@@ -137,6 +137,12 @@ export interface FlowConfig {
|
|||||||
option: string
|
option: string
|
||||||
): string;
|
): string;
|
||||||
|
|
||||||
|
renderMenuOptionDescription(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
step: DataEntryFlowStepMenu,
|
||||||
|
option: string
|
||||||
|
): string;
|
||||||
|
|
||||||
renderLoadingDescription(
|
renderLoadingDescription(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
loadingReason: LoadingReason,
|
loadingReason: LoadingReason,
|
||||||
|
|||||||
@@ -225,6 +225,13 @@ export const showOptionsFlowDialog = (
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
renderMenuOptionDescription(hass, step, option) {
|
||||||
|
return hass.localize(
|
||||||
|
`component.${step.translation_domain || configEntry.domain}.options.step.${step.step_id}.menu_option_descriptions.${option}`,
|
||||||
|
step.description_placeholders
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
renderLoadingDescription(hass, reason) {
|
renderLoadingDescription(hass, reason) {
|
||||||
return (
|
return (
|
||||||
hass.localize(`component.${configEntry.domain}.options.loading`) ||
|
hass.localize(`component.${configEntry.domain}.options.loading`) ||
|
||||||
|
|||||||
@@ -252,6 +252,13 @@ export const showSubConfigFlowDialog = (
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
renderMenuOptionDescription(hass, step, option) {
|
||||||
|
return hass.localize(
|
||||||
|
`component.${step.translation_domain || configEntry.domain}.config_subentries.${flowType}.step.${step.step_id}.menu_option_descriptions.${option}`,
|
||||||
|
step.description_placeholders
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
renderLoadingDescription(hass, reason, handler, step) {
|
renderLoadingDescription(hass, reason, handler, step) {
|
||||||
if (reason !== "loading_flow" && reason !== "loading_step") {
|
if (reason !== "loading_flow" && reason !== "loading_step") {
|
||||||
return "";
|
return "";
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import type { TemplateResult } from "lit";
|
import type { PropertyValues, TemplateResult } from "lit";
|
||||||
import { css, html, LitElement } from "lit";
|
import { css, html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property } from "lit/decorators";
|
import { customElement, property } from "lit/decorators";
|
||||||
import { fireEvent } from "../../common/dom/fire_event";
|
import { fireEvent } from "../../common/dom/fire_event";
|
||||||
import "../../components/ha-icon-next";
|
import "../../components/ha-icon-next";
|
||||||
@@ -8,6 +8,7 @@ import type { DataEntryFlowStepMenu } from "../../data/data_entry_flow";
|
|||||||
import type { HomeAssistant } from "../../types";
|
import type { HomeAssistant } from "../../types";
|
||||||
import type { FlowConfig } from "./show-dialog-data-entry-flow";
|
import type { FlowConfig } from "./show-dialog-data-entry-flow";
|
||||||
import { configFlowContentStyles } from "./styles";
|
import { configFlowContentStyles } from "./styles";
|
||||||
|
import { stringCompare } from "../../common/string/compare";
|
||||||
|
|
||||||
@customElement("step-flow-menu")
|
@customElement("step-flow-menu")
|
||||||
class StepFlowMenu extends LitElement {
|
class StepFlowMenu extends LitElement {
|
||||||
@@ -17,9 +18,18 @@ class StepFlowMenu extends LitElement {
|
|||||||
|
|
||||||
@property({ attribute: false }) public step!: DataEntryFlowStepMenu;
|
@property({ attribute: false }) public step!: DataEntryFlowStepMenu;
|
||||||
|
|
||||||
|
protected shouldUpdate(changedProps: PropertyValues): boolean {
|
||||||
|
return (
|
||||||
|
changedProps.size > 1 ||
|
||||||
|
!changedProps.has("hass") ||
|
||||||
|
this.hass.localize !== changedProps.get("hass")?.localize
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render(): TemplateResult {
|
||||||
let options: string[];
|
let options: string[];
|
||||||
let translations: Record<string, string>;
|
let translations: Record<string, string>;
|
||||||
|
let optionDescriptions: Record<string, string> = {};
|
||||||
|
|
||||||
if (Array.isArray(this.step.menu_options)) {
|
if (Array.isArray(this.step.menu_options)) {
|
||||||
options = this.step.menu_options;
|
options = this.step.menu_options;
|
||||||
@@ -30,10 +40,36 @@ class StepFlowMenu extends LitElement {
|
|||||||
this.step,
|
this.step,
|
||||||
option
|
option
|
||||||
);
|
);
|
||||||
|
optionDescriptions[option] =
|
||||||
|
this.flowConfig.renderMenuOptionDescription(
|
||||||
|
this.hass,
|
||||||
|
this.step,
|
||||||
|
option
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
options = Object.keys(this.step.menu_options);
|
options = Object.keys(this.step.menu_options);
|
||||||
translations = this.step.menu_options;
|
translations = this.step.menu_options;
|
||||||
|
optionDescriptions = Object.fromEntries(
|
||||||
|
options.map((key) => [
|
||||||
|
key,
|
||||||
|
this.flowConfig.renderMenuOptionDescription(
|
||||||
|
this.hass,
|
||||||
|
this.step,
|
||||||
|
key
|
||||||
|
),
|
||||||
|
])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.step.sort) {
|
||||||
|
options = options.sort((a, b) =>
|
||||||
|
stringCompare(
|
||||||
|
translations[a]!,
|
||||||
|
translations[b]!,
|
||||||
|
this.hass.locale.language
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const description = this.flowConfig.renderMenuDescription(
|
const description = this.flowConfig.renderMenuDescription(
|
||||||
@@ -46,8 +82,18 @@ class StepFlowMenu extends LitElement {
|
|||||||
<div class="options">
|
<div class="options">
|
||||||
${options.map(
|
${options.map(
|
||||||
(option) => html`
|
(option) => html`
|
||||||
<ha-list-item hasMeta .step=${option} @click=${this._handleStep}>
|
<ha-list-item
|
||||||
|
hasMeta
|
||||||
|
.step=${option}
|
||||||
|
@click=${this._handleStep}
|
||||||
|
?twoline=${optionDescriptions[option]}
|
||||||
|
>
|
||||||
<span>${translations[option]}</span>
|
<span>${translations[option]}</span>
|
||||||
|
${optionDescriptions[option]
|
||||||
|
? html`<span slot="secondary">
|
||||||
|
${optionDescriptions[option]}
|
||||||
|
</span>`
|
||||||
|
: nothing}
|
||||||
<ha-icon-next slot="meta"></ha-icon-next>
|
<ha-icon-next slot="meta"></ha-icon-next>
|
||||||
</ha-list-item>
|
</ha-list-item>
|
||||||
`
|
`
|
||||||
@@ -73,11 +119,10 @@ class StepFlowMenu extends LitElement {
|
|||||||
css`
|
css`
|
||||||
.options {
|
.options {
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
margin-bottom: 8px;
|
margin-bottom: 16px;
|
||||||
}
|
}
|
||||||
.content {
|
.content {
|
||||||
padding-bottom: 16px;
|
padding-bottom: 16px;
|
||||||
border-bottom: 1px solid var(--divider-color);
|
|
||||||
}
|
}
|
||||||
.content + .options {
|
.content + .options {
|
||||||
margin-top: 8px;
|
margin-top: 8px;
|
||||||
|
|||||||
@@ -3,11 +3,11 @@ import { css, html, LitElement, nothing } from "lit";
|
|||||||
import { customElement, property, query, state } from "lit/decorators";
|
import { customElement, property, query, state } from "lit/decorators";
|
||||||
import { ifDefined } from "lit/directives/if-defined";
|
import { ifDefined } from "lit/directives/if-defined";
|
||||||
import { fireEvent } from "../../common/dom/fire_event";
|
import { fireEvent } from "../../common/dom/fire_event";
|
||||||
|
import "../../components/ha-button";
|
||||||
|
import "../../components/ha-dialog-header";
|
||||||
import "../../components/ha-md-dialog";
|
import "../../components/ha-md-dialog";
|
||||||
import type { HaMdDialog } from "../../components/ha-md-dialog";
|
import type { HaMdDialog } from "../../components/ha-md-dialog";
|
||||||
import "../../components/ha-dialog-header";
|
|
||||||
import "../../components/ha-svg-icon";
|
import "../../components/ha-svg-icon";
|
||||||
import "../../components/ha-button";
|
|
||||||
import "../../components/ha-textfield";
|
import "../../components/ha-textfield";
|
||||||
import type { HaTextField } from "../../components/ha-textfield";
|
import type { HaTextField } from "../../components/ha-textfield";
|
||||||
import type { HomeAssistant } from "../../types";
|
import type { HomeAssistant } from "../../types";
|
||||||
@@ -52,7 +52,7 @@ class DialogBox extends LitElement {
|
|||||||
return nothing;
|
return nothing;
|
||||||
}
|
}
|
||||||
|
|
||||||
const confirmPrompt = this._params.confirmation || this._params.prompt;
|
const confirmPrompt = this._params.confirmation || !!this._params.prompt;
|
||||||
|
|
||||||
const dialogTitle =
|
const dialogTitle =
|
||||||
this._params.title ||
|
this._params.title ||
|
||||||
@@ -62,7 +62,7 @@ class DialogBox extends LitElement {
|
|||||||
return html`
|
return html`
|
||||||
<ha-md-dialog
|
<ha-md-dialog
|
||||||
open
|
open
|
||||||
.disableCancelAction=${confirmPrompt || false}
|
.disableCancelAction=${confirmPrompt}
|
||||||
@closed=${this._dialogClosed}
|
@closed=${this._dialogClosed}
|
||||||
type="alert"
|
type="alert"
|
||||||
aria-labelledby="dialog-box-title"
|
aria-labelledby="dialog-box-title"
|
||||||
@@ -100,23 +100,22 @@ class DialogBox extends LitElement {
|
|||||||
: ""}
|
: ""}
|
||||||
</div>
|
</div>
|
||||||
<div slot="actions">
|
<div slot="actions">
|
||||||
${confirmPrompt &&
|
${confirmPrompt
|
||||||
html`
|
? html`
|
||||||
<ha-button
|
<ha-button
|
||||||
@click=${this._dismiss}
|
@click=${this._dismiss}
|
||||||
?dialogInitialFocus=${!this._params.prompt &&
|
?autofocus=${!this._params.prompt && this._params.destructive}
|
||||||
this._params.destructive}
|
|
||||||
appearance="plain"
|
appearance="plain"
|
||||||
>
|
>
|
||||||
${this._params.dismissText
|
${this._params.dismissText
|
||||||
? this._params.dismissText
|
? this._params.dismissText
|
||||||
: this.hass.localize("ui.common.cancel")}
|
: this.hass.localize("ui.common.cancel")}
|
||||||
</ha-button>
|
</ha-button>
|
||||||
`}
|
`
|
||||||
|
: nothing}
|
||||||
<ha-button
|
<ha-button
|
||||||
@click=${this._confirm}
|
@click=${this._confirm}
|
||||||
?dialogInitialFocus=${!this._params.prompt &&
|
?autofocus=${!this._params.prompt && !this._params.destructive}
|
||||||
!this._params.destructive}
|
|
||||||
variant=${this._params.destructive ? "danger" : "brand"}
|
variant=${this._params.destructive ? "danger" : "brand"}
|
||||||
>
|
>
|
||||||
${this._params.confirmText
|
${this._params.confirmText
|
||||||
|
|||||||
@@ -6,7 +6,9 @@ import memoizeOne from "memoize-one";
|
|||||||
import { formatDateWeekdayShort } from "../../../common/datetime/format_date";
|
import { formatDateWeekdayShort } from "../../../common/datetime/format_date";
|
||||||
import { formatTime } from "../../../common/datetime/format_time";
|
import { formatTime } from "../../../common/datetime/format_time";
|
||||||
import { formatNumber } from "../../../common/number/format_number";
|
import { formatNumber } from "../../../common/number/format_number";
|
||||||
|
import "../../../components/ha-alert";
|
||||||
import "../../../components/ha-relative-time";
|
import "../../../components/ha-relative-time";
|
||||||
|
import "../../../components/ha-spinner";
|
||||||
import "../../../components/ha-state-icon";
|
import "../../../components/ha-state-icon";
|
||||||
import "../../../components/ha-svg-icon";
|
import "../../../components/ha-svg-icon";
|
||||||
import "../../../components/ha-tooltip";
|
import "../../../components/ha-tooltip";
|
||||||
@@ -292,15 +294,12 @@ class MoreInfoWeather extends LitElement {
|
|||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
: nothing}
|
: nothing}
|
||||||
${forecast
|
|
||||||
? html`
|
|
||||||
<div class="section">
|
<div class="section">
|
||||||
${this.hass.localize("ui.card.weather.forecast")}:
|
${this.hass.localize("ui.card.weather.forecast")}:
|
||||||
</div>
|
</div>
|
||||||
${supportedForecasts.length > 1
|
${supportedForecasts?.length > 1
|
||||||
? html`<sl-tab-group
|
? html`<sl-tab-group @sl-tab-show=${this._handleForecastTypeChanged}>
|
||||||
@sl-tab-show=${this._handleForecastTypeChanged}
|
|
||||||
>
|
|
||||||
${supportedForecasts.map(
|
${supportedForecasts.map(
|
||||||
(forecastType) =>
|
(forecastType) =>
|
||||||
html`<sl-tab
|
html`<sl-tab
|
||||||
@@ -308,17 +307,15 @@ class MoreInfoWeather extends LitElement {
|
|||||||
.panel=${forecastType}
|
.panel=${forecastType}
|
||||||
.active=${this._forecastType === forecastType}
|
.active=${this._forecastType === forecastType}
|
||||||
>
|
>
|
||||||
${this.hass!.localize(
|
${this.hass!.localize(`ui.card.weather.${forecastType}`)}
|
||||||
`ui.card.weather.${forecastType}`
|
|
||||||
)}
|
|
||||||
</sl-tab>`
|
</sl-tab>`
|
||||||
)}
|
)}
|
||||||
</sl-tab-group>`
|
</sl-tab-group>`
|
||||||
: nothing}
|
: nothing}
|
||||||
<div class="forecast">
|
<div class="forecast">
|
||||||
${forecast.map((item) =>
|
${forecast?.length
|
||||||
this._showValue(item.templow) ||
|
? forecast.map((item) =>
|
||||||
this._showValue(item.temperature)
|
this._showValue(item.templow) || this._showValue(item.temperature)
|
||||||
? html`
|
? html`
|
||||||
<div>
|
<div>
|
||||||
<div>
|
<div>
|
||||||
@@ -388,10 +385,10 @@ class MoreInfoWeather extends LitElement {
|
|||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
: nothing
|
: nothing
|
||||||
)}
|
)
|
||||||
|
: html`<ha-spinner size="medium"></ha-spinner>`}
|
||||||
</div>
|
</div>
|
||||||
`
|
|
||||||
: nothing}
|
|
||||||
${this.stateObj.attributes.attribution
|
${this.stateObj.attributes.attribution
|
||||||
? html`
|
? html`
|
||||||
<div class="attribution">
|
<div class="attribution">
|
||||||
@@ -589,6 +586,10 @@ class MoreInfoWeather extends LitElement {
|
|||||||
.forecast-icon {
|
.forecast-icon {
|
||||||
--mdc-icon-size: 40px;
|
--mdc-icon-size: 40px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.forecast ha-spinner {
|
||||||
|
height: 120px;
|
||||||
|
}
|
||||||
`,
|
`,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import {
|
|||||||
mdiPencil,
|
mdiPencil,
|
||||||
mdiPencilOff,
|
mdiPencilOff,
|
||||||
mdiPencilOutline,
|
mdiPencilOutline,
|
||||||
|
mdiTransitConnectionVariant,
|
||||||
} from "@mdi/js";
|
} from "@mdi/js";
|
||||||
import type { HassEntity } from "home-assistant-js-websocket";
|
import type { HassEntity } from "home-assistant-js-websocket";
|
||||||
import type { PropertyValues } from "lit";
|
import type { PropertyValues } from "lit";
|
||||||
@@ -311,6 +312,8 @@ export class MoreInfoDialog extends LitElement {
|
|||||||
const isAdmin = this.hass.user!.is_admin;
|
const isAdmin = this.hass.user!.is_admin;
|
||||||
|
|
||||||
const deviceId = this._getDeviceId();
|
const deviceId = this._getDeviceId();
|
||||||
|
const deviceType =
|
||||||
|
(deviceId && this.hass.devices[deviceId].entry_type) || "device";
|
||||||
|
|
||||||
const isDefaultView = this._currView === DEFAULT_VIEW && !this._childView;
|
const isDefaultView = this._currView === DEFAULT_VIEW && !this._childView;
|
||||||
const isSpecificInitialView =
|
const isSpecificInitialView =
|
||||||
@@ -434,11 +437,18 @@ export class MoreInfoDialog extends LitElement {
|
|||||||
@request-selected=${this._goToDevice}
|
@request-selected=${this._goToDevice}
|
||||||
>
|
>
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.dialogs.more_info_control.device_info"
|
"ui.dialogs.more_info_control.device_or_service_info",
|
||||||
|
{
|
||||||
|
type: this.hass.localize(
|
||||||
|
`ui.dialogs.more_info_control.device_type.${deviceType}`
|
||||||
|
),
|
||||||
|
}
|
||||||
)}
|
)}
|
||||||
<ha-svg-icon
|
<ha-svg-icon
|
||||||
slot="graphic"
|
slot="graphic"
|
||||||
.path=${mdiDevices}
|
.path=${deviceType === "service"
|
||||||
|
? mdiTransitConnectionVariant
|
||||||
|
: mdiDevices}
|
||||||
></ha-svg-icon>
|
></ha-svg-icon>
|
||||||
</ha-list-item>
|
</ha-list-item>
|
||||||
`
|
`
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
|
import { mdiAppleKeyboardCommand } from "@mdi/js";
|
||||||
import { css, html, LitElement, nothing } from "lit";
|
import { css, html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import { fireEvent } from "../../common/dom/fire_event";
|
import { fireEvent } from "../../common/dom/fire_event";
|
||||||
import "../../components/ha-button";
|
|
||||||
import { createCloseHeading } from "../../components/ha-dialog";
|
|
||||||
import type { HomeAssistant } from "../../types";
|
|
||||||
import { haStyleDialog } from "../../resources/styles";
|
|
||||||
import "../../components/ha-alert";
|
|
||||||
import "../../components/chips/ha-assist-chip";
|
|
||||||
import type { LocalizeKeys } from "../../common/translations/localize";
|
import type { LocalizeKeys } from "../../common/translations/localize";
|
||||||
|
import "../../components/ha-alert";
|
||||||
|
import { createCloseHeading } from "../../components/ha-dialog";
|
||||||
|
import "../../components/ha-svg-icon";
|
||||||
|
import { haStyleDialog } from "../../resources/styles";
|
||||||
|
import type { HomeAssistant } from "../../types";
|
||||||
|
import { isMac } from "../../util/is_mac";
|
||||||
|
|
||||||
interface Text {
|
interface Text {
|
||||||
type: "text";
|
type: "text";
|
||||||
@@ -27,6 +28,8 @@ interface Section {
|
|||||||
items: (Text | Shortcut)[];
|
items: (Text | Shortcut)[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const CTRL_CMD = "__CTRL_CMD__";
|
||||||
|
|
||||||
const _SHORTCUTS: Section[] = [
|
const _SHORTCUTS: Section[] = [
|
||||||
{
|
{
|
||||||
key: "ui.dialogs.shortcuts.searching.title",
|
key: "ui.dialogs.shortcuts.searching.title",
|
||||||
@@ -53,7 +56,7 @@ const _SHORTCUTS: Section[] = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "shortcut",
|
type: "shortcut",
|
||||||
shortcut: [{ key: "ui.dialogs.shortcuts.shortcuts.ctrl_cmd" }, "F"],
|
shortcut: [CTRL_CMD, "F"],
|
||||||
key: "ui.dialogs.shortcuts.searching.search_in_table",
|
key: "ui.dialogs.shortcuts.searching.search_in_table",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@@ -73,12 +76,27 @@ const _SHORTCUTS: Section[] = [
|
|||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
type: "shortcut",
|
type: "shortcut",
|
||||||
shortcut: [{ key: "ui.dialogs.shortcuts.shortcuts.ctrl_cmd" }, "V"],
|
shortcut: [CTRL_CMD, "C"],
|
||||||
|
key: "ui.dialogs.shortcuts.automation_script.copy",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "shortcut",
|
||||||
|
shortcut: [CTRL_CMD, "X"],
|
||||||
|
key: "ui.dialogs.shortcuts.automation_script.cut",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "shortcut",
|
||||||
|
shortcut: [CTRL_CMD, "del"],
|
||||||
|
key: "ui.dialogs.shortcuts.automation_script.delete",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "shortcut",
|
||||||
|
shortcut: [CTRL_CMD, "V"],
|
||||||
key: "ui.dialogs.shortcuts.automation_script.paste",
|
key: "ui.dialogs.shortcuts.automation_script.paste",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "shortcut",
|
type: "shortcut",
|
||||||
shortcut: [{ key: "ui.dialogs.shortcuts.shortcuts.ctrl_cmd" }, "S"],
|
shortcut: [CTRL_CMD, "S"],
|
||||||
key: "ui.dialogs.shortcuts.automation_script.save",
|
key: "ui.dialogs.shortcuts.automation_script.save",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@@ -88,16 +106,13 @@ const _SHORTCUTS: Section[] = [
|
|||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
type: "shortcut",
|
type: "shortcut",
|
||||||
shortcut: [
|
shortcut: [CTRL_CMD, { key: "ui.dialogs.shortcuts.shortcuts.drag" }],
|
||||||
{ key: "ui.dialogs.shortcuts.shortcuts.ctrl_cmd" },
|
|
||||||
{ key: "ui.dialogs.shortcuts.shortcuts.drag" },
|
|
||||||
],
|
|
||||||
key: "ui.dialogs.shortcuts.charts.drag_to_zoom",
|
key: "ui.dialogs.shortcuts.charts.drag_to_zoom",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "shortcut",
|
type: "shortcut",
|
||||||
shortcut: [
|
shortcut: [
|
||||||
{ key: "ui.dialogs.shortcuts.shortcuts.ctrl_cmd" },
|
CTRL_CMD,
|
||||||
{ key: "ui.dialogs.shortcuts.shortcuts.scroll_wheel" },
|
{ key: "ui.dialogs.shortcuts.shortcuts.scroll_wheel" },
|
||||||
],
|
],
|
||||||
key: "ui.dialogs.shortcuts.charts.scroll_to_zoom",
|
key: "ui.dialogs.shortcuts.charts.scroll_to_zoom",
|
||||||
@@ -146,7 +161,18 @@ class DialogShortcuts extends LitElement {
|
|||||||
|
|
||||||
return html`
|
return html`
|
||||||
<div class="shortcut">
|
<div class="shortcut">
|
||||||
${keys.map((key) => html` <span>${key.toUpperCase()}</span>`)}
|
${keys.map(
|
||||||
|
(key) =>
|
||||||
|
html`<span
|
||||||
|
>${key === CTRL_CMD
|
||||||
|
? isMac
|
||||||
|
? html`<ha-svg-icon
|
||||||
|
.path=${mdiAppleKeyboardCommand}
|
||||||
|
></ha-svg-icon>`
|
||||||
|
: this.hass.localize("ui.panel.config.automation.editor.ctrl")
|
||||||
|
: key}</span
|
||||||
|
>`
|
||||||
|
)}
|
||||||
${this.hass.localize(translationKey)}
|
${this.hass.localize(translationKey)}
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
@@ -232,6 +258,10 @@ class DialogShortcuts extends LitElement {
|
|||||||
.items p {
|
.items p {
|
||||||
margin-bottom: 8px;
|
margin-bottom: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ha-svg-icon {
|
||||||
|
width: 12px;
|
||||||
|
}
|
||||||
`,
|
`,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,6 +79,13 @@ export const demoPanels: Panels = {
|
|||||||
config: null,
|
config: null,
|
||||||
url_path: "energy",
|
url_path: "energy",
|
||||||
},
|
},
|
||||||
|
"time-picker": {
|
||||||
|
component_name: "time-picker",
|
||||||
|
icon: "hass:clock-outline",
|
||||||
|
title: "time_picker",
|
||||||
|
config: null,
|
||||||
|
url_path: "time-picker",
|
||||||
|
},
|
||||||
// config: {
|
// config: {
|
||||||
// component_name: "config",
|
// component_name: "config",
|
||||||
// icon: "hass:cog",
|
// icon: "hass:cog",
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ const COMPONENTS = {
|
|||||||
my: () => import("../panels/my/ha-panel-my"),
|
my: () => import("../panels/my/ha-panel-my"),
|
||||||
profile: () => import("../panels/profile/ha-panel-profile"),
|
profile: () => import("../panels/profile/ha-panel-profile"),
|
||||||
todo: () => import("../panels/todo/ha-panel-todo"),
|
todo: () => import("../panels/todo/ha-panel-todo"),
|
||||||
|
"time-picker": () => import("../panels/time-picker/ha-panel-time-picker"),
|
||||||
"media-browser": () =>
|
"media-browser": () =>
|
||||||
import("../panels/media-browser/ha-panel-media-browser"),
|
import("../panels/media-browser/ha-panel-media-browser"),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -11,23 +11,54 @@ export const KeyboardShortcutMixin = <T extends Constructor<LitElement>>(
|
|||||||
class extends superClass {
|
class extends superClass {
|
||||||
private _keydownEvent = (event: KeyboardEvent) => {
|
private _keydownEvent = (event: KeyboardEvent) => {
|
||||||
const supportedShortcuts = this.supportedShortcuts();
|
const supportedShortcuts = this.supportedShortcuts();
|
||||||
if ((event.ctrlKey || event.metaKey) && event.key in supportedShortcuts) {
|
if (
|
||||||
|
(event.ctrlKey || event.metaKey) &&
|
||||||
|
!event.shiftKey &&
|
||||||
|
!event.altKey &&
|
||||||
|
event.key in supportedShortcuts
|
||||||
|
) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
supportedShortcuts[event.key]();
|
supportedShortcuts[event.key]();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const supportedSingleKeyShortcuts = this.supportedSingleKeyShortcuts();
|
||||||
|
if (event.key in supportedSingleKeyShortcuts) {
|
||||||
|
event.preventDefault();
|
||||||
|
supportedSingleKeyShortcuts[event.key]();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private _listenersAdded = false;
|
||||||
|
|
||||||
public connectedCallback() {
|
public connectedCallback() {
|
||||||
super.connectedCallback();
|
super.connectedCallback();
|
||||||
window.addEventListener("keydown", this._keydownEvent);
|
this.addKeyboardShortcuts();
|
||||||
}
|
}
|
||||||
|
|
||||||
public disconnectedCallback() {
|
public disconnectedCallback() {
|
||||||
window.removeEventListener("keydown", this._keydownEvent);
|
this.removeKeyboardShortcuts();
|
||||||
super.disconnectedCallback();
|
super.disconnectedCallback();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public addKeyboardShortcuts() {
|
||||||
|
if (this._listenersAdded) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this._listenersAdded = true;
|
||||||
|
window.addEventListener("keydown", this._keydownEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public removeKeyboardShortcuts() {
|
||||||
|
this._listenersAdded = false;
|
||||||
|
window.removeEventListener("keydown", this._keydownEvent);
|
||||||
|
}
|
||||||
|
|
||||||
protected supportedShortcuts(): SupportedShortcuts {
|
protected supportedShortcuts(): SupportedShortcuts {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected supportedSingleKeyShortcuts(): SupportedShortcuts {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,12 +5,12 @@ import {
|
|||||||
mdiArrowUp,
|
mdiArrowUp,
|
||||||
mdiContentCopy,
|
mdiContentCopy,
|
||||||
mdiContentCut,
|
mdiContentCut,
|
||||||
mdiContentDuplicate,
|
|
||||||
mdiDelete,
|
mdiDelete,
|
||||||
mdiDotsVertical,
|
mdiDotsVertical,
|
||||||
mdiPlay,
|
mdiPlay,
|
||||||
mdiPlayCircleOutline,
|
mdiPlayCircleOutline,
|
||||||
mdiPlaylistEdit,
|
mdiPlaylistEdit,
|
||||||
|
mdiPlusCircleMultipleOutline,
|
||||||
mdiRenameBox,
|
mdiRenameBox,
|
||||||
mdiStopCircleOutline,
|
mdiStopCircleOutline,
|
||||||
} from "@mdi/js";
|
} from "@mdi/js";
|
||||||
@@ -195,6 +195,10 @@ export default class HaAutomationActionRow extends LitElement {
|
|||||||
@query("ha-automation-row")
|
@query("ha-automation-row")
|
||||||
private _automationRowElement?: HaAutomationRow;
|
private _automationRowElement?: HaAutomationRow;
|
||||||
|
|
||||||
|
get selected() {
|
||||||
|
return this._selected;
|
||||||
|
}
|
||||||
|
|
||||||
protected firstUpdated(changedProperties: PropertyValues): void {
|
protected firstUpdated(changedProperties: PropertyValues): void {
|
||||||
super.firstUpdated(changedProperties);
|
super.firstUpdated(changedProperties);
|
||||||
|
|
||||||
@@ -305,7 +309,7 @@ export default class HaAutomationActionRow extends LitElement {
|
|||||||
)}
|
)}
|
||||||
<ha-svg-icon
|
<ha-svg-icon
|
||||||
slot="start"
|
slot="start"
|
||||||
.path=${mdiContentDuplicate}
|
.path=${mdiPlusCircleMultipleOutline}
|
||||||
></ha-svg-icon>
|
></ha-svg-icon>
|
||||||
</ha-md-menu-item>
|
</ha-md-menu-item>
|
||||||
|
|
||||||
@@ -438,7 +442,6 @@ export default class HaAutomationActionRow extends LitElement {
|
|||||||
${this.optionsInSidebar
|
${this.optionsInSidebar
|
||||||
? html`<ha-automation-row
|
? html`<ha-automation-row
|
||||||
.disabled=${this.action.enabled === false}
|
.disabled=${this.action.enabled === false}
|
||||||
@click=${this._toggleSidebar}
|
|
||||||
.leftChevron=${[
|
.leftChevron=${[
|
||||||
...ACTION_BUILDING_BLOCKS,
|
...ACTION_BUILDING_BLOCKS,
|
||||||
...ACTION_COMBINED_BLOCKS,
|
...ACTION_COMBINED_BLOCKS,
|
||||||
@@ -450,12 +453,16 @@ export default class HaAutomationActionRow extends LitElement {
|
|||||||
.collapsed=${this._collapsed}
|
.collapsed=${this._collapsed}
|
||||||
.selected=${this._selected}
|
.selected=${this._selected}
|
||||||
.highlight=${this.highlight}
|
.highlight=${this.highlight}
|
||||||
@toggle-collapsed=${this._toggleCollapse}
|
|
||||||
.buildingBlock=${[
|
.buildingBlock=${[
|
||||||
...ACTION_BUILDING_BLOCKS,
|
...ACTION_BUILDING_BLOCKS,
|
||||||
...ACTION_COMBINED_BLOCKS,
|
...ACTION_COMBINED_BLOCKS,
|
||||||
].includes(blockType!)}
|
].includes(blockType!)}
|
||||||
.sortSelected=${this.sortSelected}
|
.sortSelected=${this.sortSelected}
|
||||||
|
@click=${this._toggleSidebar}
|
||||||
|
@toggle-collapsed=${this._toggleCollapse}
|
||||||
|
@copy-row=${this._copyAction}
|
||||||
|
@cut-row=${this._cutAction}
|
||||||
|
@delete-row=${this._onDelete}
|
||||||
>${this._renderRow()}</ha-automation-row
|
>${this._renderRow()}</ha-automation-row
|
||||||
>`
|
>`
|
||||||
: html`
|
: html`
|
||||||
@@ -514,6 +521,15 @@ export default class HaAutomationActionRow extends LitElement {
|
|||||||
};
|
};
|
||||||
|
|
||||||
private _runAction = async () => {
|
private _runAction = async () => {
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
// @ts-ignore is supported in all browsers except firefox
|
||||||
|
if (this.scrollIntoViewIfNeeded) {
|
||||||
|
// @ts-ignore is supported in all browsers except firefox
|
||||||
|
this.scrollIntoViewIfNeeded();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.scrollIntoView();
|
||||||
|
});
|
||||||
const validated = await validateConfig(this.hass, {
|
const validated = await validateConfig(this.hass, {
|
||||||
actions: this.action,
|
actions: this.action,
|
||||||
});
|
});
|
||||||
@@ -623,6 +639,12 @@ export default class HaAutomationActionRow extends LitElement {
|
|||||||
|
|
||||||
private _copyAction = () => {
|
private _copyAction = () => {
|
||||||
this._setClipboard();
|
this._setClipboard();
|
||||||
|
showToast(this, {
|
||||||
|
message: this.hass.localize(
|
||||||
|
"ui.panel.config.automation.editor.actions.copied_to_clipboard"
|
||||||
|
),
|
||||||
|
duration: 2000,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
private _cutAction = () => {
|
private _cutAction = () => {
|
||||||
@@ -631,6 +653,12 @@ export default class HaAutomationActionRow extends LitElement {
|
|||||||
if (this._selected) {
|
if (this._selected) {
|
||||||
fireEvent(this, "close-sidebar");
|
fireEvent(this, "close-sidebar");
|
||||||
}
|
}
|
||||||
|
showToast(this, {
|
||||||
|
message: this.hass.localize(
|
||||||
|
"ui.panel.config.automation.editor.actions.cut_to_clipboard"
|
||||||
|
),
|
||||||
|
duration: 2000,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
private _moveUp = () => {
|
private _moveUp = () => {
|
||||||
@@ -664,8 +692,7 @@ export default class HaAutomationActionRow extends LitElement {
|
|||||||
ev?.stopPropagation();
|
ev?.stopPropagation();
|
||||||
|
|
||||||
if (this._selected) {
|
if (this._selected) {
|
||||||
this._selected = false;
|
fireEvent(this, "request-close-sidebar");
|
||||||
fireEvent(this, "close-sidebar");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.openSidebar();
|
this.openSidebar();
|
||||||
@@ -709,12 +736,12 @@ export default class HaAutomationActionRow extends LitElement {
|
|||||||
this._collapsed = false;
|
this._collapsed = false;
|
||||||
|
|
||||||
if (this.narrow) {
|
if (this.narrow) {
|
||||||
requestAnimationFrame(() => {
|
window.setTimeout(() => {
|
||||||
this.scrollIntoView({
|
this.scrollIntoView({
|
||||||
block: "start",
|
block: "start",
|
||||||
behavior: "smooth",
|
behavior: "smooth",
|
||||||
});
|
});
|
||||||
});
|
}, 180); // duration of transition of added padding for bottom sheet
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -761,10 +788,6 @@ export default class HaAutomationActionRow extends LitElement {
|
|||||||
this._collapsed = !this._collapsed;
|
this._collapsed = !this._collapsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public isSelected() {
|
|
||||||
return this._selected;
|
|
||||||
}
|
|
||||||
|
|
||||||
public focus() {
|
public focus() {
|
||||||
this._automationRowElement?.focus();
|
this._automationRowElement?.focus();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import { fireEvent } from "../../../../common/dom/fire_event";
|
|||||||
import { nextRender } from "../../../../common/util/render-status";
|
import { nextRender } from "../../../../common/util/render-status";
|
||||||
import "../../../../components/ha-button";
|
import "../../../../components/ha-button";
|
||||||
import "../../../../components/ha-sortable";
|
import "../../../../components/ha-sortable";
|
||||||
import type { HaSortableClonedEventData } from "../../../../components/ha-sortable";
|
|
||||||
import "../../../../components/ha-svg-icon";
|
import "../../../../components/ha-svg-icon";
|
||||||
import {
|
import {
|
||||||
ACTION_BUILDING_BLOCKS,
|
ACTION_BUILDING_BLOCKS,
|
||||||
@@ -76,7 +75,6 @@ export default class HaAutomationAction extends LitElement {
|
|||||||
@item-moved=${this._actionMoved}
|
@item-moved=${this._actionMoved}
|
||||||
@item-added=${this._actionAdded}
|
@item-added=${this._actionAdded}
|
||||||
@item-removed=${this._actionRemoved}
|
@item-removed=${this._actionRemoved}
|
||||||
@item-cloned=${this._actionCloned}
|
|
||||||
>
|
>
|
||||||
<div class="rows ${!this.optionsInSidebar ? "no-sidebar" : ""}">
|
<div class="rows ${!this.optionsInSidebar ? "no-sidebar" : ""}">
|
||||||
${repeat(
|
${repeat(
|
||||||
@@ -301,11 +299,8 @@ export default class HaAutomationAction extends LitElement {
|
|||||||
private async _actionAdded(ev: CustomEvent): Promise<void> {
|
private async _actionAdded(ev: CustomEvent): Promise<void> {
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
const { index, data } = ev.detail;
|
const { index, data } = ev.detail;
|
||||||
let selected = false;
|
const item = ev.detail.item as HaAutomationActionRow;
|
||||||
if (data?.["ha-automation-row-selected"]) {
|
const selected = item.selected;
|
||||||
selected = true;
|
|
||||||
delete data["ha-automation-row-selected"];
|
|
||||||
}
|
|
||||||
|
|
||||||
let actions = [
|
let actions = [
|
||||||
...this.actions.slice(0, index),
|
...this.actions.slice(0, index),
|
||||||
@@ -363,12 +358,6 @@ export default class HaAutomationAction extends LitElement {
|
|||||||
fireEvent(this, "value-changed", { value: actions });
|
fireEvent(this, "value-changed", { value: actions });
|
||||||
}
|
}
|
||||||
|
|
||||||
private _actionCloned(ev: CustomEvent<HaSortableClonedEventData>) {
|
|
||||||
if (ev.detail.item.action && ev.detail.item.isSelected()) {
|
|
||||||
ev.detail.item.action["ha-automation-row-selected"] = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private _duplicateAction(ev: CustomEvent) {
|
private _duplicateAction(ev: CustomEvent) {
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
const index = (ev.target as any).index;
|
const index = (ev.target as any).index;
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
import { mdiClose, mdiContentPaste, mdiPlus } from "@mdi/js";
|
import {
|
||||||
|
mdiAppleKeyboardCommand,
|
||||||
|
mdiClose,
|
||||||
|
mdiContentPaste,
|
||||||
|
mdiPlus,
|
||||||
|
} from "@mdi/js";
|
||||||
import Fuse from "fuse.js";
|
import Fuse from "fuse.js";
|
||||||
import type { CSSResultGroup, PropertyValues, TemplateResult } from "lit";
|
import type { CSSResultGroup, PropertyValues, TemplateResult } from "lit";
|
||||||
import { LitElement, css, html, nothing } from "lit";
|
import { LitElement, css, html, nothing } from "lit";
|
||||||
@@ -41,11 +46,14 @@ import {
|
|||||||
} from "../../../data/integration";
|
} from "../../../data/integration";
|
||||||
import { TRIGGER_GROUPS, TRIGGER_ICONS } from "../../../data/trigger";
|
import { TRIGGER_GROUPS, TRIGGER_ICONS } from "../../../data/trigger";
|
||||||
import type { HassDialog } from "../../../dialogs/make-dialog-manager";
|
import type { HassDialog } from "../../../dialogs/make-dialog-manager";
|
||||||
|
import { KeyboardShortcutMixin } from "../../../mixins/keyboard-shortcut-mixin";
|
||||||
|
import { HaFuse } from "../../../resources/fuse";
|
||||||
import { haStyle, haStyleDialog } from "../../../resources/styles";
|
import { haStyle, haStyleDialog } from "../../../resources/styles";
|
||||||
import type { HomeAssistant } from "../../../types";
|
import type { HomeAssistant } from "../../../types";
|
||||||
|
import { isMac } from "../../../util/is_mac";
|
||||||
|
import { showToast } from "../../../util/toast";
|
||||||
import type { AddAutomationElementDialogParams } from "./show-add-automation-element-dialog";
|
import type { AddAutomationElementDialogParams } from "./show-add-automation-element-dialog";
|
||||||
import { PASTE_VALUE } from "./show-add-automation-element-dialog";
|
import { PASTE_VALUE } from "./show-add-automation-element-dialog";
|
||||||
import { HaFuse } from "../../../resources/fuse";
|
|
||||||
|
|
||||||
const TYPES = {
|
const TYPES = {
|
||||||
trigger: { groups: TRIGGER_GROUPS, icons: TRIGGER_ICONS },
|
trigger: { groups: TRIGGER_GROUPS, icons: TRIGGER_ICONS },
|
||||||
@@ -85,7 +93,10 @@ const ENTITY_DOMAINS_OTHER = new Set([
|
|||||||
const ENTITY_DOMAINS_MAIN = new Set(["notify"]);
|
const ENTITY_DOMAINS_MAIN = new Set(["notify"]);
|
||||||
|
|
||||||
@customElement("add-automation-element-dialog")
|
@customElement("add-automation-element-dialog")
|
||||||
class DialogAddAutomationElement extends LitElement implements HassDialog {
|
class DialogAddAutomationElement
|
||||||
|
extends KeyboardShortcutMixin(LitElement)
|
||||||
|
implements HassDialog
|
||||||
|
{
|
||||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||||
|
|
||||||
@state() private _params?: AddAutomationElementDialogParams;
|
@state() private _params?: AddAutomationElementDialogParams;
|
||||||
@@ -108,9 +119,14 @@ class DialogAddAutomationElement extends LitElement implements HassDialog {
|
|||||||
|
|
||||||
@state() private _height?: number;
|
@state() private _height?: number;
|
||||||
|
|
||||||
|
@state() private _narrow = false;
|
||||||
|
|
||||||
public showDialog(params): void {
|
public showDialog(params): void {
|
||||||
this._params = params;
|
this._params = params;
|
||||||
this._group = params.group;
|
this._group = params.group;
|
||||||
|
|
||||||
|
this.addKeyboardShortcuts();
|
||||||
|
|
||||||
if (this._params?.type === "action") {
|
if (this._params?.type === "action") {
|
||||||
this.hass.loadBackendTranslation("services");
|
this.hass.loadBackendTranslation("services");
|
||||||
this._fetchManifests();
|
this._fetchManifests();
|
||||||
@@ -120,9 +136,12 @@ class DialogAddAutomationElement extends LitElement implements HassDialog {
|
|||||||
this._fullScreen = matchMedia(
|
this._fullScreen = matchMedia(
|
||||||
"all and (max-width: 450px), all and (max-height: 500px)"
|
"all and (max-width: 450px), all and (max-height: 500px)"
|
||||||
).matches;
|
).matches;
|
||||||
|
|
||||||
|
this._narrow = matchMedia("(max-width: 870px)").matches;
|
||||||
}
|
}
|
||||||
|
|
||||||
public closeDialog() {
|
public closeDialog() {
|
||||||
|
this.removeKeyboardShortcuts();
|
||||||
if (this._params) {
|
if (this._params) {
|
||||||
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
||||||
}
|
}
|
||||||
@@ -555,15 +574,37 @@ class DialogAddAutomationElement extends LitElement implements HassDialog {
|
|||||||
.value=${PASTE_VALUE}
|
.value=${PASTE_VALUE}
|
||||||
@click=${this._selected}
|
@click=${this._selected}
|
||||||
>
|
>
|
||||||
|
<div class="shortcut-label">
|
||||||
|
<div class="label">
|
||||||
|
<div>
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
`ui.panel.config.automation.editor.${this._params.type}s.paste`
|
`ui.panel.config.automation.editor.${this._params.type}s.paste`
|
||||||
)}
|
)}
|
||||||
<span slot="supporting-text"
|
</div>
|
||||||
>${this.hass.localize(
|
<div class="supporting-text">
|
||||||
|
${this.hass.localize(
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
`ui.panel.config.automation.editor.${this._params.type}s.type.${this._params.clipboardItem}.label`
|
`ui.panel.config.automation.editor.${this._params.type}s.type.${this._params.clipboardItem}.label`
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
${!this._narrow
|
||||||
|
? html`<span class="shortcut">
|
||||||
|
<span
|
||||||
|
>${isMac
|
||||||
|
? html`<ha-svg-icon
|
||||||
|
slot="start"
|
||||||
|
.path=${mdiAppleKeyboardCommand}
|
||||||
|
></ha-svg-icon>`
|
||||||
|
: this.hass.localize(
|
||||||
|
"ui.panel.config.automation.editor.ctrl"
|
||||||
)}</span
|
)}</span
|
||||||
>
|
>
|
||||||
|
<span>+</span>
|
||||||
|
<span>V</span>
|
||||||
|
</span>`
|
||||||
|
: nothing}
|
||||||
|
</div>
|
||||||
<ha-svg-icon
|
<ha-svg-icon
|
||||||
slot="start"
|
slot="start"
|
||||||
.path=${mdiContentPaste}
|
.path=${mdiContentPaste}
|
||||||
@@ -571,7 +612,7 @@ class DialogAddAutomationElement extends LitElement implements HassDialog {
|
|||||||
><ha-svg-icon slot="end" .path=${mdiPlus}></ha-svg-icon>
|
><ha-svg-icon slot="end" .path=${mdiPlus}></ha-svg-icon>
|
||||||
</ha-md-list-item>
|
</ha-md-list-item>
|
||||||
<ha-md-divider role="separator" tabindex="-1"></ha-md-divider>`
|
<ha-md-divider role="separator" tabindex="-1"></ha-md-divider>`
|
||||||
: ""}
|
: nothing}
|
||||||
${repeat(
|
${repeat(
|
||||||
items,
|
items,
|
||||||
(item) => item.key,
|
(item) => item.key,
|
||||||
@@ -637,6 +678,30 @@ class DialogAddAutomationElement extends LitElement implements HassDialog {
|
|||||||
this._filter = ev.detail.value;
|
this._filter = ev.detail.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _addClipboard = () => {
|
||||||
|
if (this._params?.clipboardItem) {
|
||||||
|
this._params!.add(PASTE_VALUE);
|
||||||
|
showToast(this, {
|
||||||
|
message: this.hass.localize(
|
||||||
|
"ui.panel.config.automation.editor.item_pasted",
|
||||||
|
{
|
||||||
|
item: this.hass.localize(
|
||||||
|
// @ts-ignore
|
||||||
|
`ui.panel.config.automation.editor.${this._params.type}s.type.${this._params.clipboardItem}.label`
|
||||||
|
),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
});
|
||||||
|
this.closeDialog();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
protected supportedShortcuts(): SupportedShortcuts {
|
||||||
|
return {
|
||||||
|
v: () => this._addClipboard(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
static get styles(): CSSResultGroup {
|
static get styles(): CSSResultGroup {
|
||||||
return [
|
return [
|
||||||
haStyle,
|
haStyle,
|
||||||
@@ -660,6 +725,7 @@ class DialogAddAutomationElement extends LitElement implements HassDialog {
|
|||||||
max-width: 100vw;
|
max-width: 100vw;
|
||||||
--md-list-item-leading-space: 24px;
|
--md-list-item-leading-space: 24px;
|
||||||
--md-list-item-trailing-space: 24px;
|
--md-list-item-trailing-space: 24px;
|
||||||
|
--md-list-item-supporting-text-font: var(--ha-font-size-s);
|
||||||
}
|
}
|
||||||
ha-md-list-item img {
|
ha-md-list-item img {
|
||||||
width: 24px;
|
width: 24px;
|
||||||
@@ -668,6 +734,27 @@ class DialogAddAutomationElement extends LitElement implements HassDialog {
|
|||||||
display: block;
|
display: block;
|
||||||
margin: 0 16px;
|
margin: 0 16px;
|
||||||
}
|
}
|
||||||
|
.shortcut-label {
|
||||||
|
display: flex;
|
||||||
|
gap: 12px;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
.shortcut-label .supporting-text {
|
||||||
|
color: var(--secondary-text-color);
|
||||||
|
font-size: var(--ha-font-size-s);
|
||||||
|
}
|
||||||
|
.shortcut-label .shortcut {
|
||||||
|
--mdc-icon-size: 12px;
|
||||||
|
display: inline-flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
gap: 2px;
|
||||||
|
}
|
||||||
|
.shortcut-label .shortcut span {
|
||||||
|
font-size: var(--ha-font-size-s);
|
||||||
|
font-family: var(--ha-font-family-code);
|
||||||
|
color: var(--ha-color-text-secondary);
|
||||||
|
}
|
||||||
`,
|
`,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,12 +4,12 @@ import {
|
|||||||
mdiArrowUp,
|
mdiArrowUp,
|
||||||
mdiContentCopy,
|
mdiContentCopy,
|
||||||
mdiContentCut,
|
mdiContentCut,
|
||||||
mdiContentDuplicate,
|
|
||||||
mdiDelete,
|
mdiDelete,
|
||||||
mdiDotsVertical,
|
mdiDotsVertical,
|
||||||
mdiFlask,
|
mdiFlask,
|
||||||
mdiPlayCircleOutline,
|
mdiPlayCircleOutline,
|
||||||
mdiPlaylistEdit,
|
mdiPlaylistEdit,
|
||||||
|
mdiPlusCircleMultipleOutline,
|
||||||
mdiRenameBox,
|
mdiRenameBox,
|
||||||
mdiStopCircleOutline,
|
mdiStopCircleOutline,
|
||||||
} from "@mdi/js";
|
} from "@mdi/js";
|
||||||
@@ -53,6 +53,7 @@ import {
|
|||||||
showPromptDialog,
|
showPromptDialog,
|
||||||
} from "../../../../dialogs/generic/show-dialog-box";
|
} from "../../../../dialogs/generic/show-dialog-box";
|
||||||
import type { HomeAssistant } from "../../../../types";
|
import type { HomeAssistant } from "../../../../types";
|
||||||
|
import { showToast } from "../../../../util/toast";
|
||||||
import "../ha-automation-editor-warning";
|
import "../ha-automation-editor-warning";
|
||||||
import { rowStyles } from "../styles";
|
import { rowStyles } from "../styles";
|
||||||
import "./ha-automation-condition-editor";
|
import "./ha-automation-condition-editor";
|
||||||
@@ -154,6 +155,10 @@ export default class HaAutomationConditionRow extends LitElement {
|
|||||||
@query("ha-automation-row")
|
@query("ha-automation-row")
|
||||||
private _automationRowElement?: HaAutomationRow;
|
private _automationRowElement?: HaAutomationRow;
|
||||||
|
|
||||||
|
get selected() {
|
||||||
|
return this._selected;
|
||||||
|
}
|
||||||
|
|
||||||
private _renderRow() {
|
private _renderRow() {
|
||||||
return html`
|
return html`
|
||||||
<ha-svg-icon
|
<ha-svg-icon
|
||||||
@@ -214,7 +219,7 @@ export default class HaAutomationConditionRow extends LitElement {
|
|||||||
)}
|
)}
|
||||||
<ha-svg-icon
|
<ha-svg-icon
|
||||||
slot="start"
|
slot="start"
|
||||||
.path=${mdiContentDuplicate}
|
.path=${mdiPlusCircleMultipleOutline}
|
||||||
></ha-svg-icon>
|
></ha-svg-icon>
|
||||||
</ha-md-menu-item>
|
</ha-md-menu-item>
|
||||||
|
|
||||||
@@ -358,12 +363,15 @@ export default class HaAutomationConditionRow extends LitElement {
|
|||||||
.collapsed=${this._collapsed}
|
.collapsed=${this._collapsed}
|
||||||
.selected=${this._selected}
|
.selected=${this._selected}
|
||||||
.highlight=${this.highlight}
|
.highlight=${this.highlight}
|
||||||
@click=${this._toggleSidebar}
|
|
||||||
@toggle-collapsed=${this._toggleCollapse}
|
|
||||||
.buildingBlock=${CONDITION_BUILDING_BLOCKS.includes(
|
.buildingBlock=${CONDITION_BUILDING_BLOCKS.includes(
|
||||||
this.condition.condition
|
this.condition.condition
|
||||||
)}
|
)}
|
||||||
.sortSelected=${this.sortSelected}
|
.sortSelected=${this.sortSelected}
|
||||||
|
@click=${this._toggleSidebar}
|
||||||
|
@toggle-collapsed=${this._toggleCollapse}
|
||||||
|
@copy-row=${this._copyCondition}
|
||||||
|
@cut-row=${this._cutCondition}
|
||||||
|
@delete-row=${this._onDelete}
|
||||||
>${this._renderRow()}</ha-automation-row
|
>${this._renderRow()}</ha-automation-row
|
||||||
>`
|
>`
|
||||||
: html`
|
: html`
|
||||||
@@ -480,6 +488,15 @@ export default class HaAutomationConditionRow extends LitElement {
|
|||||||
this._testingResult = undefined;
|
this._testingResult = undefined;
|
||||||
this._testing = true;
|
this._testing = true;
|
||||||
const condition = this.condition;
|
const condition = this.condition;
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
// @ts-ignore is supported in all browsers expect firefox
|
||||||
|
if (this.scrollIntoViewIfNeeded) {
|
||||||
|
// @ts-ignore is supported in all browsers expect firefox
|
||||||
|
this.scrollIntoViewIfNeeded();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.scrollIntoView();
|
||||||
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const validateResult = await validateConfig(this.hass, {
|
const validateResult = await validateConfig(this.hass, {
|
||||||
@@ -570,6 +587,12 @@ export default class HaAutomationConditionRow extends LitElement {
|
|||||||
|
|
||||||
private _copyCondition = () => {
|
private _copyCondition = () => {
|
||||||
this._setClipboard();
|
this._setClipboard();
|
||||||
|
showToast(this, {
|
||||||
|
message: this.hass.localize(
|
||||||
|
"ui.panel.config.automation.editor.conditions.copied_to_clipboard"
|
||||||
|
),
|
||||||
|
duration: 2000,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
private _cutCondition = () => {
|
private _cutCondition = () => {
|
||||||
@@ -578,6 +601,12 @@ export default class HaAutomationConditionRow extends LitElement {
|
|||||||
if (this._selected) {
|
if (this._selected) {
|
||||||
fireEvent(this, "close-sidebar");
|
fireEvent(this, "close-sidebar");
|
||||||
}
|
}
|
||||||
|
showToast(this, {
|
||||||
|
message: this.hass.localize(
|
||||||
|
"ui.panel.config.automation.editor.conditions.cut_to_clipboard"
|
||||||
|
),
|
||||||
|
duration: 2000,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
private _moveUp = () => {
|
private _moveUp = () => {
|
||||||
@@ -638,8 +667,7 @@ export default class HaAutomationConditionRow extends LitElement {
|
|||||||
ev?.stopPropagation();
|
ev?.stopPropagation();
|
||||||
|
|
||||||
if (this._selected) {
|
if (this._selected) {
|
||||||
this._selected = false;
|
fireEvent(this, "request-close-sidebar");
|
||||||
fireEvent(this, "close-sidebar");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.openSidebar();
|
this.openSidebar();
|
||||||
@@ -679,12 +707,12 @@ export default class HaAutomationConditionRow extends LitElement {
|
|||||||
this._collapsed = false;
|
this._collapsed = false;
|
||||||
|
|
||||||
if (this.narrow) {
|
if (this.narrow) {
|
||||||
requestAnimationFrame(() => {
|
window.setTimeout(() => {
|
||||||
this.scrollIntoView({
|
this.scrollIntoView({
|
||||||
block: "start",
|
block: "start",
|
||||||
behavior: "smooth",
|
behavior: "smooth",
|
||||||
});
|
});
|
||||||
});
|
}, 180); // duration of transition of added padding for bottom sheet
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -697,10 +725,6 @@ export default class HaAutomationConditionRow extends LitElement {
|
|||||||
this._collapsed = !this._collapsed;
|
this._collapsed = !this._collapsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public isSelected() {
|
|
||||||
return this._selected;
|
|
||||||
}
|
|
||||||
|
|
||||||
public focus() {
|
public focus() {
|
||||||
this._automationRowElement?.focus();
|
this._automationRowElement?.focus();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import { nextRender } from "../../../../common/util/render-status";
|
|||||||
import "../../../../components/ha-button";
|
import "../../../../components/ha-button";
|
||||||
import "../../../../components/ha-button-menu";
|
import "../../../../components/ha-button-menu";
|
||||||
import "../../../../components/ha-sortable";
|
import "../../../../components/ha-sortable";
|
||||||
import type { HaSortableClonedEventData } from "../../../../components/ha-sortable";
|
|
||||||
import "../../../../components/ha-svg-icon";
|
import "../../../../components/ha-svg-icon";
|
||||||
import type {
|
import type {
|
||||||
AutomationClipboard,
|
AutomationClipboard,
|
||||||
@@ -153,7 +152,6 @@ export default class HaAutomationCondition extends LitElement {
|
|||||||
@item-moved=${this._conditionMoved}
|
@item-moved=${this._conditionMoved}
|
||||||
@item-added=${this._conditionAdded}
|
@item-added=${this._conditionAdded}
|
||||||
@item-removed=${this._conditionRemoved}
|
@item-removed=${this._conditionRemoved}
|
||||||
@item-cloned=${this._conditionCloned}
|
|
||||||
>
|
>
|
||||||
<div class="rows ${!this.optionsInSidebar ? "no-sidebar" : ""}">
|
<div class="rows ${!this.optionsInSidebar ? "no-sidebar" : ""}">
|
||||||
${repeat(
|
${repeat(
|
||||||
@@ -319,11 +317,8 @@ export default class HaAutomationCondition extends LitElement {
|
|||||||
private async _conditionAdded(ev: CustomEvent): Promise<void> {
|
private async _conditionAdded(ev: CustomEvent): Promise<void> {
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
const { index, data } = ev.detail;
|
const { index, data } = ev.detail;
|
||||||
let selected = false;
|
const item = ev.detail.item as HaAutomationConditionRow;
|
||||||
if (data?.["ha-automation-row-selected"]) {
|
const selected = item.selected;
|
||||||
selected = true;
|
|
||||||
delete data["ha-automation-row-selected"];
|
|
||||||
}
|
|
||||||
let conditions = [
|
let conditions = [
|
||||||
...this.conditions.slice(0, index),
|
...this.conditions.slice(0, index),
|
||||||
data,
|
data,
|
||||||
@@ -361,12 +356,6 @@ export default class HaAutomationCondition extends LitElement {
|
|||||||
fireEvent(this, "value-changed", { value: conditions });
|
fireEvent(this, "value-changed", { value: conditions });
|
||||||
}
|
}
|
||||||
|
|
||||||
private _conditionCloned(ev: CustomEvent<HaSortableClonedEventData>) {
|
|
||||||
if (ev.detail.item.isSelected()) {
|
|
||||||
ev.detail.item.condition["ha-automation-row-selected"] = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private _conditionChanged(ev: CustomEvent) {
|
private _conditionChanged(ev: CustomEvent) {
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
const conditions = [...this.conditions];
|
const conditions = [...this.conditions];
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { consume } from "@lit/context";
|
import { consume } from "@lit/context";
|
||||||
import {
|
import {
|
||||||
mdiCog,
|
mdiCog,
|
||||||
mdiContentDuplicate,
|
|
||||||
mdiContentSave,
|
mdiContentSave,
|
||||||
mdiDebugStepOver,
|
mdiDebugStepOver,
|
||||||
mdiDelete,
|
mdiDelete,
|
||||||
@@ -11,13 +10,12 @@ import {
|
|||||||
mdiPlay,
|
mdiPlay,
|
||||||
mdiPlayCircleOutline,
|
mdiPlayCircleOutline,
|
||||||
mdiPlaylistEdit,
|
mdiPlaylistEdit,
|
||||||
|
mdiPlusCircleMultipleOutline,
|
||||||
mdiRenameBox,
|
mdiRenameBox,
|
||||||
mdiRobotConfused,
|
mdiRobotConfused,
|
||||||
mdiStopCircleOutline,
|
mdiStopCircleOutline,
|
||||||
mdiTag,
|
mdiTag,
|
||||||
mdiTransitConnection,
|
mdiTransitConnection,
|
||||||
mdiUnfoldLessHorizontal,
|
|
||||||
mdiUnfoldMoreHorizontal,
|
|
||||||
} from "@mdi/js";
|
} from "@mdi/js";
|
||||||
import type { UnsubscribeFunc } from "home-assistant-js-websocket";
|
import type { UnsubscribeFunc } from "home-assistant-js-websocket";
|
||||||
import type { CSSResultGroup, PropertyValues, TemplateResult } from "lit";
|
import type { CSSResultGroup, PropertyValues, TemplateResult } from "lit";
|
||||||
@@ -337,7 +335,7 @@ export class HaAutomationEditor extends PreventUnsavedMixin(
|
|||||||
)}
|
)}
|
||||||
<ha-svg-icon
|
<ha-svg-icon
|
||||||
slot="graphic"
|
slot="graphic"
|
||||||
.path=${mdiContentDuplicate}
|
.path=${mdiPlusCircleMultipleOutline}
|
||||||
></ha-svg-icon>
|
></ha-svg-icon>
|
||||||
</ha-list-item>
|
</ha-list-item>
|
||||||
|
|
||||||
@@ -371,30 +369,6 @@ export class HaAutomationEditor extends PreventUnsavedMixin(
|
|||||||
<ha-svg-icon slot="graphic" .path=${mdiPlaylistEdit}></ha-svg-icon>
|
<ha-svg-icon slot="graphic" .path=${mdiPlaylistEdit}></ha-svg-icon>
|
||||||
</ha-list-item>
|
</ha-list-item>
|
||||||
|
|
||||||
${!useBlueprint
|
|
||||||
? html`
|
|
||||||
<ha-list-item graphic="icon" @click=${this._collapseAll}>
|
|
||||||
<ha-svg-icon
|
|
||||||
slot="graphic"
|
|
||||||
.path=${mdiUnfoldLessHorizontal}
|
|
||||||
></ha-svg-icon>
|
|
||||||
${this.hass.localize(
|
|
||||||
"ui.panel.config.automation.editor.collapse_all"
|
|
||||||
)}
|
|
||||||
</ha-list-item>
|
|
||||||
|
|
||||||
<ha-list-item graphic="icon" @click=${this._expandAll}>
|
|
||||||
<ha-svg-icon
|
|
||||||
slot="graphic"
|
|
||||||
.path=${mdiUnfoldMoreHorizontal}
|
|
||||||
></ha-svg-icon>
|
|
||||||
${this.hass.localize(
|
|
||||||
"ui.panel.config.automation.editor.expand_all"
|
|
||||||
)}
|
|
||||||
</ha-list-item>
|
|
||||||
`
|
|
||||||
: nothing}
|
|
||||||
|
|
||||||
<li divider role="separator"></li>
|
<li divider role="separator"></li>
|
||||||
|
|
||||||
<ha-list-item
|
<ha-list-item
|
||||||
@@ -1138,6 +1112,10 @@ export class HaAutomationEditor extends PreventUnsavedMixin(
|
|||||||
protected supportedShortcuts(): SupportedShortcuts {
|
protected supportedShortcuts(): SupportedShortcuts {
|
||||||
return {
|
return {
|
||||||
s: () => this._handleSaveAutomation(),
|
s: () => this._handleSaveAutomation(),
|
||||||
|
c: () => this._copySelectedRow(),
|
||||||
|
x: () => this._cutSelectedRow(),
|
||||||
|
Delete: () => this._deleteSelectedRow(),
|
||||||
|
Backspace: () => this._deleteSelectedRow(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1149,14 +1127,28 @@ export class HaAutomationEditor extends PreventUnsavedMixin(
|
|||||||
return this._confirmUnsavedChanged();
|
return this._confirmUnsavedChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
private _collapseAll() {
|
private _collapseAll() {
|
||||||
this._manualEditor?.collapseAll();
|
this._manualEditor?.collapseAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
private _expandAll() {
|
private _expandAll() {
|
||||||
this._manualEditor?.expandAll();
|
this._manualEditor?.expandAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _copySelectedRow() {
|
||||||
|
this._manualEditor?.copySelectedRow();
|
||||||
|
}
|
||||||
|
|
||||||
|
private _cutSelectedRow() {
|
||||||
|
this._manualEditor?.cutSelectedRow();
|
||||||
|
}
|
||||||
|
|
||||||
|
private _deleteSelectedRow() {
|
||||||
|
this._manualEditor?.deleteSelectedRow();
|
||||||
|
}
|
||||||
|
|
||||||
static get styles(): CSSResultGroup {
|
static get styles(): CSSResultGroup {
|
||||||
return [
|
return [
|
||||||
haStyle,
|
haStyle,
|
||||||
|
|||||||
@@ -292,7 +292,7 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) {
|
|||||||
extraTemplate: (automation) =>
|
extraTemplate: (automation) =>
|
||||||
automation.labels.length
|
automation.labels.length
|
||||||
? html`<ha-data-table-labels
|
? html`<ha-data-table-labels
|
||||||
@label-clicked=${this._labelClicked}
|
@label-clicked=${narrow ? undefined : this._labelClicked}
|
||||||
.labels=${automation.labels}
|
.labels=${automation.labels}
|
||||||
></ha-data-table-labels>`
|
></ha-data-table-labels>`
|
||||||
: nothing,
|
: nothing,
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ export default class HaAutomationSidebar extends LitElement {
|
|||||||
.yamlMode=${this._yamlMode}
|
.yamlMode=${this._yamlMode}
|
||||||
.sidebarKey=${this.sidebarKey}
|
.sidebarKey=${this.sidebarKey}
|
||||||
@toggle-yaml-mode=${this._toggleYamlMode}
|
@toggle-yaml-mode=${this._toggleYamlMode}
|
||||||
@close-sidebar=${this._handleCloseSidebar}
|
@close-sidebar=${this.triggerCloseSidebar}
|
||||||
></ha-automation-sidebar-trigger>
|
></ha-automation-sidebar-trigger>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
@@ -71,7 +71,7 @@ export default class HaAutomationSidebar extends LitElement {
|
|||||||
.yamlMode=${this._yamlMode}
|
.yamlMode=${this._yamlMode}
|
||||||
.sidebarKey=${this.sidebarKey}
|
.sidebarKey=${this.sidebarKey}
|
||||||
@toggle-yaml-mode=${this._toggleYamlMode}
|
@toggle-yaml-mode=${this._toggleYamlMode}
|
||||||
@close-sidebar=${this._handleCloseSidebar}
|
@close-sidebar=${this.triggerCloseSidebar}
|
||||||
></ha-automation-sidebar-condition>
|
></ha-automation-sidebar-condition>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
@@ -87,7 +87,7 @@ export default class HaAutomationSidebar extends LitElement {
|
|||||||
.yamlMode=${this._yamlMode}
|
.yamlMode=${this._yamlMode}
|
||||||
.sidebarKey=${this.sidebarKey}
|
.sidebarKey=${this.sidebarKey}
|
||||||
@toggle-yaml-mode=${this._toggleYamlMode}
|
@toggle-yaml-mode=${this._toggleYamlMode}
|
||||||
@close-sidebar=${this._handleCloseSidebar}
|
@close-sidebar=${this.triggerCloseSidebar}
|
||||||
></ha-automation-sidebar-action>
|
></ha-automation-sidebar-action>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
@@ -100,7 +100,7 @@ export default class HaAutomationSidebar extends LitElement {
|
|||||||
.isWide=${this.isWide}
|
.isWide=${this.isWide}
|
||||||
.narrow=${this.narrow}
|
.narrow=${this.narrow}
|
||||||
.disabled=${this.disabled}
|
.disabled=${this.disabled}
|
||||||
@close-sidebar=${this._handleCloseSidebar}
|
@close-sidebar=${this.triggerCloseSidebar}
|
||||||
></ha-automation-sidebar-option>
|
></ha-automation-sidebar-option>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
@@ -116,7 +116,7 @@ export default class HaAutomationSidebar extends LitElement {
|
|||||||
.yamlMode=${this._yamlMode}
|
.yamlMode=${this._yamlMode}
|
||||||
.sidebarKey=${this.sidebarKey}
|
.sidebarKey=${this.sidebarKey}
|
||||||
@toggle-yaml-mode=${this._toggleYamlMode}
|
@toggle-yaml-mode=${this._toggleYamlMode}
|
||||||
@close-sidebar=${this._handleCloseSidebar}
|
@close-sidebar=${this.triggerCloseSidebar}
|
||||||
></ha-automation-sidebar-script-field-selector>
|
></ha-automation-sidebar-script-field-selector>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
@@ -132,7 +132,7 @@ export default class HaAutomationSidebar extends LitElement {
|
|||||||
.yamlMode=${this._yamlMode}
|
.yamlMode=${this._yamlMode}
|
||||||
.sidebarKey=${this.sidebarKey}
|
.sidebarKey=${this.sidebarKey}
|
||||||
@toggle-yaml-mode=${this._toggleYamlMode}
|
@toggle-yaml-mode=${this._toggleYamlMode}
|
||||||
@close-sidebar=${this._handleCloseSidebar}
|
@close-sidebar=${this.triggerCloseSidebar}
|
||||||
></ha-automation-sidebar-script-field>
|
></ha-automation-sidebar-script-field>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
@@ -188,8 +188,8 @@ export default class HaAutomationSidebar extends LitElement {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _handleCloseSidebar(ev: CustomEvent) {
|
public triggerCloseSidebar(ev?: CustomEvent) {
|
||||||
ev.stopPropagation();
|
ev?.stopPropagation();
|
||||||
if (this.narrow) {
|
if (this.narrow) {
|
||||||
this._bottomSheetElement?.closeSheet();
|
this._bottomSheetElement?.closeSheet();
|
||||||
return;
|
return;
|
||||||
@@ -208,6 +208,7 @@ export default class HaAutomationSidebar extends LitElement {
|
|||||||
|
|
||||||
static styles = css`
|
static styles = css`
|
||||||
:host {
|
:host {
|
||||||
|
z-index: 6;
|
||||||
outline: none;
|
outline: none;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
--ha-card-border-radius: var(
|
--ha-card-border-radius: var(
|
||||||
|
|||||||
@@ -3,7 +3,13 @@ import type { HassEntity } from "home-assistant-js-websocket";
|
|||||||
import { load } from "js-yaml";
|
import { load } from "js-yaml";
|
||||||
import type { CSSResultGroup, PropertyValues } from "lit";
|
import type { CSSResultGroup, PropertyValues } from "lit";
|
||||||
import { css, html, LitElement, nothing } from "lit";
|
import { css, html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property, query, state } from "lit/decorators";
|
import {
|
||||||
|
customElement,
|
||||||
|
property,
|
||||||
|
query,
|
||||||
|
queryAll,
|
||||||
|
state,
|
||||||
|
} from "lit/decorators";
|
||||||
import { classMap } from "lit/directives/class-map";
|
import { classMap } from "lit/directives/class-map";
|
||||||
import {
|
import {
|
||||||
any,
|
any,
|
||||||
@@ -28,6 +34,7 @@ import "../../../components/ha-fab";
|
|||||||
import "../../../components/ha-icon-button";
|
import "../../../components/ha-icon-button";
|
||||||
import "../../../components/ha-markdown";
|
import "../../../components/ha-markdown";
|
||||||
import type {
|
import type {
|
||||||
|
ActionSidebarConfig,
|
||||||
AutomationConfig,
|
AutomationConfig,
|
||||||
Condition,
|
Condition,
|
||||||
ManualAutomationConfig,
|
ManualAutomationConfig,
|
||||||
@@ -96,6 +103,11 @@ export class HaManualAutomationEditor extends LitElement {
|
|||||||
|
|
||||||
@query("ha-automation-sidebar") private _sidebarElement?: HaAutomationSidebar;
|
@query("ha-automation-sidebar") private _sidebarElement?: HaAutomationSidebar;
|
||||||
|
|
||||||
|
@queryAll("ha-automation-action, ha-automation-condition")
|
||||||
|
private _collapsableElements?: NodeListOf<
|
||||||
|
HaAutomationAction | HaAutomationCondition
|
||||||
|
>;
|
||||||
|
|
||||||
private _previousConfig?: ManualAutomationConfig;
|
private _previousConfig?: ManualAutomationConfig;
|
||||||
|
|
||||||
public connectedCallback() {
|
public connectedCallback() {
|
||||||
@@ -154,7 +166,7 @@ export class HaManualAutomationEditor extends LitElement {
|
|||||||
.disabled=${this.disabled || this.saving}
|
.disabled=${this.disabled || this.saving}
|
||||||
.narrow=${this.narrow}
|
.narrow=${this.narrow}
|
||||||
@open-sidebar=${this._openSidebar}
|
@open-sidebar=${this._openSidebar}
|
||||||
@request-close-sidebar=${this._closeSidebar}
|
@request-close-sidebar=${this._triggerCloseSidebar}
|
||||||
@close-sidebar=${this._handleCloseSidebar}
|
@close-sidebar=${this._handleCloseSidebar}
|
||||||
root
|
root
|
||||||
sidebar
|
sidebar
|
||||||
@@ -201,7 +213,7 @@ export class HaManualAutomationEditor extends LitElement {
|
|||||||
.disabled=${this.disabled || this.saving}
|
.disabled=${this.disabled || this.saving}
|
||||||
.narrow=${this.narrow}
|
.narrow=${this.narrow}
|
||||||
@open-sidebar=${this._openSidebar}
|
@open-sidebar=${this._openSidebar}
|
||||||
@request-close-sidebar=${this._closeSidebar}
|
@request-close-sidebar=${this._triggerCloseSidebar}
|
||||||
@close-sidebar=${this._handleCloseSidebar}
|
@close-sidebar=${this._handleCloseSidebar}
|
||||||
root
|
root
|
||||||
sidebar
|
sidebar
|
||||||
@@ -243,7 +255,7 @@ export class HaManualAutomationEditor extends LitElement {
|
|||||||
.highlightedActions=${this._pastedConfig?.actions || []}
|
.highlightedActions=${this._pastedConfig?.actions || []}
|
||||||
@value-changed=${this._actionChanged}
|
@value-changed=${this._actionChanged}
|
||||||
@open-sidebar=${this._openSidebar}
|
@open-sidebar=${this._openSidebar}
|
||||||
@request-close-sidebar=${this._closeSidebar}
|
@request-close-sidebar=${this._triggerCloseSidebar}
|
||||||
@close-sidebar=${this._handleCloseSidebar}
|
@close-sidebar=${this._handleCloseSidebar}
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.narrow=${this.narrow}
|
.narrow=${this.narrow}
|
||||||
@@ -262,7 +274,11 @@ export class HaManualAutomationEditor extends LitElement {
|
|||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
<div class="content-wrapper">
|
<div class="content-wrapper">
|
||||||
<div class="content">
|
<div
|
||||||
|
class="content ${this._sidebarConfig && this.narrow
|
||||||
|
? "has-bottom-sheet"
|
||||||
|
: ""}"
|
||||||
|
>
|
||||||
<slot name="alerts"></slot>
|
<slot name="alerts"></slot>
|
||||||
${this._renderContent()}
|
${this._renderContent()}
|
||||||
</div>
|
</div>
|
||||||
@@ -335,8 +351,12 @@ export class HaManualAutomationEditor extends LitElement {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private _closeSidebar() {
|
private _triggerCloseSidebar() {
|
||||||
if (this._sidebarConfig) {
|
if (this._sidebarConfig) {
|
||||||
|
if (this._sidebarElement) {
|
||||||
|
this._sidebarElement.triggerCloseSidebar();
|
||||||
|
return;
|
||||||
|
}
|
||||||
this._sidebarConfig?.close();
|
this._sidebarConfig?.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -373,7 +393,7 @@ export class HaManualAutomationEditor extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _saveAutomation() {
|
private _saveAutomation() {
|
||||||
this._closeSidebar();
|
this._triggerCloseSidebar();
|
||||||
fireEvent(this, "save-automation");
|
fireEvent(this, "save-automation");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -478,7 +498,12 @@ export class HaManualAutomationEditor extends LitElement {
|
|||||||
if (normalized) {
|
if (normalized) {
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
|
|
||||||
if (this.dirty) {
|
if (
|
||||||
|
this.dirty ||
|
||||||
|
ensureArray(this.config.triggers)?.length ||
|
||||||
|
ensureArray(this.config.conditions)?.length ||
|
||||||
|
ensureArray(this.config.actions)?.length
|
||||||
|
) {
|
||||||
const result = await new Promise<boolean>((resolve) => {
|
const result = await new Promise<boolean>((resolve) => {
|
||||||
showPasteReplaceDialog(this, {
|
showPasteReplaceDialog(this, {
|
||||||
domain: "automation",
|
domain: "automation",
|
||||||
@@ -587,24 +612,36 @@ export class HaManualAutomationEditor extends LitElement {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private _getCollapsableElements() {
|
|
||||||
return this.shadowRoot!.querySelectorAll<
|
|
||||||
HaAutomationAction | HaAutomationCondition
|
|
||||||
>("ha-automation-action, ha-automation-condition");
|
|
||||||
}
|
|
||||||
|
|
||||||
public expandAll() {
|
public expandAll() {
|
||||||
this._getCollapsableElements().forEach((element) => {
|
this._collapsableElements?.forEach((element) => {
|
||||||
element.expandAll();
|
element.expandAll();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public collapseAll() {
|
public collapseAll() {
|
||||||
this._getCollapsableElements().forEach((element) => {
|
this._collapsableElements?.forEach((element) => {
|
||||||
element.collapseAll();
|
element.collapseAll();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public copySelectedRow() {
|
||||||
|
if ((this._sidebarConfig as ActionSidebarConfig)?.copy) {
|
||||||
|
(this._sidebarConfig as ActionSidebarConfig).copy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public cutSelectedRow() {
|
||||||
|
if ((this._sidebarConfig as ActionSidebarConfig)?.cut) {
|
||||||
|
(this._sidebarConfig as ActionSidebarConfig).cut();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public deleteSelectedRow() {
|
||||||
|
if ((this._sidebarConfig as ActionSidebarConfig)?.delete) {
|
||||||
|
(this._sidebarConfig as ActionSidebarConfig).delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static get styles(): CSSResultGroup {
|
static get styles(): CSSResultGroup {
|
||||||
return [
|
return [
|
||||||
saveFabStyles,
|
saveFabStyles,
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ import { consume } from "@lit/context";
|
|||||||
import {
|
import {
|
||||||
mdiArrowDown,
|
mdiArrowDown,
|
||||||
mdiArrowUp,
|
mdiArrowUp,
|
||||||
mdiContentDuplicate,
|
|
||||||
mdiDelete,
|
mdiDelete,
|
||||||
mdiDotsVertical,
|
mdiDotsVertical,
|
||||||
|
mdiPlusCircleMultipleOutline,
|
||||||
mdiRenameBox,
|
mdiRenameBox,
|
||||||
} from "@mdi/js";
|
} from "@mdi/js";
|
||||||
import type { CSSResultGroup } from "lit";
|
import type { CSSResultGroup } from "lit";
|
||||||
@@ -86,6 +86,10 @@ export default class HaAutomationOptionRow extends LitElement {
|
|||||||
@query("ha-automation-row")
|
@query("ha-automation-row")
|
||||||
private _automationRowElement?: HaAutomationRow;
|
private _automationRowElement?: HaAutomationRow;
|
||||||
|
|
||||||
|
get selected() {
|
||||||
|
return this._selected;
|
||||||
|
}
|
||||||
|
|
||||||
private _expandedChanged(ev) {
|
private _expandedChanged(ev) {
|
||||||
if (ev.currentTarget.id !== "option") {
|
if (ev.currentTarget.id !== "option") {
|
||||||
return;
|
return;
|
||||||
@@ -167,7 +171,7 @@ export default class HaAutomationOptionRow extends LitElement {
|
|||||||
)}
|
)}
|
||||||
<ha-svg-icon
|
<ha-svg-icon
|
||||||
slot="start"
|
slot="start"
|
||||||
.path=${mdiContentDuplicate}
|
.path=${mdiPlusCircleMultipleOutline}
|
||||||
></ha-svg-icon>
|
></ha-svg-icon>
|
||||||
</ha-md-menu-item>
|
</ha-md-menu-item>
|
||||||
|
|
||||||
@@ -271,9 +275,10 @@ export default class HaAutomationOptionRow extends LitElement {
|
|||||||
left-chevron
|
left-chevron
|
||||||
.collapsed=${this._collapsed}
|
.collapsed=${this._collapsed}
|
||||||
.selected=${this._selected}
|
.selected=${this._selected}
|
||||||
|
.sortSelected=${this.sortSelected}
|
||||||
@click=${this._toggleSidebar}
|
@click=${this._toggleSidebar}
|
||||||
@toggle-collapsed=${this._toggleCollapse}
|
@toggle-collapsed=${this._toggleCollapse}
|
||||||
.sortSelected=${this.sortSelected}
|
@delete-row=${this._removeOption}
|
||||||
>${this._renderRow()}</ha-automation-row
|
>${this._renderRow()}</ha-automation-row
|
||||||
>`
|
>`
|
||||||
: html`
|
: html`
|
||||||
@@ -376,8 +381,7 @@ export default class HaAutomationOptionRow extends LitElement {
|
|||||||
ev?.stopPropagation();
|
ev?.stopPropagation();
|
||||||
|
|
||||||
if (this._selected) {
|
if (this._selected) {
|
||||||
this._selected = false;
|
fireEvent(this, "request-close-sidebar");
|
||||||
fireEvent(this, "close-sidebar");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.openSidebar();
|
this.openSidebar();
|
||||||
@@ -403,12 +407,12 @@ export default class HaAutomationOptionRow extends LitElement {
|
|||||||
this._collapsed = false;
|
this._collapsed = false;
|
||||||
|
|
||||||
if (this.narrow) {
|
if (this.narrow) {
|
||||||
requestAnimationFrame(() => {
|
window.setTimeout(() => {
|
||||||
this.scrollIntoView({
|
this.scrollIntoView({
|
||||||
block: "start",
|
block: "start",
|
||||||
behavior: "smooth",
|
behavior: "smooth",
|
||||||
});
|
});
|
||||||
});
|
}, 180); // duration of transition of added padding for bottom sheet
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -445,10 +449,6 @@ export default class HaAutomationOptionRow extends LitElement {
|
|||||||
this._collapsed = !this._collapsed;
|
this._collapsed = !this._collapsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public isSelected() {
|
|
||||||
return this._selected;
|
|
||||||
}
|
|
||||||
|
|
||||||
public focus() {
|
public focus() {
|
||||||
this._automationRowElement?.focus();
|
this._automationRowElement?.focus();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import { fireEvent } from "../../../../common/dom/fire_event";
|
|||||||
import { nextRender } from "../../../../common/util/render-status";
|
import { nextRender } from "../../../../common/util/render-status";
|
||||||
import "../../../../components/ha-button";
|
import "../../../../components/ha-button";
|
||||||
import "../../../../components/ha-sortable";
|
import "../../../../components/ha-sortable";
|
||||||
import type { HaSortableClonedEventData } from "../../../../components/ha-sortable";
|
|
||||||
import "../../../../components/ha-svg-icon";
|
import "../../../../components/ha-svg-icon";
|
||||||
import type { AutomationClipboard } from "../../../../data/automation";
|
import type { AutomationClipboard } from "../../../../data/automation";
|
||||||
import type { Option } from "../../../../data/script";
|
import type { Option } from "../../../../data/script";
|
||||||
@@ -65,7 +64,6 @@ export default class HaAutomationOption extends LitElement {
|
|||||||
@item-moved=${this._optionMoved}
|
@item-moved=${this._optionMoved}
|
||||||
@item-added=${this._optionAdded}
|
@item-added=${this._optionAdded}
|
||||||
@item-removed=${this._optionRemoved}
|
@item-removed=${this._optionRemoved}
|
||||||
@item-cloned=${this._optionCloned}
|
|
||||||
>
|
>
|
||||||
<div class="rows ${!this.optionsInSidebar ? "no-sidebar" : ""}">
|
<div class="rows ${!this.optionsInSidebar ? "no-sidebar" : ""}">
|
||||||
${repeat(
|
${repeat(
|
||||||
@@ -241,11 +239,8 @@ export default class HaAutomationOption extends LitElement {
|
|||||||
private async _optionAdded(ev: CustomEvent): Promise<void> {
|
private async _optionAdded(ev: CustomEvent): Promise<void> {
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
const { index, data } = ev.detail;
|
const { index, data } = ev.detail;
|
||||||
let selected = false;
|
const item = ev.detail.item as HaAutomationOptionRow;
|
||||||
if (data?.["ha-automation-row-selected"]) {
|
const selected = item.selected;
|
||||||
selected = true;
|
|
||||||
delete data["ha-automation-row-selected"];
|
|
||||||
}
|
|
||||||
|
|
||||||
const options = [
|
const options = [
|
||||||
...this.options.slice(0, index),
|
...this.options.slice(0, index),
|
||||||
@@ -273,12 +268,6 @@ export default class HaAutomationOption extends LitElement {
|
|||||||
fireEvent(this, "value-changed", { value: options });
|
fireEvent(this, "value-changed", { value: options });
|
||||||
}
|
}
|
||||||
|
|
||||||
private _optionCloned(ev: CustomEvent<HaSortableClonedEventData>) {
|
|
||||||
if (ev.detail.item.isSelected()) {
|
|
||||||
ev.detail.item.option["ha-automation-row-selected"] = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private _optionChanged(ev: CustomEvent) {
|
private _optionChanged(ev: CustomEvent) {
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
const options = [...this.options];
|
const options = [...this.options];
|
||||||
|
|||||||
@@ -1,15 +1,16 @@
|
|||||||
import {
|
import {
|
||||||
|
mdiAppleKeyboardCommand,
|
||||||
mdiContentCopy,
|
mdiContentCopy,
|
||||||
mdiContentCut,
|
mdiContentCut,
|
||||||
mdiContentDuplicate,
|
|
||||||
mdiDelete,
|
mdiDelete,
|
||||||
mdiPlay,
|
mdiPlay,
|
||||||
mdiPlayCircleOutline,
|
mdiPlayCircleOutline,
|
||||||
mdiPlaylistEdit,
|
mdiPlaylistEdit,
|
||||||
|
mdiPlusCircleMultipleOutline,
|
||||||
mdiRenameBox,
|
mdiRenameBox,
|
||||||
mdiStopCircleOutline,
|
mdiStopCircleOutline,
|
||||||
} from "@mdi/js";
|
} from "@mdi/js";
|
||||||
import { html, LitElement } from "lit";
|
import { html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property, query, state } from "lit/decorators";
|
import { customElement, property, query, state } from "lit/decorators";
|
||||||
import { keyed } from "lit/directives/keyed";
|
import { keyed } from "lit/directives/keyed";
|
||||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||||
@@ -21,6 +22,7 @@ import { ACTION_BUILDING_BLOCKS } from "../../../../data/action";
|
|||||||
import type { ActionSidebarConfig } from "../../../../data/automation";
|
import type { ActionSidebarConfig } from "../../../../data/automation";
|
||||||
import type { RepeatAction } from "../../../../data/script";
|
import type { RepeatAction } from "../../../../data/script";
|
||||||
import type { HomeAssistant } from "../../../../types";
|
import type { HomeAssistant } from "../../../../types";
|
||||||
|
import { isMac } from "../../../../util/is_mac";
|
||||||
import type HaAutomationConditionEditor from "../action/ha-automation-action-editor";
|
import type HaAutomationConditionEditor from "../action/ha-automation-action-editor";
|
||||||
import { getAutomationActionType } from "../action/ha-automation-action-row";
|
import { getAutomationActionType } from "../action/ha-automation-action-row";
|
||||||
import { getRepeatType } from "../action/types/ha-automation-action-repeat";
|
import { getRepeatType } from "../action/types/ha-automation-action-repeat";
|
||||||
@@ -103,18 +105,24 @@ export default class HaAutomationSidebarAction extends LitElement {
|
|||||||
<span slot="subtitle">${subtitle}</span>
|
<span slot="subtitle">${subtitle}</span>
|
||||||
|
|
||||||
<ha-md-menu-item slot="menu-items" .clickAction=${this.config.run}>
|
<ha-md-menu-item slot="menu-items" .clickAction=${this.config.run}>
|
||||||
${this.hass.localize("ui.panel.config.automation.editor.actions.run")}
|
|
||||||
<ha-svg-icon slot="start" .path=${mdiPlay}></ha-svg-icon>
|
<ha-svg-icon slot="start" .path=${mdiPlay}></ha-svg-icon>
|
||||||
|
<div class="overflow-label">
|
||||||
|
${this.hass.localize("ui.panel.config.automation.editor.actions.run")}
|
||||||
|
<span class="shortcut-placeholder ${isMac ? "mac" : ""}"></span>
|
||||||
|
</div>
|
||||||
</ha-md-menu-item>
|
</ha-md-menu-item>
|
||||||
<ha-md-menu-item
|
<ha-md-menu-item
|
||||||
slot="menu-items"
|
slot="menu-items"
|
||||||
.clickAction=${this.config.rename}
|
.clickAction=${this.config.rename}
|
||||||
.disabled=${!!disabled}
|
.disabled=${!!disabled}
|
||||||
>
|
>
|
||||||
|
<ha-svg-icon slot="start" .path=${mdiRenameBox}></ha-svg-icon>
|
||||||
|
<div class="overflow-label">
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.automation.editor.triggers.rename"
|
"ui.panel.config.automation.editor.triggers.rename"
|
||||||
)}
|
)}
|
||||||
<ha-svg-icon slot="start" .path=${mdiRenameBox}></ha-svg-icon>
|
<span class="shortcut-placeholder ${isMac ? "mac" : ""}"></span>
|
||||||
|
</div>
|
||||||
</ha-md-menu-item>
|
</ha-md-menu-item>
|
||||||
<ha-md-divider
|
<ha-md-divider
|
||||||
slot="menu-items"
|
slot="menu-items"
|
||||||
@@ -126,36 +134,85 @@ export default class HaAutomationSidebarAction extends LitElement {
|
|||||||
.clickAction=${this.config.duplicate}
|
.clickAction=${this.config.duplicate}
|
||||||
.disabled=${this.disabled}
|
.disabled=${this.disabled}
|
||||||
>
|
>
|
||||||
|
<ha-svg-icon
|
||||||
|
slot="start"
|
||||||
|
.path=${mdiPlusCircleMultipleOutline}
|
||||||
|
></ha-svg-icon>
|
||||||
|
<div class="overflow-label">
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.automation.editor.actions.duplicate"
|
"ui.panel.config.automation.editor.actions.duplicate"
|
||||||
)}
|
)}
|
||||||
<ha-svg-icon slot="start" .path=${mdiContentDuplicate}></ha-svg-icon>
|
<span class="shortcut-placeholder ${isMac ? "mac" : ""}"></span>
|
||||||
|
</div>
|
||||||
</ha-md-menu-item>
|
</ha-md-menu-item>
|
||||||
<ha-md-menu-item
|
<ha-md-menu-item
|
||||||
slot="menu-items"
|
slot="menu-items"
|
||||||
.clickAction=${this.config.copy}
|
.clickAction=${this.config.copy}
|
||||||
.disabled=${this.disabled}
|
.disabled=${this.disabled}
|
||||||
>
|
>
|
||||||
${this.hass.localize("ui.panel.config.automation.editor.triggers.copy")}
|
|
||||||
<ha-svg-icon slot="start" .path=${mdiContentCopy}></ha-svg-icon>
|
<ha-svg-icon slot="start" .path=${mdiContentCopy}></ha-svg-icon>
|
||||||
|
<div class="overflow-label">
|
||||||
|
${this.hass.localize(
|
||||||
|
"ui.panel.config.automation.editor.triggers.copy"
|
||||||
|
)}
|
||||||
|
${!this.narrow
|
||||||
|
? html`<span class="shortcut">
|
||||||
|
<span
|
||||||
|
>${isMac
|
||||||
|
? html`<ha-svg-icon
|
||||||
|
slot="start"
|
||||||
|
.path=${mdiAppleKeyboardCommand}
|
||||||
|
></ha-svg-icon>`
|
||||||
|
: this.hass.localize(
|
||||||
|
"ui.panel.config.automation.editor.ctrl"
|
||||||
|
)}</span
|
||||||
|
>
|
||||||
|
<span>+</span>
|
||||||
|
<span>C</span>
|
||||||
|
</span>`
|
||||||
|
: nothing}
|
||||||
|
</div>
|
||||||
</ha-md-menu-item>
|
</ha-md-menu-item>
|
||||||
<ha-md-menu-item
|
<ha-md-menu-item
|
||||||
slot="menu-items"
|
slot="menu-items"
|
||||||
.clickAction=${this.config.cut}
|
.clickAction=${this.config.cut}
|
||||||
.disabled=${this.disabled}
|
.disabled=${this.disabled}
|
||||||
>
|
>
|
||||||
${this.hass.localize("ui.panel.config.automation.editor.triggers.cut")}
|
|
||||||
<ha-svg-icon slot="start" .path=${mdiContentCut}></ha-svg-icon>
|
<ha-svg-icon slot="start" .path=${mdiContentCut}></ha-svg-icon>
|
||||||
|
<div class="overflow-label">
|
||||||
|
${this.hass.localize(
|
||||||
|
"ui.panel.config.automation.editor.triggers.cut"
|
||||||
|
)}
|
||||||
|
${!this.narrow
|
||||||
|
? html`<span class="shortcut">
|
||||||
|
<span
|
||||||
|
>${isMac
|
||||||
|
? html`<ha-svg-icon
|
||||||
|
slot="start"
|
||||||
|
.path=${mdiAppleKeyboardCommand}
|
||||||
|
></ha-svg-icon>`
|
||||||
|
: this.hass.localize(
|
||||||
|
"ui.panel.config.automation.editor.ctrl"
|
||||||
|
)}</span
|
||||||
|
>
|
||||||
|
<span>+</span>
|
||||||
|
<span>X</span>
|
||||||
|
</span>`
|
||||||
|
: nothing}
|
||||||
|
</div>
|
||||||
</ha-md-menu-item>
|
</ha-md-menu-item>
|
||||||
<ha-md-menu-item
|
<ha-md-menu-item
|
||||||
slot="menu-items"
|
slot="menu-items"
|
||||||
.clickAction=${this._toggleYamlMode}
|
.clickAction=${this._toggleYamlMode}
|
||||||
.disabled=${!this.config.uiSupported || !!this._warnings}
|
.disabled=${!this.config.uiSupported || !!this._warnings}
|
||||||
>
|
>
|
||||||
|
<ha-svg-icon slot="start" .path=${mdiPlaylistEdit}></ha-svg-icon>
|
||||||
|
<div class="overflow-label">
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
`ui.panel.config.automation.editor.edit_${!this.yamlMode ? "yaml" : "ui"}`
|
`ui.panel.config.automation.editor.edit_${!this.yamlMode ? "yaml" : "ui"}`
|
||||||
)}
|
)}
|
||||||
<ha-svg-icon slot="start" .path=${mdiPlaylistEdit}></ha-svg-icon>
|
<span class="shortcut-placeholder ${isMac ? "mac" : ""}"></span>
|
||||||
|
</div>
|
||||||
</ha-md-menu-item>
|
</ha-md-menu-item>
|
||||||
<ha-md-divider
|
<ha-md-divider
|
||||||
slot="menu-items"
|
slot="menu-items"
|
||||||
@@ -163,13 +220,16 @@ export default class HaAutomationSidebarAction extends LitElement {
|
|||||||
tabindex="-1"
|
tabindex="-1"
|
||||||
></ha-md-divider>
|
></ha-md-divider>
|
||||||
<ha-md-menu-item slot="menu-items" .clickAction=${this.config.disable}>
|
<ha-md-menu-item slot="menu-items" .clickAction=${this.config.disable}>
|
||||||
${this.hass.localize(
|
|
||||||
`ui.panel.config.automation.editor.actions.${disabled ? "enable" : "disable"}`
|
|
||||||
)}
|
|
||||||
<ha-svg-icon
|
<ha-svg-icon
|
||||||
slot="start"
|
slot="start"
|
||||||
.path=${this.disabled ? mdiPlayCircleOutline : mdiStopCircleOutline}
|
.path=${this.disabled ? mdiPlayCircleOutline : mdiStopCircleOutline}
|
||||||
></ha-svg-icon>
|
></ha-svg-icon>
|
||||||
|
<div class="overflow-label">
|
||||||
|
${this.hass.localize(
|
||||||
|
`ui.panel.config.automation.editor.actions.${disabled ? "enable" : "disable"}`
|
||||||
|
)}
|
||||||
|
<span class="shortcut-placeholder ${isMac ? "mac" : ""}"></span>
|
||||||
|
</div>
|
||||||
</ha-md-menu-item>
|
</ha-md-menu-item>
|
||||||
<ha-md-menu-item
|
<ha-md-menu-item
|
||||||
slot="menu-items"
|
slot="menu-items"
|
||||||
@@ -177,10 +237,32 @@ export default class HaAutomationSidebarAction extends LitElement {
|
|||||||
.disabled=${this.disabled}
|
.disabled=${this.disabled}
|
||||||
class="warning"
|
class="warning"
|
||||||
>
|
>
|
||||||
|
<ha-svg-icon slot="start" .path=${mdiDelete}></ha-svg-icon>
|
||||||
|
<div class="overflow-label">
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.automation.editor.actions.delete"
|
"ui.panel.config.automation.editor.actions.delete"
|
||||||
)}
|
)}
|
||||||
<ha-svg-icon slot="start" .path=${mdiDelete}></ha-svg-icon>
|
${!this.narrow
|
||||||
|
? html`<span class="shortcut">
|
||||||
|
<span
|
||||||
|
>${isMac
|
||||||
|
? html`<ha-svg-icon
|
||||||
|
slot="start"
|
||||||
|
.path=${mdiAppleKeyboardCommand}
|
||||||
|
></ha-svg-icon>`
|
||||||
|
: this.hass.localize(
|
||||||
|
"ui.panel.config.automation.editor.ctrl"
|
||||||
|
)}</span
|
||||||
|
>
|
||||||
|
<span>+</span>
|
||||||
|
<span
|
||||||
|
>${this.hass.localize(
|
||||||
|
"ui.panel.config.automation.editor.del"
|
||||||
|
)}</span
|
||||||
|
>
|
||||||
|
</span>`
|
||||||
|
: nothing}
|
||||||
|
</div>
|
||||||
</ha-md-menu-item>
|
</ha-md-menu-item>
|
||||||
${description && !this.yamlMode
|
${description && !this.yamlMode
|
||||||
? html`<div class="description">${description}</div>`
|
? html`<div class="description">${description}</div>`
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
|
import { ResizeController } from "@lit-labs/observers/resize-controller";
|
||||||
import { mdiClose, mdiDotsVertical } from "@mdi/js";
|
import { mdiClose, mdiDotsVertical } from "@mdi/js";
|
||||||
|
import type { PropertyValues } from "lit";
|
||||||
import { css, html, LitElement, nothing } from "lit";
|
import { css, html, LitElement, nothing } from "lit";
|
||||||
import {
|
import {
|
||||||
customElement,
|
customElement,
|
||||||
@@ -43,7 +45,22 @@ export default class HaAutomationSidebarCard extends LitElement {
|
|||||||
|
|
||||||
@state() private _contentScrolled = false;
|
@state() private _contentScrolled = false;
|
||||||
|
|
||||||
@query(".card-content") private _contentElement?: HTMLDivElement;
|
@state() private _contentScrollable = false;
|
||||||
|
|
||||||
|
@query(".card-content") private _contentElement!: HTMLDivElement;
|
||||||
|
|
||||||
|
private _contentSize = new ResizeController(this, {
|
||||||
|
target: null,
|
||||||
|
callback: (entries) => {
|
||||||
|
if (entries[0]?.target) {
|
||||||
|
this._canScrollDown(entries[0].target);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
protected firstUpdated(_changedProperties: PropertyValues): void {
|
||||||
|
this._contentSize.observe(this._contentElement);
|
||||||
|
}
|
||||||
|
|
||||||
protected render() {
|
protected render() {
|
||||||
return html`
|
return html`
|
||||||
@@ -94,14 +111,29 @@ export default class HaAutomationSidebarCard extends LitElement {
|
|||||||
<div class="card-content" @scroll=${this._onScroll}>
|
<div class="card-content" @scroll=${this._onScroll}>
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
</div>
|
</div>
|
||||||
|
${this.narrow
|
||||||
|
? html`
|
||||||
|
<div
|
||||||
|
class="fade ${this._contentScrollable ? "scrollable" : ""}"
|
||||||
|
></div>
|
||||||
|
`
|
||||||
|
: nothing}
|
||||||
</ha-card>
|
</ha-card>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@eventOptions({ passive: true })
|
@eventOptions({ passive: true })
|
||||||
private _onScroll() {
|
private _onScroll(ev) {
|
||||||
const top = this._contentElement?.scrollTop ?? 0;
|
const top = ev.target.scrollTop ?? 0;
|
||||||
this._contentScrolled = top > 0;
|
this._contentScrolled = top > 0;
|
||||||
|
|
||||||
|
this._canScrollDown(ev.target);
|
||||||
|
}
|
||||||
|
|
||||||
|
private _canScrollDown(element: HTMLElement) {
|
||||||
|
this._contentScrollable =
|
||||||
|
(element.scrollHeight ?? 0) - (element.clientHeight ?? 0) >
|
||||||
|
(element.scrollTop ?? 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _closeSidebar() {
|
private _closeSidebar() {
|
||||||
@@ -125,6 +157,7 @@ export default class HaAutomationSidebarCard extends LitElement {
|
|||||||
@media all and (max-width: 870px) {
|
@media all and (max-width: 870px) {
|
||||||
ha-card.mobile {
|
ha-card.mobile {
|
||||||
border: none;
|
border: none;
|
||||||
|
box-shadow: none;
|
||||||
}
|
}
|
||||||
ha-card.mobile {
|
ha-card.mobile {
|
||||||
border-bottom-right-radius: var(--ha-border-radius-square);
|
border-bottom-right-radius: var(--ha-border-radius-square);
|
||||||
@@ -147,7 +180,22 @@ export default class HaAutomationSidebarCard extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ha-dialog-header.scrolled {
|
ha-dialog-header.scrolled {
|
||||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
|
box-shadow: var(--bar-box-shadow);
|
||||||
|
}
|
||||||
|
|
||||||
|
.fade {
|
||||||
|
position: fixed;
|
||||||
|
bottom: -12px;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
height: 12px;
|
||||||
|
pointer-events: none;
|
||||||
|
transition: box-shadow 180ms ease-in-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fade.scrollable {
|
||||||
|
box-shadow: var(--bar-box-shadow);
|
||||||
|
transform: rotate(180deg);
|
||||||
}
|
}
|
||||||
|
|
||||||
.card-content {
|
.card-content {
|
||||||
|
|||||||
@@ -1,22 +1,30 @@
|
|||||||
import {
|
import {
|
||||||
|
mdiAppleKeyboardCommand,
|
||||||
mdiContentCopy,
|
mdiContentCopy,
|
||||||
mdiContentCut,
|
mdiContentCut,
|
||||||
mdiContentDuplicate,
|
|
||||||
mdiDelete,
|
mdiDelete,
|
||||||
mdiFlask,
|
mdiFlask,
|
||||||
mdiPlayCircleOutline,
|
mdiPlayCircleOutline,
|
||||||
mdiPlaylistEdit,
|
mdiPlaylistEdit,
|
||||||
|
mdiPlusCircleMultipleOutline,
|
||||||
mdiRenameBox,
|
mdiRenameBox,
|
||||||
mdiStopCircleOutline,
|
mdiStopCircleOutline,
|
||||||
} from "@mdi/js";
|
} from "@mdi/js";
|
||||||
import { html, LitElement } from "lit";
|
import { css, html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property, query, state } from "lit/decorators";
|
import { customElement, property, query, state } from "lit/decorators";
|
||||||
|
import { classMap } from "lit/directives/class-map";
|
||||||
import { keyed } from "lit/directives/keyed";
|
import { keyed } from "lit/directives/keyed";
|
||||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||||
import { handleStructError } from "../../../../common/structs/handle-errors";
|
import { handleStructError } from "../../../../common/structs/handle-errors";
|
||||||
import type { ConditionSidebarConfig } from "../../../../data/automation";
|
import {
|
||||||
|
testCondition,
|
||||||
|
type ConditionSidebarConfig,
|
||||||
|
} from "../../../../data/automation";
|
||||||
import { CONDITION_BUILDING_BLOCKS } from "../../../../data/condition";
|
import { CONDITION_BUILDING_BLOCKS } from "../../../../data/condition";
|
||||||
|
import { validateConfig } from "../../../../data/config";
|
||||||
import type { HomeAssistant } from "../../../../types";
|
import type { HomeAssistant } from "../../../../types";
|
||||||
|
import { isMac } from "../../../../util/is_mac";
|
||||||
|
import { showAlertDialog } from "../../../lovelace/custom-card-helpers";
|
||||||
import "../condition/ha-automation-condition-editor";
|
import "../condition/ha-automation-condition-editor";
|
||||||
import type HaAutomationConditionEditor from "../condition/ha-automation-condition-editor";
|
import type HaAutomationConditionEditor from "../condition/ha-automation-condition-editor";
|
||||||
import { sidebarEditorStyles } from "../styles";
|
import { sidebarEditorStyles } from "../styles";
|
||||||
@@ -40,6 +48,10 @@ export default class HaAutomationSidebarCondition extends LitElement {
|
|||||||
|
|
||||||
@state() private _warnings?: string[];
|
@state() private _warnings?: string[];
|
||||||
|
|
||||||
|
@state() private _testing = false;
|
||||||
|
|
||||||
|
@state() private _testingResult?: boolean;
|
||||||
|
|
||||||
@query(".sidebar-editor")
|
@query(".sidebar-editor")
|
||||||
public editor?: HaAutomationConditionEditor;
|
public editor?: HaAutomationConditionEditor;
|
||||||
|
|
||||||
@@ -88,21 +100,27 @@ export default class HaAutomationSidebarCondition extends LitElement {
|
|||||||
>
|
>
|
||||||
<span slot="title">${title}</span>
|
<span slot="title">${title}</span>
|
||||||
<span slot="subtitle">${subtitle}</span>
|
<span slot="subtitle">${subtitle}</span>
|
||||||
<ha-md-menu-item slot="menu-items" .clickAction=${this.config.test}>
|
<ha-md-menu-item slot="menu-items" .clickAction=${this._testCondition}>
|
||||||
|
<ha-svg-icon slot="start" .path=${mdiFlask}></ha-svg-icon>
|
||||||
|
<div class="overflow-label">
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.automation.editor.conditions.test"
|
"ui.panel.config.automation.editor.conditions.test"
|
||||||
)}
|
)}
|
||||||
<ha-svg-icon slot="start" .path=${mdiFlask}></ha-svg-icon>
|
<span class="shortcut-placeholder ${isMac ? "mac" : ""}"></span>
|
||||||
|
</div>
|
||||||
</ha-md-menu-item>
|
</ha-md-menu-item>
|
||||||
<ha-md-menu-item
|
<ha-md-menu-item
|
||||||
slot="menu-items"
|
slot="menu-items"
|
||||||
.clickAction=${this.config.rename}
|
.clickAction=${this.config.rename}
|
||||||
.disabled=${!!disabled}
|
.disabled=${!!disabled}
|
||||||
>
|
>
|
||||||
|
<ha-svg-icon slot="start" .path=${mdiRenameBox}></ha-svg-icon>
|
||||||
|
<div class="overflow-label">
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.automation.editor.triggers.rename"
|
"ui.panel.config.automation.editor.triggers.rename"
|
||||||
)}
|
)}
|
||||||
<ha-svg-icon slot="start" .path=${mdiRenameBox}></ha-svg-icon>
|
<span class="shortcut-placeholder ${isMac ? "mac" : ""}"></span>
|
||||||
|
</div>
|
||||||
</ha-md-menu-item>
|
</ha-md-menu-item>
|
||||||
|
|
||||||
<ha-md-divider
|
<ha-md-divider
|
||||||
@@ -116,10 +134,16 @@ export default class HaAutomationSidebarCondition extends LitElement {
|
|||||||
.clickAction=${this.config.duplicate}
|
.clickAction=${this.config.duplicate}
|
||||||
.disabled=${this.disabled}
|
.disabled=${this.disabled}
|
||||||
>
|
>
|
||||||
|
<ha-svg-icon
|
||||||
|
slot="start"
|
||||||
|
.path=${mdiPlusCircleMultipleOutline}
|
||||||
|
></ha-svg-icon>
|
||||||
|
<div class="overflow-label">
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.automation.editor.actions.duplicate"
|
"ui.panel.config.automation.editor.actions.duplicate"
|
||||||
)}
|
)}
|
||||||
<ha-svg-icon slot="start" .path=${mdiContentDuplicate}></ha-svg-icon>
|
<span class="shortcut-placeholder ${isMac ? "mac" : ""}"></span>
|
||||||
|
</div>
|
||||||
</ha-md-menu-item>
|
</ha-md-menu-item>
|
||||||
|
|
||||||
<ha-md-menu-item
|
<ha-md-menu-item
|
||||||
@@ -127,8 +151,28 @@ export default class HaAutomationSidebarCondition extends LitElement {
|
|||||||
.clickAction=${this.config.copy}
|
.clickAction=${this.config.copy}
|
||||||
.disabled=${this.disabled}
|
.disabled=${this.disabled}
|
||||||
>
|
>
|
||||||
${this.hass.localize("ui.panel.config.automation.editor.triggers.copy")}
|
|
||||||
<ha-svg-icon slot="start" .path=${mdiContentCopy}></ha-svg-icon>
|
<ha-svg-icon slot="start" .path=${mdiContentCopy}></ha-svg-icon>
|
||||||
|
<div class="overflow-label">
|
||||||
|
${this.hass.localize(
|
||||||
|
"ui.panel.config.automation.editor.triggers.copy"
|
||||||
|
)}
|
||||||
|
${!this.narrow
|
||||||
|
? html`<span class="shortcut">
|
||||||
|
<span
|
||||||
|
>${isMac
|
||||||
|
? html`<ha-svg-icon
|
||||||
|
slot="start"
|
||||||
|
.path=${mdiAppleKeyboardCommand}
|
||||||
|
></ha-svg-icon>`
|
||||||
|
: this.hass.localize(
|
||||||
|
"ui.panel.config.automation.editor.ctrl"
|
||||||
|
)}</span
|
||||||
|
>
|
||||||
|
<span>+</span>
|
||||||
|
<span>C</span>
|
||||||
|
</span>`
|
||||||
|
: nothing}
|
||||||
|
</div>
|
||||||
</ha-md-menu-item>
|
</ha-md-menu-item>
|
||||||
|
|
||||||
<ha-md-menu-item
|
<ha-md-menu-item
|
||||||
@@ -136,18 +180,41 @@ export default class HaAutomationSidebarCondition extends LitElement {
|
|||||||
.clickAction=${this.config.cut}
|
.clickAction=${this.config.cut}
|
||||||
.disabled=${this.disabled}
|
.disabled=${this.disabled}
|
||||||
>
|
>
|
||||||
${this.hass.localize("ui.panel.config.automation.editor.triggers.cut")}
|
|
||||||
<ha-svg-icon slot="start" .path=${mdiContentCut}></ha-svg-icon>
|
<ha-svg-icon slot="start" .path=${mdiContentCut}></ha-svg-icon>
|
||||||
|
<div class="overflow-label">
|
||||||
|
${this.hass.localize(
|
||||||
|
"ui.panel.config.automation.editor.triggers.cut"
|
||||||
|
)}
|
||||||
|
${!this.narrow
|
||||||
|
? html`<span class="shortcut">
|
||||||
|
<span
|
||||||
|
>${isMac
|
||||||
|
? html`<ha-svg-icon
|
||||||
|
slot="start"
|
||||||
|
.path=${mdiAppleKeyboardCommand}
|
||||||
|
></ha-svg-icon>`
|
||||||
|
: this.hass.localize(
|
||||||
|
"ui.panel.config.automation.editor.ctrl"
|
||||||
|
)}</span
|
||||||
|
>
|
||||||
|
<span>+</span>
|
||||||
|
<span>X</span>
|
||||||
|
</span>`
|
||||||
|
: nothing}
|
||||||
|
</div>
|
||||||
</ha-md-menu-item>
|
</ha-md-menu-item>
|
||||||
<ha-md-menu-item
|
<ha-md-menu-item
|
||||||
slot="menu-items"
|
slot="menu-items"
|
||||||
.clickAction=${this._toggleYamlMode}
|
.clickAction=${this._toggleYamlMode}
|
||||||
.disabled=${!this.config.uiSupported || !!this._warnings}
|
.disabled=${!this.config.uiSupported || !!this._warnings}
|
||||||
>
|
>
|
||||||
|
<ha-svg-icon slot="start" .path=${mdiPlaylistEdit}></ha-svg-icon>
|
||||||
|
<div class="overflow-label">
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
`ui.panel.config.automation.editor.edit_${!this.yamlMode ? "yaml" : "ui"}`
|
`ui.panel.config.automation.editor.edit_${!this.yamlMode ? "yaml" : "ui"}`
|
||||||
)}
|
)}
|
||||||
<ha-svg-icon slot="start" .path=${mdiPlaylistEdit}></ha-svg-icon>
|
<span class="shortcut-placeholder ${isMac ? "mac" : ""}"></span>
|
||||||
|
</div>
|
||||||
</ha-md-menu-item>
|
</ha-md-menu-item>
|
||||||
<ha-md-divider
|
<ha-md-divider
|
||||||
slot="menu-items"
|
slot="menu-items"
|
||||||
@@ -155,13 +222,16 @@ export default class HaAutomationSidebarCondition extends LitElement {
|
|||||||
tabindex="-1"
|
tabindex="-1"
|
||||||
></ha-md-divider>
|
></ha-md-divider>
|
||||||
<ha-md-menu-item slot="menu-items" .clickAction=${this.config.disable}>
|
<ha-md-menu-item slot="menu-items" .clickAction=${this.config.disable}>
|
||||||
${this.hass.localize(
|
|
||||||
`ui.panel.config.automation.editor.actions.${disabled ? "enable" : "disable"}`
|
|
||||||
)}
|
|
||||||
<ha-svg-icon
|
<ha-svg-icon
|
||||||
slot="start"
|
slot="start"
|
||||||
.path=${this.disabled ? mdiPlayCircleOutline : mdiStopCircleOutline}
|
.path=${this.disabled ? mdiPlayCircleOutline : mdiStopCircleOutline}
|
||||||
></ha-svg-icon>
|
></ha-svg-icon>
|
||||||
|
<div class="overflow-label">
|
||||||
|
${this.hass.localize(
|
||||||
|
`ui.panel.config.automation.editor.actions.${disabled ? "enable" : "disable"}`
|
||||||
|
)}
|
||||||
|
<span class="shortcut-placeholder ${isMac ? "mac" : ""}"></span>
|
||||||
|
</div>
|
||||||
</ha-md-menu-item>
|
</ha-md-menu-item>
|
||||||
<ha-md-menu-item
|
<ha-md-menu-item
|
||||||
slot="menu-items"
|
slot="menu-items"
|
||||||
@@ -169,10 +239,32 @@ export default class HaAutomationSidebarCondition extends LitElement {
|
|||||||
.disabled=${this.disabled}
|
.disabled=${this.disabled}
|
||||||
class="warning"
|
class="warning"
|
||||||
>
|
>
|
||||||
|
<ha-svg-icon slot="start" .path=${mdiDelete}></ha-svg-icon>
|
||||||
|
<div class="overflow-label">
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.automation.editor.actions.delete"
|
"ui.panel.config.automation.editor.actions.delete"
|
||||||
)}
|
)}
|
||||||
<ha-svg-icon slot="start" .path=${mdiDelete}></ha-svg-icon>
|
${!this.narrow
|
||||||
|
? html`<span class="shortcut">
|
||||||
|
<span
|
||||||
|
>${isMac
|
||||||
|
? html`<ha-svg-icon
|
||||||
|
slot="start"
|
||||||
|
.path=${mdiAppleKeyboardCommand}
|
||||||
|
></ha-svg-icon>`
|
||||||
|
: this.hass.localize(
|
||||||
|
"ui.panel.config.automation.editor.ctrl"
|
||||||
|
)}</span
|
||||||
|
>
|
||||||
|
<span>+</span>
|
||||||
|
<span
|
||||||
|
>${this.hass.localize(
|
||||||
|
"ui.panel.config.automation.editor.del"
|
||||||
|
)}</span
|
||||||
|
>
|
||||||
|
</span>`
|
||||||
|
: nothing}
|
||||||
|
</div>
|
||||||
</ha-md-menu-item>
|
</ha-md-menu-item>
|
||||||
${description && !this.yamlMode
|
${description && !this.yamlMode
|
||||||
? html`<div class="description">${description}</div>`
|
? html`<div class="description">${description}</div>`
|
||||||
@@ -191,9 +283,81 @@ export default class HaAutomationSidebarCondition extends LitElement {
|
|||||||
sidebar
|
sidebar
|
||||||
></ha-automation-condition-editor>`
|
></ha-automation-condition-editor>`
|
||||||
)}
|
)}
|
||||||
|
<div
|
||||||
|
class="testing ${classMap({
|
||||||
|
active: this._testing,
|
||||||
|
pass: this._testingResult === true,
|
||||||
|
error: this._testingResult === false,
|
||||||
|
})}"
|
||||||
|
>
|
||||||
|
${this._testingResult
|
||||||
|
? this.hass.localize(
|
||||||
|
"ui.panel.config.automation.editor.conditions.testing_pass"
|
||||||
|
)
|
||||||
|
: this.hass.localize(
|
||||||
|
"ui.panel.config.automation.editor.conditions.testing_error"
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
</ha-automation-sidebar-card>`;
|
</ha-automation-sidebar-card>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _testCondition = async () => {
|
||||||
|
if (this._testing) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this._testingResult = undefined;
|
||||||
|
this._testing = true;
|
||||||
|
const condition = this.config.config;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const validateResult = await validateConfig(this.hass, {
|
||||||
|
conditions: condition,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Abort if condition changed.
|
||||||
|
if (this.config.config !== condition) {
|
||||||
|
this._testing = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!validateResult.conditions.valid) {
|
||||||
|
showAlertDialog(this, {
|
||||||
|
title: this.hass.localize(
|
||||||
|
"ui.panel.config.automation.editor.conditions.invalid_condition"
|
||||||
|
),
|
||||||
|
text: validateResult.conditions.error,
|
||||||
|
});
|
||||||
|
this._testing = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let result: { result: boolean };
|
||||||
|
try {
|
||||||
|
result = await testCondition(this.hass, condition);
|
||||||
|
} catch (err: any) {
|
||||||
|
if (this.config.config !== condition) {
|
||||||
|
this._testing = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
showAlertDialog(this, {
|
||||||
|
title: this.hass.localize(
|
||||||
|
"ui.panel.config.automation.editor.conditions.test_failed"
|
||||||
|
),
|
||||||
|
text: err.message,
|
||||||
|
});
|
||||||
|
this._testing = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this._testingResult = result.result;
|
||||||
|
} finally {
|
||||||
|
setTimeout(() => {
|
||||||
|
this._testing = false;
|
||||||
|
}, 2500);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
private _handleUiModeNotAvailable(ev: CustomEvent) {
|
private _handleUiModeNotAvailable(ev: CustomEvent) {
|
||||||
this._warnings = handleStructError(this.hass, ev.detail).warnings;
|
this._warnings = handleStructError(this.hass, ev.detail).warnings;
|
||||||
if (!this.yamlMode) {
|
if (!this.yamlMode) {
|
||||||
@@ -226,7 +390,47 @@ export default class HaAutomationSidebarCondition extends LitElement {
|
|||||||
fireEvent(this, "toggle-yaml-mode");
|
fireEvent(this, "toggle-yaml-mode");
|
||||||
};
|
};
|
||||||
|
|
||||||
static styles = sidebarEditorStyles;
|
static styles = [
|
||||||
|
sidebarEditorStyles,
|
||||||
|
css`
|
||||||
|
ha-automation-sidebar-card {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
.testing {
|
||||||
|
position: absolute;
|
||||||
|
z-index: 6;
|
||||||
|
top: 0px;
|
||||||
|
right: 0px;
|
||||||
|
left: 0px;
|
||||||
|
text-transform: uppercase;
|
||||||
|
font-size: var(--ha-font-size-m);
|
||||||
|
font-weight: var(--ha-font-weight-bold);
|
||||||
|
background-color: var(--divider-color, #e0e0e0);
|
||||||
|
color: var(--text-primary-color);
|
||||||
|
max-height: 0px;
|
||||||
|
overflow: hidden;
|
||||||
|
transition: max-height 0.3s;
|
||||||
|
text-align: center;
|
||||||
|
border-top-right-radius: var(
|
||||||
|
--ha-card-border-radius,
|
||||||
|
var(--ha-border-radius-lg)
|
||||||
|
);
|
||||||
|
border-top-left-radius: var(
|
||||||
|
--ha-card-border-radius,
|
||||||
|
var(--ha-border-radius-lg)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
.testing.active {
|
||||||
|
max-height: 100px;
|
||||||
|
}
|
||||||
|
.testing.error {
|
||||||
|
background-color: var(--accent-color);
|
||||||
|
}
|
||||||
|
.testing.pass {
|
||||||
|
background-color: var(--success-color);
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
|
|||||||
@@ -1,8 +1,14 @@
|
|||||||
import { mdiContentDuplicate, mdiDelete, mdiRenameBox } from "@mdi/js";
|
import {
|
||||||
import { html, LitElement } from "lit";
|
mdiAppleKeyboardCommand,
|
||||||
|
mdiDelete,
|
||||||
|
mdiPlusCircleMultipleOutline,
|
||||||
|
mdiRenameBox,
|
||||||
|
} from "@mdi/js";
|
||||||
|
import { html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property, query } from "lit/decorators";
|
import { customElement, property, query } from "lit/decorators";
|
||||||
import type { OptionSidebarConfig } from "../../../../data/automation";
|
import type { OptionSidebarConfig } from "../../../../data/automation";
|
||||||
import type { HomeAssistant } from "../../../../types";
|
import type { HomeAssistant } from "../../../../types";
|
||||||
|
import { isMac } from "../../../../util/is_mac";
|
||||||
import type HaAutomationConditionEditor from "../action/ha-automation-action-editor";
|
import type HaAutomationConditionEditor from "../action/ha-automation-action-editor";
|
||||||
import { sidebarEditorStyles } from "../styles";
|
import { sidebarEditorStyles } from "../styles";
|
||||||
import "./ha-automation-sidebar-card";
|
import "./ha-automation-sidebar-card";
|
||||||
@@ -52,10 +58,13 @@ export default class HaAutomationSidebarOption extends LitElement {
|
|||||||
.clickAction=${this.config.rename}
|
.clickAction=${this.config.rename}
|
||||||
.disabled=${!!disabled}
|
.disabled=${!!disabled}
|
||||||
>
|
>
|
||||||
|
<ha-svg-icon slot="start" .path=${mdiRenameBox}></ha-svg-icon>
|
||||||
|
<div class="overflow-label">
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.automation.editor.triggers.rename"
|
"ui.panel.config.automation.editor.triggers.rename"
|
||||||
)}
|
)}
|
||||||
<ha-svg-icon slot="start" .path=${mdiRenameBox}></ha-svg-icon>
|
<span class="shortcut-placeholder ${isMac ? "mac" : ""}"></span>
|
||||||
|
</div>
|
||||||
</ha-md-menu-item>
|
</ha-md-menu-item>
|
||||||
|
|
||||||
<ha-md-menu-item
|
<ha-md-menu-item
|
||||||
@@ -63,13 +72,16 @@ export default class HaAutomationSidebarOption extends LitElement {
|
|||||||
@click=${this.config.duplicate}
|
@click=${this.config.duplicate}
|
||||||
.disabled=${this.disabled}
|
.disabled=${this.disabled}
|
||||||
>
|
>
|
||||||
|
<ha-svg-icon
|
||||||
|
slot="start"
|
||||||
|
.path=${mdiPlusCircleMultipleOutline}
|
||||||
|
></ha-svg-icon>
|
||||||
|
<div class="overflow-label">
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.automation.editor.actions.duplicate"
|
"ui.panel.config.automation.editor.actions.duplicate"
|
||||||
)}
|
)}
|
||||||
<ha-svg-icon
|
<span class="shortcut-placeholder ${isMac ? "mac" : ""}"></span>
|
||||||
slot="start"
|
</div>
|
||||||
.path=${mdiContentDuplicate}
|
|
||||||
></ha-svg-icon>
|
|
||||||
</ha-md-menu-item>
|
</ha-md-menu-item>
|
||||||
<ha-md-divider
|
<ha-md-divider
|
||||||
slot="menu-items"
|
slot="menu-items"
|
||||||
@@ -82,10 +94,32 @@ export default class HaAutomationSidebarOption extends LitElement {
|
|||||||
.disabled=${this.disabled}
|
.disabled=${this.disabled}
|
||||||
class="warning"
|
class="warning"
|
||||||
>
|
>
|
||||||
|
<ha-svg-icon slot="start" .path=${mdiDelete}></ha-svg-icon>
|
||||||
|
<div class="overflow-label">
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.automation.editor.actions.type.choose.remove_option"
|
"ui.panel.config.automation.editor.actions.type.choose.remove_option"
|
||||||
)}
|
)}
|
||||||
<ha-svg-icon slot="start" .path=${mdiDelete}></ha-svg-icon>
|
${!this.narrow
|
||||||
|
? html`<span class="shortcut">
|
||||||
|
<span
|
||||||
|
>${isMac
|
||||||
|
? html`<ha-svg-icon
|
||||||
|
slot="start"
|
||||||
|
.path=${mdiAppleKeyboardCommand}
|
||||||
|
></ha-svg-icon>`
|
||||||
|
: this.hass.localize(
|
||||||
|
"ui.panel.config.automation.editor.ctrl"
|
||||||
|
)}</span
|
||||||
|
>
|
||||||
|
<span>+</span>
|
||||||
|
<span
|
||||||
|
>${this.hass.localize(
|
||||||
|
"ui.panel.config.automation.editor.del"
|
||||||
|
)}</span
|
||||||
|
>
|
||||||
|
</span>`
|
||||||
|
: nothing}
|
||||||
|
</div>
|
||||||
</ha-md-menu-item>
|
</ha-md-menu-item>
|
||||||
`}
|
`}
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
import { mdiDelete, mdiPlaylistEdit } from "@mdi/js";
|
import { mdiAppleKeyboardCommand, mdiDelete, mdiPlaylistEdit } from "@mdi/js";
|
||||||
import { html, LitElement } from "lit";
|
import { html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property, query, state } from "lit/decorators";
|
import { customElement, property, query, state } from "lit/decorators";
|
||||||
import { keyed } from "lit/directives/keyed";
|
import { keyed } from "lit/directives/keyed";
|
||||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||||
import type { LocalizeKeys } from "../../../../common/translations/localize";
|
import type { LocalizeKeys } from "../../../../common/translations/localize";
|
||||||
import type { ScriptFieldSidebarConfig } from "../../../../data/automation";
|
import type { ScriptFieldSidebarConfig } from "../../../../data/automation";
|
||||||
import type { HomeAssistant } from "../../../../types";
|
import type { HomeAssistant } from "../../../../types";
|
||||||
|
import { isMac } from "../../../../util/is_mac";
|
||||||
import "../../script/ha-script-field-selector-editor";
|
import "../../script/ha-script-field-selector-editor";
|
||||||
import type HaAutomationConditionEditor from "../action/ha-automation-action-editor";
|
import type HaAutomationConditionEditor from "../action/ha-automation-action-editor";
|
||||||
import { sidebarEditorStyles } from "../styles";
|
import { sidebarEditorStyles } from "../styles";
|
||||||
@@ -68,10 +69,13 @@ export default class HaAutomationSidebarScriptFieldSelector extends LitElement {
|
|||||||
.clickAction=${this._toggleYamlMode}
|
.clickAction=${this._toggleYamlMode}
|
||||||
.disabled=${!!this._warnings}
|
.disabled=${!!this._warnings}
|
||||||
>
|
>
|
||||||
|
<ha-svg-icon slot="start" .path=${mdiPlaylistEdit}></ha-svg-icon>
|
||||||
|
<div class="overflow-label">
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
`ui.panel.config.automation.editor.edit_${!this.yamlMode ? "yaml" : "ui"}`
|
`ui.panel.config.automation.editor.edit_${!this.yamlMode ? "yaml" : "ui"}`
|
||||||
)}
|
)}
|
||||||
<ha-svg-icon slot="start" .path=${mdiPlaylistEdit}></ha-svg-icon>
|
<span class="shortcut-placeholder ${isMac ? "mac" : ""}"></span>
|
||||||
|
</div>
|
||||||
</ha-md-menu-item>
|
</ha-md-menu-item>
|
||||||
<ha-md-menu-item
|
<ha-md-menu-item
|
||||||
slot="menu-items"
|
slot="menu-items"
|
||||||
@@ -79,10 +83,32 @@ export default class HaAutomationSidebarScriptFieldSelector extends LitElement {
|
|||||||
.disabled=${this.disabled}
|
.disabled=${this.disabled}
|
||||||
class="warning"
|
class="warning"
|
||||||
>
|
>
|
||||||
|
<ha-svg-icon slot="start" .path=${mdiDelete}></ha-svg-icon>
|
||||||
|
<div class="overflow-label">
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.automation.editor.actions.delete"
|
"ui.panel.config.automation.editor.actions.delete"
|
||||||
)}
|
)}
|
||||||
<ha-svg-icon slot="start" .path=${mdiDelete}></ha-svg-icon>
|
${!this.narrow
|
||||||
|
? html`<span class="shortcut">
|
||||||
|
<span
|
||||||
|
>${isMac
|
||||||
|
? html`<ha-svg-icon
|
||||||
|
slot="start"
|
||||||
|
.path=${mdiAppleKeyboardCommand}
|
||||||
|
></ha-svg-icon>`
|
||||||
|
: this.hass.localize(
|
||||||
|
"ui.panel.config.automation.editor.ctrl"
|
||||||
|
)}</span
|
||||||
|
>
|
||||||
|
<span>+</span>
|
||||||
|
<span
|
||||||
|
>${this.hass.localize(
|
||||||
|
"ui.panel.config.automation.editor.del"
|
||||||
|
)}</span
|
||||||
|
>
|
||||||
|
</span>`
|
||||||
|
: nothing}
|
||||||
|
</div>
|
||||||
</ha-md-menu-item>
|
</ha-md-menu-item>
|
||||||
${keyed(
|
${keyed(
|
||||||
this.sidebarKey,
|
this.sidebarKey,
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import { mdiDelete, mdiPlaylistEdit } from "@mdi/js";
|
import { mdiAppleKeyboardCommand, mdiDelete, mdiPlaylistEdit } from "@mdi/js";
|
||||||
import { html, LitElement } from "lit";
|
import { html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property, query, state } from "lit/decorators";
|
import { customElement, property, query, state } from "lit/decorators";
|
||||||
import { keyed } from "lit/directives/keyed";
|
import { keyed } from "lit/directives/keyed";
|
||||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||||
import type { ScriptFieldSidebarConfig } from "../../../../data/automation";
|
import type { ScriptFieldSidebarConfig } from "../../../../data/automation";
|
||||||
import type { HomeAssistant } from "../../../../types";
|
import type { HomeAssistant } from "../../../../types";
|
||||||
|
import { isMac } from "../../../../util/is_mac";
|
||||||
import "../../script/ha-script-field-editor";
|
import "../../script/ha-script-field-editor";
|
||||||
import type HaAutomationConditionEditor from "../action/ha-automation-action-editor";
|
import type HaAutomationConditionEditor from "../action/ha-automation-action-editor";
|
||||||
import { sidebarEditorStyles } from "../styles";
|
import { sidebarEditorStyles } from "../styles";
|
||||||
@@ -61,10 +62,13 @@ export default class HaAutomationSidebarScriptField extends LitElement {
|
|||||||
.clickAction=${this._toggleYamlMode}
|
.clickAction=${this._toggleYamlMode}
|
||||||
.disabled=${!!this._warnings}
|
.disabled=${!!this._warnings}
|
||||||
>
|
>
|
||||||
|
<ha-svg-icon slot="start" .path=${mdiPlaylistEdit}></ha-svg-icon>
|
||||||
|
<div class="overflow-label">
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
`ui.panel.config.automation.editor.edit_${!this.yamlMode ? "yaml" : "ui"}`
|
`ui.panel.config.automation.editor.edit_${!this.yamlMode ? "yaml" : "ui"}`
|
||||||
)}
|
)}
|
||||||
<ha-svg-icon slot="start" .path=${mdiPlaylistEdit}></ha-svg-icon>
|
<span class="shortcut-placeholder ${isMac ? "mac" : ""}"></span>
|
||||||
|
</div>
|
||||||
</ha-md-menu-item>
|
</ha-md-menu-item>
|
||||||
<ha-md-menu-item
|
<ha-md-menu-item
|
||||||
slot="menu-items"
|
slot="menu-items"
|
||||||
@@ -72,10 +76,32 @@ export default class HaAutomationSidebarScriptField extends LitElement {
|
|||||||
.disabled=${this.disabled}
|
.disabled=${this.disabled}
|
||||||
class="warning"
|
class="warning"
|
||||||
>
|
>
|
||||||
|
<ha-svg-icon slot="start" .path=${mdiDelete}></ha-svg-icon>
|
||||||
|
<div class="overflow-label">
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.automation.editor.actions.delete"
|
"ui.panel.config.automation.editor.actions.delete"
|
||||||
)}
|
)}
|
||||||
<ha-svg-icon slot="start" .path=${mdiDelete}></ha-svg-icon>
|
${!this.narrow
|
||||||
|
? html`<span class="shortcut">
|
||||||
|
<span
|
||||||
|
>${isMac
|
||||||
|
? html`<ha-svg-icon
|
||||||
|
slot="start"
|
||||||
|
.path=${mdiAppleKeyboardCommand}
|
||||||
|
></ha-svg-icon>`
|
||||||
|
: this.hass.localize(
|
||||||
|
"ui.panel.config.automation.editor.ctrl"
|
||||||
|
)}</span
|
||||||
|
>
|
||||||
|
<span>+</span>
|
||||||
|
<span
|
||||||
|
>${this.hass.localize(
|
||||||
|
"ui.panel.config.automation.editor.del"
|
||||||
|
)}</span
|
||||||
|
>
|
||||||
|
</span>`
|
||||||
|
: nothing}
|
||||||
|
</div>
|
||||||
</ha-md-menu-item>
|
</ha-md-menu-item>
|
||||||
${keyed(
|
${keyed(
|
||||||
this.sidebarKey,
|
this.sidebarKey,
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
import {
|
import {
|
||||||
|
mdiAppleKeyboardCommand,
|
||||||
mdiContentCopy,
|
mdiContentCopy,
|
||||||
mdiContentCut,
|
mdiContentCut,
|
||||||
mdiContentDuplicate,
|
|
||||||
mdiDelete,
|
mdiDelete,
|
||||||
mdiIdentifier,
|
mdiIdentifier,
|
||||||
mdiPlayCircleOutline,
|
mdiPlayCircleOutline,
|
||||||
mdiPlaylistEdit,
|
mdiPlaylistEdit,
|
||||||
|
mdiPlusCircleMultipleOutline,
|
||||||
mdiRenameBox,
|
mdiRenameBox,
|
||||||
mdiStopCircleOutline,
|
mdiStopCircleOutline,
|
||||||
} from "@mdi/js";
|
} from "@mdi/js";
|
||||||
@@ -17,6 +18,7 @@ import { handleStructError } from "../../../../common/structs/handle-errors";
|
|||||||
import type { TriggerSidebarConfig } from "../../../../data/automation";
|
import type { TriggerSidebarConfig } from "../../../../data/automation";
|
||||||
import { isTriggerList } from "../../../../data/trigger";
|
import { isTriggerList } from "../../../../data/trigger";
|
||||||
import type { HomeAssistant } from "../../../../types";
|
import type { HomeAssistant } from "../../../../types";
|
||||||
|
import { isMac } from "../../../../util/is_mac";
|
||||||
import { sidebarEditorStyles } from "../styles";
|
import { sidebarEditorStyles } from "../styles";
|
||||||
import "../trigger/ha-automation-trigger-editor";
|
import "../trigger/ha-automation-trigger-editor";
|
||||||
import type HaAutomationTriggerEditor from "../trigger/ha-automation-trigger-editor";
|
import type HaAutomationTriggerEditor from "../trigger/ha-automation-trigger-editor";
|
||||||
@@ -89,10 +91,13 @@ export default class HaAutomationSidebarTrigger extends LitElement {
|
|||||||
.clickAction=${this.config.rename}
|
.clickAction=${this.config.rename}
|
||||||
.disabled=${disabled || type === "list"}
|
.disabled=${disabled || type === "list"}
|
||||||
>
|
>
|
||||||
|
<ha-svg-icon slot="start" .path=${mdiRenameBox}></ha-svg-icon>
|
||||||
|
<div class="overflow-label">
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.automation.editor.triggers.rename"
|
"ui.panel.config.automation.editor.triggers.rename"
|
||||||
)}
|
)}
|
||||||
<ha-svg-icon slot="start" .path=${mdiRenameBox}></ha-svg-icon>
|
<span class="shortcut-placeholder ${isMac ? "mac" : ""}"></span>
|
||||||
|
</div>
|
||||||
</ha-md-menu-item>
|
</ha-md-menu-item>
|
||||||
${!this.yamlMode &&
|
${!this.yamlMode &&
|
||||||
!("id" in this.config.config) &&
|
!("id" in this.config.config) &&
|
||||||
@@ -102,10 +107,13 @@ export default class HaAutomationSidebarTrigger extends LitElement {
|
|||||||
.clickAction=${this._showTriggerId}
|
.clickAction=${this._showTriggerId}
|
||||||
.disabled=${disabled || type === "list"}
|
.disabled=${disabled || type === "list"}
|
||||||
>
|
>
|
||||||
|
<ha-svg-icon slot="start" .path=${mdiIdentifier}></ha-svg-icon>
|
||||||
|
<div class="overflow-label">
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.automation.editor.triggers.edit_id"
|
"ui.panel.config.automation.editor.triggers.edit_id"
|
||||||
)}
|
)}
|
||||||
<ha-svg-icon slot="start" .path=${mdiIdentifier}></ha-svg-icon>
|
<span class="shortcut-placeholder ${isMac ? "mac" : ""}"></span>
|
||||||
|
</div>
|
||||||
</ha-md-menu-item>`
|
</ha-md-menu-item>`
|
||||||
: nothing}
|
: nothing}
|
||||||
|
|
||||||
@@ -123,7 +131,10 @@ export default class HaAutomationSidebarTrigger extends LitElement {
|
|||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.automation.editor.triggers.duplicate"
|
"ui.panel.config.automation.editor.triggers.duplicate"
|
||||||
)}
|
)}
|
||||||
<ha-svg-icon slot="start" .path=${mdiContentDuplicate}></ha-svg-icon>
|
<ha-svg-icon
|
||||||
|
slot="start"
|
||||||
|
.path=${mdiPlusCircleMultipleOutline}
|
||||||
|
></ha-svg-icon>
|
||||||
</ha-md-menu-item>
|
</ha-md-menu-item>
|
||||||
|
|
||||||
<ha-md-menu-item
|
<ha-md-menu-item
|
||||||
@@ -131,10 +142,28 @@ export default class HaAutomationSidebarTrigger extends LitElement {
|
|||||||
.clickAction=${this.config.copy}
|
.clickAction=${this.config.copy}
|
||||||
.disabled=${this.disabled}
|
.disabled=${this.disabled}
|
||||||
>
|
>
|
||||||
|
<ha-svg-icon slot="start" .path=${mdiContentCopy}></ha-svg-icon>
|
||||||
|
<div class="overflow-label">
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.automation.editor.triggers.copy"
|
"ui.panel.config.automation.editor.triggers.copy"
|
||||||
)}
|
)}
|
||||||
<ha-svg-icon slot="start" .path=${mdiContentCopy}></ha-svg-icon>
|
${!this.narrow
|
||||||
|
? html`<span class="shortcut">
|
||||||
|
<span
|
||||||
|
>${isMac
|
||||||
|
? html`<ha-svg-icon
|
||||||
|
slot="start"
|
||||||
|
.path=${mdiAppleKeyboardCommand}
|
||||||
|
></ha-svg-icon>`
|
||||||
|
: this.hass.localize(
|
||||||
|
"ui.panel.config.automation.editor.ctrl"
|
||||||
|
)}</span
|
||||||
|
>
|
||||||
|
<span>+</span>
|
||||||
|
<span>C</span>
|
||||||
|
</span>`
|
||||||
|
: nothing}
|
||||||
|
</div>
|
||||||
</ha-md-menu-item>
|
</ha-md-menu-item>
|
||||||
|
|
||||||
<ha-md-menu-item
|
<ha-md-menu-item
|
||||||
@@ -142,20 +171,41 @@ export default class HaAutomationSidebarTrigger extends LitElement {
|
|||||||
.clickAction=${this.config.cut}
|
.clickAction=${this.config.cut}
|
||||||
.disabled=${this.disabled}
|
.disabled=${this.disabled}
|
||||||
>
|
>
|
||||||
|
<ha-svg-icon slot="start" .path=${mdiContentCut}></ha-svg-icon>
|
||||||
|
<div class="overflow-label">
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.automation.editor.triggers.cut"
|
"ui.panel.config.automation.editor.triggers.cut"
|
||||||
)}
|
)}
|
||||||
<ha-svg-icon slot="start" .path=${mdiContentCut}></ha-svg-icon>
|
${!this.narrow
|
||||||
|
? html`<span class="shortcut">
|
||||||
|
<span
|
||||||
|
>${isMac
|
||||||
|
? html`<ha-svg-icon
|
||||||
|
slot="start"
|
||||||
|
.path=${mdiAppleKeyboardCommand}
|
||||||
|
></ha-svg-icon>`
|
||||||
|
: this.hass.localize(
|
||||||
|
"ui.panel.config.automation.editor.ctrl"
|
||||||
|
)}</span
|
||||||
|
>
|
||||||
|
<span>+</span>
|
||||||
|
<span>X</span>
|
||||||
|
</span>`
|
||||||
|
: nothing}
|
||||||
|
</div>
|
||||||
</ha-md-menu-item>
|
</ha-md-menu-item>
|
||||||
<ha-md-menu-item
|
<ha-md-menu-item
|
||||||
slot="menu-items"
|
slot="menu-items"
|
||||||
.clickAction=${this._toggleYamlMode}
|
.clickAction=${this._toggleYamlMode}
|
||||||
.disabled=${!this.config.uiSupported || !!this._warnings}
|
.disabled=${!this.config.uiSupported || !!this._warnings}
|
||||||
>
|
>
|
||||||
|
<ha-svg-icon slot="start" .path=${mdiPlaylistEdit}></ha-svg-icon>
|
||||||
|
<div class="overflow-label">
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
`ui.panel.config.automation.editor.edit_${!this.yamlMode ? "yaml" : "ui"}`
|
`ui.panel.config.automation.editor.edit_${!this.yamlMode ? "yaml" : "ui"}`
|
||||||
)}
|
)}
|
||||||
<ha-svg-icon slot="start" .path=${mdiPlaylistEdit}></ha-svg-icon>
|
<span class="shortcut-placeholder ${isMac ? "mac" : ""}"></span>
|
||||||
|
</div>
|
||||||
</ha-md-menu-item>
|
</ha-md-menu-item>
|
||||||
<ha-md-divider
|
<ha-md-divider
|
||||||
slot="menu-items"
|
slot="menu-items"
|
||||||
@@ -167,13 +217,16 @@ export default class HaAutomationSidebarTrigger extends LitElement {
|
|||||||
.clickAction=${this.config.disable}
|
.clickAction=${this.config.disable}
|
||||||
.disabled=${type === "list"}
|
.disabled=${type === "list"}
|
||||||
>
|
>
|
||||||
${this.hass.localize(
|
|
||||||
`ui.panel.config.automation.editor.actions.${disabled ? "enable" : "disable"}`
|
|
||||||
)}
|
|
||||||
<ha-svg-icon
|
<ha-svg-icon
|
||||||
slot="start"
|
slot="start"
|
||||||
.path=${this.disabled ? mdiPlayCircleOutline : mdiStopCircleOutline}
|
.path=${this.disabled ? mdiPlayCircleOutline : mdiStopCircleOutline}
|
||||||
></ha-svg-icon>
|
></ha-svg-icon>
|
||||||
|
<div class="overflow-label">
|
||||||
|
${this.hass.localize(
|
||||||
|
`ui.panel.config.automation.editor.actions.${disabled ? "enable" : "disable"}`
|
||||||
|
)}
|
||||||
|
<span class="shortcut-placeholder ${isMac ? "mac" : ""}"></span>
|
||||||
|
</div>
|
||||||
</ha-md-menu-item>
|
</ha-md-menu-item>
|
||||||
<ha-md-menu-item
|
<ha-md-menu-item
|
||||||
slot="menu-items"
|
slot="menu-items"
|
||||||
@@ -181,10 +234,32 @@ export default class HaAutomationSidebarTrigger extends LitElement {
|
|||||||
.disabled=${this.disabled}
|
.disabled=${this.disabled}
|
||||||
class="warning"
|
class="warning"
|
||||||
>
|
>
|
||||||
|
<ha-svg-icon slot="start" .path=${mdiDelete}></ha-svg-icon>
|
||||||
|
<div class="overflow-label">
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.automation.editor.actions.delete"
|
"ui.panel.config.automation.editor.actions.delete"
|
||||||
)}
|
)}
|
||||||
<ha-svg-icon slot="start" .path=${mdiDelete}></ha-svg-icon>
|
${!this.narrow
|
||||||
|
? html`<span class="shortcut">
|
||||||
|
<span
|
||||||
|
>${isMac
|
||||||
|
? html`<ha-svg-icon
|
||||||
|
slot="start"
|
||||||
|
.path=${mdiAppleKeyboardCommand}
|
||||||
|
></ha-svg-icon>`
|
||||||
|
: this.hass.localize(
|
||||||
|
"ui.panel.config.automation.editor.ctrl"
|
||||||
|
)}</span
|
||||||
|
>
|
||||||
|
<span>+</span>
|
||||||
|
<span
|
||||||
|
>${this.hass.localize(
|
||||||
|
"ui.panel.config.automation.editor.del"
|
||||||
|
)}</span
|
||||||
|
>
|
||||||
|
</span>`
|
||||||
|
: nothing}
|
||||||
|
</div>
|
||||||
</ha-md-menu-item>
|
</ha-md-menu-item>
|
||||||
${keyed(
|
${keyed(
|
||||||
this.sidebarKey,
|
this.sidebarKey,
|
||||||
|
|||||||
@@ -136,6 +136,11 @@ export const manualEditorStyles = css`
|
|||||||
.content {
|
.content {
|
||||||
padding-top: 24px;
|
padding-top: 24px;
|
||||||
padding-bottom: 72px;
|
padding-bottom: 72px;
|
||||||
|
transition: padding-bottom 180ms ease-in-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content.has-bottom-sheet {
|
||||||
|
padding-bottom: calc(90vh - 72px);
|
||||||
}
|
}
|
||||||
|
|
||||||
ha-automation-sidebar {
|
ha-automation-sidebar {
|
||||||
@@ -184,8 +189,7 @@ export const automationRowsStyles = css`
|
|||||||
scroll-margin-top: 48px;
|
scroll-margin-top: 48px;
|
||||||
}
|
}
|
||||||
.handle {
|
.handle {
|
||||||
margin: 4px;
|
padding: 4px;
|
||||||
padding: 8px;
|
|
||||||
cursor: move; /* fallback if grab cursor is unsupported */
|
cursor: move; /* fallback if grab cursor is unsupported */
|
||||||
cursor: grab;
|
cursor: grab;
|
||||||
border-radius: var(--ha-border-radius-pill);
|
border-radius: var(--ha-border-radius-pill);
|
||||||
@@ -218,4 +222,34 @@ export const sidebarEditorStyles = css`
|
|||||||
.description {
|
.description {
|
||||||
padding-top: 16px;
|
padding-top: 16px;
|
||||||
}
|
}
|
||||||
|
.overflow-label {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 12px;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
.overflow-label .shortcut {
|
||||||
|
--mdc-icon-size: 12px;
|
||||||
|
display: inline-flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
gap: 2px;
|
||||||
|
}
|
||||||
|
.overflow-label .shortcut span {
|
||||||
|
font-size: var(--ha-font-size-s);
|
||||||
|
font-family: var(--ha-font-family-code);
|
||||||
|
color: var(--ha-color-text-secondary);
|
||||||
|
}
|
||||||
|
.shortcut-placeholder {
|
||||||
|
display: inline-block;
|
||||||
|
width: 60px;
|
||||||
|
}
|
||||||
|
.shortcut-placeholder.mac {
|
||||||
|
width: 46px;
|
||||||
|
}
|
||||||
|
@media all and (max-width: 870px) {
|
||||||
|
.shortcut-placeholder {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
`;
|
`;
|
||||||
|
|||||||
@@ -4,12 +4,12 @@ import {
|
|||||||
mdiArrowUp,
|
mdiArrowUp,
|
||||||
mdiContentCopy,
|
mdiContentCopy,
|
||||||
mdiContentCut,
|
mdiContentCut,
|
||||||
mdiContentDuplicate,
|
|
||||||
mdiDelete,
|
mdiDelete,
|
||||||
mdiDotsVertical,
|
mdiDotsVertical,
|
||||||
mdiIdentifier,
|
mdiIdentifier,
|
||||||
mdiPlayCircleOutline,
|
mdiPlayCircleOutline,
|
||||||
mdiPlaylistEdit,
|
mdiPlaylistEdit,
|
||||||
|
mdiPlusCircleMultipleOutline,
|
||||||
mdiRenameBox,
|
mdiRenameBox,
|
||||||
mdiStopCircleOutline,
|
mdiStopCircleOutline,
|
||||||
} from "@mdi/js";
|
} from "@mdi/js";
|
||||||
@@ -52,6 +52,7 @@ import {
|
|||||||
showPromptDialog,
|
showPromptDialog,
|
||||||
} from "../../../../dialogs/generic/show-dialog-box";
|
} from "../../../../dialogs/generic/show-dialog-box";
|
||||||
import type { HomeAssistant } from "../../../../types";
|
import type { HomeAssistant } from "../../../../types";
|
||||||
|
import { showToast } from "../../../../util/toast";
|
||||||
import "../ha-automation-editor-warning";
|
import "../ha-automation-editor-warning";
|
||||||
import { rowStyles } from "../styles";
|
import { rowStyles } from "../styles";
|
||||||
import "./ha-automation-trigger-editor";
|
import "./ha-automation-trigger-editor";
|
||||||
@@ -153,6 +154,10 @@ export default class HaAutomationTriggerRow extends LitElement {
|
|||||||
@consume({ context: fullEntitiesContext, subscribe: true })
|
@consume({ context: fullEntitiesContext, subscribe: true })
|
||||||
_entityReg!: EntityRegistryEntry[];
|
_entityReg!: EntityRegistryEntry[];
|
||||||
|
|
||||||
|
get selected() {
|
||||||
|
return this._selected;
|
||||||
|
}
|
||||||
|
|
||||||
private _triggerUnsub?: Promise<UnsubscribeFunc>;
|
private _triggerUnsub?: Promise<UnsubscribeFunc>;
|
||||||
|
|
||||||
private _renderRow() {
|
private _renderRow() {
|
||||||
@@ -221,7 +226,7 @@ export default class HaAutomationTriggerRow extends LitElement {
|
|||||||
)}
|
)}
|
||||||
<ha-svg-icon
|
<ha-svg-icon
|
||||||
slot="start"
|
slot="start"
|
||||||
.path=${mdiContentDuplicate}
|
.path=${mdiPlusCircleMultipleOutline}
|
||||||
></ha-svg-icon>
|
></ha-svg-icon>
|
||||||
</ha-md-menu-item>
|
</ha-md-menu-item>
|
||||||
|
|
||||||
@@ -349,10 +354,13 @@ export default class HaAutomationTriggerRow extends LitElement {
|
|||||||
? html`<ha-automation-row
|
? html`<ha-automation-row
|
||||||
.disabled=${"enabled" in this.trigger &&
|
.disabled=${"enabled" in this.trigger &&
|
||||||
this.trigger.enabled === false}
|
this.trigger.enabled === false}
|
||||||
@click=${this._toggleSidebar}
|
|
||||||
.selected=${this._selected}
|
.selected=${this._selected}
|
||||||
.highlight=${this.highlight}
|
.highlight=${this.highlight}
|
||||||
.sortSelected=${this.sortSelected}
|
.sortSelected=${this.sortSelected}
|
||||||
|
@click=${this._toggleSidebar}
|
||||||
|
@copy-row=${this._copyTrigger}
|
||||||
|
@cut-row=${this._cutTrigger}
|
||||||
|
@delete-row=${this._onDelete}
|
||||||
>${this._selected
|
>${this._selected
|
||||||
? "selected"
|
? "selected"
|
||||||
: nothing}${this._renderRow()}</ha-automation-row
|
: nothing}${this._renderRow()}</ha-automation-row
|
||||||
@@ -473,8 +481,7 @@ export default class HaAutomationTriggerRow extends LitElement {
|
|||||||
ev?.stopPropagation();
|
ev?.stopPropagation();
|
||||||
|
|
||||||
if (this._selected) {
|
if (this._selected) {
|
||||||
this._selected = false;
|
fireEvent(this, "request-close-sidebar");
|
||||||
fireEvent(this, "close-sidebar");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.openSidebar();
|
this.openSidebar();
|
||||||
@@ -511,12 +518,12 @@ export default class HaAutomationTriggerRow extends LitElement {
|
|||||||
this._selected = true;
|
this._selected = true;
|
||||||
|
|
||||||
if (this.narrow) {
|
if (this.narrow) {
|
||||||
requestAnimationFrame(() => {
|
window.setTimeout(() => {
|
||||||
this.scrollIntoView({
|
this.scrollIntoView({
|
||||||
block: "start",
|
block: "start",
|
||||||
behavior: "smooth",
|
behavior: "smooth",
|
||||||
});
|
});
|
||||||
});
|
}, 180);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -634,6 +641,12 @@ export default class HaAutomationTriggerRow extends LitElement {
|
|||||||
|
|
||||||
private _copyTrigger = () => {
|
private _copyTrigger = () => {
|
||||||
this._setClipboard();
|
this._setClipboard();
|
||||||
|
showToast(this, {
|
||||||
|
message: this.hass.localize(
|
||||||
|
"ui.panel.config.automation.editor.triggers.copied_to_clipboard"
|
||||||
|
),
|
||||||
|
duration: 2000,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
private _cutTrigger = () => {
|
private _cutTrigger = () => {
|
||||||
@@ -642,6 +655,12 @@ export default class HaAutomationTriggerRow extends LitElement {
|
|||||||
if (this._selected) {
|
if (this._selected) {
|
||||||
fireEvent(this, "close-sidebar");
|
fireEvent(this, "close-sidebar");
|
||||||
}
|
}
|
||||||
|
showToast(this, {
|
||||||
|
message: this.hass.localize(
|
||||||
|
"ui.panel.config.automation.editor.triggers.cut_to_clipboard"
|
||||||
|
),
|
||||||
|
duration: 2000,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
private _moveUp = () => {
|
private _moveUp = () => {
|
||||||
@@ -679,10 +698,6 @@ export default class HaAutomationTriggerRow extends LitElement {
|
|||||||
customElements.get(`ha-automation-trigger-${type}`) !== undefined
|
customElements.get(`ha-automation-trigger-${type}`) !== undefined
|
||||||
);
|
);
|
||||||
|
|
||||||
public isSelected() {
|
|
||||||
return this._selected;
|
|
||||||
}
|
|
||||||
|
|
||||||
public focus() {
|
public focus() {
|
||||||
this._automationRowElement?.focus();
|
this._automationRowElement?.focus();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import { nextRender } from "../../../../common/util/render-status";
|
|||||||
import "../../../../components/ha-button";
|
import "../../../../components/ha-button";
|
||||||
import "../../../../components/ha-button-menu";
|
import "../../../../components/ha-button-menu";
|
||||||
import "../../../../components/ha-sortable";
|
import "../../../../components/ha-sortable";
|
||||||
import type { HaSortableClonedEventData } from "../../../../components/ha-sortable";
|
|
||||||
import "../../../../components/ha-svg-icon";
|
import "../../../../components/ha-svg-icon";
|
||||||
import type {
|
import type {
|
||||||
AutomationClipboard,
|
AutomationClipboard,
|
||||||
@@ -72,7 +71,6 @@ export default class HaAutomationTrigger extends LitElement {
|
|||||||
@item-moved=${this._triggerMoved}
|
@item-moved=${this._triggerMoved}
|
||||||
@item-added=${this._triggerAdded}
|
@item-added=${this._triggerAdded}
|
||||||
@item-removed=${this._triggerRemoved}
|
@item-removed=${this._triggerRemoved}
|
||||||
@item-cloned=${this._triggerCloned}
|
|
||||||
>
|
>
|
||||||
<div class="rows ${!this.optionsInSidebar ? "no-sidebar" : ""}">
|
<div class="rows ${!this.optionsInSidebar ? "no-sidebar" : ""}">
|
||||||
${repeat(
|
${repeat(
|
||||||
@@ -260,11 +258,8 @@ export default class HaAutomationTrigger extends LitElement {
|
|||||||
private async _triggerAdded(ev: CustomEvent): Promise<void> {
|
private async _triggerAdded(ev: CustomEvent): Promise<void> {
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
const { index, data } = ev.detail;
|
const { index, data } = ev.detail;
|
||||||
let selected = false;
|
const item = ev.detail.item as HaAutomationTriggerRow;
|
||||||
if (data?.["ha-automation-row-selected"]) {
|
const selected = item.selected;
|
||||||
selected = true;
|
|
||||||
delete data["ha-automation-row-selected"];
|
|
||||||
}
|
|
||||||
|
|
||||||
let triggers = [
|
let triggers = [
|
||||||
...this.triggers.slice(0, index),
|
...this.triggers.slice(0, index),
|
||||||
@@ -303,12 +298,6 @@ export default class HaAutomationTrigger extends LitElement {
|
|||||||
fireEvent(this, "value-changed", { value: triggers });
|
fireEvent(this, "value-changed", { value: triggers });
|
||||||
}
|
}
|
||||||
|
|
||||||
private _triggerCloned(ev: CustomEvent<HaSortableClonedEventData>) {
|
|
||||||
if (ev.detail.item.isSelected()) {
|
|
||||||
ev.detail.item.trigger["ha-automation-row-selected"] = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private _triggerChanged(ev: CustomEvent) {
|
private _triggerChanged(ev: CustomEvent) {
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
const triggers = [...this.triggers];
|
const triggers = [...this.triggers];
|
||||||
|
|||||||
@@ -42,6 +42,8 @@ export class HaTagTrigger extends LitElement implements TriggerElement {
|
|||||||
.disabled=${this.disabled || this._tags.length === 0}
|
.disabled=${this.disabled || this._tags.length === 0}
|
||||||
.value=${this.trigger.tag_id}
|
.value=${this.trigger.tag_id}
|
||||||
@selected=${this._tagChanged}
|
@selected=${this._tagChanged}
|
||||||
|
fixedMenuPosition
|
||||||
|
naturalMenuWidth
|
||||||
>
|
>
|
||||||
${this._tags.map(
|
${this._tags.map(
|
||||||
(tag) => html`
|
(tag) => html`
|
||||||
|
|||||||
@@ -773,6 +773,11 @@ export class HaConfigDevicePage extends LitElement {
|
|||||||
appearance="plain"
|
appearance="plain"
|
||||||
target=${ifDefined(firstDeviceAction!.target)}
|
target=${ifDefined(firstDeviceAction!.target)}
|
||||||
class=${ifDefined(firstDeviceAction!.classes)}
|
class=${ifDefined(firstDeviceAction!.classes)}
|
||||||
|
.variant=${firstDeviceAction!.classes?.includes(
|
||||||
|
"warning"
|
||||||
|
)
|
||||||
|
? "danger"
|
||||||
|
: "brand"}
|
||||||
.action=${firstDeviceAction!.action}
|
.action=${firstDeviceAction!.action}
|
||||||
@click=${this._deviceActionClicked}
|
@click=${this._deviceActionClicked}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import type { CSSResultGroup, TemplateResult } from "lit";
|
import type { CSSResultGroup, TemplateResult } from "lit";
|
||||||
import { css, html, LitElement } from "lit";
|
import { css, html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import "../../../../../components/ha-card";
|
import "../../../../../components/ha-card";
|
||||||
import "../../../../../components/ha-code-editor";
|
import "../../../../../components/ha-code-editor";
|
||||||
@@ -11,13 +11,22 @@ import { showOptionsFlowDialog } from "../../../../../dialogs/config-flow/show-d
|
|||||||
import "../../../../../layouts/hass-subpage";
|
import "../../../../../layouts/hass-subpage";
|
||||||
import { haStyle } from "../../../../../resources/styles";
|
import { haStyle } from "../../../../../resources/styles";
|
||||||
import type { HomeAssistant } from "../../../../../types";
|
import type { HomeAssistant } from "../../../../../types";
|
||||||
import { subscribeBluetoothConnectionAllocations } from "../../../../../data/bluetooth";
|
import {
|
||||||
|
subscribeBluetoothConnectionAllocations,
|
||||||
|
subscribeBluetoothScannerState,
|
||||||
|
subscribeBluetoothScannersDetails,
|
||||||
|
} from "../../../../../data/bluetooth";
|
||||||
|
import type {
|
||||||
|
BluetoothAllocationsData,
|
||||||
|
BluetoothScannerState,
|
||||||
|
BluetoothScannersDetails,
|
||||||
|
HaScannerType,
|
||||||
|
} from "../../../../../data/bluetooth";
|
||||||
import {
|
import {
|
||||||
getValueInPercentage,
|
getValueInPercentage,
|
||||||
roundWithOneDecimal,
|
roundWithOneDecimal,
|
||||||
} from "../../../../../util/calculate";
|
} from "../../../../../util/calculate";
|
||||||
import "../../../../../components/ha-metric";
|
import "../../../../../components/ha-metric";
|
||||||
import type { BluetoothAllocationsData } from "../../../../../data/bluetooth";
|
|
||||||
|
|
||||||
@customElement("bluetooth-config-dashboard")
|
@customElement("bluetooth-config-dashboard")
|
||||||
export class BluetoothConfigDashboard extends LitElement {
|
export class BluetoothConfigDashboard extends LitElement {
|
||||||
@@ -29,16 +38,26 @@ export class BluetoothConfigDashboard extends LitElement {
|
|||||||
|
|
||||||
@state() private _connectionAllocationsError?: string;
|
@state() private _connectionAllocationsError?: string;
|
||||||
|
|
||||||
|
@state() private _scannerState?: BluetoothScannerState;
|
||||||
|
|
||||||
|
@state() private _scannerDetails?: BluetoothScannersDetails;
|
||||||
|
|
||||||
private _configEntry = new URLSearchParams(window.location.search).get(
|
private _configEntry = new URLSearchParams(window.location.search).get(
|
||||||
"config_entry"
|
"config_entry"
|
||||||
);
|
);
|
||||||
|
|
||||||
private _unsubConnectionAllocations?: (() => Promise<void>) | undefined;
|
private _unsubConnectionAllocations?: (() => Promise<void>) | undefined;
|
||||||
|
|
||||||
|
private _unsubScannerState?: (() => Promise<void>) | undefined;
|
||||||
|
|
||||||
|
private _unsubScannerDetails?: (() => void) | undefined;
|
||||||
|
|
||||||
public connectedCallback(): void {
|
public connectedCallback(): void {
|
||||||
super.connectedCallback();
|
super.connectedCallback();
|
||||||
if (this.hass) {
|
if (this.hass) {
|
||||||
this._subscribeBluetoothConnectionAllocations();
|
this._subscribeBluetoothConnectionAllocations();
|
||||||
|
this._subscribeBluetoothScannerState();
|
||||||
|
this._subscribeScannerDetails();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,12 +80,45 @@ export class BluetoothConfigDashboard extends LitElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async _subscribeBluetoothScannerState(): Promise<void> {
|
||||||
|
if (this._unsubScannerState || !this._configEntry) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this._unsubScannerState = await subscribeBluetoothScannerState(
|
||||||
|
this.hass.connection,
|
||||||
|
(scannerState) => {
|
||||||
|
this._scannerState = scannerState;
|
||||||
|
},
|
||||||
|
this._configEntry
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private _subscribeScannerDetails(): void {
|
||||||
|
if (this._unsubScannerDetails) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this._unsubScannerDetails = subscribeBluetoothScannersDetails(
|
||||||
|
this.hass.connection,
|
||||||
|
(details) => {
|
||||||
|
this._scannerDetails = details;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public disconnectedCallback() {
|
public disconnectedCallback() {
|
||||||
super.disconnectedCallback();
|
super.disconnectedCallback();
|
||||||
if (this._unsubConnectionAllocations) {
|
if (this._unsubConnectionAllocations) {
|
||||||
this._unsubConnectionAllocations();
|
this._unsubConnectionAllocations();
|
||||||
this._unsubConnectionAllocations = undefined;
|
this._unsubConnectionAllocations = undefined;
|
||||||
}
|
}
|
||||||
|
if (this._unsubScannerState) {
|
||||||
|
this._unsubScannerState();
|
||||||
|
this._unsubScannerState = undefined;
|
||||||
|
}
|
||||||
|
if (this._unsubScannerDetails) {
|
||||||
|
this._unsubScannerDetails();
|
||||||
|
this._unsubScannerDetails = undefined;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render(): TemplateResult {
|
||||||
@@ -78,6 +130,7 @@ export class BluetoothConfigDashboard extends LitElement {
|
|||||||
"ui.panel.config.bluetooth.settings_title"
|
"ui.panel.config.bluetooth.settings_title"
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
|
<div class="card-content">${this._renderScannerState()}</div>
|
||||||
<div class="card-actions">
|
<div class="card-actions">
|
||||||
<ha-button @click=${this._openOptionFlow}
|
<ha-button @click=${this._openOptionFlow}
|
||||||
>${this.hass.localize(
|
>${this.hass.localize(
|
||||||
@@ -142,6 +195,118 @@ export class BluetoothConfigDashboard extends LitElement {
|
|||||||
private _getUsedAllocations = (used: number, total: number) =>
|
private _getUsedAllocations = (used: number, total: number) =>
|
||||||
roundWithOneDecimal(getValueInPercentage(used, 0, total));
|
roundWithOneDecimal(getValueInPercentage(used, 0, total));
|
||||||
|
|
||||||
|
private _renderScannerMismatchWarning(
|
||||||
|
scannerState: BluetoothScannerState,
|
||||||
|
scannerType: HaScannerType,
|
||||||
|
formatMode: (mode: string | null) => string
|
||||||
|
) {
|
||||||
|
const instructions: string[] = [];
|
||||||
|
|
||||||
|
if (scannerType === "remote" || scannerType === "unknown") {
|
||||||
|
instructions.push(
|
||||||
|
this.hass.localize(
|
||||||
|
"ui.panel.config.bluetooth.scanner_mode_mismatch_remote"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (scannerType === "usb" || scannerType === "unknown") {
|
||||||
|
instructions.push(
|
||||||
|
this.hass.localize(
|
||||||
|
"ui.panel.config.bluetooth.scanner_mode_mismatch_usb"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (scannerType === "uart" || scannerType === "unknown") {
|
||||||
|
instructions.push(
|
||||||
|
this.hass.localize(
|
||||||
|
"ui.panel.config.bluetooth.scanner_mode_mismatch_uart"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return html`<ha-alert alert-type="warning">
|
||||||
|
<div>
|
||||||
|
${this.hass.localize(
|
||||||
|
"ui.panel.config.bluetooth.scanner_mode_mismatch",
|
||||||
|
{
|
||||||
|
requested: formatMode(scannerState.requested_mode),
|
||||||
|
current: formatMode(scannerState.current_mode),
|
||||||
|
}
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<ul>
|
||||||
|
${instructions.map((instruction) => html`<li>${instruction}</li>`)}
|
||||||
|
</ul>
|
||||||
|
</ha-alert>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
private _renderScannerState() {
|
||||||
|
if (!this._configEntry || !this._scannerState) {
|
||||||
|
return html`<div>
|
||||||
|
${this.hass.localize(
|
||||||
|
"ui.panel.config.bluetooth.no_scanner_state_available"
|
||||||
|
)}
|
||||||
|
</div>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
const scannerState = this._scannerState;
|
||||||
|
// Find the scanner details for this source
|
||||||
|
const scannerDetails = this._scannerDetails?.[scannerState.source];
|
||||||
|
const scannerType: HaScannerType =
|
||||||
|
scannerDetails?.scanner_type ?? "unknown";
|
||||||
|
|
||||||
|
const formatMode = (mode: string | null) => {
|
||||||
|
switch (mode) {
|
||||||
|
case null:
|
||||||
|
return this.hass.localize(
|
||||||
|
"ui.panel.config.bluetooth.scanning_mode_none"
|
||||||
|
);
|
||||||
|
case "active":
|
||||||
|
return this.hass.localize(
|
||||||
|
"ui.panel.config.bluetooth.scanning_mode_active"
|
||||||
|
);
|
||||||
|
case "passive":
|
||||||
|
return this.hass.localize(
|
||||||
|
"ui.panel.config.bluetooth.scanning_mode_passive"
|
||||||
|
);
|
||||||
|
default:
|
||||||
|
return mode; // Fallback for unknown modes
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return html`
|
||||||
|
<div class="scanner-state">
|
||||||
|
<div class="state-row">
|
||||||
|
<span
|
||||||
|
>${this.hass.localize(
|
||||||
|
"ui.panel.config.bluetooth.current_scanning_mode"
|
||||||
|
)}:</span
|
||||||
|
>
|
||||||
|
<span class="state-value"
|
||||||
|
>${formatMode(scannerState.current_mode)}</span
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<div class="state-row">
|
||||||
|
<span
|
||||||
|
>${this.hass.localize(
|
||||||
|
"ui.panel.config.bluetooth.requested_scanning_mode"
|
||||||
|
)}:</span
|
||||||
|
>
|
||||||
|
<span class="state-value"
|
||||||
|
>${formatMode(scannerState.requested_mode)}</span
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
${scannerState.current_mode !== scannerState.requested_mode
|
||||||
|
? this._renderScannerMismatchWarning(
|
||||||
|
scannerState,
|
||||||
|
scannerType,
|
||||||
|
formatMode
|
||||||
|
)
|
||||||
|
: nothing}
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
private _renderConnectionAllocations() {
|
private _renderConnectionAllocations() {
|
||||||
if (this._connectionAllocationsError) {
|
if (this._connectionAllocationsError) {
|
||||||
return html`<ha-alert alert-type="error"
|
return html`<ha-alert alert-type="error"
|
||||||
@@ -220,6 +385,18 @@ export class BluetoothConfigDashboard extends LitElement {
|
|||||||
display: flex;
|
display: flex;
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
}
|
}
|
||||||
|
.scanner-state {
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
.state-row {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
padding: 4px 0;
|
||||||
|
}
|
||||||
|
.state-value {
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
`,
|
`,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -289,6 +289,15 @@ export const showRepairsFlowDialog = (
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
renderMenuOptionDescription(hass, step, option) {
|
||||||
|
return hass.localize(
|
||||||
|
`component.${issue.domain}.issues.${
|
||||||
|
issue.translation_key || issue.issue_id
|
||||||
|
}.fix_flow.step.${step.step_id}.menu_option_descriptions.${option}`,
|
||||||
|
mergePlaceholders(issue, step)
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
renderLoadingDescription(hass, reason) {
|
renderLoadingDescription(hass, reason) {
|
||||||
return (
|
return (
|
||||||
hass.localize(
|
hass.localize(
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { consume } from "@lit/context";
|
import { consume } from "@lit/context";
|
||||||
import {
|
import {
|
||||||
mdiCog,
|
mdiCog,
|
||||||
mdiContentDuplicate,
|
|
||||||
mdiContentSave,
|
mdiContentSave,
|
||||||
mdiDebugStepOver,
|
mdiDebugStepOver,
|
||||||
mdiDelete,
|
mdiDelete,
|
||||||
@@ -11,12 +10,11 @@ import {
|
|||||||
mdiInformationOutline,
|
mdiInformationOutline,
|
||||||
mdiPlay,
|
mdiPlay,
|
||||||
mdiPlaylistEdit,
|
mdiPlaylistEdit,
|
||||||
|
mdiPlusCircleMultipleOutline,
|
||||||
mdiRenameBox,
|
mdiRenameBox,
|
||||||
mdiRobotConfused,
|
mdiRobotConfused,
|
||||||
mdiTag,
|
mdiTag,
|
||||||
mdiTransitConnection,
|
mdiTransitConnection,
|
||||||
mdiUnfoldLessHorizontal,
|
|
||||||
mdiUnfoldMoreHorizontal,
|
|
||||||
} from "@mdi/js";
|
} from "@mdi/js";
|
||||||
import type { CSSResultGroup, PropertyValues, TemplateResult } from "lit";
|
import type { CSSResultGroup, PropertyValues, TemplateResult } from "lit";
|
||||||
import { LitElement, css, html, nothing } from "lit";
|
import { LitElement, css, html, nothing } from "lit";
|
||||||
@@ -308,7 +306,7 @@ export class HaScriptEditor extends SubscribeMixin(
|
|||||||
)}
|
)}
|
||||||
<ha-svg-icon
|
<ha-svg-icon
|
||||||
slot="graphic"
|
slot="graphic"
|
||||||
.path=${mdiContentDuplicate}
|
.path=${mdiPlusCircleMultipleOutline}
|
||||||
></ha-svg-icon>
|
></ha-svg-icon>
|
||||||
</ha-list-item>
|
</ha-list-item>
|
||||||
|
|
||||||
@@ -342,30 +340,6 @@ export class HaScriptEditor extends SubscribeMixin(
|
|||||||
<ha-svg-icon slot="graphic" .path=${mdiPlaylistEdit}></ha-svg-icon>
|
<ha-svg-icon slot="graphic" .path=${mdiPlaylistEdit}></ha-svg-icon>
|
||||||
</ha-list-item>
|
</ha-list-item>
|
||||||
|
|
||||||
${!useBlueprint
|
|
||||||
? html`
|
|
||||||
<ha-list-item graphic="icon" @click=${this._collapseAll}>
|
|
||||||
<ha-svg-icon
|
|
||||||
slot="graphic"
|
|
||||||
.path=${mdiUnfoldLessHorizontal}
|
|
||||||
></ha-svg-icon>
|
|
||||||
${this.hass.localize(
|
|
||||||
"ui.panel.config.automation.editor.collapse_all"
|
|
||||||
)}
|
|
||||||
</ha-list-item>
|
|
||||||
|
|
||||||
<ha-list-item graphic="icon" @click=${this._expandAll}>
|
|
||||||
<ha-svg-icon
|
|
||||||
slot="graphic"
|
|
||||||
.path=${mdiUnfoldMoreHorizontal}
|
|
||||||
></ha-svg-icon>
|
|
||||||
${this.hass.localize(
|
|
||||||
"ui.panel.config.automation.editor.expand_all"
|
|
||||||
)}
|
|
||||||
</ha-list-item>
|
|
||||||
`
|
|
||||||
: nothing}
|
|
||||||
|
|
||||||
<li divider role="separator"></li>
|
<li divider role="separator"></li>
|
||||||
|
|
||||||
<ha-list-item
|
<ha-list-item
|
||||||
@@ -1047,6 +1021,9 @@ export class HaScriptEditor extends SubscribeMixin(
|
|||||||
protected supportedShortcuts(): SupportedShortcuts {
|
protected supportedShortcuts(): SupportedShortcuts {
|
||||||
return {
|
return {
|
||||||
s: () => this._handleSaveScript(),
|
s: () => this._handleSaveScript(),
|
||||||
|
c: () => this._copySelectedRow(),
|
||||||
|
x: () => this._cutSelectedRow(),
|
||||||
|
Delete: () => this._deleteSelectedRow(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1058,14 +1035,28 @@ export class HaScriptEditor extends SubscribeMixin(
|
|||||||
return this._confirmUnsavedChanged();
|
return this._confirmUnsavedChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
private _collapseAll() {
|
private _collapseAll() {
|
||||||
this._manualEditor?.collapseAll();
|
this._manualEditor?.collapseAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
private _expandAll() {
|
private _expandAll() {
|
||||||
this._manualEditor?.expandAll();
|
this._manualEditor?.expandAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _copySelectedRow() {
|
||||||
|
this._manualEditor?.copySelectedRow();
|
||||||
|
}
|
||||||
|
|
||||||
|
private _cutSelectedRow() {
|
||||||
|
this._manualEditor?.cutSelectedRow();
|
||||||
|
}
|
||||||
|
|
||||||
|
private _deleteSelectedRow() {
|
||||||
|
this._manualEditor?.deleteSelectedRow();
|
||||||
|
}
|
||||||
|
|
||||||
static get styles(): CSSResultGroup {
|
static get styles(): CSSResultGroup {
|
||||||
return [
|
return [
|
||||||
haStyle,
|
haStyle,
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ export default class HaScriptFieldRow extends LitElement {
|
|||||||
@toggle-collapsed=${this._toggleCollapse}
|
@toggle-collapsed=${this._toggleCollapse}
|
||||||
.collapsed=${this._collapsed}
|
.collapsed=${this._collapsed}
|
||||||
.highlight=${this.highlight}
|
.highlight=${this.highlight}
|
||||||
|
@delete-row=${this._onDelete}
|
||||||
>
|
>
|
||||||
<h3 slot="header">${this.key}</h3>
|
<h3 slot="header">${this.key}</h3>
|
||||||
|
|
||||||
@@ -161,8 +162,7 @@ export default class HaScriptFieldRow extends LitElement {
|
|||||||
ev?.stopPropagation();
|
ev?.stopPropagation();
|
||||||
|
|
||||||
if (this._selected) {
|
if (this._selected) {
|
||||||
this._selected = false;
|
fireEvent(this, "request-close-sidebar");
|
||||||
fireEvent(this, "close-sidebar");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,8 +175,7 @@ export default class HaScriptFieldRow extends LitElement {
|
|||||||
ev?.stopPropagation();
|
ev?.stopPropagation();
|
||||||
|
|
||||||
if (this._selectorRowSelected) {
|
if (this._selectorRowSelected) {
|
||||||
this._selectorRowSelected = false;
|
fireEvent(this, "request-close-sidebar");
|
||||||
fireEvent(this, "close-sidebar");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -235,12 +234,12 @@ export default class HaScriptFieldRow extends LitElement {
|
|||||||
} satisfies ScriptFieldSidebarConfig);
|
} satisfies ScriptFieldSidebarConfig);
|
||||||
|
|
||||||
if (this.narrow) {
|
if (this.narrow) {
|
||||||
requestAnimationFrame(() => {
|
window.setTimeout(() => {
|
||||||
this.scrollIntoView({
|
this.scrollIntoView({
|
||||||
block: "start",
|
block: "start",
|
||||||
behavior: "smooth",
|
behavior: "smooth",
|
||||||
});
|
});
|
||||||
});
|
}, 180); // duration of transition of added padding for bottom sheet
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -76,10 +76,12 @@ export default class HaScriptFields extends LitElement {
|
|||||||
row.focus();
|
row.focus();
|
||||||
|
|
||||||
if (this.narrow) {
|
if (this.narrow) {
|
||||||
|
window.setTimeout(() => {
|
||||||
row.scrollIntoView({
|
row.scrollIntoView({
|
||||||
block: "start",
|
block: "start",
|
||||||
behavior: "smooth",
|
behavior: "smooth",
|
||||||
});
|
});
|
||||||
|
}, 180); // duration of transition of added padding for bottom sheet
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,13 @@ import { mdiContentSave, mdiHelpCircle } from "@mdi/js";
|
|||||||
import { load } from "js-yaml";
|
import { load } from "js-yaml";
|
||||||
import type { CSSResultGroup, PropertyValues } from "lit";
|
import type { CSSResultGroup, PropertyValues } from "lit";
|
||||||
import { css, html, LitElement, nothing } from "lit";
|
import { css, html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property, query, state } from "lit/decorators";
|
import {
|
||||||
|
customElement,
|
||||||
|
property,
|
||||||
|
query,
|
||||||
|
queryAll,
|
||||||
|
state,
|
||||||
|
} from "lit/decorators";
|
||||||
import { classMap } from "lit/directives/class-map";
|
import { classMap } from "lit/directives/class-map";
|
||||||
import {
|
import {
|
||||||
any,
|
any,
|
||||||
@@ -24,7 +30,10 @@ import {
|
|||||||
} from "../../../common/url/search-params";
|
} from "../../../common/url/search-params";
|
||||||
import "../../../components/ha-icon-button";
|
import "../../../components/ha-icon-button";
|
||||||
import "../../../components/ha-markdown";
|
import "../../../components/ha-markdown";
|
||||||
import type { SidebarConfig } from "../../../data/automation";
|
import type {
|
||||||
|
ActionSidebarConfig,
|
||||||
|
SidebarConfig,
|
||||||
|
} from "../../../data/automation";
|
||||||
import type { Action, Fields, ScriptConfig } from "../../../data/script";
|
import type { Action, Fields, ScriptConfig } from "../../../data/script";
|
||||||
import {
|
import {
|
||||||
getActionType,
|
getActionType,
|
||||||
@@ -80,6 +89,11 @@ export class HaManualScriptEditor extends LitElement {
|
|||||||
|
|
||||||
@query("ha-automation-sidebar") private _sidebarElement?: HaAutomationSidebar;
|
@query("ha-automation-sidebar") private _sidebarElement?: HaAutomationSidebar;
|
||||||
|
|
||||||
|
@queryAll("ha-automation-action, ha-script-fields")
|
||||||
|
private _collapsableElements?: NodeListOf<
|
||||||
|
HaAutomationAction | HaScriptFields
|
||||||
|
>;
|
||||||
|
|
||||||
private _previousConfig?: ScriptConfig;
|
private _previousConfig?: ScriptConfig;
|
||||||
|
|
||||||
private _openFields = false;
|
private _openFields = false;
|
||||||
@@ -156,6 +170,7 @@ export class HaManualScriptEditor extends LitElement {
|
|||||||
.disabled=${this.disabled}
|
.disabled=${this.disabled}
|
||||||
.narrow=${this.narrow}
|
.narrow=${this.narrow}
|
||||||
@open-sidebar=${this._openSidebar}
|
@open-sidebar=${this._openSidebar}
|
||||||
|
@request-close-sidebar=${this._triggerCloseSidebar}
|
||||||
@close-sidebar=${this._handleCloseSidebar}
|
@close-sidebar=${this._handleCloseSidebar}
|
||||||
></ha-script-fields>`
|
></ha-script-fields>`
|
||||||
: nothing
|
: nothing
|
||||||
@@ -186,6 +201,7 @@ export class HaManualScriptEditor extends LitElement {
|
|||||||
.highlightedActions=${this._pastedConfig?.sequence || []}
|
.highlightedActions=${this._pastedConfig?.sequence || []}
|
||||||
@value-changed=${this._sequenceChanged}
|
@value-changed=${this._sequenceChanged}
|
||||||
@open-sidebar=${this._openSidebar}
|
@open-sidebar=${this._openSidebar}
|
||||||
|
@request-close-sidebar=${this._triggerCloseSidebar}
|
||||||
@close-sidebar=${this._handleCloseSidebar}
|
@close-sidebar=${this._handleCloseSidebar}
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.narrow=${this.narrow}
|
.narrow=${this.narrow}
|
||||||
@@ -204,7 +220,11 @@ export class HaManualScriptEditor extends LitElement {
|
|||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
<div class="content-wrapper">
|
<div class="content-wrapper">
|
||||||
<div class="content">
|
<div
|
||||||
|
class="content ${this._sidebarConfig && this.narrow
|
||||||
|
? "has-bottom-sheet"
|
||||||
|
: ""}"
|
||||||
|
>
|
||||||
<slot name="alerts"></slot>
|
<slot name="alerts"></slot>
|
||||||
${this._renderContent()}
|
${this._renderContent()}
|
||||||
</div>
|
</div>
|
||||||
@@ -357,7 +377,11 @@ export class HaManualScriptEditor extends LitElement {
|
|||||||
if (normalized) {
|
if (normalized) {
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
|
|
||||||
if (this.dirty) {
|
if (
|
||||||
|
this.dirty ||
|
||||||
|
ensureArray(this.config.sequence)?.length ||
|
||||||
|
Object.keys(this.config.fields || {}).length
|
||||||
|
) {
|
||||||
const result = await new Promise<boolean>((resolve) => {
|
const result = await new Promise<boolean>((resolve) => {
|
||||||
showPasteReplaceDialog(this, {
|
showPasteReplaceDialog(this, {
|
||||||
domain: "script",
|
domain: "script",
|
||||||
@@ -484,11 +508,13 @@ export class HaManualScriptEditor extends LitElement {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private _closeSidebar() {
|
private _triggerCloseSidebar() {
|
||||||
if (this._sidebarConfig) {
|
if (this._sidebarConfig) {
|
||||||
const closeRow = this._sidebarConfig?.close;
|
if (this._sidebarElement) {
|
||||||
this._sidebarConfig = undefined;
|
this._sidebarElement.triggerCloseSidebar();
|
||||||
closeRow?.();
|
return;
|
||||||
|
}
|
||||||
|
this._sidebarConfig?.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -497,28 +523,40 @@ export class HaManualScriptEditor extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _saveScript() {
|
private _saveScript() {
|
||||||
this._closeSidebar();
|
this._triggerCloseSidebar();
|
||||||
fireEvent(this, "save-script");
|
fireEvent(this, "save-script");
|
||||||
}
|
}
|
||||||
|
|
||||||
private _getCollapsableElements() {
|
|
||||||
return this.shadowRoot!.querySelectorAll<
|
|
||||||
HaAutomationAction | HaScriptFields
|
|
||||||
>("ha-automation-action, ha-script-fields");
|
|
||||||
}
|
|
||||||
|
|
||||||
public expandAll() {
|
public expandAll() {
|
||||||
this._getCollapsableElements().forEach((element) => {
|
this._collapsableElements?.forEach((element) => {
|
||||||
element.expandAll();
|
element.expandAll();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public collapseAll() {
|
public collapseAll() {
|
||||||
this._getCollapsableElements().forEach((element) => {
|
this._collapsableElements?.forEach((element) => {
|
||||||
element.collapseAll();
|
element.collapseAll();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public copySelectedRow() {
|
||||||
|
if ((this._sidebarConfig as ActionSidebarConfig)?.copy) {
|
||||||
|
(this._sidebarConfig as ActionSidebarConfig).copy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public cutSelectedRow() {
|
||||||
|
if ((this._sidebarConfig as ActionSidebarConfig)?.cut) {
|
||||||
|
(this._sidebarConfig as ActionSidebarConfig).cut();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public deleteSelectedRow() {
|
||||||
|
if ((this._sidebarConfig as ActionSidebarConfig)?.delete) {
|
||||||
|
(this._sidebarConfig as ActionSidebarConfig).delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static get styles(): CSSResultGroup {
|
static get styles(): CSSResultGroup {
|
||||||
return [
|
return [
|
||||||
saveFabStyles,
|
saveFabStyles,
|
||||||
|
|||||||
@@ -54,6 +54,10 @@ class DeveloperToolsRouter extends HassRouterPage {
|
|||||||
tag: "developer-tools-debug",
|
tag: "developer-tools-debug",
|
||||||
load: () => import("./debug/developer-tools-debug"),
|
load: () => import("./debug/developer-tools-debug"),
|
||||||
},
|
},
|
||||||
|
"time-picker": {
|
||||||
|
tag: "developer-tools-time-picker",
|
||||||
|
load: () => import("../time-picker/ha-panel-time-picker"),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -80,6 +80,13 @@ class PanelDeveloperTools extends LitElement {
|
|||||||
<sl-tab slot="nav" panel="assist" .active=${page === "assist"}
|
<sl-tab slot="nav" panel="assist" .active=${page === "assist"}
|
||||||
>Assist</sl-tab
|
>Assist</sl-tab
|
||||||
>
|
>
|
||||||
|
<sl-tab
|
||||||
|
slot="nav"
|
||||||
|
panel="time-picker"
|
||||||
|
.active=${page === "time-picker"}
|
||||||
|
>
|
||||||
|
Time Picker
|
||||||
|
</sl-tab>
|
||||||
</sl-tab-group>
|
</sl-tab-group>
|
||||||
</div>
|
</div>
|
||||||
<developer-tools-router
|
<developer-tools-router
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import { customElement, property, state } from "lit/decorators";
|
|||||||
import { computeDomain } from "../../../common/entity/compute_domain";
|
import { computeDomain } from "../../../common/entity/compute_domain";
|
||||||
import "../../../components/ha-control-button";
|
import "../../../components/ha-control-button";
|
||||||
import "../../../components/ha-control-button-group";
|
import "../../../components/ha-control-button-group";
|
||||||
|
import { hasScriptFields } from "../../../data/script";
|
||||||
|
import { showMoreInfoDialog } from "../../../dialogs/more-info/show-ha-more-info-dialog";
|
||||||
import type { HomeAssistant } from "../../../types";
|
import type { HomeAssistant } from "../../../types";
|
||||||
import type { LovelaceCardFeature, LovelaceCardFeatureEditor } from "../types";
|
import type { LovelaceCardFeature, LovelaceCardFeatureEditor } from "../types";
|
||||||
import { cardFeatureStyles } from "./common/card-feature-styles";
|
import { cardFeatureStyles } from "./common/card-feature-styles";
|
||||||
@@ -46,6 +48,14 @@ class HuiButtonCardFeature extends LitElement implements LovelaceCardFeature {
|
|||||||
const service =
|
const service =
|
||||||
domain === "button" || domain === "input_button" ? "press" : "turn_on";
|
domain === "button" || domain === "input_button" ? "press" : "turn_on";
|
||||||
|
|
||||||
|
if (domain === "script") {
|
||||||
|
const entityId = this._stateObj.entity_id;
|
||||||
|
if (hasScriptFields(this.hass!, entityId)) {
|
||||||
|
showMoreInfoDialog(this, { entityId: entityId });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.hass.callService(domain, service, {
|
this.hass.callService(domain, service, {
|
||||||
entity_id: this._stateObj.entity_id,
|
entity_id: this._stateObj.entity_id,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,317 +0,0 @@
|
|||||||
import { css, html, LitElement, nothing, svg } from "lit";
|
|
||||||
import { customElement, property, state } from "lit/decorators";
|
|
||||||
import { computeDomain } from "../../../common/entity/compute_domain";
|
|
||||||
import {
|
|
||||||
computeHistory,
|
|
||||||
subscribeHistoryStatesTimeWindow,
|
|
||||||
} from "../../../data/history";
|
|
||||||
import type {
|
|
||||||
HistoryResult,
|
|
||||||
LineChartUnit,
|
|
||||||
TimelineEntity,
|
|
||||||
} from "../../../data/history";
|
|
||||||
import type { HomeAssistant } from "../../../types";
|
|
||||||
import type { LovelaceCardFeature } from "../types";
|
|
||||||
import type {
|
|
||||||
LovelaceCardFeatureContext,
|
|
||||||
HistoryChartCardFeatureConfig,
|
|
||||||
} from "./types";
|
|
||||||
import { getSensorNumericDeviceClasses } from "../../../data/sensor";
|
|
||||||
import { isComponentLoaded } from "../../../common/config/is_component_loaded";
|
|
||||||
import { SubscribeMixin } from "../../../mixins/subscribe-mixin";
|
|
||||||
import { computeTimelineColor } from "../../../components/chart/timeline-color";
|
|
||||||
import { downSampleLineData } from "../../../components/chart/down-sample";
|
|
||||||
import { fireEvent } from "../../../common/dom/fire_event";
|
|
||||||
|
|
||||||
export const supportsHistoryChartCardFeature = (
|
|
||||||
_hass: HomeAssistant,
|
|
||||||
context: LovelaceCardFeatureContext
|
|
||||||
) =>
|
|
||||||
!!context.entity_id &&
|
|
||||||
["sensor", "binary_sensor"].includes(computeDomain(context.entity_id));
|
|
||||||
|
|
||||||
@customElement("hui-history-chart-card-feature")
|
|
||||||
class HuiHistoryChartCardFeature
|
|
||||||
extends SubscribeMixin(LitElement)
|
|
||||||
implements LovelaceCardFeature
|
|
||||||
{
|
|
||||||
@property({ attribute: false, hasChanged: () => false })
|
|
||||||
public hass?: HomeAssistant;
|
|
||||||
|
|
||||||
@property({ attribute: false }) public context?: LovelaceCardFeatureContext;
|
|
||||||
|
|
||||||
@state() private _config?: HistoryChartCardFeatureConfig;
|
|
||||||
|
|
||||||
@state() private _stateHistory?: HistoryResult;
|
|
||||||
|
|
||||||
private _interval?: number;
|
|
||||||
|
|
||||||
static getStubConfig(): HistoryChartCardFeatureConfig {
|
|
||||||
return {
|
|
||||||
type: "history-chart",
|
|
||||||
hours_to_show: 24,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public setConfig(config: HistoryChartCardFeatureConfig): void {
|
|
||||||
if (!config) {
|
|
||||||
throw new Error("Invalid configuration");
|
|
||||||
}
|
|
||||||
this._config = config;
|
|
||||||
}
|
|
||||||
|
|
||||||
public connectedCallback() {
|
|
||||||
super.connectedCallback();
|
|
||||||
// redraw the graph every minute to update the time axis
|
|
||||||
clearInterval(this._interval);
|
|
||||||
this._interval = window.setInterval(() => this.requestUpdate(), 1000 * 60);
|
|
||||||
}
|
|
||||||
|
|
||||||
public disconnectedCallback() {
|
|
||||||
super.disconnectedCallback();
|
|
||||||
clearInterval(this._interval);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected hassSubscribe() {
|
|
||||||
return [this._subscribeHistory()];
|
|
||||||
}
|
|
||||||
|
|
||||||
protected render() {
|
|
||||||
if (
|
|
||||||
!this._config ||
|
|
||||||
!this.hass ||
|
|
||||||
!this.context ||
|
|
||||||
!this._stateHistory ||
|
|
||||||
!supportsHistoryChartCardFeature(this.hass, this.context)
|
|
||||||
) {
|
|
||||||
return nothing;
|
|
||||||
}
|
|
||||||
|
|
||||||
const line = this._stateHistory.line[0];
|
|
||||||
const timeline = this._stateHistory.timeline[0];
|
|
||||||
const width = this.clientWidth;
|
|
||||||
const height = this.clientHeight;
|
|
||||||
if (line) {
|
|
||||||
const { points, yAxisOrigin } = this._generateLinePoints(line);
|
|
||||||
const { paths, filledPaths } = this._getLinePaths(points, yAxisOrigin);
|
|
||||||
|
|
||||||
return html`
|
|
||||||
<div class="line" @click=${this._handleClick}>
|
|
||||||
${svg`<svg width="${width}" height="${height}" viewBox="0 0 ${width} ${height}">
|
|
||||||
${paths.map(
|
|
||||||
(path) =>
|
|
||||||
svg`<path d="${path}" stroke="var(--feature-color)" stroke-width="1" stroke-linecap="round" fill="none" />`
|
|
||||||
)}
|
|
||||||
${filledPaths.map(
|
|
||||||
(path) =>
|
|
||||||
svg`<path d="${path}" stroke="none" stroke-linecap="round" fill="var(--feature-color)" fill-opacity="0.2" />`
|
|
||||||
)}
|
|
||||||
</svg>`}
|
|
||||||
</div>
|
|
||||||
`;
|
|
||||||
}
|
|
||||||
if (timeline) {
|
|
||||||
const ranges = this._generateTimelineRanges(timeline);
|
|
||||||
return html`
|
|
||||||
<div class="timeline" @click=${this._handleClick}>
|
|
||||||
${svg`<svg width="${width}" height="${height}" viewBox="0 0 ${width} ${height}">
|
|
||||||
<g>
|
|
||||||
${ranges.map((r) => svg`<rect x="${r.startX}" y="0" width="${r.endX - r.startX}" height="${height}" fill="${r.color}" />`)}
|
|
||||||
</g>
|
|
||||||
</svg>`}
|
|
||||||
</div>
|
|
||||||
`;
|
|
||||||
}
|
|
||||||
return nothing;
|
|
||||||
}
|
|
||||||
|
|
||||||
private _handleClick() {
|
|
||||||
// open more info dialog to show more detailed history
|
|
||||||
fireEvent(this, "hass-more-info", { entityId: this.context!.entity_id! });
|
|
||||||
}
|
|
||||||
|
|
||||||
private async _subscribeHistory(): Promise<() => Promise<void>> {
|
|
||||||
if (
|
|
||||||
!isComponentLoaded(this.hass!, "history") ||
|
|
||||||
!this.context?.entity_id ||
|
|
||||||
!this._config
|
|
||||||
) {
|
|
||||||
return () => Promise.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
const { numeric_device_classes: sensorNumericDeviceClasses } =
|
|
||||||
await getSensorNumericDeviceClasses(this.hass!);
|
|
||||||
|
|
||||||
return subscribeHistoryStatesTimeWindow(
|
|
||||||
this.hass!,
|
|
||||||
(historyStates) => {
|
|
||||||
this._stateHistory = computeHistory(
|
|
||||||
this.hass!,
|
|
||||||
historyStates,
|
|
||||||
[this.context!.entity_id!],
|
|
||||||
this.hass!.localize,
|
|
||||||
sensorNumericDeviceClasses,
|
|
||||||
false
|
|
||||||
);
|
|
||||||
},
|
|
||||||
this._config!.hours_to_show ?? 24,
|
|
||||||
[this.context!.entity_id!]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private _generateLinePoints(line: LineChartUnit): {
|
|
||||||
points: { x: number; y: number }[];
|
|
||||||
yAxisOrigin: number;
|
|
||||||
} {
|
|
||||||
const width = this.clientWidth;
|
|
||||||
const height = this.clientHeight;
|
|
||||||
let yAxisOrigin = height;
|
|
||||||
let minY = Number(line.data[0].states[0].state);
|
|
||||||
let maxY = Number(line.data[0].states[0].state);
|
|
||||||
const minX = line.data[0].states[0].last_changed;
|
|
||||||
const maxX = Date.now();
|
|
||||||
line.data[0].states.forEach((stateData) => {
|
|
||||||
const stateValue = Number(stateData.state);
|
|
||||||
if (stateValue < minY) {
|
|
||||||
minY = stateValue;
|
|
||||||
} else if (stateValue > maxY) {
|
|
||||||
maxY = stateValue;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
const rangeY = maxY - minY || minY * 0.1;
|
|
||||||
const sampledData = downSampleLineData(
|
|
||||||
line.data[0].states.map((stateData) => [
|
|
||||||
stateData.last_changed,
|
|
||||||
Number(stateData.state),
|
|
||||||
]),
|
|
||||||
width,
|
|
||||||
minX,
|
|
||||||
maxX
|
|
||||||
);
|
|
||||||
if (maxY < 0) {
|
|
||||||
// all values are negative
|
|
||||||
// add margin
|
|
||||||
maxY += rangeY * 0.1;
|
|
||||||
maxY = Math.min(0, maxY);
|
|
||||||
yAxisOrigin = 0;
|
|
||||||
} else if (minY < 0) {
|
|
||||||
// some values are negative
|
|
||||||
yAxisOrigin = (maxY / (maxY - minY || 1)) * height;
|
|
||||||
} else {
|
|
||||||
// all values are positive
|
|
||||||
// add margin
|
|
||||||
minY -= rangeY * 0.1;
|
|
||||||
minY = Math.max(0, minY);
|
|
||||||
}
|
|
||||||
const yDenom = maxY - minY || 1;
|
|
||||||
const xDenom = maxX - minX || 1;
|
|
||||||
const points = sampledData!.map((point) => {
|
|
||||||
const x = ((point![0] - minX) / xDenom) * width;
|
|
||||||
const y = height - ((Number(point![1]) - minY) / yDenom) * height;
|
|
||||||
return { x, y };
|
|
||||||
});
|
|
||||||
points.push({ x: width, y: points[points.length - 1].y });
|
|
||||||
return { points, yAxisOrigin };
|
|
||||||
}
|
|
||||||
|
|
||||||
private _generateTimelineRanges(timeline: TimelineEntity) {
|
|
||||||
if (timeline.data.length === 0) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
const computedStyles = getComputedStyle(this);
|
|
||||||
const width = this.clientWidth;
|
|
||||||
const minX = timeline.data[0].last_changed;
|
|
||||||
const maxX = Date.now();
|
|
||||||
let prevEndX = 0;
|
|
||||||
let prevStateColor = "";
|
|
||||||
const ranges = timeline.data.map((t) => {
|
|
||||||
const x = ((t.last_changed - minX) / (maxX - minX)) * width;
|
|
||||||
const range = {
|
|
||||||
startX: prevEndX,
|
|
||||||
endX: x,
|
|
||||||
color: prevStateColor,
|
|
||||||
};
|
|
||||||
prevStateColor = computeTimelineColor(
|
|
||||||
t.state,
|
|
||||||
computedStyles,
|
|
||||||
this.hass!.states[timeline.entity_id]
|
|
||||||
);
|
|
||||||
prevEndX = x;
|
|
||||||
return range;
|
|
||||||
});
|
|
||||||
ranges.push({
|
|
||||||
startX: prevEndX,
|
|
||||||
endX: width,
|
|
||||||
color: prevStateColor,
|
|
||||||
});
|
|
||||||
return ranges;
|
|
||||||
}
|
|
||||||
|
|
||||||
private _getLinePaths(
|
|
||||||
points: { x: number; y: number }[],
|
|
||||||
yAxisOrigin: number
|
|
||||||
) {
|
|
||||||
const paths: string[] = [];
|
|
||||||
const filledPaths: string[] = [];
|
|
||||||
if (!points.length) {
|
|
||||||
return { paths, filledPaths };
|
|
||||||
}
|
|
||||||
// path can interupted by missing data, so we need to split the path into segments
|
|
||||||
const pathSegments: { x: number; y: number }[][] = [[]];
|
|
||||||
points.forEach((point) => {
|
|
||||||
if (!isNaN(point.y)) {
|
|
||||||
pathSegments[pathSegments.length - 1].push(point);
|
|
||||||
} else if (pathSegments[pathSegments.length - 1].length > 0) {
|
|
||||||
pathSegments.push([]);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
pathSegments.forEach((pathPoints) => {
|
|
||||||
// create a smoothed path
|
|
||||||
let next: { x: number; y: number };
|
|
||||||
let path = "";
|
|
||||||
let last = pathPoints[0];
|
|
||||||
|
|
||||||
path += `M ${last.x},${last.y}`;
|
|
||||||
|
|
||||||
pathPoints.forEach((coord) => {
|
|
||||||
next = coord;
|
|
||||||
path += ` ${(next.x + last.x) / 2},${(next.y + last.y) / 2}`;
|
|
||||||
path += ` Q${next.x},${next.y}`;
|
|
||||||
last = next;
|
|
||||||
});
|
|
||||||
|
|
||||||
path += ` ${next!.x},${next!.y}`;
|
|
||||||
paths.push(path);
|
|
||||||
filledPaths.push(
|
|
||||||
path +
|
|
||||||
` L ${next!.x},${yAxisOrigin} L ${pathPoints[0].x},${yAxisOrigin} Z`
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
return { paths, filledPaths };
|
|
||||||
}
|
|
||||||
|
|
||||||
static styles = css`
|
|
||||||
:host {
|
|
||||||
display: block;
|
|
||||||
width: 100%;
|
|
||||||
height: var(--feature-height);
|
|
||||||
}
|
|
||||||
:host > div {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
.timeline {
|
|
||||||
border-radius: 4px;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
}
|
|
||||||
|
|
||||||
declare global {
|
|
||||||
interface HTMLElementTagNameMap {
|
|
||||||
"hui-history-chart-card-feature": HuiHistoryChartCardFeature;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,157 @@
|
|||||||
|
import { css, html, LitElement, nothing } from "lit";
|
||||||
|
import { customElement, property, state } from "lit/decorators";
|
||||||
|
import { isComponentLoaded } from "../../../common/config/is_component_loaded";
|
||||||
|
import { computeDomain } from "../../../common/entity/compute_domain";
|
||||||
|
import { isNumericFromAttributes } from "../../../common/number/format_number";
|
||||||
|
import "../../../components/ha-spinner";
|
||||||
|
import { subscribeHistoryStatesTimeWindow } from "../../../data/history";
|
||||||
|
import { SubscribeMixin } from "../../../mixins/subscribe-mixin";
|
||||||
|
import type { HomeAssistant } from "../../../types";
|
||||||
|
import { coordinatesMinimalResponseCompressedState } from "../common/graph/coordinates";
|
||||||
|
import "../components/hui-graph-base";
|
||||||
|
import type { LovelaceCardFeature } from "../types";
|
||||||
|
import type {
|
||||||
|
TrendGraphCardFeatureConfig,
|
||||||
|
LovelaceCardFeatureContext,
|
||||||
|
} from "./types";
|
||||||
|
|
||||||
|
export const supportsTrendGraphCardFeature = (
|
||||||
|
hass: HomeAssistant,
|
||||||
|
context: LovelaceCardFeatureContext
|
||||||
|
) => {
|
||||||
|
const stateObj = context.entity_id
|
||||||
|
? hass.states[context.entity_id]
|
||||||
|
: undefined;
|
||||||
|
if (!stateObj) return false;
|
||||||
|
const domain = computeDomain(stateObj.entity_id);
|
||||||
|
return domain === "sensor" && isNumericFromAttributes(stateObj.attributes);
|
||||||
|
};
|
||||||
|
|
||||||
|
const DEFAULT_HOURS_TO_SHOW = 24;
|
||||||
|
|
||||||
|
@customElement("hui-trend-graph-card-feature")
|
||||||
|
class HuiHistoryChartCardFeature
|
||||||
|
extends SubscribeMixin(LitElement)
|
||||||
|
implements LovelaceCardFeature
|
||||||
|
{
|
||||||
|
@property({ attribute: false, hasChanged: () => false })
|
||||||
|
public hass?: HomeAssistant;
|
||||||
|
|
||||||
|
@property({ attribute: false }) public context?: LovelaceCardFeatureContext;
|
||||||
|
|
||||||
|
@state() private _config?: TrendGraphCardFeatureConfig;
|
||||||
|
|
||||||
|
@state() private _coordinates?: [number, number][];
|
||||||
|
|
||||||
|
private _interval?: number;
|
||||||
|
|
||||||
|
static getStubConfig(): TrendGraphCardFeatureConfig {
|
||||||
|
return {
|
||||||
|
type: "trend-graph",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public setConfig(config: TrendGraphCardFeatureConfig): void {
|
||||||
|
if (!config) {
|
||||||
|
throw new Error("Invalid configuration");
|
||||||
|
}
|
||||||
|
this._config = config;
|
||||||
|
}
|
||||||
|
|
||||||
|
public connectedCallback() {
|
||||||
|
super.connectedCallback();
|
||||||
|
// redraw the graph every minute to update the time axis
|
||||||
|
clearInterval(this._interval);
|
||||||
|
this._interval = window.setInterval(() => this.requestUpdate(), 1000 * 60);
|
||||||
|
}
|
||||||
|
|
||||||
|
public disconnectedCallback() {
|
||||||
|
super.disconnectedCallback();
|
||||||
|
clearInterval(this._interval);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected hassSubscribe() {
|
||||||
|
return [this._subscribeHistory()];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected render() {
|
||||||
|
if (
|
||||||
|
!this._config ||
|
||||||
|
!this.hass ||
|
||||||
|
!this.context ||
|
||||||
|
!supportsTrendGraphCardFeature(this.hass, this.context)
|
||||||
|
) {
|
||||||
|
return nothing;
|
||||||
|
}
|
||||||
|
if (!this._coordinates) {
|
||||||
|
return html`
|
||||||
|
<div class="container">
|
||||||
|
<ha-spinner size="small"></ha-spinner>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
if (!this._coordinates.length) {
|
||||||
|
return html`
|
||||||
|
<div class="container">
|
||||||
|
<div class="info">No state history found.</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
return html`
|
||||||
|
<hui-graph-base .coordinates=${this._coordinates}></hui-graph-base>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async _subscribeHistory(): Promise<() => Promise<void>> {
|
||||||
|
if (
|
||||||
|
!isComponentLoaded(this.hass!, "history") ||
|
||||||
|
!this.context?.entity_id ||
|
||||||
|
!this._config
|
||||||
|
) {
|
||||||
|
return () => Promise.resolve();
|
||||||
|
}
|
||||||
|
|
||||||
|
const hourToShow = this._config.hours_to_show ?? DEFAULT_HOURS_TO_SHOW;
|
||||||
|
|
||||||
|
return subscribeHistoryStatesTimeWindow(
|
||||||
|
this.hass!,
|
||||||
|
(historyStates) => {
|
||||||
|
this._coordinates =
|
||||||
|
coordinatesMinimalResponseCompressedState(
|
||||||
|
historyStates[this.context!.entity_id!],
|
||||||
|
hourToShow,
|
||||||
|
500,
|
||||||
|
2,
|
||||||
|
undefined
|
||||||
|
) || [];
|
||||||
|
},
|
||||||
|
hourToShow,
|
||||||
|
[this.context!.entity_id!]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static styles = css`
|
||||||
|
:host {
|
||||||
|
display: flex;
|
||||||
|
width: 100%;
|
||||||
|
height: var(--feature-height);
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: flex-end;
|
||||||
|
align-items: flex-end;
|
||||||
|
pointer-events: none !important;
|
||||||
|
}
|
||||||
|
hui-graph-base {
|
||||||
|
width: 100%;
|
||||||
|
--accent-color: var(--feature-color);
|
||||||
|
border-bottom-right-radius: 8px;
|
||||||
|
border-bottom-left-radius: 8px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface HTMLElementTagNameMap {
|
||||||
|
"hui-trend-graph-card-feature": HuiHistoryChartCardFeature;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -187,9 +187,9 @@ export interface UpdateActionsCardFeatureConfig {
|
|||||||
backup?: "yes" | "no" | "ask";
|
backup?: "yes" | "no" | "ask";
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface HistoryChartCardFeatureConfig {
|
export interface TrendGraphCardFeatureConfig {
|
||||||
type: "history-chart";
|
type: "trend-graph";
|
||||||
hours_to_show: number;
|
hours_to_show?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const AREA_CONTROLS = [
|
export const AREA_CONTROLS = [
|
||||||
@@ -239,7 +239,7 @@ export type LovelaceCardFeatureConfig =
|
|||||||
| FanOscillateCardFeatureConfig
|
| FanOscillateCardFeatureConfig
|
||||||
| FanPresetModesCardFeatureConfig
|
| FanPresetModesCardFeatureConfig
|
||||||
| FanSpeedCardFeatureConfig
|
| FanSpeedCardFeatureConfig
|
||||||
| HistoryChartCardFeatureConfig
|
| TrendGraphCardFeatureConfig
|
||||||
| HumidifierToggleCardFeatureConfig
|
| HumidifierToggleCardFeatureConfig
|
||||||
| HumidifierModesCardFeatureConfig
|
| HumidifierModesCardFeatureConfig
|
||||||
| LawnMowerCommandsCardFeatureConfig
|
| LawnMowerCommandsCardFeatureConfig
|
||||||
@@ -251,7 +251,7 @@ export type LovelaceCardFeatureConfig =
|
|||||||
| MediaPlayerVolumeSliderCardFeatureConfig
|
| MediaPlayerVolumeSliderCardFeatureConfig
|
||||||
| NumericInputCardFeatureConfig
|
| NumericInputCardFeatureConfig
|
||||||
| SelectOptionsCardFeatureConfig
|
| SelectOptionsCardFeatureConfig
|
||||||
| HistoryChartCardFeatureConfig
|
| TrendGraphCardFeatureConfig
|
||||||
| TargetHumidityCardFeatureConfig
|
| TargetHumidityCardFeatureConfig
|
||||||
| TargetTemperatureCardFeatureConfig
|
| TargetTemperatureCardFeatureConfig
|
||||||
| ToggleCardFeatureConfig
|
| ToggleCardFeatureConfig
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ import type { HomeSummaryCard } from "./types";
|
|||||||
const COLORS: Record<HomeSummary, string> = {
|
const COLORS: Record<HomeSummary, string> = {
|
||||||
lights: "amber",
|
lights: "amber",
|
||||||
climate: "deep-orange",
|
climate: "deep-orange",
|
||||||
security: "blue",
|
security: "blue-grey",
|
||||||
media_players: "purple",
|
media_players: "blue",
|
||||||
};
|
};
|
||||||
|
|
||||||
@customElement("hui-home-summary-card")
|
@customElement("hui-home-summary-card")
|
||||||
@@ -119,7 +119,7 @@ export class HuiHomeSummaryCard extends LitElement implements LovelaceCard {
|
|||||||
|
|
||||||
const sensorsValues = areaSensors
|
const sensorsValues = areaSensors
|
||||||
.map(
|
.map(
|
||||||
(entityId) => parseFloat(this.hass!.states[entityId!].state) || NaN
|
(entityId) => parseFloat(this.hass!.states[entityId!]?.state) || NaN
|
||||||
)
|
)
|
||||||
.filter((value) => !isNaN(value));
|
.filter((value) => !isNaN(value));
|
||||||
|
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ const calcPoints = (
|
|||||||
detail: number,
|
detail: number,
|
||||||
min: number,
|
min: number,
|
||||||
max: number
|
max: number
|
||||||
): number[][] => {
|
): [number, number][] => {
|
||||||
const coords = [] as number[][];
|
const coords = [] as [number, number][];
|
||||||
const height = 80;
|
const height = 80;
|
||||||
let yRatio = (max - min) / height;
|
let yRatio = (max - min) / height;
|
||||||
yRatio = yRatio !== 0 ? yRatio : height;
|
yRatio = yRatio !== 0 ? yRatio : height;
|
||||||
@@ -61,7 +61,7 @@ export const coordinates = (
|
|||||||
width: number,
|
width: number,
|
||||||
detail: number,
|
detail: number,
|
||||||
limits?: { min?: number; max?: number }
|
limits?: { min?: number; max?: number }
|
||||||
): number[][] | undefined => {
|
): [number, number][] | undefined => {
|
||||||
history.forEach((item) => {
|
history.forEach((item) => {
|
||||||
item.state = Number(item.state);
|
item.state = Number(item.state);
|
||||||
});
|
});
|
||||||
@@ -119,7 +119,7 @@ export const coordinatesMinimalResponseCompressedState = (
|
|||||||
width: number,
|
width: number,
|
||||||
detail: number,
|
detail: number,
|
||||||
limits?: { min?: number; max?: number }
|
limits?: { min?: number; max?: number }
|
||||||
): number[][] | undefined => {
|
): [number, number][] | undefined => {
|
||||||
if (!history) {
|
if (!history) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ export class HuiGraphBase extends LitElement {
|
|||||||
protected render(): TemplateResult {
|
protected render(): TemplateResult {
|
||||||
return html`
|
return html`
|
||||||
${this._path
|
${this._path
|
||||||
? svg`<svg width="100%" height="100%" viewBox="0 0 500 100">
|
? svg`<svg width="100%" height="100%" viewBox="0 0 500 100" preserveAspectRatio="none">
|
||||||
<g>
|
<g>
|
||||||
<mask id="fill">
|
<mask id="fill">
|
||||||
<path
|
<path
|
||||||
@@ -25,8 +25,10 @@ export class HuiGraphBase extends LitElement {
|
|||||||
<rect height="100%" width="100%" id="fill-rect" fill="var(--accent-color)" mask="url(#fill)"></rect>
|
<rect height="100%" width="100%" id="fill-rect" fill="var(--accent-color)" mask="url(#fill)"></rect>
|
||||||
<mask id="line">
|
<mask id="line">
|
||||||
<path
|
<path
|
||||||
|
vector-effect="non-scaling-stroke"
|
||||||
|
class='line'
|
||||||
fill="none"
|
fill="none"
|
||||||
stroke="var(--accent-color)"
|
stroke="white"
|
||||||
stroke-width="${strokeWidth}"
|
stroke-width="${strokeWidth}"
|
||||||
stroke-linecap="round"
|
stroke-linecap="round"
|
||||||
stroke-linejoin="round"
|
stroke-linejoin="round"
|
||||||
@@ -54,6 +56,10 @@ export class HuiGraphBase extends LitElement {
|
|||||||
:host {
|
:host {
|
||||||
display: flex;
|
display: flex;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
.line {
|
||||||
|
opacity: 0.8;
|
||||||
}
|
}
|
||||||
.fill {
|
.fill {
|
||||||
opacity: 0.1;
|
opacity: 0.1;
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ import "../card-features/hui-valve-position-card-feature";
|
|||||||
import "../card-features/hui-water-heater-operation-modes-card-feature";
|
import "../card-features/hui-water-heater-operation-modes-card-feature";
|
||||||
import "../card-features/hui-area-controls-card-feature";
|
import "../card-features/hui-area-controls-card-feature";
|
||||||
import "../card-features/hui-bar-gauge-card-feature";
|
import "../card-features/hui-bar-gauge-card-feature";
|
||||||
import "../card-features/hui-history-chart-card-feature";
|
import "../card-features/hui-trend-graph-card-feature";
|
||||||
|
|
||||||
import type { LovelaceCardFeatureConfig } from "../card-features/types";
|
import type { LovelaceCardFeatureConfig } from "../card-features/types";
|
||||||
import {
|
import {
|
||||||
@@ -75,7 +75,7 @@ const TYPES = new Set<LovelaceCardFeatureConfig["type"]>([
|
|||||||
"media-player-volume-slider",
|
"media-player-volume-slider",
|
||||||
"numeric-input",
|
"numeric-input",
|
||||||
"select-options",
|
"select-options",
|
||||||
"history-chart",
|
"trend-graph",
|
||||||
"target-humidity",
|
"target-humidity",
|
||||||
"target-temperature",
|
"target-temperature",
|
||||||
"toggle",
|
"toggle",
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ import { supportsMediaPlayerPlaybackCardFeature } from "../../card-features/hui-
|
|||||||
import { supportsMediaPlayerVolumeSliderCardFeature } from "../../card-features/hui-media-player-volume-slider-card-feature";
|
import { supportsMediaPlayerVolumeSliderCardFeature } from "../../card-features/hui-media-player-volume-slider-card-feature";
|
||||||
import { supportsNumericInputCardFeature } from "../../card-features/hui-numeric-input-card-feature";
|
import { supportsNumericInputCardFeature } from "../../card-features/hui-numeric-input-card-feature";
|
||||||
import { supportsSelectOptionsCardFeature } from "../../card-features/hui-select-options-card-feature";
|
import { supportsSelectOptionsCardFeature } from "../../card-features/hui-select-options-card-feature";
|
||||||
import { supportsHistoryChartCardFeature } from "../../card-features/hui-history-chart-card-feature";
|
import { supportsTrendGraphCardFeature } from "../../card-features/hui-trend-graph-card-feature";
|
||||||
import { supportsTargetHumidityCardFeature } from "../../card-features/hui-target-humidity-card-feature";
|
import { supportsTargetHumidityCardFeature } from "../../card-features/hui-target-humidity-card-feature";
|
||||||
import { supportsTargetTemperatureCardFeature } from "../../card-features/hui-target-temperature-card-feature";
|
import { supportsTargetTemperatureCardFeature } from "../../card-features/hui-target-temperature-card-feature";
|
||||||
import { supportsToggleCardFeature } from "../../card-features/hui-toggle-card-feature";
|
import { supportsToggleCardFeature } from "../../card-features/hui-toggle-card-feature";
|
||||||
@@ -100,7 +100,7 @@ const UI_FEATURE_TYPES = [
|
|||||||
"media-player-volume-slider",
|
"media-player-volume-slider",
|
||||||
"numeric-input",
|
"numeric-input",
|
||||||
"select-options",
|
"select-options",
|
||||||
"history-chart",
|
"trend-graph",
|
||||||
"target-humidity",
|
"target-humidity",
|
||||||
"target-temperature",
|
"target-temperature",
|
||||||
"toggle",
|
"toggle",
|
||||||
@@ -168,7 +168,7 @@ const SUPPORTS_FEATURE_TYPES: Record<
|
|||||||
"media-player-volume-slider": supportsMediaPlayerVolumeSliderCardFeature,
|
"media-player-volume-slider": supportsMediaPlayerVolumeSliderCardFeature,
|
||||||
"numeric-input": supportsNumericInputCardFeature,
|
"numeric-input": supportsNumericInputCardFeature,
|
||||||
"select-options": supportsSelectOptionsCardFeature,
|
"select-options": supportsSelectOptionsCardFeature,
|
||||||
"history-chart": supportsHistoryChartCardFeature,
|
"trend-graph": supportsTrendGraphCardFeature,
|
||||||
"target-humidity": supportsTargetHumidityCardFeature,
|
"target-humidity": supportsTargetHumidityCardFeature,
|
||||||
"target-temperature": supportsTargetTemperatureCardFeature,
|
"target-temperature": supportsTargetTemperatureCardFeature,
|
||||||
toggle: supportsToggleCardFeature,
|
toggle: supportsToggleCardFeature,
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ export class HuiGraphHeaderFooter
|
|||||||
|
|
||||||
@state() protected _config?: GraphHeaderFooterConfig;
|
@state() protected _config?: GraphHeaderFooterConfig;
|
||||||
|
|
||||||
@state() private _coordinates?: number[][];
|
@state() private _coordinates?: [number, number][];
|
||||||
|
|
||||||
private _error?: string;
|
private _error?: string;
|
||||||
|
|
||||||
|
|||||||
@@ -12,30 +12,11 @@ import {
|
|||||||
} from "../areas/helpers/areas-strategy-helper";
|
} from "../areas/helpers/areas-strategy-helper";
|
||||||
import { getHomeStructure } from "./helpers/home-structure";
|
import { getHomeStructure } from "./helpers/home-structure";
|
||||||
import { findEntities, HOME_SUMMARIES_FILTERS } from "./helpers/home-summaries";
|
import { findEntities, HOME_SUMMARIES_FILTERS } from "./helpers/home-summaries";
|
||||||
import { computeStateName } from "../../../../common/entity/compute_state_name";
|
|
||||||
import { computeObjectId } from "../../../../common/entity/compute_object_id";
|
|
||||||
|
|
||||||
export interface HomeClimateViewStrategyConfig {
|
export interface HomeClimateViewStrategyConfig {
|
||||||
type: "home-climate";
|
type: "home-climate";
|
||||||
}
|
}
|
||||||
|
|
||||||
const createTempHumidBadge = (hass: HomeAssistant, entityId: string) => {
|
|
||||||
const stateObj = hass.states[entityId];
|
|
||||||
return {
|
|
||||||
type: "tile",
|
|
||||||
entity: entityId,
|
|
||||||
name: stateObj
|
|
||||||
? computeStateName(stateObj)
|
|
||||||
: computeObjectId(entityId).replace(/_/g, " "),
|
|
||||||
features: [
|
|
||||||
{
|
|
||||||
type: "history-chart",
|
|
||||||
hours_to_show: 3,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
const processAreasForClimate = (
|
const processAreasForClimate = (
|
||||||
areaIds: string[],
|
areaIds: string[],
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
@@ -52,8 +33,28 @@ const processAreasForClimate = (
|
|||||||
area: area.area_id,
|
area: area.area_id,
|
||||||
});
|
});
|
||||||
const areaEntities = entities.filter(areaFilter);
|
const areaEntities = entities.filter(areaFilter);
|
||||||
|
const areaCards: LovelaceCardConfig[] = [];
|
||||||
|
|
||||||
if (areaEntities.length > 0) {
|
const temperatureEntityId = area.temperature_entity_id;
|
||||||
|
if (temperatureEntityId && hass.states[temperatureEntityId]) {
|
||||||
|
areaCards.push({
|
||||||
|
...computeTileCard(temperatureEntityId),
|
||||||
|
features: [{ type: "trend-graph" }],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const humidityEntityId = area.humidity_entity_id;
|
||||||
|
if (humidityEntityId && hass.states[humidityEntityId]) {
|
||||||
|
areaCards.push({
|
||||||
|
...computeTileCard(humidityEntityId),
|
||||||
|
features: [{ type: "trend-graph" }],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const entityId of areaEntities) {
|
||||||
|
areaCards.push(computeTileCard(entityId));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (areaCards.length > 0) {
|
||||||
cards.push({
|
cards.push({
|
||||||
heading_style: "subtitle",
|
heading_style: "subtitle",
|
||||||
type: "heading",
|
type: "heading",
|
||||||
@@ -63,21 +64,7 @@ const processAreasForClimate = (
|
|||||||
navigation_path: `areas-${area.area_id}`,
|
navigation_path: `areas-${area.area_id}`,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
cards.push(...areaCards);
|
||||||
if (hass.areas[areaId].temperature_entity_id) {
|
|
||||||
cards.push(
|
|
||||||
createTempHumidBadge(hass, hass.areas[areaId].temperature_entity_id)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (hass.areas[areaId].humidity_entity_id) {
|
|
||||||
cards.push(
|
|
||||||
createTempHumidBadge(hass, hass.areas[areaId].humidity_entity_id)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const entityId of areaEntities) {
|
|
||||||
cards.push(computeTileCard(entityId));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,10 +32,15 @@ const processAreasForLights = (
|
|||||||
area: area.area_id,
|
area: area.area_id,
|
||||||
});
|
});
|
||||||
const areaLights = entities.filter(areaFilter);
|
const areaLights = entities.filter(areaFilter);
|
||||||
|
const areaCards: LovelaceCardConfig[] = [];
|
||||||
|
|
||||||
const computeTileCard = computeAreaTileCardConfig(hass, "", false);
|
const computeTileCard = computeAreaTileCardConfig(hass, "", false);
|
||||||
|
|
||||||
if (areaLights.length > 0) {
|
for (const entityId of areaLights) {
|
||||||
|
areaCards.push(computeTileCard(entityId));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (areaCards.length > 0) {
|
||||||
cards.push({
|
cards.push({
|
||||||
heading_style: "subtitle",
|
heading_style: "subtitle",
|
||||||
type: "heading",
|
type: "heading",
|
||||||
@@ -45,10 +50,7 @@ const processAreasForLights = (
|
|||||||
navigation_path: `areas-${area.area_id}`,
|
navigation_path: `areas-${area.area_id}`,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
cards.push(...areaCards);
|
||||||
for (const entityId of areaLights) {
|
|
||||||
cards.push(computeTileCard(entityId));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -207,6 +207,7 @@ export class HomeMainViewStrategy extends ReactiveElement {
|
|||||||
"ui.panel.lovelace.cards.energy.energy_distribution.title_today"
|
"ui.panel.lovelace.cards.energy.energy_distribution.title_today"
|
||||||
),
|
),
|
||||||
type: "energy-distribution",
|
type: "energy-distribution",
|
||||||
|
collection_key: "energy_home_dashboard",
|
||||||
link_dashboard: true,
|
link_dashboard: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,14 @@ const processAreasForMediaPlayers = (
|
|||||||
area: area.area_id,
|
area: area.area_id,
|
||||||
});
|
});
|
||||||
const areaEntities = entities.filter(areaFilter);
|
const areaEntities = entities.filter(areaFilter);
|
||||||
|
const areaCards: LovelaceCardConfig[] = [];
|
||||||
|
|
||||||
|
for (const entityId of areaEntities) {
|
||||||
|
cards.push({
|
||||||
|
type: "media-control",
|
||||||
|
entity: entityId,
|
||||||
|
} satisfies MediaControlCardConfig);
|
||||||
|
}
|
||||||
|
|
||||||
if (areaEntities.length > 0) {
|
if (areaEntities.length > 0) {
|
||||||
cards.push({
|
cards.push({
|
||||||
@@ -40,13 +48,7 @@ const processAreasForMediaPlayers = (
|
|||||||
navigation_path: `areas-${area.area_id}`,
|
navigation_path: `areas-${area.area_id}`,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
cards.push(...areaCards);
|
||||||
for (const entityId of areaEntities) {
|
|
||||||
cards.push({
|
|
||||||
type: "media-control",
|
|
||||||
entity: entityId,
|
|
||||||
} satisfies MediaControlCardConfig);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,9 +12,6 @@ import {
|
|||||||
} from "../areas/helpers/areas-strategy-helper";
|
} from "../areas/helpers/areas-strategy-helper";
|
||||||
import { getHomeStructure } from "./helpers/home-structure";
|
import { getHomeStructure } from "./helpers/home-structure";
|
||||||
import { findEntities, HOME_SUMMARIES_FILTERS } from "./helpers/home-summaries";
|
import { findEntities, HOME_SUMMARIES_FILTERS } from "./helpers/home-summaries";
|
||||||
import { computeDomain } from "../../../../common/entity/compute_domain";
|
|
||||||
import { computeStateName } from "../../../../common/entity/compute_state_name";
|
|
||||||
import { computeObjectId } from "../../../../common/entity/compute_object_id";
|
|
||||||
|
|
||||||
export interface HomeSecurityViewStrategyConfig {
|
export interface HomeSecurityViewStrategyConfig {
|
||||||
type: "home-security";
|
type: "home-security";
|
||||||
@@ -35,7 +32,13 @@ const processAreasForSecurity = (
|
|||||||
const areaFilter = generateEntityFilter(hass, {
|
const areaFilter = generateEntityFilter(hass, {
|
||||||
area: area.area_id,
|
area: area.area_id,
|
||||||
});
|
});
|
||||||
|
|
||||||
const areaEntities = entities.filter(areaFilter);
|
const areaEntities = entities.filter(areaFilter);
|
||||||
|
const areaCards: LovelaceCardConfig[] = [];
|
||||||
|
|
||||||
|
for (const entityId of areaEntities) {
|
||||||
|
areaCards.push(computeTileCard(entityId));
|
||||||
|
}
|
||||||
|
|
||||||
if (areaEntities.length > 0) {
|
if (areaEntities.length > 0) {
|
||||||
cards.push({
|
cards.push({
|
||||||
@@ -47,28 +50,7 @@ const processAreasForSecurity = (
|
|||||||
navigation_path: `areas-${area.area_id}`,
|
navigation_path: `areas-${area.area_id}`,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
cards.push(...areaCards);
|
||||||
for (const entityId of areaEntities) {
|
|
||||||
const stateObj = hass.states[entityId];
|
|
||||||
cards.push(
|
|
||||||
computeDomain(entityId) === "binary_sensor" &&
|
|
||||||
stateObj?.attributes.device_class === "motion"
|
|
||||||
? {
|
|
||||||
type: "tile",
|
|
||||||
entity: entityId,
|
|
||||||
name: stateObj
|
|
||||||
? computeStateName(stateObj)
|
|
||||||
: computeObjectId(entityId).replace(/_/g, " "),
|
|
||||||
features: [
|
|
||||||
{
|
|
||||||
type: "history-chart",
|
|
||||||
hours_to_show: 6,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
}
|
|
||||||
: computeTileCard(entityId)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
180
src/panels/time-picker/ha-panel-time-picker.ts
Normal file
180
src/panels/time-picker/ha-panel-time-picker.ts
Normal file
@@ -0,0 +1,180 @@
|
|||||||
|
import { html, LitElement, css } from "lit";
|
||||||
|
import { customElement, property, state } from "lit/decorators";
|
||||||
|
import type { HomeAssistant } from "../../types";
|
||||||
|
import "../../components/ha-time-picker";
|
||||||
|
import "../../components/ha-card";
|
||||||
|
import "../../components/ha-button";
|
||||||
|
import "../../components/ha-alert";
|
||||||
|
import "../../components/ha-selector/ha-selector";
|
||||||
|
|
||||||
|
@customElement("developer-tools-time-picker")
|
||||||
|
export class DeveloperToolsTimePicker extends LitElement {
|
||||||
|
@property({ attribute: false })
|
||||||
|
public hass!: HomeAssistant;
|
||||||
|
|
||||||
|
@property({ type: Boolean, reflect: true })
|
||||||
|
public narrow = false;
|
||||||
|
|
||||||
|
@state()
|
||||||
|
private _timeValue = "14:15:00";
|
||||||
|
|
||||||
|
@state()
|
||||||
|
private _timeValue2 = "09:05:05";
|
||||||
|
|
||||||
|
static get styles() {
|
||||||
|
return css`
|
||||||
|
:host {
|
||||||
|
display: block;
|
||||||
|
padding: 16px;
|
||||||
|
max-width: 800px;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header {
|
||||||
|
margin-bottom: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header h1 {
|
||||||
|
margin: 0 0 8px 0;
|
||||||
|
color: var(--primary-text-color);
|
||||||
|
font-size: 28px;
|
||||||
|
font-weight: 400;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header p {
|
||||||
|
margin: 0;
|
||||||
|
color: var(--secondary-text-color);
|
||||||
|
font-size: 16px;
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section {
|
||||||
|
margin-bottom: 32px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section h2 {
|
||||||
|
margin: 0 0 16px 0;
|
||||||
|
color: var(--primary-text-color);
|
||||||
|
font-size: 20px;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.example {
|
||||||
|
background: var(--card-background-color);
|
||||||
|
border-radius: 12px;
|
||||||
|
padding: 24px;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
border: 1px solid var(--divider-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.example h3 {
|
||||||
|
margin: 0 0 16px 0;
|
||||||
|
color: var(--primary-text-color);
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.time-picker-container {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 16px;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.value-display {
|
||||||
|
background: var(--secondary-background-color);
|
||||||
|
padding: 8px 12px;
|
||||||
|
border-radius: 6px;
|
||||||
|
font-family: monospace;
|
||||||
|
font-size: 14px;
|
||||||
|
color: var(--primary-text-color);
|
||||||
|
min-width: 100px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.controls {
|
||||||
|
display: flex;
|
||||||
|
gap: 12px;
|
||||||
|
align-items: center;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-toggle {
|
||||||
|
margin-top: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 600px) {
|
||||||
|
:host {
|
||||||
|
padding: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.time-picker-container {
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: stretch;
|
||||||
|
}
|
||||||
|
|
||||||
|
.controls {
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: stretch;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected render() {
|
||||||
|
return html`
|
||||||
|
<div class="header">
|
||||||
|
<h1>Time picker demo</h1>
|
||||||
|
<p>
|
||||||
|
This page demonstrates the ha-time-picker component with various
|
||||||
|
configurations and use cases.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="section">
|
||||||
|
<h2>Time picker</h2>
|
||||||
|
<div class="example">
|
||||||
|
<div class="time-picker-container">
|
||||||
|
<ha-time-picker
|
||||||
|
.locale=${this.hass.locale}
|
||||||
|
.value=${this._timeValue}
|
||||||
|
@value-changed=${this._onTimeChanged}
|
||||||
|
></ha-time-picker>
|
||||||
|
<div class="value-display">${this._timeValue}</div>
|
||||||
|
</div>
|
||||||
|
<p>Current value: ${this._timeValue}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="section">
|
||||||
|
<h2>Time picker with seconds</h2>
|
||||||
|
<div class="example">
|
||||||
|
<div class="time-picker-container">
|
||||||
|
<ha-time-picker
|
||||||
|
.locale=${this.hass.locale}
|
||||||
|
.value=${this._timeValue2}
|
||||||
|
.enableSeconds=${true}
|
||||||
|
@value-changed=${this._onTime2Changed}
|
||||||
|
></ha-time-picker>
|
||||||
|
<div class="value-display">${this._timeValue2}</div>
|
||||||
|
</div>
|
||||||
|
<p>Current value: ${this._timeValue2}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
private _onTimeChanged(ev: CustomEvent) {
|
||||||
|
this._timeValue = ev.detail.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private _onTime2Changed(ev: CustomEvent) {
|
||||||
|
this._timeValue2 = ev.detail.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface HTMLElementTagNameMap {
|
||||||
|
"developer-tools-time-picker": DeveloperToolsTimePicker;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -218,6 +218,7 @@ export const colorStyles = css`
|
|||||||
--table-row-alternative-background-color: var(--secondary-background-color);
|
--table-row-alternative-background-color: var(--secondary-background-color);
|
||||||
--data-table-background-color: var(--card-background-color);
|
--data-table-background-color: var(--card-background-color);
|
||||||
--markdown-code-background-color: var(--primary-background-color);
|
--markdown-code-background-color: var(--primary-background-color);
|
||||||
|
--bar-box-shadow: 0 2px 12px rgba(0, 0, 0, 0.16);
|
||||||
|
|
||||||
/* https://github.com/material-components/material-web/blob/master/docs/theming.md */
|
/* https://github.com/material-components/material-web/blob/master/docs/theming.md */
|
||||||
--mdc-theme-primary: var(--primary-color);
|
--mdc-theme-primary: var(--primary-color);
|
||||||
@@ -246,6 +247,7 @@ export const colorStyles = css`
|
|||||||
--mdc-dialog-scroll-divider-color: var(--divider-color);
|
--mdc-dialog-scroll-divider-color: var(--divider-color);
|
||||||
--mdc-dialog-heading-ink-color: var(--primary-text-color);
|
--mdc-dialog-heading-ink-color: var(--primary-text-color);
|
||||||
--mdc-dialog-content-ink-color: var(--primary-text-color);
|
--mdc-dialog-content-ink-color: var(--primary-text-color);
|
||||||
|
--mdc-top-app-bar-fixed-box-shadow: var(--bar-box-shadow);
|
||||||
|
|
||||||
--mdc-text-field-idle-line-color: var(--input-idle-line-color);
|
--mdc-text-field-idle-line-color: var(--input-idle-line-color);
|
||||||
--mdc-text-field-hover-line-color: var(--input-hover-line-color);
|
--mdc-text-field-hover-line-color: var(--input-hover-line-color);
|
||||||
@@ -360,6 +362,8 @@ export const darkColorStyles = css`
|
|||||||
--ha-button-warning-light-color: #917b54c1;
|
--ha-button-warning-light-color: #917b54c1;
|
||||||
--ha-button-neutral-color: #d9dae0;
|
--ha-button-neutral-color: #d9dae0;
|
||||||
--ha-button-neutral-light-color: #6a7081;
|
--ha-button-neutral-light-color: #6a7081;
|
||||||
|
|
||||||
|
--bar-box-shadow: 0 2px 12px rgba(0, 0, 0, 0.48);
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
"config": "Settings",
|
"config": "Settings",
|
||||||
"states": "Overview",
|
"states": "Overview",
|
||||||
"map": "Map",
|
"map": "Map",
|
||||||
"logbook": "Activity",
|
"logbook": "Logbook",
|
||||||
"history": "History",
|
"history": "History",
|
||||||
"todo": "To-do lists",
|
"todo": "To-do lists",
|
||||||
"developer_tools": "Developer tools",
|
"developer_tools": "Developer tools",
|
||||||
@@ -526,7 +526,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"logbook": {
|
"logbook": {
|
||||||
"entries_not_found": "No activity found.",
|
"entries_not_found": "No logbook events found.",
|
||||||
"triggered_by": "triggered by",
|
"triggered_by": "triggered by",
|
||||||
"triggered_by_automation": "triggered by automation",
|
"triggered_by_automation": "triggered by automation",
|
||||||
"triggered_by_script": "triggered by script",
|
"triggered_by_script": "triggered by script",
|
||||||
@@ -539,7 +539,7 @@
|
|||||||
"triggered_by_homeassistant_stopping": "triggered by Home Assistant stopping",
|
"triggered_by_homeassistant_stopping": "triggered by Home Assistant stopping",
|
||||||
"triggered_by_homeassistant_starting": "triggered by Home Assistant starting",
|
"triggered_by_homeassistant_starting": "triggered by Home Assistant starting",
|
||||||
"show_trace": "[%key:ui::panel::config::automation::editor::show_trace%]",
|
"show_trace": "[%key:ui::panel::config::automation::editor::show_trace%]",
|
||||||
"retrieval_error": "Could not load activity",
|
"retrieval_error": "Could not load logbook",
|
||||||
"not_loaded": "[%key:ui::dialogs::helper_settings::platform_not_loaded%]",
|
"not_loaded": "[%key:ui::dialogs::helper_settings::platform_not_loaded%]",
|
||||||
"messages": {
|
"messages": {
|
||||||
"was_away": "was detected away",
|
"was_away": "was detected away",
|
||||||
@@ -678,7 +678,7 @@
|
|||||||
},
|
},
|
||||||
"subpage-data-table": {
|
"subpage-data-table": {
|
||||||
"filters": "Filters",
|
"filters": "Filters",
|
||||||
"show_results": "show {number} results",
|
"show_results": "Show {number} results",
|
||||||
"clear_filter": "Clear filter",
|
"clear_filter": "Clear filter",
|
||||||
"close_filter": "Close filters",
|
"close_filter": "Close filters",
|
||||||
"exit_selection_mode": "Exit selection mode",
|
"exit_selection_mode": "Exit selection mode",
|
||||||
@@ -1382,8 +1382,13 @@
|
|||||||
"info": "Information",
|
"info": "Information",
|
||||||
"related": "Related",
|
"related": "Related",
|
||||||
"history": "History",
|
"history": "History",
|
||||||
"logbook": "Activity",
|
"logbook": "Logbook",
|
||||||
"device_info": "Device info",
|
"device_info": "Device info",
|
||||||
|
"device_or_service_info": "[%key:ui::panel::config::devices::device_info%]",
|
||||||
|
"device_type": {
|
||||||
|
"device": "[%key:ui::panel::config::devices::type::device_heading%]",
|
||||||
|
"service": "[%key:ui::panel::config::devices::type::service_heading%]"
|
||||||
|
},
|
||||||
"last_changed": "Last changed",
|
"last_changed": "Last changed",
|
||||||
"last_updated": "Last updated",
|
"last_updated": "Last updated",
|
||||||
"show_more": "Show more",
|
"show_more": "Show more",
|
||||||
@@ -1614,7 +1619,7 @@
|
|||||||
"preload_stream": "Preload camera stream",
|
"preload_stream": "Preload camera stream",
|
||||||
"preload_stream_description": "This keeps the camera stream open in the background so it shows quicker. Warning! This is device intensive.",
|
"preload_stream_description": "This keeps the camera stream open in the background so it shows quicker. Warning! This is device intensive.",
|
||||||
"stream_orientation": "Camera stream orientation",
|
"stream_orientation": "Camera stream orientation",
|
||||||
"stream_orientation_description": "The orientation transformation to use for the camera stream.",
|
"stream_orientation_description": "The orientation transformation to use for the camera stream.\nWarning: Stream orientation processing occurs on the Home Assistant device and may impact system performance. When possible, configure this setting directly on your camera instead.",
|
||||||
"stream_orientation_1": "No orientation transform",
|
"stream_orientation_1": "No orientation transform",
|
||||||
"stream_orientation_2": "Mirror",
|
"stream_orientation_2": "Mirror",
|
||||||
"stream_orientation_3": "Rotate 180",
|
"stream_orientation_3": "Rotate 180",
|
||||||
@@ -2038,8 +2043,7 @@
|
|||||||
"shortcuts": {
|
"shortcuts": {
|
||||||
"double_click": "Double-click",
|
"double_click": "Double-click",
|
||||||
"scroll_wheel": "Scroll",
|
"scroll_wheel": "Scroll",
|
||||||
"drag": "Drag",
|
"drag": "Drag"
|
||||||
"ctrl_cmd": "Ctrl/Cmd"
|
|
||||||
},
|
},
|
||||||
"searching": {
|
"searching": {
|
||||||
"title": "Searching",
|
"title": "Searching",
|
||||||
@@ -2056,6 +2060,9 @@
|
|||||||
},
|
},
|
||||||
"automation_script": {
|
"automation_script": {
|
||||||
"title": "Automations / Scripts",
|
"title": "Automations / Scripts",
|
||||||
|
"copy": "to copy the selected item to clipboard",
|
||||||
|
"cut": "to cut the selected item and place it on the clipboard",
|
||||||
|
"delete": "to delete the selected item",
|
||||||
"paste": "to paste automation/script YAML from clipboard to editor",
|
"paste": "to paste automation/script YAML from clipboard to editor",
|
||||||
"save": "to save automation/script"
|
"save": "to save automation/script"
|
||||||
},
|
},
|
||||||
@@ -3856,6 +3863,9 @@
|
|||||||
"type_script_plural": "[%key:ui::panel::config::blueprint::overview::types_plural::script%]",
|
"type_script_plural": "[%key:ui::panel::config::blueprint::overview::types_plural::script%]",
|
||||||
"new_automation_setup_failed_title": "New {type} setup failed",
|
"new_automation_setup_failed_title": "New {type} setup failed",
|
||||||
"new_automation_setup_failed_text": "Your new {type} has saved, but waiting for it to setup has timed out. This could be due to errors parsing your configuration.yaml, please check the configuration in developer tools. Your {type} will not be visible until this is corrected, and {types} are reloaded. Changes to area, category, or labels were not saved and must be reapplied.",
|
"new_automation_setup_failed_text": "Your new {type} has saved, but waiting for it to setup has timed out. This could be due to errors parsing your configuration.yaml, please check the configuration in developer tools. Your {type} will not be visible until this is corrected, and {types} are reloaded. Changes to area, category, or labels were not saved and must be reapplied.",
|
||||||
|
"item_pasted": "{item} pasted",
|
||||||
|
"ctrl": "Ctrl",
|
||||||
|
"del": "Del",
|
||||||
"triggers": {
|
"triggers": {
|
||||||
"name": "Triggers",
|
"name": "Triggers",
|
||||||
"header": "When",
|
"header": "When",
|
||||||
@@ -3882,6 +3892,8 @@
|
|||||||
"unknown_trigger": "[%key:ui::panel::config::devices::automation::triggers::unknown_trigger%]",
|
"unknown_trigger": "[%key:ui::panel::config::devices::automation::triggers::unknown_trigger%]",
|
||||||
"triggering_event_detail": "Triggering event detail",
|
"triggering_event_detail": "Triggering event detail",
|
||||||
"trigger": "Trigger",
|
"trigger": "Trigger",
|
||||||
|
"copied_to_clipboard": "Trigger copied to clipboard",
|
||||||
|
"cut_to_clipboard": "Trigger cut to clipboard",
|
||||||
"groups": {
|
"groups": {
|
||||||
"entity": {
|
"entity": {
|
||||||
"label": "Entity",
|
"label": "Entity",
|
||||||
@@ -4144,6 +4156,8 @@
|
|||||||
"type_select": "Condition type",
|
"type_select": "Condition type",
|
||||||
"unknown_condition": "[%key:ui::panel::config::devices::automation::conditions::unknown_condition%]",
|
"unknown_condition": "[%key:ui::panel::config::devices::automation::conditions::unknown_condition%]",
|
||||||
"condition": "Condition",
|
"condition": "Condition",
|
||||||
|
"copied_to_clipboard": "Condition copied to clipboard",
|
||||||
|
"cut_to_clipboard": "Condition cut to clipboard",
|
||||||
"groups": {
|
"groups": {
|
||||||
"entity": {
|
"entity": {
|
||||||
"label": "Entity",
|
"label": "Entity",
|
||||||
@@ -4313,6 +4327,8 @@
|
|||||||
"type_select": "Action type",
|
"type_select": "Action type",
|
||||||
"continue_on_error": "Continue on error",
|
"continue_on_error": "Continue on error",
|
||||||
"action": "Action",
|
"action": "Action",
|
||||||
|
"copied_to_clipboard": "Action copied to clipboard",
|
||||||
|
"cut_to_clipboard": "Action cut to clipboard",
|
||||||
"groups": {
|
"groups": {
|
||||||
"helpers": {
|
"helpers": {
|
||||||
"label": "Helpers"
|
"label": "Helpers"
|
||||||
@@ -4577,7 +4593,7 @@
|
|||||||
"tabs": {
|
"tabs": {
|
||||||
"details": "Step details",
|
"details": "Step details",
|
||||||
"timeline": "Trace timeline",
|
"timeline": "Trace timeline",
|
||||||
"logbook": "Related activity",
|
"logbook": "Related logbook entries",
|
||||||
"automation_config": "Automation config",
|
"automation_config": "Automation config",
|
||||||
"step_config": "Step config",
|
"step_config": "Step config",
|
||||||
"changed_variables": "Changed variables",
|
"changed_variables": "Changed variables",
|
||||||
@@ -4594,7 +4610,7 @@
|
|||||||
"error": "Error: {error}",
|
"error": "Error: {error}",
|
||||||
"result": "Result:",
|
"result": "Result:",
|
||||||
"step_not_executed": "This step was not executed.",
|
"step_not_executed": "This step was not executed.",
|
||||||
"no_logbook_entries": "No activity found for this step.",
|
"no_logbook_entries": "No logbook entries found for this step.",
|
||||||
"no_variables_changed": "No variables changed",
|
"no_variables_changed": "No variables changed",
|
||||||
"unable_to_find_config": "Unable to find config"
|
"unable_to_find_config": "Unable to find config"
|
||||||
},
|
},
|
||||||
@@ -4620,8 +4636,8 @@
|
|||||||
"disabled": "(disabled)",
|
"disabled": "(disabled)",
|
||||||
"triggered_by": "{triggeredBy, select, \n alias {{alias} triggered}\n other {Triggered} \n} {triggeredPath, select, \n trigger {by the {trigger}}\n other {manually} \n} at {time}",
|
"triggered_by": "{triggeredBy, select, \n alias {{alias} triggered}\n other {Triggered} \n} {triggeredPath, select, \n trigger {by the {trigger}}\n other {manually} \n} at {time}",
|
||||||
"path_error": "Unable to extract path {path}. Download trace and report as bug.",
|
"path_error": "Unable to extract path {path}. Download trace and report as bug.",
|
||||||
"not_all_entries_are_related_automation_note": "Not all shown activity might be related to this automation.",
|
"not_all_entries_are_related_automation_note": "Not all shown logbook entries might be related to this automation.",
|
||||||
"not_all_entries_are_related_script_note": "Not all shown activity might be related to this script."
|
"not_all_entries_are_related_script_note": "Not all shown logbook entries might be related to this script."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -5724,6 +5740,16 @@
|
|||||||
"no_advertisements_found": "No matching Bluetooth advertisements found",
|
"no_advertisements_found": "No matching Bluetooth advertisements found",
|
||||||
"no_connection_slot_allocations": "No connection slot allocations information available",
|
"no_connection_slot_allocations": "No connection slot allocations information available",
|
||||||
"no_active_connection_support": "This adapter does not support making active (GATT) connections.",
|
"no_active_connection_support": "This adapter does not support making active (GATT) connections.",
|
||||||
|
"no_scanner_state_available": "No scanner state available",
|
||||||
|
"current_scanning_mode": "Current scanning mode",
|
||||||
|
"requested_scanning_mode": "Requested scanning mode",
|
||||||
|
"scanning_mode_none": "none",
|
||||||
|
"scanning_mode_active": "active",
|
||||||
|
"scanning_mode_passive": "passive",
|
||||||
|
"scanner_mode_mismatch": "Scanner requested {requested} mode but is operating in {current} mode. The scanner is in a bad state and needs to be power cycled.",
|
||||||
|
"scanner_mode_mismatch_remote": "For proxies: reboot the device",
|
||||||
|
"scanner_mode_mismatch_usb": "For USB adapters: unplug and plug back in",
|
||||||
|
"scanner_mode_mismatch_uart": "For UART/onboard adapters: power down the system completely and power it back up",
|
||||||
"address": "Address",
|
"address": "Address",
|
||||||
"name": "Name",
|
"name": "Name",
|
||||||
"source": "Source",
|
"source": "Source",
|
||||||
@@ -7538,8 +7564,8 @@
|
|||||||
"square": "Render cards as squares"
|
"square": "Render cards as squares"
|
||||||
},
|
},
|
||||||
"logbook": {
|
"logbook": {
|
||||||
"name": "Activity",
|
"name": "Logbook",
|
||||||
"description": "The Activity card shows a list of events for entities."
|
"description": "The Logbook card shows a list of events for entities."
|
||||||
},
|
},
|
||||||
"history-graph": {
|
"history-graph": {
|
||||||
"name": "History graph",
|
"name": "History graph",
|
||||||
@@ -8180,8 +8206,8 @@
|
|||||||
"bar-gauge": {
|
"bar-gauge": {
|
||||||
"label": "Bar gauge"
|
"label": "Bar gauge"
|
||||||
},
|
},
|
||||||
"history-chart": {
|
"trend-graph": {
|
||||||
"label": "History chart"
|
"label": "Trend graph"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
10
yarn.lock
10
yarn.lock
@@ -4445,10 +4445,10 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"@types/chromecast-caf-receiver@npm:6.0.22":
|
"@types/chromecast-caf-receiver@npm:6.0.24":
|
||||||
version: 6.0.22
|
version: 6.0.24
|
||||||
resolution: "@types/chromecast-caf-receiver@npm:6.0.22"
|
resolution: "@types/chromecast-caf-receiver@npm:6.0.24"
|
||||||
checksum: 10/6c51cb52527776ddfa187a261b88184c98bdd61c129dd8719cba213894d565cf69073734d6473696ffd60a768f6fb5a3fe9932693f43174fbc5e7af201db8a90
|
checksum: 10/1f2b95e8a15dbb36d5328895229d4a5cb255b33e62d46335bd6ed75e16aa9ea6a7d765a64ae120d19b3134fb3e51e9547d2544c7277f7bffe0bf0b3999f026da
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
@@ -9385,7 +9385,7 @@ __metadata:
|
|||||||
"@tsparticles/engine": "npm:3.9.1"
|
"@tsparticles/engine": "npm:3.9.1"
|
||||||
"@tsparticles/preset-links": "npm:3.2.0"
|
"@tsparticles/preset-links": "npm:3.2.0"
|
||||||
"@types/babel__plugin-transform-runtime": "npm:7.9.5"
|
"@types/babel__plugin-transform-runtime": "npm:7.9.5"
|
||||||
"@types/chromecast-caf-receiver": "npm:6.0.22"
|
"@types/chromecast-caf-receiver": "npm:6.0.24"
|
||||||
"@types/chromecast-caf-sender": "npm:1.0.11"
|
"@types/chromecast-caf-sender": "npm:1.0.11"
|
||||||
"@types/color-name": "npm:2.0.0"
|
"@types/color-name": "npm:2.0.0"
|
||||||
"@types/culori": "npm:4.0.0"
|
"@types/culori": "npm:4.0.0"
|
||||||
|
|||||||
Reference in New Issue
Block a user