mirror of
				https://github.com/home-assistant/frontend.git
				synced 2025-11-04 00:19:47 +00:00 
			
		
		
		
	Compare commits
	
		
			140 Commits
		
	
	
		
			20220424.0
			...
			zwave-js-m
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					e5f64bb26d | ||
| 
						 | 
					6faa3eb848 | ||
| 
						 | 
					ce77ddf365 | ||
| 
						 | 
					cf05fbaa9d | ||
| 
						 | 
					552c474feb | ||
| 
						 | 
					a4f8e886bc | ||
| 
						 | 
					cc0c96b8b4 | ||
| 
						 | 
					445f0e23fe | ||
| 
						 | 
					6f240297d1 | ||
| 
						 | 
					6da4981b70 | ||
| 
						 | 
					cfadf4d700 | ||
| 
						 | 
					7e60de0531 | ||
| 
						 | 
					aaef6d7b91 | ||
| 
						 | 
					58c5ce2638 | ||
| 
						 | 
					a9d01c7b55 | ||
| 
						 | 
					c5de8a4361 | ||
| 
						 | 
					b53645ce92 | ||
| 
						 | 
					de34a5a597 | ||
| 
						 | 
					bd8e15bdd1 | ||
| 
						 | 
					45c7e0eeeb | ||
| 
						 | 
					a35a380ec7 | ||
| 
						 | 
					02e67d1146 | ||
| 
						 | 
					a5411f7ac4 | ||
| 
						 | 
					e8da203fe1 | ||
| 
						 | 
					10aa0a8829 | ||
| 
						 | 
					85a37e2d2f | ||
| 
						 | 
					ba8621fa2c | ||
| 
						 | 
					43e80f1a2e | ||
| 
						 | 
					3a305a44b6 | ||
| 
						 | 
					e99143139e | ||
| 
						 | 
					f0c7232704 | ||
| 
						 | 
					b2186592df | ||
| 
						 | 
					e51e3e79d5 | ||
| 
						 | 
					3b6b4d7664 | ||
| 
						 | 
					239e71b414 | ||
| 
						 | 
					080cad0ccd | ||
| 
						 | 
					dd49fd2788 | ||
| 
						 | 
					a571fb5528 | ||
| 
						 | 
					1369c1ae8c | ||
| 
						 | 
					f5864181af | ||
| 
						 | 
					a4a0d7cf19 | ||
| 
						 | 
					092dfd1e87 | ||
| 
						 | 
					a29ac33810 | ||
| 
						 | 
					1421df2a5a | ||
| 
						 | 
					591b8cc503 | ||
| 
						 | 
					011467ece0 | ||
| 
						 | 
					f52e8c3392 | ||
| 
						 | 
					c8b87b65bd | ||
| 
						 | 
					98cc82db44 | ||
| 
						 | 
					f510e2a8e0 | ||
| 
						 | 
					3438912ba5 | ||
| 
						 | 
					671c8e387f | ||
| 
						 | 
					0108ec65cf | ||
| 
						 | 
					39f7034578 | ||
| 
						 | 
					bf8affaf2b | ||
| 
						 | 
					e16a61eb53 | ||
| 
						 | 
					cadbe45bab | ||
| 
						 | 
					51f971337d | ||
| 
						 | 
					1f3c23de29 | ||
| 
						 | 
					bdfb17d957 | ||
| 
						 | 
					8c97aee1fe | ||
| 
						 | 
					38b4090daa | ||
| 
						 | 
					b8c55f2f65 | ||
| 
						 | 
					7ca379e0a1 | ||
| 
						 | 
					1617a9dfed | ||
| 
						 | 
					2c9411c6c3 | ||
| 
						 | 
					67626d4a06 | ||
| 
						 | 
					8135611688 | ||
| 
						 | 
					3ccbf6983e | ||
| 
						 | 
					e4f91195d8 | ||
| 
						 | 
					2751f8f33b | ||
| 
						 | 
					57f2df3b3e | ||
| 
						 | 
					6822f0d067 | ||
| 
						 | 
					cfba957313 | ||
| 
						 | 
					3149ffbf19 | ||
| 
						 | 
					4cd8b76d7e | ||
| 
						 | 
					4b644d8bc5 | ||
| 
						 | 
					307cd5ad8c | ||
| 
						 | 
					ebc807a6a4 | ||
| 
						 | 
					66adecdfc9 | ||
| 
						 | 
					2cc6432a0f | ||
| 
						 | 
					a2c0c0474a | ||
| 
						 | 
					27884b9a54 | ||
| 
						 | 
					293df61872 | ||
| 
						 | 
					f82dada3e5 | ||
| 
						 | 
					e5824c4794 | ||
| 
						 | 
					186550229c | ||
| 
						 | 
					7877dd8e6b | ||
| 
						 | 
					b03abc249b | ||
| 
						 | 
					fda03918b9 | ||
| 
						 | 
					6747375a1b | ||
| 
						 | 
					53b6e31881 | ||
| 
						 | 
					fa004de2d1 | ||
| 
						 | 
					3605f7b70f | ||
| 
						 | 
					5348c54c91 | ||
| 
						 | 
					684e4421bc | ||
| 
						 | 
					28f5611df5 | ||
| 
						 | 
					8da73d49d7 | ||
| 
						 | 
					049ddd5f84 | ||
| 
						 | 
					8ae2d4e93a | ||
| 
						 | 
					824bb9ba35 | ||
| 
						 | 
					d550b1a18e | ||
| 
						 | 
					dea6c0e761 | ||
| 
						 | 
					9caee357c0 | ||
| 
						 | 
					35d892c418 | ||
| 
						 | 
					9572a2a46b | ||
| 
						 | 
					8996361b26 | ||
| 
						 | 
					02ee731602 | ||
| 
						 | 
					bb1e6bf35b | ||
| 
						 | 
					c1b65285c1 | ||
| 
						 | 
					8b8d6e5fa3 | ||
| 
						 | 
					c34fe184e8 | ||
| 
						 | 
					7363838f86 | ||
| 
						 | 
					3081425ccd | ||
| 
						 | 
					95d494a54c | ||
| 
						 | 
					145e5d7bc6 | ||
| 
						 | 
					876fd9e85a | ||
| 
						 | 
					e8c30cabca | ||
| 
						 | 
					490f84a7b1 | ||
| 
						 | 
					ca28178b86 | ||
| 
						 | 
					2fceb0aeee | ||
| 
						 | 
					86f39d1d43 | ||
| 
						 | 
					1faf60444d | ||
| 
						 | 
					e927091d21 | ||
| 
						 | 
					cff2f856b3 | ||
| 
						 | 
					a743e3bbba | ||
| 
						 | 
					f8a52d250e | ||
| 
						 | 
					b70a523bdf | ||
| 
						 | 
					8f2ed747e6 | ||
| 
						 | 
					5deccefb15 | ||
| 
						 | 
					3f04abfa9d | ||
| 
						 | 
					8e55c83996 | ||
| 
						 | 
					dee59486ba | ||
| 
						 | 
					77ef509aea | ||
| 
						 | 
					bfa7bccfa6 | ||
| 
						 | 
					a8c365edc8 | ||
| 
						 | 
					94953ddf6c | ||
| 
						 | 
					6b67546daf | ||
| 
						 | 
					3e188d1f87 | ||
| 
						 | 
					f69eb15a90 | 
							
								
								
									
										4
									
								
								.github/ISSUE_TEMPLATE/bug_report.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								.github/ISSUE_TEMPLATE/bug_report.yml
									
									
									
									
										vendored
									
									
								
							@@ -1,4 +1,4 @@
 | 
			
		||||
name: Report a bug with the UI, Frontend or Lovelace
 | 
			
		||||
name: Report a bug with the UI / Dashboards
 | 
			
		||||
description: Report an issue related to the Home Assistant frontend.
 | 
			
		||||
labels: bug
 | 
			
		||||
body:
 | 
			
		||||
@@ -9,7 +9,7 @@ body:
 | 
			
		||||
 | 
			
		||||
        If you have a feature or enhancement request for the frontend, please [start an discussion][fr] instead of creating an issue.
 | 
			
		||||
 | 
			
		||||
        **Please not not report issues for custom Lovelace cards.**
 | 
			
		||||
        **Please not not report issues for custom cards.**
 | 
			
		||||
 | 
			
		||||
        [fr]: https://github.com/home-assistant/frontend/discussions
 | 
			
		||||
        [releases]: https://github.com/home-assistant/home-assistant/releases
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										8
									
								
								.github/ISSUE_TEMPLATE/config.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										8
									
								
								.github/ISSUE_TEMPLATE/config.yml
									
									
									
									
										vendored
									
									
								
							@@ -1,17 +1,17 @@
 | 
			
		||||
blank_issues_enabled: false
 | 
			
		||||
contact_links:
 | 
			
		||||
  - name: Request a feature for the UI, Frontend or Lovelace
 | 
			
		||||
  - name: Request a feature for the UI / Dashboards
 | 
			
		||||
    url: https://github.com/home-assistant/frontend/discussions/category_choices
 | 
			
		||||
    about: Request an new feature for the Home Assistant frontend.
 | 
			
		||||
  - name: Report a bug that is NOT related to the UI, Frontend or Lovelace
 | 
			
		||||
  - name: Report a bug that is NOT related to the UI / Dashboards
 | 
			
		||||
    url: https://github.com/home-assistant/core/issues
 | 
			
		||||
    about: This is the issue tracker for our frontend. Please report other issues with the backend repository.
 | 
			
		||||
    about: This is the issue tracker for our frontend. Please report other issues in the backend ("core") repository.
 | 
			
		||||
  - name: Report incorrect or missing information on our website
 | 
			
		||||
    url: https://github.com/home-assistant/home-assistant.io/issues
 | 
			
		||||
    about: Our documentation has its own issue tracker. Please report issues with the website there.
 | 
			
		||||
  - name: I have a question or need support
 | 
			
		||||
    url: https://www.home-assistant.io/help
 | 
			
		||||
    about: We use GitHub for tracking bugs, check our website for resources on getting help.
 | 
			
		||||
    about: We use GitHub for tracking bugs. Check our website for resources on getting help.
 | 
			
		||||
  - name: I'm unsure where to go
 | 
			
		||||
    url: https://www.home-assistant.io/join-chat
 | 
			
		||||
    about: If you are unsure where to go, then joining our chat is recommended; Just ask!
 | 
			
		||||
 
 | 
			
		||||
@@ -3,10 +3,10 @@ const webpack = require("webpack");
 | 
			
		||||
const path = require("path");
 | 
			
		||||
const TerserPlugin = require("terser-webpack-plugin");
 | 
			
		||||
const { WebpackManifestPlugin } = require("webpack-manifest-plugin");
 | 
			
		||||
const paths = require("./paths.js");
 | 
			
		||||
const bundle = require("./bundle.js");
 | 
			
		||||
const log = require("fancy-log");
 | 
			
		||||
const WebpackBar = require("webpackbar");
 | 
			
		||||
const paths = require("./paths.js");
 | 
			
		||||
const bundle = require("./bundle.js");
 | 
			
		||||
 | 
			
		||||
class LogStartCompilePlugin {
 | 
			
		||||
  ignoredFirst = false;
 | 
			
		||||
@@ -138,6 +138,8 @@ const createWebpackConfig = ({
 | 
			
		||||
        "lit/directives/cache$": "lit/directives/cache.js",
 | 
			
		||||
        "lit/directives/repeat$": "lit/directives/repeat.js",
 | 
			
		||||
        "lit/polyfill-support$": "lit/polyfill-support.js",
 | 
			
		||||
        "@lit-labs/virtualizer/layouts/grid":
 | 
			
		||||
          "@lit-labs/virtualizer/layouts/grid.js",
 | 
			
		||||
      },
 | 
			
		||||
    },
 | 
			
		||||
    output: {
 | 
			
		||||
 
 | 
			
		||||
@@ -62,6 +62,45 @@ const ACTIONS = [
 | 
			
		||||
      entity_id: "input_boolean.toggle_4",
 | 
			
		||||
    },
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    parallel: [
 | 
			
		||||
      { scene: "scene.kitchen_morning" },
 | 
			
		||||
      {
 | 
			
		||||
        service: "media_player.play_media",
 | 
			
		||||
        target: { entity_id: "media_player.living_room" },
 | 
			
		||||
        data: { media_content_id: "", media_content_type: "" },
 | 
			
		||||
        metadata: { title: "Happy Song" },
 | 
			
		||||
      },
 | 
			
		||||
    ],
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    stop: "No one is home!",
 | 
			
		||||
  },
 | 
			
		||||
  { repeat: { count: 3, sequence: [{ delay: "00:00:01" }] } },
 | 
			
		||||
  {
 | 
			
		||||
    repeat: {
 | 
			
		||||
      for_each: ["bread", "butter", "cheese"],
 | 
			
		||||
      sequence: [{ delay: "00:00:01" }],
 | 
			
		||||
    },
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    if: [{ condition: "state" }],
 | 
			
		||||
    then: [{ delay: "00:00:01" }],
 | 
			
		||||
    else: [{ delay: "00:00:05" }],
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    choose: [
 | 
			
		||||
      {
 | 
			
		||||
        conditions: [{ condition: "state" }],
 | 
			
		||||
        sequence: [{ delay: "00:00:01" }],
 | 
			
		||||
      },
 | 
			
		||||
      {
 | 
			
		||||
        conditions: [{ condition: "sun" }],
 | 
			
		||||
        sequence: [{ delay: "00:00:05" }],
 | 
			
		||||
      },
 | 
			
		||||
    ],
 | 
			
		||||
    default: [{ delay: "00:00:03" }],
 | 
			
		||||
  },
 | 
			
		||||
];
 | 
			
		||||
 | 
			
		||||
@customElement("demo-automation-describe-action")
 | 
			
		||||
 
 | 
			
		||||
@@ -20,6 +20,10 @@ import { HaWaitForTriggerAction } from "../../../../src/panels/config/automation
 | 
			
		||||
import { HaWaitAction } from "../../../../src/panels/config/automation/action/types/ha-automation-action-wait_template";
 | 
			
		||||
import { Action } from "../../../../src/data/script";
 | 
			
		||||
import { HaConditionAction } from "../../../../src/panels/config/automation/action/types/ha-automation-action-condition";
 | 
			
		||||
import { HaParallelAction } from "../../../../src/panels/config/automation/action/types/ha-automation-action-parallel";
 | 
			
		||||
import { HaIfAction } from "../../../../src/panels/config/automation/action/types/ha-automation-action-if";
 | 
			
		||||
import { HaStopAction } from "../../../../src/panels/config/automation/action/types/ha-automation-action-stop";
 | 
			
		||||
import { HaPlayMediaAction } from "../../../../src/panels/config/automation/action/types/ha-automation-action-play_media";
 | 
			
		||||
 | 
			
		||||
const SCHEMAS: { name: string; actions: Action[] }[] = [
 | 
			
		||||
  { name: "Event", actions: [HaEventAction.defaultConfig] },
 | 
			
		||||
@@ -28,11 +32,15 @@ const SCHEMAS: { name: string; actions: Action[] }[] = [
 | 
			
		||||
  { name: "Condition", actions: [HaConditionAction.defaultConfig] },
 | 
			
		||||
  { name: "Delay", actions: [HaDelayAction.defaultConfig] },
 | 
			
		||||
  { name: "Scene", actions: [HaSceneAction.defaultConfig] },
 | 
			
		||||
  { name: "Play media", actions: [HaPlayMediaAction.defaultConfig] },
 | 
			
		||||
  { name: "Wait", actions: [HaWaitAction.defaultConfig] },
 | 
			
		||||
  { name: "WaitForTrigger", actions: [HaWaitForTriggerAction.defaultConfig] },
 | 
			
		||||
  { name: "Repeat", actions: [HaRepeatAction.defaultConfig] },
 | 
			
		||||
  { name: "If-Then", actions: [HaIfAction.defaultConfig] },
 | 
			
		||||
  { name: "Choose", actions: [HaChooseAction.defaultConfig] },
 | 
			
		||||
  { name: "Variables", actions: [{ variables: { hello: "1" } }] },
 | 
			
		||||
  { name: "Parallel", actions: [HaParallelAction.defaultConfig] },
 | 
			
		||||
  { name: "Stop", actions: [HaStopAction.defaultConfig] },
 | 
			
		||||
];
 | 
			
		||||
 | 
			
		||||
@customElement("demo-automation-editor-action")
 | 
			
		||||
@@ -86,6 +94,6 @@ class DemoHaAutomationEditorAction extends LitElement {
 | 
			
		||||
 | 
			
		||||
declare global {
 | 
			
		||||
  interface HTMLElementTagNameMap {
 | 
			
		||||
    "demo-ha-automation-editor-action": DemoHaAutomationEditorAction;
 | 
			
		||||
    "demo-automation-editor-action": DemoHaAutomationEditorAction;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -8,7 +8,7 @@ import { mockEntityRegistry } from "../../../../demo/src/stubs/entity_registry";
 | 
			
		||||
import { mockDeviceRegistry } from "../../../../demo/src/stubs/device_registry";
 | 
			
		||||
import { mockAreaRegistry } from "../../../../demo/src/stubs/area_registry";
 | 
			
		||||
import { mockHassioSupervisor } from "../../../../demo/src/stubs/hassio_supervisor";
 | 
			
		||||
import type { Condition } from "../../../../src/data/automation";
 | 
			
		||||
import type { ConditionWithShorthand } from "../../../../src/data/automation";
 | 
			
		||||
import "../../../../src/panels/config/automation/condition/ha-automation-condition";
 | 
			
		||||
import { HaDeviceCondition } from "../../../../src/panels/config/automation/condition/types/ha-automation-condition-device";
 | 
			
		||||
import { HaLogicalCondition } from "../../../../src/panels/config/automation/condition/types/ha-automation-condition-logical";
 | 
			
		||||
@@ -20,7 +20,7 @@ import { HaTimeCondition } from "../../../../src/panels/config/automation/condit
 | 
			
		||||
import { HaTriggerCondition } from "../../../../src/panels/config/automation/condition/types/ha-automation-condition-trigger";
 | 
			
		||||
import { HaZoneCondition } from "../../../../src/panels/config/automation/condition/types/ha-automation-condition-zone";
 | 
			
		||||
 | 
			
		||||
const SCHEMAS: { name: string; conditions: Condition[] }[] = [
 | 
			
		||||
const SCHEMAS: { name: string; conditions: ConditionWithShorthand[] }[] = [
 | 
			
		||||
  {
 | 
			
		||||
    name: "State",
 | 
			
		||||
    conditions: [{ condition: "state", ...HaStateCondition.defaultConfig }],
 | 
			
		||||
@@ -69,6 +69,14 @@ const SCHEMAS: { name: string; conditions: Condition[] }[] = [
 | 
			
		||||
    name: "Trigger",
 | 
			
		||||
    conditions: [{ condition: "trigger", ...HaTriggerCondition.defaultConfig }],
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    name: "Shorthand",
 | 
			
		||||
    conditions: [
 | 
			
		||||
      { and: HaLogicalCondition.defaultConfig.conditions },
 | 
			
		||||
      { or: HaLogicalCondition.defaultConfig.conditions },
 | 
			
		||||
      { not: HaLogicalCondition.defaultConfig.conditions },
 | 
			
		||||
    ],
 | 
			
		||||
  },
 | 
			
		||||
];
 | 
			
		||||
 | 
			
		||||
@customElement("demo-automation-editor-condition")
 | 
			
		||||
 
 | 
			
		||||
@@ -68,6 +68,7 @@ class HassioAddonRepositoryEl extends LitElement {
 | 
			
		||||
          ${addons.map(
 | 
			
		||||
            (addon) => html`
 | 
			
		||||
              <ha-card
 | 
			
		||||
                outlined
 | 
			
		||||
                .addon=${addon}
 | 
			
		||||
                class=${addon.available ? "" : "not_available"}
 | 
			
		||||
                @click=${this._addonTapped}
 | 
			
		||||
 
 | 
			
		||||
@@ -50,6 +50,7 @@ class HassioAddonAudio extends LitElement {
 | 
			
		||||
  protected render(): TemplateResult {
 | 
			
		||||
    return html`
 | 
			
		||||
      <ha-card
 | 
			
		||||
        outlined
 | 
			
		||||
        .header=${this.supervisor.localize("addon.configuration.audio.header")}
 | 
			
		||||
      >
 | 
			
		||||
        <div class="card-content">
 | 
			
		||||
 
 | 
			
		||||
@@ -162,7 +162,7 @@ class HassioAddonConfig extends LitElement {
 | 
			
		||||
        );
 | 
			
		||||
    return html`
 | 
			
		||||
      <h1>${this.addon.name}</h1>
 | 
			
		||||
      <ha-card>
 | 
			
		||||
      <ha-card outlined>
 | 
			
		||||
        <div class="header">
 | 
			
		||||
          <h2>
 | 
			
		||||
            ${this.supervisor.localize("addon.configuration.options.header")}
 | 
			
		||||
 
 | 
			
		||||
@@ -58,6 +58,7 @@ class HassioAddonNetwork extends LitElement {
 | 
			
		||||
 | 
			
		||||
    return html`
 | 
			
		||||
      <ha-card
 | 
			
		||||
        outlined
 | 
			
		||||
        .header=${this.supervisor.localize(
 | 
			
		||||
          "addon.configuration.network.header"
 | 
			
		||||
        )}
 | 
			
		||||
 
 | 
			
		||||
@@ -38,7 +38,7 @@ class HassioAddonDocumentationDashboard extends LitElement {
 | 
			
		||||
    }
 | 
			
		||||
    return html`
 | 
			
		||||
      <div class="content">
 | 
			
		||||
        <ha-card>
 | 
			
		||||
        <ha-card outlined>
 | 
			
		||||
          ${this._error
 | 
			
		||||
            ? html`<ha-alert alert-type="error">${this._error}</ha-alert>`
 | 
			
		||||
            : ""}
 | 
			
		||||
 
 | 
			
		||||
@@ -17,7 +17,9 @@ import {
 | 
			
		||||
  HassioAddonDetails,
 | 
			
		||||
} from "../../../src/data/hassio/addon";
 | 
			
		||||
import { extractApiErrorMessage } from "../../../src/data/hassio/common";
 | 
			
		||||
import { setSupervisorOption } from "../../../src/data/hassio/supervisor";
 | 
			
		||||
import { Supervisor } from "../../../src/data/supervisor/supervisor";
 | 
			
		||||
import { showConfirmationDialog } from "../../../src/dialogs/generic/show-dialog-box";
 | 
			
		||||
import "../../../src/layouts/hass-error-screen";
 | 
			
		||||
import "../../../src/layouts/hass-loading-screen";
 | 
			
		||||
import "../../../src/layouts/hass-tabs-subpage";
 | 
			
		||||
@@ -166,6 +168,42 @@ class HassioAddonDashboard extends LitElement {
 | 
			
		||||
  protected async firstUpdated(): Promise<void> {
 | 
			
		||||
    if (this.route.path === "") {
 | 
			
		||||
      const requestedAddon = extractSearchParam("addon");
 | 
			
		||||
      const requestedAddonRepository = extractSearchParam("repository_url");
 | 
			
		||||
      if (
 | 
			
		||||
        requestedAddonRepository &&
 | 
			
		||||
        !this.supervisor.supervisor.addons_repositories.find(
 | 
			
		||||
          (repo) => repo === requestedAddonRepository
 | 
			
		||||
        )
 | 
			
		||||
      ) {
 | 
			
		||||
        if (
 | 
			
		||||
          !(await showConfirmationDialog(this, {
 | 
			
		||||
            title: this.supervisor.localize("my.add_addon_repository_title"),
 | 
			
		||||
            text: this.supervisor.localize(
 | 
			
		||||
              "my.add_addon_repository_description",
 | 
			
		||||
              { addon: requestedAddon, repository: requestedAddonRepository }
 | 
			
		||||
            ),
 | 
			
		||||
            confirmText: this.supervisor.localize("common.add"),
 | 
			
		||||
            dismissText: this.supervisor.localize("common.cancel"),
 | 
			
		||||
          }))
 | 
			
		||||
        ) {
 | 
			
		||||
          this._error = this.supervisor.localize(
 | 
			
		||||
            "my.error_repository_not_found"
 | 
			
		||||
          );
 | 
			
		||||
          return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        try {
 | 
			
		||||
          await setSupervisorOption(this.hass, {
 | 
			
		||||
            addons_repositories: [
 | 
			
		||||
              ...this.supervisor.supervisor.addons_repositories,
 | 
			
		||||
              requestedAddonRepository,
 | 
			
		||||
            ],
 | 
			
		||||
          });
 | 
			
		||||
        } catch (err: any) {
 | 
			
		||||
          this._error = extractApiErrorMessage(err);
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      if (requestedAddon) {
 | 
			
		||||
        const addonsInfo = await fetchHassioAddonsInfo(this.hass);
 | 
			
		||||
        const validAddon = addonsInfo.addons.some(
 | 
			
		||||
 
 | 
			
		||||
@@ -166,7 +166,7 @@ class HassioAddonInfo extends LitElement {
 | 
			
		||||
          `
 | 
			
		||||
        : ""}
 | 
			
		||||
 | 
			
		||||
      <ha-card>
 | 
			
		||||
      <ha-card outlined>
 | 
			
		||||
        <div class="card-content">
 | 
			
		||||
          <div class="addon-header">
 | 
			
		||||
            ${!this.narrow ? this.addon.name : ""}
 | 
			
		||||
@@ -649,7 +649,7 @@ class HassioAddonInfo extends LitElement {
 | 
			
		||||
 | 
			
		||||
      ${this.addon.long_description
 | 
			
		||||
        ? html`
 | 
			
		||||
            <ha-card>
 | 
			
		||||
            <ha-card outlined>
 | 
			
		||||
              <div class="card-content">
 | 
			
		||||
                <ha-markdown
 | 
			
		||||
                  .content=${this.addon.long_description}
 | 
			
		||||
 
 | 
			
		||||
@@ -2,6 +2,7 @@ import "@material/mwc-button";
 | 
			
		||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
 | 
			
		||||
import { customElement, property, state } from "lit/decorators";
 | 
			
		||||
import "../../../../src/components/ha-alert";
 | 
			
		||||
import "../../../../src/components/ha-ansi-to-html";
 | 
			
		||||
import "../../../../src/components/ha-card";
 | 
			
		||||
import {
 | 
			
		||||
  fetchHassioAddonLogs,
 | 
			
		||||
@@ -11,7 +12,6 @@ import { extractApiErrorMessage } from "../../../../src/data/hassio/common";
 | 
			
		||||
import { Supervisor } from "../../../../src/data/supervisor/supervisor";
 | 
			
		||||
import { haStyle } from "../../../../src/resources/styles";
 | 
			
		||||
import { HomeAssistant } from "../../../../src/types";
 | 
			
		||||
import "../../components/hassio-ansi-to-html";
 | 
			
		||||
import { hassioStyle } from "../../resources/hassio-style";
 | 
			
		||||
 | 
			
		||||
@customElement("hassio-addon-logs")
 | 
			
		||||
@@ -34,15 +34,15 @@ class HassioAddonLogs extends LitElement {
 | 
			
		||||
  protected render(): TemplateResult {
 | 
			
		||||
    return html`
 | 
			
		||||
      <h1>${this.addon.name}</h1>
 | 
			
		||||
      <ha-card>
 | 
			
		||||
      <ha-card outlined>
 | 
			
		||||
        ${this._error
 | 
			
		||||
          ? html`<ha-alert alert-type="error">${this._error}</ha-alert>`
 | 
			
		||||
          : ""}
 | 
			
		||||
        <div class="card-content">
 | 
			
		||||
          ${this._content
 | 
			
		||||
            ? html`<hassio-ansi-to-html
 | 
			
		||||
            ? html`<ha-ansi-to-html
 | 
			
		||||
                .content=${this._content}
 | 
			
		||||
              ></hassio-ansi-to-html>`
 | 
			
		||||
              ></ha-ansi-to-html>`
 | 
			
		||||
            : ""}
 | 
			
		||||
        </div>
 | 
			
		||||
        <div class="card-actions">
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
import "@material/mwc-button";
 | 
			
		||||
import { ActionDetail } from "@material/mwc-list";
 | 
			
		||||
import "@material/mwc-list/mwc-list-item";
 | 
			
		||||
import { mdiDelete, mdiDotsVertical, mdiPlus } from "@mdi/js";
 | 
			
		||||
import { mdiBackupRestore, mdiDelete, mdiDotsVertical, mdiPlus } from "@mdi/js";
 | 
			
		||||
import {
 | 
			
		||||
  css,
 | 
			
		||||
  CSSResultGroup,
 | 
			
		||||
@@ -166,7 +166,15 @@ export class HassioBackups extends LitElement {
 | 
			
		||||
    }
 | 
			
		||||
    return html`
 | 
			
		||||
      <hass-tabs-subpage-data-table
 | 
			
		||||
        .tabs=${supervisorTabs(this.hass)}
 | 
			
		||||
        .tabs=${atLeastVersion(this.hass.config.version, 2022, 5)
 | 
			
		||||
          ? [
 | 
			
		||||
              {
 | 
			
		||||
                translationKey: "panel.backups",
 | 
			
		||||
                path: `/hassio/backups`,
 | 
			
		||||
                iconPath: mdiBackupRestore,
 | 
			
		||||
              },
 | 
			
		||||
            ]
 | 
			
		||||
          : supervisorTabs(this.hass)}
 | 
			
		||||
        .hass=${this.hass}
 | 
			
		||||
        .localizeFunc=${this.supervisor.localize}
 | 
			
		||||
        .searchLabel=${this.supervisor.localize("search")}
 | 
			
		||||
@@ -182,7 +190,9 @@ export class HassioBackups extends LitElement {
 | 
			
		||||
        selectable
 | 
			
		||||
        hasFab
 | 
			
		||||
        .mainPage=${!atLeastVersion(this.hass.config.version, 2021, 12)}
 | 
			
		||||
        back-path="/config"
 | 
			
		||||
        back-path=${atLeastVersion(this.hass.config.version, 2022, 5)
 | 
			
		||||
          ? "/config/system"
 | 
			
		||||
          : "/config"}
 | 
			
		||||
        supervisor
 | 
			
		||||
      >
 | 
			
		||||
        <ha-button-menu
 | 
			
		||||
 
 | 
			
		||||
@@ -26,7 +26,7 @@ class HassioAddons extends LitElement {
 | 
			
		||||
        <div class="card-group">
 | 
			
		||||
          ${!this.supervisor.supervisor.addons?.length
 | 
			
		||||
            ? html`
 | 
			
		||||
                <ha-card>
 | 
			
		||||
                <ha-card outlined>
 | 
			
		||||
                  <div class="card-content">
 | 
			
		||||
                    <button class="link" @click=${this._openStore}>
 | 
			
		||||
                      ${this.supervisor.localize("dashboard.no_addons")}
 | 
			
		||||
@@ -38,7 +38,11 @@ class HassioAddons extends LitElement {
 | 
			
		||||
                .sort((a, b) => caseInsensitiveStringCompare(a.name, b.name))
 | 
			
		||||
                .map(
 | 
			
		||||
                  (addon) => html`
 | 
			
		||||
                    <ha-card .addon=${addon} @click=${this._addonTapped}>
 | 
			
		||||
                    <ha-card
 | 
			
		||||
                      outlined
 | 
			
		||||
                      .addon=${addon}
 | 
			
		||||
                      @click=${this._addonTapped}
 | 
			
		||||
                    >
 | 
			
		||||
                      <div class="card-content">
 | 
			
		||||
                        <hassio-card-content
 | 
			
		||||
                          .hass=${this.hass}
 | 
			
		||||
 
 | 
			
		||||
@@ -10,6 +10,7 @@ import { HomeAssistant, Route } from "../../../src/types";
 | 
			
		||||
import { supervisorTabs } from "../hassio-tabs";
 | 
			
		||||
import "./hassio-addons";
 | 
			
		||||
import "./hassio-update";
 | 
			
		||||
import "../../../src/layouts/hass-subpage";
 | 
			
		||||
 | 
			
		||||
@customElement("hassio-dashboard")
 | 
			
		||||
class HassioDashboard extends LitElement {
 | 
			
		||||
@@ -22,6 +23,31 @@ class HassioDashboard extends LitElement {
 | 
			
		||||
  @property({ attribute: false }) public route!: Route;
 | 
			
		||||
 | 
			
		||||
  protected render(): TemplateResult {
 | 
			
		||||
    if (atLeastVersion(this.hass.config.version, 2022, 5)) {
 | 
			
		||||
      return html`<hass-subpage
 | 
			
		||||
        .hass=${this.hass}
 | 
			
		||||
        .narrow=${this.narrow}
 | 
			
		||||
        .route=${this.route}
 | 
			
		||||
        .header=${this.supervisor.localize("panel.addons")}
 | 
			
		||||
      >
 | 
			
		||||
        <hassio-addons
 | 
			
		||||
          .hass=${this.hass}
 | 
			
		||||
          .supervisor=${this.supervisor}
 | 
			
		||||
        ></hassio-addons>
 | 
			
		||||
        <a href="/hassio/store">
 | 
			
		||||
          <ha-fab
 | 
			
		||||
            .label=${this.supervisor.localize("panel.store")}
 | 
			
		||||
            extended
 | 
			
		||||
            class="non-tabs"
 | 
			
		||||
          >
 | 
			
		||||
            <ha-svg-icon
 | 
			
		||||
              slot="icon"
 | 
			
		||||
              .path=${mdiStorePlus}
 | 
			
		||||
            ></ha-svg-icon> </ha-fab
 | 
			
		||||
        ></a>
 | 
			
		||||
      </hass-subpage>`;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return html`
 | 
			
		||||
      <hass-tabs-subpage
 | 
			
		||||
        .hass=${this.hass}
 | 
			
		||||
@@ -74,6 +100,12 @@ class HassioDashboard extends LitElement {
 | 
			
		||||
        .content {
 | 
			
		||||
          margin: 0 auto;
 | 
			
		||||
        }
 | 
			
		||||
        ha-fab.non-tabs {
 | 
			
		||||
          position: fixed;
 | 
			
		||||
          right: calc(16px + env(safe-area-inset-right));
 | 
			
		||||
          bottom: calc(16px + env(safe-area-inset-bottom));
 | 
			
		||||
          z-index: 1;
 | 
			
		||||
        }
 | 
			
		||||
      `,
 | 
			
		||||
    ];
 | 
			
		||||
  }
 | 
			
		||||
 
 | 
			
		||||
@@ -85,7 +85,7 @@ export class HassioUpdate extends LitElement {
 | 
			
		||||
      return html``;
 | 
			
		||||
    }
 | 
			
		||||
    return html`
 | 
			
		||||
      <ha-card>
 | 
			
		||||
      <ha-card outlined>
 | 
			
		||||
        <div class="card-content">
 | 
			
		||||
          <div class="icon">
 | 
			
		||||
            <ha-svg-icon .path=${mdiHomeAssistant}></ha-svg-icon>
 | 
			
		||||
 
 | 
			
		||||
@@ -3,8 +3,8 @@ import { customElement, property } from "lit/decorators";
 | 
			
		||||
import { atLeastVersion } from "../../src/common/config/version";
 | 
			
		||||
import { applyThemesOnElement } from "../../src/common/dom/apply_themes_on_element";
 | 
			
		||||
import { fireEvent } from "../../src/common/dom/fire_event";
 | 
			
		||||
import { isNavigationClick } from "../../src/common/dom/is-navigation-click";
 | 
			
		||||
import { mainWindow } from "../../src/common/dom/get_main_window";
 | 
			
		||||
import { isNavigationClick } from "../../src/common/dom/is-navigation-click";
 | 
			
		||||
import { navigate } from "../../src/common/navigate";
 | 
			
		||||
import { HassioPanelInfo } from "../../src/data/hassio/supervisor";
 | 
			
		||||
import { Supervisor } from "../../src/data/supervisor/supervisor";
 | 
			
		||||
@@ -73,6 +73,18 @@ export class HassioMain extends SupervisorBaseElement {
 | 
			
		||||
      });
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    // Forward keydown events to the main window for quickbar access
 | 
			
		||||
    document.body.addEventListener("keydown", (ev: KeyboardEvent) => {
 | 
			
		||||
      if (ev.altKey || ev.ctrlKey || ev.shiftKey || ev.metaKey) {
 | 
			
		||||
        // Ignore if modifier keys are pressed
 | 
			
		||||
        return;
 | 
			
		||||
      }
 | 
			
		||||
      // @ts-ignore
 | 
			
		||||
      fireEvent(mainWindow, "hass-quick-bar-trigger", ev, {
 | 
			
		||||
        bubbles: false,
 | 
			
		||||
      });
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    makeDialogManager(this, this.shadowRoot!);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -15,7 +15,7 @@ import {
 | 
			
		||||
} from "../../src/panels/my/ha-panel-my";
 | 
			
		||||
import { HomeAssistant, Route } from "../../src/types";
 | 
			
		||||
 | 
			
		||||
const REDIRECTS: Redirects = {
 | 
			
		||||
export const REDIRECTS: Redirects = {
 | 
			
		||||
  supervisor: {
 | 
			
		||||
    redirect: "/hassio/dashboard",
 | 
			
		||||
  },
 | 
			
		||||
@@ -42,6 +42,9 @@ const REDIRECTS: Redirects = {
 | 
			
		||||
    params: {
 | 
			
		||||
      addon: "string",
 | 
			
		||||
    },
 | 
			
		||||
    optional_params: {
 | 
			
		||||
      repository_url: "url",
 | 
			
		||||
    },
 | 
			
		||||
  },
 | 
			
		||||
  supervisor_ingress: {
 | 
			
		||||
    redirect: "/hassio/ingress",
 | 
			
		||||
@@ -124,6 +127,14 @@ class HassioMyRedirect extends LitElement {
 | 
			
		||||
      }
 | 
			
		||||
      resultParams[key] = params[key];
 | 
			
		||||
    });
 | 
			
		||||
    Object.entries(redirect.optional_params || {}).forEach(([key, type]) => {
 | 
			
		||||
      if (params[key]) {
 | 
			
		||||
        if (!this._checkParamType(type, params[key])) {
 | 
			
		||||
          throw Error();
 | 
			
		||||
        }
 | 
			
		||||
        resultParams[key] = params[key];
 | 
			
		||||
      }
 | 
			
		||||
    });
 | 
			
		||||
    return `?${createSearchParam(resultParams)}`;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -8,24 +8,27 @@ import { atLeastVersion } from "../../src/common/config/version";
 | 
			
		||||
import type { PageNavigation } from "../../src/layouts/hass-tabs-subpage";
 | 
			
		||||
import { HomeAssistant } from "../../src/types";
 | 
			
		||||
 | 
			
		||||
export const supervisorTabs = (hass: HomeAssistant): PageNavigation[] => [
 | 
			
		||||
  {
 | 
			
		||||
    translationKey: atLeastVersion(hass.config.version, 2021, 12)
 | 
			
		||||
      ? "panel.addons"
 | 
			
		||||
      : "panel.dashboard",
 | 
			
		||||
    path: `/hassio/dashboard`,
 | 
			
		||||
    iconPath: atLeastVersion(hass.config.version, 2021, 12)
 | 
			
		||||
      ? mdiPuzzle
 | 
			
		||||
      : mdiViewDashboard,
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    translationKey: "panel.backups",
 | 
			
		||||
    path: `/hassio/backups`,
 | 
			
		||||
    iconPath: mdiBackupRestore,
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    translationKey: "panel.system",
 | 
			
		||||
    path: `/hassio/system`,
 | 
			
		||||
    iconPath: mdiCogs,
 | 
			
		||||
  },
 | 
			
		||||
];
 | 
			
		||||
export const supervisorTabs = (hass: HomeAssistant): PageNavigation[] =>
 | 
			
		||||
  atLeastVersion(hass.config.version, 2022, 5)
 | 
			
		||||
    ? []
 | 
			
		||||
    : [
 | 
			
		||||
        {
 | 
			
		||||
          translationKey: atLeastVersion(hass.config.version, 2021, 12)
 | 
			
		||||
            ? "panel.addons"
 | 
			
		||||
            : "panel.dashboard",
 | 
			
		||||
          path: `/hassio/dashboard`,
 | 
			
		||||
          iconPath: atLeastVersion(hass.config.version, 2021, 12)
 | 
			
		||||
            ? mdiPuzzle
 | 
			
		||||
            : mdiViewDashboard,
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
          translationKey: "panel.backups",
 | 
			
		||||
          path: `/hassio/backups`,
 | 
			
		||||
          iconPath: mdiBackupRestore,
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
          translationKey: "panel.system",
 | 
			
		||||
          path: `/hassio/system`,
 | 
			
		||||
          iconPath: mdiCogs,
 | 
			
		||||
        },
 | 
			
		||||
      ];
 | 
			
		||||
 
 | 
			
		||||
@@ -48,7 +48,7 @@ class HassioCoreInfo extends LitElement {
 | 
			
		||||
    ];
 | 
			
		||||
 | 
			
		||||
    return html`
 | 
			
		||||
      <ha-card header="Core">
 | 
			
		||||
      <ha-card header="Core" outlined>
 | 
			
		||||
        <div class="card-content">
 | 
			
		||||
          <div>
 | 
			
		||||
            <ha-settings-row>
 | 
			
		||||
 
 | 
			
		||||
@@ -66,7 +66,7 @@ class HassioHostInfo extends LitElement {
 | 
			
		||||
      },
 | 
			
		||||
    ];
 | 
			
		||||
    return html`
 | 
			
		||||
      <ha-card header="Host">
 | 
			
		||||
      <ha-card header="Host" outlined>
 | 
			
		||||
        <div class="card-content">
 | 
			
		||||
          <div>
 | 
			
		||||
            ${this.supervisor.host.features.includes("hostname")
 | 
			
		||||
 
 | 
			
		||||
@@ -23,6 +23,10 @@ import {
 | 
			
		||||
  showAlertDialog,
 | 
			
		||||
  showConfirmationDialog,
 | 
			
		||||
} from "../../../src/dialogs/generic/show-dialog-box";
 | 
			
		||||
import {
 | 
			
		||||
  UNHEALTHY_REASON_URL,
 | 
			
		||||
  UNSUPPORTED_REASON_URL,
 | 
			
		||||
} from "../../../src/panels/config/system-health/ha-config-system-health";
 | 
			
		||||
import { haStyle } from "../../../src/resources/styles";
 | 
			
		||||
import { HomeAssistant } from "../../../src/types";
 | 
			
		||||
import { bytesToString } from "../../../src/util/bytes-to-string";
 | 
			
		||||
@@ -30,11 +34,6 @@ import { documentationUrl } from "../../../src/util/documentation-url";
 | 
			
		||||
import "../components/supervisor-metric";
 | 
			
		||||
import { hassioStyle } from "../resources/hassio-style";
 | 
			
		||||
 | 
			
		||||
const UNSUPPORTED_REASON_URL = {};
 | 
			
		||||
const UNHEALTHY_REASON_URL = {
 | 
			
		||||
  privileged: "/more-info/unsupported/privileged",
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@customElement("hassio-supervisor-info")
 | 
			
		||||
class HassioSupervisorInfo extends LitElement {
 | 
			
		||||
  @property({ attribute: false }) public hass!: HomeAssistant;
 | 
			
		||||
@@ -58,7 +57,7 @@ class HassioSupervisorInfo extends LitElement {
 | 
			
		||||
      },
 | 
			
		||||
    ];
 | 
			
		||||
    return html`
 | 
			
		||||
      <ha-card header="Supervisor">
 | 
			
		||||
      <ha-card header="Supervisor" outlined>
 | 
			
		||||
        <div class="card-content">
 | 
			
		||||
          <div>
 | 
			
		||||
            <ha-settings-row>
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,4 @@
 | 
			
		||||
import "../../../src/components/ha-ansi-to-html";
 | 
			
		||||
import "@material/mwc-button";
 | 
			
		||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
 | 
			
		||||
import { customElement, property, state } from "lit/decorators";
 | 
			
		||||
@@ -11,7 +12,6 @@ import { Supervisor } from "../../../src/data/supervisor/supervisor";
 | 
			
		||||
import "../../../src/layouts/hass-loading-screen";
 | 
			
		||||
import { haStyle } from "../../../src/resources/styles";
 | 
			
		||||
import { HomeAssistant } from "../../../src/types";
 | 
			
		||||
import "../components/hassio-ansi-to-html";
 | 
			
		||||
import { hassioStyle } from "../resources/hassio-style";
 | 
			
		||||
 | 
			
		||||
interface LogProvider {
 | 
			
		||||
@@ -65,7 +65,7 @@ class HassioSupervisorLog extends LitElement {
 | 
			
		||||
 | 
			
		||||
  protected render(): TemplateResult | void {
 | 
			
		||||
    return html`
 | 
			
		||||
      <ha-card>
 | 
			
		||||
      <ha-card outlined>
 | 
			
		||||
        ${this._error
 | 
			
		||||
          ? html`<ha-alert alert-type="error">${this._error}</ha-alert>`
 | 
			
		||||
          : ""}
 | 
			
		||||
@@ -89,8 +89,8 @@ class HassioSupervisorLog extends LitElement {
 | 
			
		||||
 | 
			
		||||
        <div class="card-content" id="content">
 | 
			
		||||
          ${this._content
 | 
			
		||||
            ? html`<hassio-ansi-to-html .content=${this._content}>
 | 
			
		||||
              </hassio-ansi-to-html>`
 | 
			
		||||
            ? html`<ha-ansi-to-html .content=${this._content}>
 | 
			
		||||
              </ha-ansi-to-html>`
 | 
			
		||||
            : html`<hass-loading-screen no-toolbar></hass-loading-screen>`}
 | 
			
		||||
        </div>
 | 
			
		||||
        <div class="card-actions">
 | 
			
		||||
 
 | 
			
		||||
@@ -128,6 +128,7 @@ class UpdateAvailableCard extends LitElement {
 | 
			
		||||
 | 
			
		||||
    return html`
 | 
			
		||||
      <ha-card
 | 
			
		||||
        outlined
 | 
			
		||||
        .header=${this.supervisor.localize("update_available.update_name", {
 | 
			
		||||
          name: this._name,
 | 
			
		||||
        })}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
[metadata]
 | 
			
		||||
name         = home-assistant-frontend
 | 
			
		||||
version      = 20220424.0
 | 
			
		||||
version      = 20220504.0
 | 
			
		||||
author       = The Home Assistant Authors
 | 
			
		||||
author_email = hello@home-assistant.io
 | 
			
		||||
license      = Apache-2.0
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										16
									
								
								src/common/datetime/duration.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								src/common/datetime/duration.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,16 @@
 | 
			
		||||
import secondsToDuration from "./seconds_to_duration";
 | 
			
		||||
 | 
			
		||||
const DAY_IN_SECONDS = 86400;
 | 
			
		||||
const HOUR_IN_SECONDS = 3600;
 | 
			
		||||
const MINUTE_IN_SECONDS = 60;
 | 
			
		||||
 | 
			
		||||
export const UNIT_TO_SECOND_CONVERT = {
 | 
			
		||||
  s: 1,
 | 
			
		||||
  min: MINUTE_IN_SECONDS,
 | 
			
		||||
  h: HOUR_IN_SECONDS,
 | 
			
		||||
  d: DAY_IN_SECONDS,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const formatDuration = (duration: string, units: string): string =>
 | 
			
		||||
  secondsToDuration(parseFloat(duration) * UNIT_TO_SECOND_CONVERT[units]) ||
 | 
			
		||||
  "0";
 | 
			
		||||
@@ -13,6 +13,7 @@ import { formatNumber, isNumericState } from "../number/format_number";
 | 
			
		||||
import { LocalizeFunc } from "../translations/localize";
 | 
			
		||||
import { computeStateDomain } from "./compute_state_domain";
 | 
			
		||||
import { supportsFeature } from "./supports-feature";
 | 
			
		||||
import { formatDuration, UNIT_TO_SECOND_CONVERT } from "../datetime/duration";
 | 
			
		||||
 | 
			
		||||
export const computeStateDisplay = (
 | 
			
		||||
  localize: LocalizeFunc,
 | 
			
		||||
@@ -28,6 +29,21 @@ export const computeStateDisplay = (
 | 
			
		||||
 | 
			
		||||
  // Entities with a `unit_of_measurement` or `state_class` are numeric values and should use `formatNumber`
 | 
			
		||||
  if (isNumericState(stateObj)) {
 | 
			
		||||
    // state is duration
 | 
			
		||||
    if (
 | 
			
		||||
      stateObj.attributes.device_class === "duration" &&
 | 
			
		||||
      stateObj.attributes.unit_of_measurement &&
 | 
			
		||||
      UNIT_TO_SECOND_CONVERT[stateObj.attributes.unit_of_measurement]
 | 
			
		||||
    ) {
 | 
			
		||||
      try {
 | 
			
		||||
        return formatDuration(
 | 
			
		||||
          compareState,
 | 
			
		||||
          stateObj.attributes.unit_of_measurement
 | 
			
		||||
        );
 | 
			
		||||
      } catch (_err) {
 | 
			
		||||
        // fallback to default
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    if (stateObj.attributes.device_class === "monetary") {
 | 
			
		||||
      try {
 | 
			
		||||
        return formatNumber(compareState, locale, {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
export const promiseTimeout = (ms: number, promise: Promise<any>) => {
 | 
			
		||||
export const promiseTimeout = (ms: number, promise: Promise<any> | any) => {
 | 
			
		||||
  const timeout = new Promise((_resolve, reject) => {
 | 
			
		||||
    setTimeout(() => {
 | 
			
		||||
      reject(`Timed out in ${ms} ms.`);
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										18
									
								
								src/common/util/subscribe-polling.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								src/common/util/subscribe-polling.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,18 @@
 | 
			
		||||
import { HomeAssistant } from "../../types";
 | 
			
		||||
 | 
			
		||||
export const subscribePollingCollection = (
 | 
			
		||||
  hass: HomeAssistant,
 | 
			
		||||
  updateData: (hass: HomeAssistant) => void,
 | 
			
		||||
  interval: number
 | 
			
		||||
) => {
 | 
			
		||||
  let timeout;
 | 
			
		||||
  const fetchData = async () => {
 | 
			
		||||
    try {
 | 
			
		||||
      await updateData(hass);
 | 
			
		||||
    } finally {
 | 
			
		||||
      timeout = setTimeout(() => fetchData(), interval);
 | 
			
		||||
    }
 | 
			
		||||
  };
 | 
			
		||||
  fetchData();
 | 
			
		||||
  return () => clearTimeout(timeout);
 | 
			
		||||
};
 | 
			
		||||
@@ -5,6 +5,7 @@ import { fireEvent } from "../../common/dom/fire_event";
 | 
			
		||||
import {
 | 
			
		||||
  DeviceAutomation,
 | 
			
		||||
  deviceAutomationsEqual,
 | 
			
		||||
  sortDeviceAutomations,
 | 
			
		||||
} from "../../data/device_automation";
 | 
			
		||||
import { HomeAssistant } from "../../types";
 | 
			
		||||
import "../ha-select";
 | 
			
		||||
@@ -127,7 +128,9 @@ export abstract class HaDeviceAutomationPicker<
 | 
			
		||||
 | 
			
		||||
  private async _updateDeviceInfo() {
 | 
			
		||||
    this._automations = this.deviceId
 | 
			
		||||
      ? await this._fetchDeviceAutomations(this.hass, this.deviceId)
 | 
			
		||||
      ? (await this._fetchDeviceAutomations(this.hass, this.deviceId)).sort(
 | 
			
		||||
          sortDeviceAutomations
 | 
			
		||||
        )
 | 
			
		||||
      : // No device, clear the list of automations
 | 
			
		||||
        [];
 | 
			
		||||
 | 
			
		||||
@@ -161,8 +164,9 @@ export abstract class HaDeviceAutomationPicker<
 | 
			
		||||
    if (this.value && deviceAutomationsEqual(automation, this.value)) {
 | 
			
		||||
      return;
 | 
			
		||||
    }
 | 
			
		||||
    fireEvent(this, "change");
 | 
			
		||||
    fireEvent(this, "value-changed", { value: automation });
 | 
			
		||||
    const value = { ...automation };
 | 
			
		||||
    delete value.metadata;
 | 
			
		||||
    fireEvent(this, "value-changed", { value });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  static get styles(): CSSResultGroup {
 | 
			
		||||
 
 | 
			
		||||
@@ -198,9 +198,10 @@ export class HaDevicePicker extends SubscribeMixin(LitElement) {
 | 
			
		||||
          this.hass,
 | 
			
		||||
          deviceEntityLookup[device.id]
 | 
			
		||||
        ),
 | 
			
		||||
        area: device.area_id
 | 
			
		||||
          ? areaLookup[device.area_id].name
 | 
			
		||||
          : this.hass.localize("ui.components.device-picker.no_area"),
 | 
			
		||||
        area:
 | 
			
		||||
          device.area_id && areaLookup[device.area_id]
 | 
			
		||||
            ? areaLookup[device.area_id].name
 | 
			
		||||
            : this.hass.localize("ui.components.device-picker.no_area"),
 | 
			
		||||
      }));
 | 
			
		||||
      if (!outputDevices.length) {
 | 
			
		||||
        return [
 | 
			
		||||
 
 | 
			
		||||
@@ -10,8 +10,8 @@ interface State {
 | 
			
		||||
  backgroundColor: null | string;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@customElement("hassio-ansi-to-html")
 | 
			
		||||
class HassioAnsiToHtml extends LitElement {
 | 
			
		||||
@customElement("ha-ansi-to-html")
 | 
			
		||||
class HaAnsiToHtml extends LitElement {
 | 
			
		||||
  @property() public content!: string;
 | 
			
		||||
 | 
			
		||||
  protected render(): TemplateResult | void {
 | 
			
		||||
@@ -241,6 +241,6 @@ class HassioAnsiToHtml extends LitElement {
 | 
			
		||||
 | 
			
		||||
declare global {
 | 
			
		||||
  interface HTMLElementTagNameMap {
 | 
			
		||||
    "hassio-ansi-to-html": HassioAnsiToHtml;
 | 
			
		||||
    "ha-ansi-to-html": HaAnsiToHtml;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@@ -409,7 +409,7 @@ export class HaAreaPicker extends SubscribeMixin(LitElement) {
 | 
			
		||||
            name,
 | 
			
		||||
          });
 | 
			
		||||
          this._areas = [...this._areas!, area];
 | 
			
		||||
          (this.comboBox as any).items = this._getAreas(
 | 
			
		||||
          (this.comboBox as any).filteredItems = this._getAreas(
 | 
			
		||||
            this._areas!,
 | 
			
		||||
            this._devices!,
 | 
			
		||||
            this._entities!,
 | 
			
		||||
 
 | 
			
		||||
@@ -12,6 +12,8 @@ export class HaClickableListItem extends ListItemBase {
 | 
			
		||||
  // property used only in css
 | 
			
		||||
  @property({ type: Boolean, reflect: true }) public rtl = false;
 | 
			
		||||
 | 
			
		||||
  @property({ type: Boolean, reflect: true }) public openNewTab = false;
 | 
			
		||||
 | 
			
		||||
  @query("a") private _anchor!: HTMLAnchorElement;
 | 
			
		||||
 | 
			
		||||
  public render() {
 | 
			
		||||
@@ -20,7 +22,12 @@ export class HaClickableListItem extends ListItemBase {
 | 
			
		||||
 | 
			
		||||
    return html`${this.disableHref
 | 
			
		||||
      ? html`<a aria-role="option">${r}</a>`
 | 
			
		||||
      : html`<a aria-role="option" href=${href}>${r}</a>`}`;
 | 
			
		||||
      : html`<a
 | 
			
		||||
          aria-role="option"
 | 
			
		||||
          target=${this.openNewTab ? "_blank" : ""}
 | 
			
		||||
          href=${href}
 | 
			
		||||
          >${r}</a
 | 
			
		||||
        >`}`;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  firstUpdated() {
 | 
			
		||||
@@ -55,6 +62,7 @@ export class HaClickableListItem extends ListItemBase {
 | 
			
		||||
          align-items: center;
 | 
			
		||||
          padding-left: var(--mdc-list-side-padding, 20px);
 | 
			
		||||
          padding-right: var(--mdc-list-side-padding, 20px);
 | 
			
		||||
          overflow: hidden;
 | 
			
		||||
        }
 | 
			
		||||
      `,
 | 
			
		||||
    ];
 | 
			
		||||
 
 | 
			
		||||
@@ -132,6 +132,11 @@ export class HaFormString extends LitElement implements HaFormElement {
 | 
			
		||||
        --mdc-icon-button-size: 24px;
 | 
			
		||||
        color: var(--secondary-text-color);
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      :host-context([style*="direction: rtl;"]) ha-icon-button {
 | 
			
		||||
        right: auto;
 | 
			
		||||
        left: 12px;
 | 
			
		||||
      }
 | 
			
		||||
    `;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -9,25 +9,27 @@ import "./ha-settings-row";
 | 
			
		||||
class HaMetric extends LitElement {
 | 
			
		||||
  @property({ type: Number }) public value!: number;
 | 
			
		||||
 | 
			
		||||
  @property({ type: String }) public description!: string;
 | 
			
		||||
  @property({ type: String }) public heading!: string;
 | 
			
		||||
 | 
			
		||||
  @property({ type: String }) public tooltip?: string;
 | 
			
		||||
 | 
			
		||||
  protected render(): TemplateResult {
 | 
			
		||||
    const roundedValue = roundWithOneDecimal(this.value);
 | 
			
		||||
    return html`<ha-settings-row>
 | 
			
		||||
      <span slot="heading"> ${this.description} </span>
 | 
			
		||||
      <div slot="description" .title=${this.tooltip ?? ""}>
 | 
			
		||||
        <span class="value"> ${roundedValue} % </span>
 | 
			
		||||
        <ha-bar
 | 
			
		||||
          class=${classMap({
 | 
			
		||||
            "target-warning": roundedValue > 50,
 | 
			
		||||
            "target-critical": roundedValue > 85,
 | 
			
		||||
          })}
 | 
			
		||||
          .value=${this.value}
 | 
			
		||||
        ></ha-bar>
 | 
			
		||||
      </div>
 | 
			
		||||
    </ha-settings-row>`;
 | 
			
		||||
    return html`
 | 
			
		||||
      <ha-settings-row>
 | 
			
		||||
        <span slot="heading"> ${this.heading} </span>
 | 
			
		||||
        <div slot="description" .title=${this.tooltip ?? ""}>
 | 
			
		||||
          <span class="value"> ${roundedValue} % </span>
 | 
			
		||||
          <ha-bar
 | 
			
		||||
            class=${classMap({
 | 
			
		||||
              "target-warning": roundedValue > 50,
 | 
			
		||||
              "target-critical": roundedValue > 85,
 | 
			
		||||
            })}
 | 
			
		||||
            .value=${this.value}
 | 
			
		||||
          ></ha-bar>
 | 
			
		||||
        </div>
 | 
			
		||||
      </ha-settings-row>
 | 
			
		||||
    `;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  static get styles(): CSSResultGroup {
 | 
			
		||||
 
 | 
			
		||||
@@ -56,18 +56,15 @@ class HaNavigationList extends LitElement {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  static styles: CSSResultGroup = css`
 | 
			
		||||
    a {
 | 
			
		||||
      text-decoration: none;
 | 
			
		||||
      color: var(--primary-text-color);
 | 
			
		||||
      position: relative;
 | 
			
		||||
      display: block;
 | 
			
		||||
      outline: 0;
 | 
			
		||||
    :host {
 | 
			
		||||
      --mdc-list-vertical-padding: 0;
 | 
			
		||||
    }
 | 
			
		||||
    ha-svg-icon,
 | 
			
		||||
    ha-icon-next {
 | 
			
		||||
      color: var(--secondary-text-color);
 | 
			
		||||
      height: 24px;
 | 
			
		||||
      width: 24px;
 | 
			
		||||
      display: block;
 | 
			
		||||
    }
 | 
			
		||||
    ha-svg-icon {
 | 
			
		||||
      padding: 8px;
 | 
			
		||||
@@ -81,6 +78,7 @@ class HaNavigationList extends LitElement {
 | 
			
		||||
    ha-clickable-list-item {
 | 
			
		||||
      cursor: pointer;
 | 
			
		||||
      font-size: var(--navigation-list-item-title-font-size);
 | 
			
		||||
      padding: var(--navigation-list-item-padding) 0;
 | 
			
		||||
    }
 | 
			
		||||
  `;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -163,6 +163,9 @@ export class HaNetwork extends LitElement {
 | 
			
		||||
 | 
			
		||||
        ha-settings-row {
 | 
			
		||||
          padding: 0;
 | 
			
		||||
          --paper-time-input-justify-content: flex-end;
 | 
			
		||||
          --settings-row-content-display: contents;
 | 
			
		||||
          --settings-row-prefix-display: contents;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        span[slot="heading"],
 | 
			
		||||
 
 | 
			
		||||
@@ -27,8 +27,8 @@ export class HaColorTempSelector extends LitElement {
 | 
			
		||||
        pin
 | 
			
		||||
        icon="hass:thermometer"
 | 
			
		||||
        .caption=${this.label || ""}
 | 
			
		||||
        .min=${this.selector.color_temp.min_mireds ?? 153}
 | 
			
		||||
        .max=${this.selector.color_temp.max_mireds ?? 500}
 | 
			
		||||
        .min=${this.selector.color_temp?.min_mireds ?? 153}
 | 
			
		||||
        .max=${this.selector.color_temp?.max_mireds ?? 500}
 | 
			
		||||
        .value=${this.value}
 | 
			
		||||
        .disabled=${this.disabled}
 | 
			
		||||
        .helper=${this.helper}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
import { html, LitElement } from "lit";
 | 
			
		||||
import { css, html, LitElement } from "lit";
 | 
			
		||||
import { customElement, property } from "lit/decorators";
 | 
			
		||||
import memoizeOne from "memoize-one";
 | 
			
		||||
import { fireEvent } from "../../common/dom/fire_event";
 | 
			
		||||
@@ -76,6 +76,13 @@ export class HaLocationSelector extends LitElement {
 | 
			
		||||
    const radius = ev.detail.radius;
 | 
			
		||||
    fireEvent(this, "value-changed", { value: { ...this.value, radius } });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  static styles = css`
 | 
			
		||||
    :host {
 | 
			
		||||
      display: block;
 | 
			
		||||
      height: 400px;
 | 
			
		||||
    }
 | 
			
		||||
  `;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
declare global {
 | 
			
		||||
 
 | 
			
		||||
@@ -472,6 +472,7 @@ export class HaServiceControl extends LitElement {
 | 
			
		||||
      ha-settings-row {
 | 
			
		||||
        --paper-time-input-justify-content: flex-end;
 | 
			
		||||
        --settings-row-content-width: 100%;
 | 
			
		||||
        --settings-row-prefix-display: contents;
 | 
			
		||||
        border-top: var(
 | 
			
		||||
          --service-control-items-border-top,
 | 
			
		||||
          1px solid var(--divider-color)
 | 
			
		||||
 
 | 
			
		||||
@@ -47,7 +47,7 @@ export class HaSettingsRow extends LitElement {
 | 
			
		||||
        display: contents;
 | 
			
		||||
      }
 | 
			
		||||
      :host(:not([narrow])) .content {
 | 
			
		||||
        display: flex;
 | 
			
		||||
        display: var(--settings-row-content-display, flex);
 | 
			
		||||
        justify-content: flex-end;
 | 
			
		||||
        flex: 1;
 | 
			
		||||
        padding: 16px 0;
 | 
			
		||||
@@ -68,7 +68,7 @@ export class HaSettingsRow extends LitElement {
 | 
			
		||||
        white-space: normal;
 | 
			
		||||
      }
 | 
			
		||||
      .prefix-wrap {
 | 
			
		||||
        display: contents;
 | 
			
		||||
        display: var(--settings-row-prefix-display);
 | 
			
		||||
      }
 | 
			
		||||
      :host([narrow]) .prefix-wrap {
 | 
			
		||||
        display: flex;
 | 
			
		||||
 
 | 
			
		||||
@@ -1051,9 +1051,6 @@ class HaSidebar extends LitElement {
 | 
			
		||||
          padding: 0px 6px;
 | 
			
		||||
          color: var(--text-accent-color, var(--text-primary-color));
 | 
			
		||||
        }
 | 
			
		||||
        .configuration-badge {
 | 
			
		||||
          background-color: var(--primary-color);
 | 
			
		||||
        }
 | 
			
		||||
        ha-svg-icon + .notification-badge,
 | 
			
		||||
        ha-svg-icon + .configuration-badge {
 | 
			
		||||
          position: absolute;
 | 
			
		||||
 
 | 
			
		||||
@@ -302,6 +302,10 @@ class DialogMediaManage extends LitElement {
 | 
			
		||||
          --mdc-theme-primary: var(--mdc-theme-on-primary);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        mwc-list {
 | 
			
		||||
          direction: ltr;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        .danger {
 | 
			
		||||
          --mdc-theme-primary: var(--error-color);
 | 
			
		||||
        }
 | 
			
		||||
@@ -310,6 +314,11 @@ class DialogMediaManage extends LitElement {
 | 
			
		||||
          vertical-align: middle;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        :host-context([style*="direction: rtl;"]) ha-svg-icon[slot="icon"] {
 | 
			
		||||
          margin-left: 8px !important;
 | 
			
		||||
          margin-right: 0px !important;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        .refresh {
 | 
			
		||||
          display: flex;
 | 
			
		||||
          height: 200px;
 | 
			
		||||
 
 | 
			
		||||
@@ -151,6 +151,8 @@ class DialogMediaPlayerBrowse extends LitElement {
 | 
			
		||||
 | 
			
		||||
        ha-media-player-browse {
 | 
			
		||||
          --media-browser-max-height: calc(100vh - 65px);
 | 
			
		||||
          height: calc(100vh - 65px);
 | 
			
		||||
          direction: ltr;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        @media (min-width: 800px) {
 | 
			
		||||
@@ -163,6 +165,7 @@ class DialogMediaPlayerBrowse extends LitElement {
 | 
			
		||||
          ha-media-player-browse {
 | 
			
		||||
            position: initial;
 | 
			
		||||
            --media-browser-max-height: 100vh - 137px;
 | 
			
		||||
            height: 100vh - 137px;
 | 
			
		||||
            width: 700px;
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -59,6 +59,11 @@ class MediaManageButton extends LitElement {
 | 
			
		||||
    ha-circular-progress[slot="icon"] {
 | 
			
		||||
      vertical-align: middle;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    :host-context([style*="direction: rtl;"]) ha-svg-icon[slot="icon"] {
 | 
			
		||||
      margin-left: 8px;
 | 
			
		||||
      margin-right: 0px;
 | 
			
		||||
    }
 | 
			
		||||
  `;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,6 @@
 | 
			
		||||
import "@lit-labs/virtualizer";
 | 
			
		||||
import type { LitVirtualizer } from "@lit-labs/virtualizer";
 | 
			
		||||
import { grid } from "@lit-labs/virtualizer/layouts/grid";
 | 
			
		||||
import "@material/mwc-button/mwc-button";
 | 
			
		||||
import "@material/mwc-list/mwc-list";
 | 
			
		||||
import "@material/mwc-list/mwc-list-item";
 | 
			
		||||
@@ -16,12 +19,11 @@ import {
 | 
			
		||||
  eventOptions,
 | 
			
		||||
  property,
 | 
			
		||||
  query,
 | 
			
		||||
  queryAll,
 | 
			
		||||
  state,
 | 
			
		||||
} from "lit/decorators";
 | 
			
		||||
import { classMap } from "lit/directives/class-map";
 | 
			
		||||
import { ifDefined } from "lit/directives/if-defined";
 | 
			
		||||
import { styleMap } from "lit/directives/style-map";
 | 
			
		||||
import { until } from "lit/directives/until";
 | 
			
		||||
import { fireEvent } from "../../common/dom/fire_event";
 | 
			
		||||
import { computeRTLDirection } from "../../common/util/compute_rtl";
 | 
			
		||||
import { debounce } from "../../common/util/debounce";
 | 
			
		||||
@@ -45,7 +47,6 @@ import { documentationUrl } from "../../util/documentation-url";
 | 
			
		||||
import "../entity/ha-entity-picker";
 | 
			
		||||
import "../ha-button-menu";
 | 
			
		||||
import "../ha-card";
 | 
			
		||||
import type { HaCard } from "../ha-card";
 | 
			
		||||
import "../ha-circular-progress";
 | 
			
		||||
import "../ha-fab";
 | 
			
		||||
import "../ha-icon-button";
 | 
			
		||||
@@ -101,7 +102,9 @@ export class HaMediaPlayerBrowse extends LitElement {
 | 
			
		||||
 | 
			
		||||
  @query(".content") private _content?: HTMLDivElement;
 | 
			
		||||
 | 
			
		||||
  @queryAll(".lazythumbnail") private _thumbnails?: HaCard[];
 | 
			
		||||
  @query("lit-virtualizer") private _virtualizer?: LitVirtualizer;
 | 
			
		||||
 | 
			
		||||
  private _observed = false;
 | 
			
		||||
 | 
			
		||||
  private _headerOffsetHeight = 0;
 | 
			
		||||
 | 
			
		||||
@@ -148,326 +151,6 @@ export class HaMediaPlayerBrowse extends LitElement {
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  protected render(): TemplateResult {
 | 
			
		||||
    if (this._error) {
 | 
			
		||||
      return html`
 | 
			
		||||
        <div class="container">${this._renderError(this._error)}</div>
 | 
			
		||||
      `;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (!this._currentItem) {
 | 
			
		||||
      return html`<ha-circular-progress active></ha-circular-progress>`;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    const currentItem = this._currentItem;
 | 
			
		||||
 | 
			
		||||
    const subtitle = this.hass.localize(
 | 
			
		||||
      `ui.components.media-browser.class.${currentItem.media_class}`
 | 
			
		||||
    );
 | 
			
		||||
    const children = currentItem.children || [];
 | 
			
		||||
    const mediaClass = MediaClassBrowserSettings[currentItem.media_class];
 | 
			
		||||
    const childrenMediaClass = currentItem.children_media_class
 | 
			
		||||
      ? MediaClassBrowserSettings[currentItem.children_media_class]
 | 
			
		||||
      : MediaClassBrowserSettings.directory;
 | 
			
		||||
 | 
			
		||||
    return html`
 | 
			
		||||
              ${
 | 
			
		||||
                currentItem.can_play
 | 
			
		||||
                  ? html` <div
 | 
			
		||||
                      class="header ${classMap({
 | 
			
		||||
                        "no-img": !currentItem.thumbnail,
 | 
			
		||||
                        "no-dialog": !this.dialog,
 | 
			
		||||
                      })}"
 | 
			
		||||
                      @transitionend=${this._setHeaderHeight}
 | 
			
		||||
                    >
 | 
			
		||||
                      <div class="header-content">
 | 
			
		||||
                        ${currentItem.thumbnail
 | 
			
		||||
                          ? html`
 | 
			
		||||
                              <div
 | 
			
		||||
                                class="img"
 | 
			
		||||
                                style=${styleMap({
 | 
			
		||||
                                  backgroundImage: currentItem.thumbnail
 | 
			
		||||
                                    ? `url(${currentItem.thumbnail})`
 | 
			
		||||
                                    : "none",
 | 
			
		||||
                                })}
 | 
			
		||||
                              >
 | 
			
		||||
                                ${this._narrow && currentItem?.can_play
 | 
			
		||||
                                  ? html`
 | 
			
		||||
                                      <ha-fab
 | 
			
		||||
                                        mini
 | 
			
		||||
                                        .item=${currentItem}
 | 
			
		||||
                                        @click=${this._actionClicked}
 | 
			
		||||
                                      >
 | 
			
		||||
                                        <ha-svg-icon
 | 
			
		||||
                                          slot="icon"
 | 
			
		||||
                                          .label=${this.hass.localize(
 | 
			
		||||
                                            `ui.components.media-browser.${this.action}-media`
 | 
			
		||||
                                          )}
 | 
			
		||||
                                          .path=${this.action === "play"
 | 
			
		||||
                                            ? mdiPlay
 | 
			
		||||
                                            : mdiPlus}
 | 
			
		||||
                                        ></ha-svg-icon>
 | 
			
		||||
                                        ${this.hass.localize(
 | 
			
		||||
                                          `ui.components.media-browser.${this.action}`
 | 
			
		||||
                                        )}
 | 
			
		||||
                                      </ha-fab>
 | 
			
		||||
                                    `
 | 
			
		||||
                                  : ""}
 | 
			
		||||
                              </div>
 | 
			
		||||
                            `
 | 
			
		||||
                          : html``}
 | 
			
		||||
                        <div class="header-info">
 | 
			
		||||
                          <div class="breadcrumb">
 | 
			
		||||
                            <h1 class="title">${currentItem.title}</h1>
 | 
			
		||||
                            ${subtitle
 | 
			
		||||
                              ? html` <h2 class="subtitle">${subtitle}</h2> `
 | 
			
		||||
                              : ""}
 | 
			
		||||
                          </div>
 | 
			
		||||
                          ${currentItem.can_play &&
 | 
			
		||||
                          (!currentItem.thumbnail || !this._narrow)
 | 
			
		||||
                            ? html`
 | 
			
		||||
                                <mwc-button
 | 
			
		||||
                                  raised
 | 
			
		||||
                                  .item=${currentItem}
 | 
			
		||||
                                  @click=${this._actionClicked}
 | 
			
		||||
                                >
 | 
			
		||||
                                  <ha-svg-icon
 | 
			
		||||
                                    .label=${this.hass.localize(
 | 
			
		||||
                                      `ui.components.media-browser.${this.action}-media`
 | 
			
		||||
                                    )}
 | 
			
		||||
                                    .path=${this.action === "play"
 | 
			
		||||
                                      ? mdiPlay
 | 
			
		||||
                                      : mdiPlus}
 | 
			
		||||
                                  ></ha-svg-icon>
 | 
			
		||||
                                  ${this.hass.localize(
 | 
			
		||||
                                    `ui.components.media-browser.${this.action}`
 | 
			
		||||
                                  )}
 | 
			
		||||
                                </mwc-button>
 | 
			
		||||
                              `
 | 
			
		||||
                            : ""}
 | 
			
		||||
                        </div>
 | 
			
		||||
                      </div>
 | 
			
		||||
                    </div>`
 | 
			
		||||
                  : ""
 | 
			
		||||
              }
 | 
			
		||||
          <div
 | 
			
		||||
            class="content"
 | 
			
		||||
            @scroll=${this._scroll}
 | 
			
		||||
            @touchmove=${this._scroll}
 | 
			
		||||
          >
 | 
			
		||||
            ${
 | 
			
		||||
              this._error
 | 
			
		||||
                ? html`
 | 
			
		||||
                    <div class="container">
 | 
			
		||||
                      ${this._renderError(this._error)}
 | 
			
		||||
                    </div>
 | 
			
		||||
                  `
 | 
			
		||||
                : isTTSMediaSource(currentItem.media_content_id)
 | 
			
		||||
                ? html`
 | 
			
		||||
                    <ha-browse-media-tts
 | 
			
		||||
                      .item=${currentItem}
 | 
			
		||||
                      .hass=${this.hass}
 | 
			
		||||
                      .action=${this.action}
 | 
			
		||||
                      @tts-picked=${this._ttsPicked}
 | 
			
		||||
                    ></ha-browse-media-tts>
 | 
			
		||||
                  `
 | 
			
		||||
                : !children.length && !currentItem.not_shown
 | 
			
		||||
                ? html`
 | 
			
		||||
                    <div class="container no-items">
 | 
			
		||||
                      ${currentItem.media_content_id ===
 | 
			
		||||
                      "media-source://media_source/local/."
 | 
			
		||||
                        ? html`
 | 
			
		||||
                            <div class="highlight-add-button">
 | 
			
		||||
                              <span>
 | 
			
		||||
                                <ha-svg-icon
 | 
			
		||||
                                  .path=${mdiArrowUpRight}
 | 
			
		||||
                                ></ha-svg-icon>
 | 
			
		||||
                              </span>
 | 
			
		||||
                              <span>
 | 
			
		||||
                                ${this.hass.localize(
 | 
			
		||||
                                  "ui.components.media-browser.file_management.highlight_button"
 | 
			
		||||
                                )}
 | 
			
		||||
                              </span>
 | 
			
		||||
                            </div>
 | 
			
		||||
                          `
 | 
			
		||||
                        : this.hass.localize(
 | 
			
		||||
                            "ui.components.media-browser.no_items"
 | 
			
		||||
                          )}
 | 
			
		||||
                    </div>
 | 
			
		||||
                  `
 | 
			
		||||
                : childrenMediaClass.layout === "grid"
 | 
			
		||||
                ? html`
 | 
			
		||||
                    <div
 | 
			
		||||
                      class="children ${classMap({
 | 
			
		||||
                        portrait:
 | 
			
		||||
                          childrenMediaClass.thumbnail_ratio === "portrait",
 | 
			
		||||
                      })}"
 | 
			
		||||
                    >
 | 
			
		||||
                      ${children.map(
 | 
			
		||||
                        (child) => html`
 | 
			
		||||
                          <div
 | 
			
		||||
                            class="child"
 | 
			
		||||
                            .item=${child}
 | 
			
		||||
                            @click=${this._childClicked}
 | 
			
		||||
                          >
 | 
			
		||||
                            <ha-card outlined>
 | 
			
		||||
                              <div class="thumbnail">
 | 
			
		||||
                                ${child.thumbnail
 | 
			
		||||
                                  ? html`
 | 
			
		||||
                                      <div
 | 
			
		||||
                                        class="${["app", "directory"].includes(
 | 
			
		||||
                                          child.media_class
 | 
			
		||||
                                        )
 | 
			
		||||
                                          ? "centered-image"
 | 
			
		||||
                                          : ""} image lazythumbnail"
 | 
			
		||||
                                        data-src=${child.thumbnail}
 | 
			
		||||
                                      ></div>
 | 
			
		||||
                                    `
 | 
			
		||||
                                  : html`
 | 
			
		||||
                                      <div class="icon-holder image">
 | 
			
		||||
                                        <ha-svg-icon
 | 
			
		||||
                                          class="folder"
 | 
			
		||||
                                          .path=${MediaClassBrowserSettings[
 | 
			
		||||
                                            child.media_class === "directory"
 | 
			
		||||
                                              ? child.children_media_class ||
 | 
			
		||||
                                                child.media_class
 | 
			
		||||
                                              : child.media_class
 | 
			
		||||
                                          ].icon}
 | 
			
		||||
                                        ></ha-svg-icon>
 | 
			
		||||
                                      </div>
 | 
			
		||||
                                    `}
 | 
			
		||||
                                ${child.can_play
 | 
			
		||||
                                  ? html`
 | 
			
		||||
                                      <ha-icon-button
 | 
			
		||||
                                        class="play ${classMap({
 | 
			
		||||
                                          can_expand: child.can_expand,
 | 
			
		||||
                                        })}"
 | 
			
		||||
                                        .item=${child}
 | 
			
		||||
                                        .label=${this.hass.localize(
 | 
			
		||||
                                          `ui.components.media-browser.${this.action}-media`
 | 
			
		||||
                                        )}
 | 
			
		||||
                                        .path=${this.action === "play"
 | 
			
		||||
                                          ? mdiPlay
 | 
			
		||||
                                          : mdiPlus}
 | 
			
		||||
                                        @click=${this._actionClicked}
 | 
			
		||||
                                      ></ha-icon-button>
 | 
			
		||||
                                    `
 | 
			
		||||
                                  : ""}
 | 
			
		||||
                              </div>
 | 
			
		||||
                              <div class="title">
 | 
			
		||||
                                ${child.title}
 | 
			
		||||
                                <paper-tooltip
 | 
			
		||||
                                  fitToVisibleBounds
 | 
			
		||||
                                  position="top"
 | 
			
		||||
                                  offset="4"
 | 
			
		||||
                                  >${child.title}</paper-tooltip
 | 
			
		||||
                                >
 | 
			
		||||
                              </div>
 | 
			
		||||
                            </ha-card>
 | 
			
		||||
                          </div>
 | 
			
		||||
                        `
 | 
			
		||||
                      )}
 | 
			
		||||
                      ${currentItem.not_shown
 | 
			
		||||
                        ? html`
 | 
			
		||||
                            <div class="grid not-shown">
 | 
			
		||||
                              <div class="title">
 | 
			
		||||
                                ${this.hass.localize(
 | 
			
		||||
                                  "ui.components.media-browser.not_shown",
 | 
			
		||||
                                  { count: currentItem.not_shown }
 | 
			
		||||
                                )}
 | 
			
		||||
                              </div>
 | 
			
		||||
                            </div>
 | 
			
		||||
                          `
 | 
			
		||||
                        : ""}
 | 
			
		||||
                    </div>
 | 
			
		||||
                  `
 | 
			
		||||
                : html`
 | 
			
		||||
                    <mwc-list>
 | 
			
		||||
                      ${children.map(
 | 
			
		||||
                        (child) => html`
 | 
			
		||||
                          <mwc-list-item
 | 
			
		||||
                            @click=${this._childClicked}
 | 
			
		||||
                            .item=${child}
 | 
			
		||||
                            .graphic=${mediaClass.show_list_images
 | 
			
		||||
                              ? "medium"
 | 
			
		||||
                              : "avatar"}
 | 
			
		||||
                            dir=${computeRTLDirection(this.hass)}
 | 
			
		||||
                          >
 | 
			
		||||
                            <div
 | 
			
		||||
                              class=${classMap({
 | 
			
		||||
                                graphic: true,
 | 
			
		||||
                                lazythumbnail:
 | 
			
		||||
                                  mediaClass.show_list_images === true,
 | 
			
		||||
                              })}
 | 
			
		||||
                              data-src=${ifDefined(
 | 
			
		||||
                                mediaClass.show_list_images && child.thumbnail
 | 
			
		||||
                                  ? child.thumbnail
 | 
			
		||||
                                  : undefined
 | 
			
		||||
                              )}
 | 
			
		||||
                              slot="graphic"
 | 
			
		||||
                            >
 | 
			
		||||
                              <ha-icon-button
 | 
			
		||||
                                class="play ${classMap({
 | 
			
		||||
                                  show:
 | 
			
		||||
                                    !mediaClass.show_list_images ||
 | 
			
		||||
                                    !child.thumbnail,
 | 
			
		||||
                                })}"
 | 
			
		||||
                                .item=${child}
 | 
			
		||||
                                .label=${this.hass.localize(
 | 
			
		||||
                                  `ui.components.media-browser.${this.action}-media`
 | 
			
		||||
                                )}
 | 
			
		||||
                                .path=${this.action === "play"
 | 
			
		||||
                                  ? mdiPlay
 | 
			
		||||
                                  : mdiPlus}
 | 
			
		||||
                                @click=${this._actionClicked}
 | 
			
		||||
                              ></ha-icon-button>
 | 
			
		||||
                            </div>
 | 
			
		||||
                            <span class="title">${child.title}</span>
 | 
			
		||||
                          </mwc-list-item>
 | 
			
		||||
                          <li divider role="separator"></li>
 | 
			
		||||
                        `
 | 
			
		||||
                      )}
 | 
			
		||||
                      ${currentItem.not_shown
 | 
			
		||||
                        ? html`
 | 
			
		||||
                            <mwc-list-item
 | 
			
		||||
                              noninteractive
 | 
			
		||||
                              class="not-shown"
 | 
			
		||||
                              .graphic=${mediaClass.show_list_images
 | 
			
		||||
                                ? "medium"
 | 
			
		||||
                                : "avatar"}
 | 
			
		||||
                              dir=${computeRTLDirection(this.hass)}
 | 
			
		||||
                            >
 | 
			
		||||
                              <span class="title">
 | 
			
		||||
                                ${this.hass.localize(
 | 
			
		||||
                                  "ui.components.media-browser.not_shown",
 | 
			
		||||
                                  { count: currentItem.not_shown }
 | 
			
		||||
                                )}
 | 
			
		||||
                              </span>
 | 
			
		||||
                            </mwc-list-item>
 | 
			
		||||
                          `
 | 
			
		||||
                        : ""}
 | 
			
		||||
                    </mwc-list>
 | 
			
		||||
                  `
 | 
			
		||||
            }
 | 
			
		||||
          </div>
 | 
			
		||||
        </div>
 | 
			
		||||
      </div>
 | 
			
		||||
    `;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  protected firstUpdated(): void {
 | 
			
		||||
    this._measureCard();
 | 
			
		||||
    this._attachResizeObserver();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  protected shouldUpdate(changedProps: PropertyValues): boolean {
 | 
			
		||||
    if (changedProps.size > 1 || !changedProps.has("hass")) {
 | 
			
		||||
      return true;
 | 
			
		||||
    }
 | 
			
		||||
    const oldHass = changedProps.get("hass") as this["hass"];
 | 
			
		||||
    return oldHass === undefined || oldHass.localize !== this.hass.localize;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public willUpdate(changedProps: PropertyValues<this>): void {
 | 
			
		||||
    super.willUpdate(changedProps);
 | 
			
		||||
 | 
			
		||||
@@ -583,6 +266,19 @@ export class HaMediaPlayerBrowse extends LitElement {
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  protected shouldUpdate(changedProps: PropertyValues): boolean {
 | 
			
		||||
    if (changedProps.size > 1 || !changedProps.has("hass")) {
 | 
			
		||||
      return true;
 | 
			
		||||
    }
 | 
			
		||||
    const oldHass = changedProps.get("hass") as this["hass"];
 | 
			
		||||
    return oldHass === undefined || oldHass.localize !== this.hass.localize;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  protected firstUpdated(): void {
 | 
			
		||||
    this._measureCard();
 | 
			
		||||
    this._attachResizeObserver();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  protected updated(changedProps: PropertyValues): void {
 | 
			
		||||
    super.updated(changedProps);
 | 
			
		||||
 | 
			
		||||
@@ -590,16 +286,383 @@ export class HaMediaPlayerBrowse extends LitElement {
 | 
			
		||||
      this._animateHeaderHeight();
 | 
			
		||||
    } else if (changedProps.has("_currentItem")) {
 | 
			
		||||
      this._setHeaderHeight();
 | 
			
		||||
      this._attachIntersectionObserver();
 | 
			
		||||
 | 
			
		||||
      // This fixes a race condition for resizing of the cards using the grid layout
 | 
			
		||||
      if (this._observed) {
 | 
			
		||||
        return;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      // @ts-ignore
 | 
			
		||||
      const virtualizer = this._virtualizer?._virtualizer;
 | 
			
		||||
 | 
			
		||||
      if (virtualizer) {
 | 
			
		||||
        this._observed = true;
 | 
			
		||||
        setTimeout(() => virtualizer._observeMutations(), 0);
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private _actionClicked(ev: MouseEvent): void {
 | 
			
		||||
  protected render(): TemplateResult {
 | 
			
		||||
    if (this._error) {
 | 
			
		||||
      return html`
 | 
			
		||||
        <div class="container">${this._renderError(this._error)}</div>
 | 
			
		||||
      `;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (!this._currentItem) {
 | 
			
		||||
      return html`<ha-circular-progress active></ha-circular-progress>`;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    const currentItem = this._currentItem;
 | 
			
		||||
 | 
			
		||||
    const subtitle = this.hass.localize(
 | 
			
		||||
      `ui.components.media-browser.class.${currentItem.media_class}`
 | 
			
		||||
    );
 | 
			
		||||
    const children = currentItem.children || [];
 | 
			
		||||
    const mediaClass = MediaClassBrowserSettings[currentItem.media_class];
 | 
			
		||||
    const childrenMediaClass = currentItem.children_media_class
 | 
			
		||||
      ? MediaClassBrowserSettings[currentItem.children_media_class]
 | 
			
		||||
      : MediaClassBrowserSettings.directory;
 | 
			
		||||
 | 
			
		||||
    const backgroundImage = currentItem.thumbnail
 | 
			
		||||
      ? this._getSignedThumbnail(currentItem.thumbnail).then(
 | 
			
		||||
          (value) => `url(${value})`
 | 
			
		||||
        )
 | 
			
		||||
      : "none";
 | 
			
		||||
 | 
			
		||||
    return html`
 | 
			
		||||
              ${
 | 
			
		||||
                currentItem.can_play
 | 
			
		||||
                  ? html`
 | 
			
		||||
                      <div
 | 
			
		||||
                        class="header ${classMap({
 | 
			
		||||
                          "no-img": !currentItem.thumbnail,
 | 
			
		||||
                          "no-dialog": !this.dialog,
 | 
			
		||||
                        })}"
 | 
			
		||||
                        @transitionend=${this._setHeaderHeight}
 | 
			
		||||
                      >
 | 
			
		||||
                        <div class="header-content">
 | 
			
		||||
                          ${currentItem.thumbnail
 | 
			
		||||
                            ? html`
 | 
			
		||||
                                <div
 | 
			
		||||
                                  class="img"
 | 
			
		||||
                                  style="background-image: ${until(
 | 
			
		||||
                                    backgroundImage,
 | 
			
		||||
                                    ""
 | 
			
		||||
                                  )}"
 | 
			
		||||
                                >
 | 
			
		||||
                                  ${this._narrow && currentItem?.can_play
 | 
			
		||||
                                    ? html`
 | 
			
		||||
                                        <ha-fab
 | 
			
		||||
                                          mini
 | 
			
		||||
                                          .item=${currentItem}
 | 
			
		||||
                                          @click=${this._actionClicked}
 | 
			
		||||
                                        >
 | 
			
		||||
                                          <ha-svg-icon
 | 
			
		||||
                                            slot="icon"
 | 
			
		||||
                                            .label=${this.hass.localize(
 | 
			
		||||
                                              `ui.components.media-browser.${this.action}-media`
 | 
			
		||||
                                            )}
 | 
			
		||||
                                            .path=${this.action === "play"
 | 
			
		||||
                                              ? mdiPlay
 | 
			
		||||
                                              : mdiPlus}
 | 
			
		||||
                                          ></ha-svg-icon>
 | 
			
		||||
                                          ${this.hass.localize(
 | 
			
		||||
                                            `ui.components.media-browser.${this.action}`
 | 
			
		||||
                                          )}
 | 
			
		||||
                                        </ha-fab>
 | 
			
		||||
                                      `
 | 
			
		||||
                                    : ""}
 | 
			
		||||
                                </div>
 | 
			
		||||
                              `
 | 
			
		||||
                            : html``}
 | 
			
		||||
                          <div class="header-info">
 | 
			
		||||
                            <div class="breadcrumb">
 | 
			
		||||
                              <h1 class="title">${currentItem.title}</h1>
 | 
			
		||||
                              ${subtitle
 | 
			
		||||
                                ? html` <h2 class="subtitle">${subtitle}</h2> `
 | 
			
		||||
                                : ""}
 | 
			
		||||
                            </div>
 | 
			
		||||
                            ${currentItem.can_play &&
 | 
			
		||||
                            (!currentItem.thumbnail || !this._narrow)
 | 
			
		||||
                              ? html`
 | 
			
		||||
                                  <mwc-button
 | 
			
		||||
                                    raised
 | 
			
		||||
                                    .item=${currentItem}
 | 
			
		||||
                                    @click=${this._actionClicked}
 | 
			
		||||
                                  >
 | 
			
		||||
                                    <ha-svg-icon
 | 
			
		||||
                                      .label=${this.hass.localize(
 | 
			
		||||
                                        `ui.components.media-browser.${this.action}-media`
 | 
			
		||||
                                      )}
 | 
			
		||||
                                      .path=${this.action === "play"
 | 
			
		||||
                                        ? mdiPlay
 | 
			
		||||
                                        : mdiPlus}
 | 
			
		||||
                                    ></ha-svg-icon>
 | 
			
		||||
                                    ${this.hass.localize(
 | 
			
		||||
                                      `ui.components.media-browser.${this.action}`
 | 
			
		||||
                                    )}
 | 
			
		||||
                                  </mwc-button>
 | 
			
		||||
                                `
 | 
			
		||||
                              : ""}
 | 
			
		||||
                          </div>
 | 
			
		||||
                        </div>
 | 
			
		||||
                      </div>
 | 
			
		||||
                    `
 | 
			
		||||
                  : ""
 | 
			
		||||
              }
 | 
			
		||||
          <div
 | 
			
		||||
            class="content"
 | 
			
		||||
            @scroll=${this._scroll}
 | 
			
		||||
            @touchmove=${this._scroll}
 | 
			
		||||
          >
 | 
			
		||||
            ${
 | 
			
		||||
              this._error
 | 
			
		||||
                ? html`
 | 
			
		||||
                    <div class="container">
 | 
			
		||||
                      ${this._renderError(this._error)}
 | 
			
		||||
                    </div>
 | 
			
		||||
                  `
 | 
			
		||||
                : isTTSMediaSource(currentItem.media_content_id)
 | 
			
		||||
                ? html`
 | 
			
		||||
                    <ha-browse-media-tts
 | 
			
		||||
                      .item=${currentItem}
 | 
			
		||||
                      .hass=${this.hass}
 | 
			
		||||
                      .action=${this.action}
 | 
			
		||||
                      @tts-picked=${this._ttsPicked}
 | 
			
		||||
                    ></ha-browse-media-tts>
 | 
			
		||||
                  `
 | 
			
		||||
                : !children.length && !currentItem.not_shown
 | 
			
		||||
                ? html`
 | 
			
		||||
                    <div class="container no-items">
 | 
			
		||||
                      ${currentItem.media_content_id ===
 | 
			
		||||
                      "media-source://media_source/local/."
 | 
			
		||||
                        ? html`
 | 
			
		||||
                            <div class="highlight-add-button">
 | 
			
		||||
                              <span>
 | 
			
		||||
                                <ha-svg-icon
 | 
			
		||||
                                  .path=${mdiArrowUpRight}
 | 
			
		||||
                                ></ha-svg-icon>
 | 
			
		||||
                              </span>
 | 
			
		||||
                              <span>
 | 
			
		||||
                                ${this.hass.localize(
 | 
			
		||||
                                  "ui.components.media-browser.file_management.highlight_button"
 | 
			
		||||
                                )}
 | 
			
		||||
                              </span>
 | 
			
		||||
                            </div>
 | 
			
		||||
                          `
 | 
			
		||||
                        : this.hass.localize(
 | 
			
		||||
                            "ui.components.media-browser.no_items"
 | 
			
		||||
                          )}
 | 
			
		||||
                    </div>
 | 
			
		||||
                  `
 | 
			
		||||
                : childrenMediaClass.layout === "grid"
 | 
			
		||||
                ? html`
 | 
			
		||||
                    <lit-virtualizer
 | 
			
		||||
                      scroller
 | 
			
		||||
                      .layout=${grid({
 | 
			
		||||
                        itemSize: {
 | 
			
		||||
                          width: "175px",
 | 
			
		||||
                          height: "225px",
 | 
			
		||||
                        },
 | 
			
		||||
                        gap: "16px",
 | 
			
		||||
                        flex: { preserve: "aspect-ratio" },
 | 
			
		||||
                        justify: "space-evenly",
 | 
			
		||||
                        direction: "vertical",
 | 
			
		||||
                      })}
 | 
			
		||||
                      .items=${children}
 | 
			
		||||
                      .renderItem=${this._renderGridItem}
 | 
			
		||||
                      class="children ${classMap({
 | 
			
		||||
                        portrait:
 | 
			
		||||
                          childrenMediaClass.thumbnail_ratio === "portrait",
 | 
			
		||||
                        not_shown: !!currentItem.not_shown,
 | 
			
		||||
                      })}"
 | 
			
		||||
                    ></lit-virtualizer>
 | 
			
		||||
                    ${currentItem.not_shown
 | 
			
		||||
                      ? html`
 | 
			
		||||
                          <div class="grid not-shown">
 | 
			
		||||
                            <div class="title">
 | 
			
		||||
                              ${this.hass.localize(
 | 
			
		||||
                                "ui.components.media-browser.not_shown",
 | 
			
		||||
                                { count: currentItem.not_shown }
 | 
			
		||||
                              )}
 | 
			
		||||
                            </div>
 | 
			
		||||
                          </div>
 | 
			
		||||
                        `
 | 
			
		||||
                      : ""}
 | 
			
		||||
                  `
 | 
			
		||||
                : html`
 | 
			
		||||
                    <mwc-list>
 | 
			
		||||
                      <lit-virtualizer
 | 
			
		||||
                        scroller
 | 
			
		||||
                        .items=${children}
 | 
			
		||||
                        style=${styleMap({
 | 
			
		||||
                          height: `${children.length * 72 + 26}px`,
 | 
			
		||||
                        })}
 | 
			
		||||
                        .renderItem=${this._renderListItem}
 | 
			
		||||
                      ></lit-virtualizer>
 | 
			
		||||
                      ${currentItem.not_shown
 | 
			
		||||
                        ? html`
 | 
			
		||||
                            <mwc-list-item
 | 
			
		||||
                              noninteractive
 | 
			
		||||
                              class="not-shown"
 | 
			
		||||
                              .graphic=${mediaClass.show_list_images
 | 
			
		||||
                                ? "medium"
 | 
			
		||||
                                : "avatar"}
 | 
			
		||||
                              dir=${computeRTLDirection(this.hass)}
 | 
			
		||||
                            >
 | 
			
		||||
                              <span class="title">
 | 
			
		||||
                                ${this.hass.localize(
 | 
			
		||||
                                  "ui.components.media-browser.not_shown",
 | 
			
		||||
                                  { count: currentItem.not_shown }
 | 
			
		||||
                                )}
 | 
			
		||||
                              </span>
 | 
			
		||||
                            </mwc-list-item>
 | 
			
		||||
                          `
 | 
			
		||||
                        : ""}
 | 
			
		||||
                    </mwc-list>
 | 
			
		||||
                  `
 | 
			
		||||
            }
 | 
			
		||||
          </div>
 | 
			
		||||
        </div>
 | 
			
		||||
      </div>
 | 
			
		||||
    `;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private _renderGridItem = (child: MediaPlayerItem): TemplateResult => {
 | 
			
		||||
    const backgroundImage = child.thumbnail
 | 
			
		||||
      ? this._getSignedThumbnail(child.thumbnail).then(
 | 
			
		||||
          (value) => `url(${value})`
 | 
			
		||||
        )
 | 
			
		||||
      : "none";
 | 
			
		||||
 | 
			
		||||
    return html`
 | 
			
		||||
      <div class="child" .item=${child} @click=${this._childClicked}>
 | 
			
		||||
        <ha-card outlined>
 | 
			
		||||
          <div class="thumbnail">
 | 
			
		||||
            ${child.thumbnail
 | 
			
		||||
              ? html`
 | 
			
		||||
                  <div
 | 
			
		||||
                    class="${["app", "directory"].includes(child.media_class)
 | 
			
		||||
                      ? "centered-image"
 | 
			
		||||
                      : ""} image"
 | 
			
		||||
                    style="background-image: ${until(backgroundImage, "")}"
 | 
			
		||||
                  ></div>
 | 
			
		||||
                `
 | 
			
		||||
              : html`
 | 
			
		||||
                  <div class="icon-holder image">
 | 
			
		||||
                    <ha-svg-icon
 | 
			
		||||
                      class="folder"
 | 
			
		||||
                      .path=${MediaClassBrowserSettings[
 | 
			
		||||
                        child.media_class === "directory"
 | 
			
		||||
                          ? child.children_media_class || child.media_class
 | 
			
		||||
                          : child.media_class
 | 
			
		||||
                      ].icon}
 | 
			
		||||
                    ></ha-svg-icon>
 | 
			
		||||
                  </div>
 | 
			
		||||
                `}
 | 
			
		||||
            ${child.can_play
 | 
			
		||||
              ? html`
 | 
			
		||||
                  <ha-icon-button
 | 
			
		||||
                    class="play ${classMap({
 | 
			
		||||
                      can_expand: child.can_expand,
 | 
			
		||||
                    })}"
 | 
			
		||||
                    .item=${child}
 | 
			
		||||
                    .label=${this.hass.localize(
 | 
			
		||||
                      `ui.components.media-browser.${this.action}-media`
 | 
			
		||||
                    )}
 | 
			
		||||
                    .path=${this.action === "play" ? mdiPlay : mdiPlus}
 | 
			
		||||
                    @click=${this._actionClicked}
 | 
			
		||||
                  ></ha-icon-button>
 | 
			
		||||
                `
 | 
			
		||||
              : ""}
 | 
			
		||||
          </div>
 | 
			
		||||
          <div class="title">
 | 
			
		||||
            ${child.title}
 | 
			
		||||
            <paper-tooltip fitToVisibleBounds position="top" offset="4"
 | 
			
		||||
              >${child.title}</paper-tooltip
 | 
			
		||||
            >
 | 
			
		||||
          </div>
 | 
			
		||||
        </ha-card>
 | 
			
		||||
      </div>
 | 
			
		||||
    `;
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  private _renderListItem = (child: MediaPlayerItem): TemplateResult => {
 | 
			
		||||
    const currentItem = this._currentItem;
 | 
			
		||||
    const mediaClass = MediaClassBrowserSettings[currentItem!.media_class];
 | 
			
		||||
 | 
			
		||||
    const backgroundImage =
 | 
			
		||||
      mediaClass.show_list_images && child.thumbnail
 | 
			
		||||
        ? this._getSignedThumbnail(child.thumbnail).then(
 | 
			
		||||
            (value) => `url(${value})`
 | 
			
		||||
          )
 | 
			
		||||
        : "none";
 | 
			
		||||
 | 
			
		||||
    return html`
 | 
			
		||||
      <mwc-list-item
 | 
			
		||||
        @click=${this._childClicked}
 | 
			
		||||
        .item=${child}
 | 
			
		||||
        .graphic=${mediaClass.show_list_images ? "medium" : "avatar"}
 | 
			
		||||
        dir=${computeRTLDirection(this.hass)}
 | 
			
		||||
      >
 | 
			
		||||
        <div
 | 
			
		||||
          class=${classMap({
 | 
			
		||||
            graphic: true,
 | 
			
		||||
            thumbnail: mediaClass.show_list_images === true,
 | 
			
		||||
          })}
 | 
			
		||||
          style="background-image: ${until(backgroundImage, "")}"
 | 
			
		||||
          slot="graphic"
 | 
			
		||||
        >
 | 
			
		||||
          <ha-icon-button
 | 
			
		||||
            class="play ${classMap({
 | 
			
		||||
              show: !mediaClass.show_list_images || !child.thumbnail,
 | 
			
		||||
            })}"
 | 
			
		||||
            .item=${child}
 | 
			
		||||
            .label=${this.hass.localize(
 | 
			
		||||
              `ui.components.media-browser.${this.action}-media`
 | 
			
		||||
            )}
 | 
			
		||||
            .path=${this.action === "play" ? mdiPlay : mdiPlus}
 | 
			
		||||
            @click=${this._actionClicked}
 | 
			
		||||
          ></ha-icon-button>
 | 
			
		||||
        </div>
 | 
			
		||||
        <span class="title">${child.title}</span>
 | 
			
		||||
      </mwc-list-item>
 | 
			
		||||
    `;
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  private async _getSignedThumbnail(
 | 
			
		||||
    thumbnailUrl: string | undefined
 | 
			
		||||
  ): Promise<string> {
 | 
			
		||||
    if (!thumbnailUrl) {
 | 
			
		||||
      return "";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (thumbnailUrl.startsWith("/")) {
 | 
			
		||||
      // Thumbnails served by local API require authentication
 | 
			
		||||
      return (await getSignedPath(this.hass, thumbnailUrl)).path;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (thumbnailUrl.startsWith("https://brands.home-assistant.io")) {
 | 
			
		||||
      // The backend is not aware of the theme used by the users,
 | 
			
		||||
      // so we rewrite the URL to show a proper icon
 | 
			
		||||
      thumbnailUrl = brandsUrl({
 | 
			
		||||
        domain: extractDomainFromBrandUrl(thumbnailUrl),
 | 
			
		||||
        type: "icon",
 | 
			
		||||
        useFallback: true,
 | 
			
		||||
        darkOptimized: this.hass.themes?.darkMode,
 | 
			
		||||
      });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return thumbnailUrl;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private _actionClicked = (ev: MouseEvent): void => {
 | 
			
		||||
    ev.stopPropagation();
 | 
			
		||||
    const item = (ev.currentTarget as any).item;
 | 
			
		||||
 | 
			
		||||
    this._runAction(item);
 | 
			
		||||
  }
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  private _runAction(item: MediaPlayerItem): void {
 | 
			
		||||
    fireEvent(this, "media-picked", { item, navigateIds: this.navigateIds });
 | 
			
		||||
@@ -615,7 +678,7 @@ export class HaMediaPlayerBrowse extends LitElement {
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private async _childClicked(ev: MouseEvent): Promise<void> {
 | 
			
		||||
  private _childClicked = async (ev: MouseEvent): Promise<void> => {
 | 
			
		||||
    const target = ev.currentTarget as any;
 | 
			
		||||
    const item: MediaPlayerItem = target.item;
 | 
			
		||||
 | 
			
		||||
@@ -631,7 +694,7 @@ export class HaMediaPlayerBrowse extends LitElement {
 | 
			
		||||
    fireEvent(this, "media-browsed", {
 | 
			
		||||
      ids: [...this.navigateIds, item],
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  private async _fetchData(
 | 
			
		||||
    entityId: string,
 | 
			
		||||
@@ -658,55 +721,6 @@ export class HaMediaPlayerBrowse extends LitElement {
 | 
			
		||||
    this._resizeObserver.observe(this);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Load thumbnails for images on demand as they become visible.
 | 
			
		||||
   */
 | 
			
		||||
  private async _attachIntersectionObserver(): Promise<void> {
 | 
			
		||||
    if (!("IntersectionObserver" in window) || !this._thumbnails) {
 | 
			
		||||
      return;
 | 
			
		||||
    }
 | 
			
		||||
    if (!this._intersectionObserver) {
 | 
			
		||||
      this._intersectionObserver = new IntersectionObserver(
 | 
			
		||||
        async (entries, observer) => {
 | 
			
		||||
          await Promise.all(
 | 
			
		||||
            entries.map(async (entry) => {
 | 
			
		||||
              if (!entry.isIntersecting) {
 | 
			
		||||
                return;
 | 
			
		||||
              }
 | 
			
		||||
              const thumbnailCard = entry.target as HTMLElement;
 | 
			
		||||
              let thumbnailUrl = thumbnailCard.dataset.src;
 | 
			
		||||
              if (!thumbnailUrl) {
 | 
			
		||||
                return;
 | 
			
		||||
              }
 | 
			
		||||
              if (thumbnailUrl.startsWith("/")) {
 | 
			
		||||
                // Thumbnails served by local API require authentication
 | 
			
		||||
                const signedPath = await getSignedPath(this.hass, thumbnailUrl);
 | 
			
		||||
                thumbnailUrl = signedPath.path;
 | 
			
		||||
              } else if (
 | 
			
		||||
                thumbnailUrl.startsWith("https://brands.home-assistant.io")
 | 
			
		||||
              ) {
 | 
			
		||||
                // The backend is not aware of the theme used by the users,
 | 
			
		||||
                // so we rewrite the URL to show a proper icon
 | 
			
		||||
                thumbnailUrl = brandsUrl({
 | 
			
		||||
                  domain: extractDomainFromBrandUrl(thumbnailUrl),
 | 
			
		||||
                  type: "icon",
 | 
			
		||||
                  useFallback: true,
 | 
			
		||||
                  darkOptimized: this.hass.themes?.darkMode,
 | 
			
		||||
                });
 | 
			
		||||
              }
 | 
			
		||||
              thumbnailCard.style.backgroundImage = `url(${thumbnailUrl})`;
 | 
			
		||||
              observer.unobserve(thumbnailCard); // loaded, so no need to observe anymore
 | 
			
		||||
            })
 | 
			
		||||
          );
 | 
			
		||||
        }
 | 
			
		||||
      );
 | 
			
		||||
    }
 | 
			
		||||
    const observer = this._intersectionObserver!;
 | 
			
		||||
    for (const thumbnailCard of this._thumbnails) {
 | 
			
		||||
      observer.observe(thumbnailCard);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private _closeDialogAction(): void {
 | 
			
		||||
    fireEvent(this, "close-dialog");
 | 
			
		||||
  }
 | 
			
		||||
@@ -841,6 +855,7 @@ export class HaMediaPlayerBrowse extends LitElement {
 | 
			
		||||
        .content {
 | 
			
		||||
          overflow-y: auto;
 | 
			
		||||
          box-sizing: border-box;
 | 
			
		||||
          height: 100%;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /* HEADER */
 | 
			
		||||
@@ -926,6 +941,7 @@ export class HaMediaPlayerBrowse extends LitElement {
 | 
			
		||||
        .not-shown {
 | 
			
		||||
          font-style: italic;
 | 
			
		||||
          color: var(--secondary-text-color);
 | 
			
		||||
          padding: 8px 16px 8px;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        .grid.not-shown {
 | 
			
		||||
@@ -951,7 +967,11 @@ export class HaMediaPlayerBrowse extends LitElement {
 | 
			
		||||
          border-bottom-color: var(--divider-color);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        .children {
 | 
			
		||||
        mwc-list-item {
 | 
			
		||||
          width: 100%;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        div.children {
 | 
			
		||||
          display: grid;
 | 
			
		||||
          grid-template-columns: repeat(
 | 
			
		||||
            auto-fit,
 | 
			
		||||
@@ -988,7 +1008,7 @@ export class HaMediaPlayerBrowse extends LitElement {
 | 
			
		||||
          padding-bottom: 100%;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        .portrait.children ha-card .thumbnail {
 | 
			
		||||
        .portrait ha-card .thumbnail {
 | 
			
		||||
          padding-bottom: 150%;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@@ -1062,10 +1082,6 @@ export class HaMediaPlayerBrowse extends LitElement {
 | 
			
		||||
          color: var(--primary-color);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        ha-card:hover .lazythumbnail {
 | 
			
		||||
          opacity: 0.5;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        .child .title {
 | 
			
		||||
          font-size: 16px;
 | 
			
		||||
          padding-top: 16px;
 | 
			
		||||
@@ -1127,7 +1143,7 @@ export class HaMediaPlayerBrowse extends LitElement {
 | 
			
		||||
          padding: 0 24px;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        :host([narrow]) .children {
 | 
			
		||||
        :host([narrow]) div.children {
 | 
			
		||||
          grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@@ -1232,6 +1248,16 @@ export class HaMediaPlayerBrowse extends LitElement {
 | 
			
		||||
          --mdc-fab-box-shadow: none;
 | 
			
		||||
          --mdc-theme-secondary: rgba(var(--rgb-primary-color), 0.5);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        lit-virtualizer {
 | 
			
		||||
          height: 100%;
 | 
			
		||||
          overflow: overlay !important;
 | 
			
		||||
          contain: size layout !important;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        lit-virtualizer.not_shown {
 | 
			
		||||
          height: calc(100% - 36px);
 | 
			
		||||
        }
 | 
			
		||||
      `,
 | 
			
		||||
    ];
 | 
			
		||||
  }
 | 
			
		||||
 
 | 
			
		||||
@@ -119,6 +119,11 @@ class MediaUploadButton extends LitElement {
 | 
			
		||||
    ha-circular-progress[slot="icon"] {
 | 
			
		||||
      vertical-align: middle;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    :host-context([style*="direction: rtl;"]) ha-svg-icon[slot="icon"] {
 | 
			
		||||
      margin-left: 8px;
 | 
			
		||||
      margin-right: 0px;
 | 
			
		||||
    }
 | 
			
		||||
  `;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -10,6 +10,8 @@ export class HaTimeline extends LitElement {
 | 
			
		||||
 | 
			
		||||
  @property({ type: Boolean, reflect: true }) public raised = false;
 | 
			
		||||
 | 
			
		||||
  @property({ reflect: true, type: Boolean }) notEnabled = false;
 | 
			
		||||
 | 
			
		||||
  @property({ type: Boolean }) public lastItem = false;
 | 
			
		||||
 | 
			
		||||
  @property({ type: String }) public icon?: string;
 | 
			
		||||
@@ -76,6 +78,9 @@ export class HaTimeline extends LitElement {
 | 
			
		||||
          margin-right: 8px;
 | 
			
		||||
          width: 24px;
 | 
			
		||||
        }
 | 
			
		||||
        :host([notEnabled]) ha-svg-icon {
 | 
			
		||||
          opacity: 0.5;
 | 
			
		||||
        }
 | 
			
		||||
        ha-svg-icon {
 | 
			
		||||
          color: var(
 | 
			
		||||
            --timeline-ball-color,
 | 
			
		||||
 
 | 
			
		||||
@@ -114,6 +114,11 @@ export class HaTracePathDetails extends LitElement {
 | 
			
		||||
          const { path, timestamp, result, error, changed_variables, ...rest } =
 | 
			
		||||
            trace as any;
 | 
			
		||||
 | 
			
		||||
          if (result?.enabled === false) {
 | 
			
		||||
            return html`This node was disabled and skipped during execution so
 | 
			
		||||
            no further trace information is available.`;
 | 
			
		||||
          }
 | 
			
		||||
 | 
			
		||||
          return html`
 | 
			
		||||
            ${curPath === this.selected.path
 | 
			
		||||
              ? ""
 | 
			
		||||
 
 | 
			
		||||
@@ -19,6 +19,8 @@ export class HatGraphNode extends LitElement {
 | 
			
		||||
 | 
			
		||||
  @property({ reflect: true, type: Boolean }) disabled?: boolean;
 | 
			
		||||
 | 
			
		||||
  @property({ reflect: true, type: Boolean }) notEnabled = false;
 | 
			
		||||
 | 
			
		||||
  @property({ reflect: true, type: Boolean }) graphStart?: boolean;
 | 
			
		||||
 | 
			
		||||
  @property({ type: Boolean, attribute: "nofocus" }) noFocus = false;
 | 
			
		||||
@@ -114,8 +116,14 @@ export class HatGraphNode extends LitElement {
 | 
			
		||||
        --stroke-clr: var(--hover-clr);
 | 
			
		||||
        --icon-clr: var(--default-icon-clr);
 | 
			
		||||
      }
 | 
			
		||||
      :host([disabled]) circle {
 | 
			
		||||
        stroke: var(--disabled-clr);
 | 
			
		||||
      :host([notEnabled]) circle {
 | 
			
		||||
        --stroke-clr: var(--disabled-clr);
 | 
			
		||||
      }
 | 
			
		||||
      :host([notEnabled][active]) circle {
 | 
			
		||||
        --stroke-clr: var(--disabled-active-clr);
 | 
			
		||||
      }
 | 
			
		||||
      :host([notEnabled]:hover) circle {
 | 
			
		||||
        --stroke-clr: var(--disabled-hover-clr);
 | 
			
		||||
      }
 | 
			
		||||
      svg {
 | 
			
		||||
        width: 100%;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,11 @@
 | 
			
		||||
import {
 | 
			
		||||
  mdiAbTesting,
 | 
			
		||||
  mdiAlertOctagon,
 | 
			
		||||
  mdiArrowDecision,
 | 
			
		||||
  mdiArrowUp,
 | 
			
		||||
  mdiAsterisk,
 | 
			
		||||
  mdiCallMissed,
 | 
			
		||||
  mdiCallReceived,
 | 
			
		||||
  mdiCallSplit,
 | 
			
		||||
  mdiCheckboxBlankOutline,
 | 
			
		||||
  mdiCheckboxMarkedOutline,
 | 
			
		||||
@@ -9,10 +13,12 @@ import {
 | 
			
		||||
  mdiChevronRight,
 | 
			
		||||
  mdiChevronUp,
 | 
			
		||||
  mdiClose,
 | 
			
		||||
  mdiCloseOctagon,
 | 
			
		||||
  mdiCodeBrackets,
 | 
			
		||||
  mdiDevices,
 | 
			
		||||
  mdiExclamation,
 | 
			
		||||
  mdiRefresh,
 | 
			
		||||
  mdiShuffleDisabled,
 | 
			
		||||
  mdiTimerOutline,
 | 
			
		||||
  mdiTrafficLight,
 | 
			
		||||
} from "@mdi/js";
 | 
			
		||||
@@ -27,6 +33,9 @@ import {
 | 
			
		||||
  DelayAction,
 | 
			
		||||
  DeviceAction,
 | 
			
		||||
  EventAction,
 | 
			
		||||
  IfAction,
 | 
			
		||||
  ManualScriptConfig,
 | 
			
		||||
  ParallelAction,
 | 
			
		||||
  RepeatAction,
 | 
			
		||||
  SceneAction,
 | 
			
		||||
  ServiceAction,
 | 
			
		||||
@@ -36,6 +45,8 @@ import {
 | 
			
		||||
import {
 | 
			
		||||
  ChooseActionTraceStep,
 | 
			
		||||
  ConditionTraceStep,
 | 
			
		||||
  IfActionTraceStep,
 | 
			
		||||
  StopActionTraceStep,
 | 
			
		||||
  TraceExtended,
 | 
			
		||||
} from "../../data/trace";
 | 
			
		||||
import "../ha-icon-button";
 | 
			
		||||
@@ -85,6 +96,7 @@ export class HatScriptGraph extends LitElement {
 | 
			
		||||
        @focus=${this.selectNode(config, path)}
 | 
			
		||||
        ?active=${this.selected === path}
 | 
			
		||||
        .iconPath=${mdiAsterisk}
 | 
			
		||||
        .notEnabled=${config.enabled === false}
 | 
			
		||||
        tabindex=${track ? "0" : "-1"}
 | 
			
		||||
      ></hat-graph-node>
 | 
			
		||||
    `;
 | 
			
		||||
@@ -101,6 +113,9 @@ export class HatScriptGraph extends LitElement {
 | 
			
		||||
 | 
			
		||||
  private typeRenderers = {
 | 
			
		||||
    condition: this.render_condition_node,
 | 
			
		||||
    and: this.render_condition_node,
 | 
			
		||||
    or: this.render_condition_node,
 | 
			
		||||
    not: this.render_condition_node,
 | 
			
		||||
    delay: this.render_delay_node,
 | 
			
		||||
    event: this.render_event_node,
 | 
			
		||||
    scene: this.render_scene_node,
 | 
			
		||||
@@ -110,23 +125,37 @@ export class HatScriptGraph extends LitElement {
 | 
			
		||||
    repeat: this.render_repeat_node,
 | 
			
		||||
    choose: this.render_choose_node,
 | 
			
		||||
    device_id: this.render_device_node,
 | 
			
		||||
    if: this.render_if_node,
 | 
			
		||||
    stop: this.render_stop_node,
 | 
			
		||||
    parallel: this.render_parallel_node,
 | 
			
		||||
    other: this.render_other_node,
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  private render_action_node(node: Action, path: string, graphStart = false) {
 | 
			
		||||
  private render_action_node(
 | 
			
		||||
    node: Action,
 | 
			
		||||
    path: string,
 | 
			
		||||
    graphStart = false,
 | 
			
		||||
    disabled = false
 | 
			
		||||
  ) {
 | 
			
		||||
    const type =
 | 
			
		||||
      Object.keys(this.typeRenderers).find((key) => key in node) || "other";
 | 
			
		||||
    this.renderedNodes[path] = { config: node, path };
 | 
			
		||||
    if (this.trace && path in this.trace.trace) {
 | 
			
		||||
      this.trackedNodes[path] = this.renderedNodes[path];
 | 
			
		||||
    }
 | 
			
		||||
    return this.typeRenderers[type].bind(this)(node, path, graphStart);
 | 
			
		||||
    return this.typeRenderers[type].bind(this)(
 | 
			
		||||
      node,
 | 
			
		||||
      path,
 | 
			
		||||
      graphStart,
 | 
			
		||||
      disabled
 | 
			
		||||
    );
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private render_choose_node(
 | 
			
		||||
    config: ChooseAction,
 | 
			
		||||
    path: string,
 | 
			
		||||
    graphStart = false
 | 
			
		||||
    graphStart = false,
 | 
			
		||||
    disabled = false
 | 
			
		||||
  ) {
 | 
			
		||||
    const trace = this.trace.trace[path] as ChooseActionTraceStep[] | undefined;
 | 
			
		||||
    const trace_path = trace
 | 
			
		||||
@@ -143,12 +172,14 @@ export class HatScriptGraph extends LitElement {
 | 
			
		||||
        @focus=${this.selectNode(config, path)}
 | 
			
		||||
        ?track=${trace !== undefined}
 | 
			
		||||
        ?active=${this.selected === path}
 | 
			
		||||
        .notEnabled=${disabled || config.enabled === false}
 | 
			
		||||
      >
 | 
			
		||||
        <hat-graph-node
 | 
			
		||||
          .graphStart=${graphStart}
 | 
			
		||||
          .iconPath=${mdiCallSplit}
 | 
			
		||||
          .iconPath=${mdiArrowDecision}
 | 
			
		||||
          ?track=${trace !== undefined}
 | 
			
		||||
          ?active=${this.selected === path}
 | 
			
		||||
          .notEnabled=${disabled || config.enabled === false}
 | 
			
		||||
          slot="head"
 | 
			
		||||
          nofocus
 | 
			
		||||
        ></hat-graph-node>
 | 
			
		||||
@@ -171,12 +202,15 @@ export class HatScriptGraph extends LitElement {
 | 
			
		||||
                    @focus=${this.selectNode(config, branch_path)}
 | 
			
		||||
                    ?track=${track_this}
 | 
			
		||||
                    ?active=${this.selected === branch_path}
 | 
			
		||||
                    .notEnabled=${disabled || config.enabled === false}
 | 
			
		||||
                  ></hat-graph-node>
 | 
			
		||||
                  ${branch.sequence !== null
 | 
			
		||||
                    ? ensureArray(branch.sequence).map((action, j) =>
 | 
			
		||||
                        this.render_action_node(
 | 
			
		||||
                          action,
 | 
			
		||||
                          `${branch_path}/sequence/${j}`
 | 
			
		||||
                          `${branch_path}/sequence/${j}`,
 | 
			
		||||
                          false,
 | 
			
		||||
                          disabled || config.enabled === false
 | 
			
		||||
                        )
 | 
			
		||||
                      )
 | 
			
		||||
                    : ""}
 | 
			
		||||
@@ -188,7 +222,12 @@ export class HatScriptGraph extends LitElement {
 | 
			
		||||
          <hat-graph-spacer ?track=${track_default}></hat-graph-spacer>
 | 
			
		||||
          ${config.default !== null
 | 
			
		||||
            ? ensureArray(config.default)?.map((action, i) =>
 | 
			
		||||
                this.render_action_node(action, `${path}/default/${i}`)
 | 
			
		||||
                this.render_action_node(
 | 
			
		||||
                  action,
 | 
			
		||||
                  `${path}/default/${i}`,
 | 
			
		||||
                  false,
 | 
			
		||||
                  disabled || config.enabled === false
 | 
			
		||||
                )
 | 
			
		||||
              )
 | 
			
		||||
            : ""}
 | 
			
		||||
        </div>
 | 
			
		||||
@@ -196,10 +235,88 @@ export class HatScriptGraph extends LitElement {
 | 
			
		||||
    `;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private render_if_node(
 | 
			
		||||
    config: IfAction,
 | 
			
		||||
    path: string,
 | 
			
		||||
    graphStart = false,
 | 
			
		||||
    disabled = false
 | 
			
		||||
  ) {
 | 
			
		||||
    const trace = this.trace.trace[path] as IfActionTraceStep[] | undefined;
 | 
			
		||||
    let trackThen = false;
 | 
			
		||||
    let trackElse = false;
 | 
			
		||||
    for (const trc of trace || []) {
 | 
			
		||||
      if (!trackThen && trc.result?.choice === "then") {
 | 
			
		||||
        trackThen = true;
 | 
			
		||||
      }
 | 
			
		||||
      if ((!trackElse && trc.result?.choice === "else") || !trc.result) {
 | 
			
		||||
        trackElse = true;
 | 
			
		||||
      }
 | 
			
		||||
      if (trackElse && trackThen) {
 | 
			
		||||
        break;
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    return html`
 | 
			
		||||
      <hat-graph-branch
 | 
			
		||||
        tabindex=${trace === undefined ? "-1" : "0"}
 | 
			
		||||
        @focus=${this.selectNode(config, path)}
 | 
			
		||||
        ?track=${trace !== undefined}
 | 
			
		||||
        ?active=${this.selected === path}
 | 
			
		||||
        .notEnabled=${disabled || config.enabled === false}
 | 
			
		||||
      >
 | 
			
		||||
        <hat-graph-node
 | 
			
		||||
          .graphStart=${graphStart}
 | 
			
		||||
          .iconPath=${mdiCallSplit}
 | 
			
		||||
          ?track=${trace !== undefined}
 | 
			
		||||
          ?active=${this.selected === path}
 | 
			
		||||
          .notEnabled=${disabled || config.enabled === false}
 | 
			
		||||
          slot="head"
 | 
			
		||||
          nofocus
 | 
			
		||||
        ></hat-graph-node>
 | 
			
		||||
        ${config.else
 | 
			
		||||
          ? html`<div class="graph-container" ?track=${trackElse}>
 | 
			
		||||
              <hat-graph-node
 | 
			
		||||
                .iconPath=${mdiCallMissed}
 | 
			
		||||
                ?track=${trackElse}
 | 
			
		||||
                ?active=${this.selected === path}
 | 
			
		||||
                .notEnabled=${disabled || config.enabled === false}
 | 
			
		||||
                nofocus
 | 
			
		||||
              ></hat-graph-node
 | 
			
		||||
              >${ensureArray(config.else).map((action, j) =>
 | 
			
		||||
                this.render_action_node(
 | 
			
		||||
                  action,
 | 
			
		||||
                  `${path}/else/${j}`,
 | 
			
		||||
                  false,
 | 
			
		||||
                  disabled || config.enabled === false
 | 
			
		||||
                )
 | 
			
		||||
              )}
 | 
			
		||||
            </div>`
 | 
			
		||||
          : html`<hat-graph-spacer ?track=${trackElse}></hat-graph-spacer>`}
 | 
			
		||||
        <div class="graph-container" ?track=${trackThen}>
 | 
			
		||||
          <hat-graph-node
 | 
			
		||||
            .iconPath=${mdiCallReceived}
 | 
			
		||||
            ?track=${trackThen}
 | 
			
		||||
            ?active=${this.selected === path}
 | 
			
		||||
            .notEnabled=${disabled || config.enabled === false}
 | 
			
		||||
            nofocus
 | 
			
		||||
          ></hat-graph-node>
 | 
			
		||||
          ${ensureArray(config.then).map((action, j) =>
 | 
			
		||||
            this.render_action_node(
 | 
			
		||||
              action,
 | 
			
		||||
              `${path}/then/${j}`,
 | 
			
		||||
              false,
 | 
			
		||||
              disabled || config.enabled === false
 | 
			
		||||
            )
 | 
			
		||||
          )}
 | 
			
		||||
        </div>
 | 
			
		||||
      </hat-graph-branch>
 | 
			
		||||
    `;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private render_condition_node(
 | 
			
		||||
    node: Condition,
 | 
			
		||||
    path: string,
 | 
			
		||||
    graphStart = false
 | 
			
		||||
    graphStart = false,
 | 
			
		||||
    disabled = false
 | 
			
		||||
  ) {
 | 
			
		||||
    const trace = this.trace.trace[path] as ConditionTraceStep[] | undefined;
 | 
			
		||||
    let track = false;
 | 
			
		||||
@@ -225,6 +342,7 @@ export class HatScriptGraph extends LitElement {
 | 
			
		||||
        @focus=${this.selectNode(node, path)}
 | 
			
		||||
        ?track=${track}
 | 
			
		||||
        ?active=${this.selected === path}
 | 
			
		||||
        .notEnabled=${disabled || node.enabled === false}
 | 
			
		||||
        tabindex=${trace === undefined ? "-1" : "0"}
 | 
			
		||||
        short
 | 
			
		||||
      >
 | 
			
		||||
@@ -233,6 +351,7 @@ export class HatScriptGraph extends LitElement {
 | 
			
		||||
          slot="head"
 | 
			
		||||
          ?track=${track}
 | 
			
		||||
          ?active=${this.selected === path}
 | 
			
		||||
          .notEnabled=${disabled || node.enabled === false}
 | 
			
		||||
          .iconPath=${mdiAbTesting}
 | 
			
		||||
          nofocus
 | 
			
		||||
        ></hat-graph-node>
 | 
			
		||||
@@ -247,6 +366,7 @@ export class HatScriptGraph extends LitElement {
 | 
			
		||||
          nofocus
 | 
			
		||||
          ?track=${trackFailed}
 | 
			
		||||
          ?active=${this.selected === path}
 | 
			
		||||
          .notEnabled=${disabled || node.enabled === false}
 | 
			
		||||
        ></hat-graph-node>
 | 
			
		||||
      </hat-graph-branch>
 | 
			
		||||
    `;
 | 
			
		||||
@@ -255,7 +375,8 @@ export class HatScriptGraph extends LitElement {
 | 
			
		||||
  private render_delay_node(
 | 
			
		||||
    node: DelayAction,
 | 
			
		||||
    path: string,
 | 
			
		||||
    graphStart = false
 | 
			
		||||
    graphStart = false,
 | 
			
		||||
    disabled = false
 | 
			
		||||
  ) {
 | 
			
		||||
    return html`
 | 
			
		||||
      <hat-graph-node
 | 
			
		||||
@@ -264,6 +385,7 @@ export class HatScriptGraph extends LitElement {
 | 
			
		||||
        @focus=${this.selectNode(node, path)}
 | 
			
		||||
        ?track=${path in this.trace.trace}
 | 
			
		||||
        ?active=${this.selected === path}
 | 
			
		||||
        .notEnabled=${disabled || node.enabled === false}
 | 
			
		||||
        tabindex=${this.trace && path in this.trace.trace ? "0" : "-1"}
 | 
			
		||||
      ></hat-graph-node>
 | 
			
		||||
    `;
 | 
			
		||||
@@ -272,7 +394,8 @@ export class HatScriptGraph extends LitElement {
 | 
			
		||||
  private render_device_node(
 | 
			
		||||
    node: DeviceAction,
 | 
			
		||||
    path: string,
 | 
			
		||||
    graphStart = false
 | 
			
		||||
    graphStart = false,
 | 
			
		||||
    disabled = false
 | 
			
		||||
  ) {
 | 
			
		||||
    return html`
 | 
			
		||||
      <hat-graph-node
 | 
			
		||||
@@ -281,6 +404,7 @@ export class HatScriptGraph extends LitElement {
 | 
			
		||||
        @focus=${this.selectNode(node, path)}
 | 
			
		||||
        ?track=${path in this.trace.trace}
 | 
			
		||||
        ?active=${this.selected === path}
 | 
			
		||||
        .notEnabled=${disabled || node.enabled === false}
 | 
			
		||||
        tabindex=${this.trace && path in this.trace.trace ? "0" : "-1"}
 | 
			
		||||
      ></hat-graph-node>
 | 
			
		||||
    `;
 | 
			
		||||
@@ -289,7 +413,8 @@ export class HatScriptGraph extends LitElement {
 | 
			
		||||
  private render_event_node(
 | 
			
		||||
    node: EventAction,
 | 
			
		||||
    path: string,
 | 
			
		||||
    graphStart = false
 | 
			
		||||
    graphStart = false,
 | 
			
		||||
    disabled = false
 | 
			
		||||
  ) {
 | 
			
		||||
    return html`
 | 
			
		||||
      <hat-graph-node
 | 
			
		||||
@@ -298,6 +423,7 @@ export class HatScriptGraph extends LitElement {
 | 
			
		||||
        @focus=${this.selectNode(node, path)}
 | 
			
		||||
        ?track=${path in this.trace.trace}
 | 
			
		||||
        ?active=${this.selected === path}
 | 
			
		||||
        .notEnabled=${disabled || node.enabled === false}
 | 
			
		||||
        tabindex=${this.trace && path in this.trace.trace ? "0" : "-1"}
 | 
			
		||||
      ></hat-graph-node>
 | 
			
		||||
    `;
 | 
			
		||||
@@ -306,7 +432,8 @@ export class HatScriptGraph extends LitElement {
 | 
			
		||||
  private render_repeat_node(
 | 
			
		||||
    node: RepeatAction,
 | 
			
		||||
    path: string,
 | 
			
		||||
    graphStart = false
 | 
			
		||||
    graphStart = false,
 | 
			
		||||
    disabled = false
 | 
			
		||||
  ) {
 | 
			
		||||
    const trace: any = this.trace.trace[path];
 | 
			
		||||
    const repeats = this.trace?.trace[`${path}/repeat/sequence/0`]?.length;
 | 
			
		||||
@@ -316,12 +443,14 @@ export class HatScriptGraph extends LitElement {
 | 
			
		||||
        @focus=${this.selectNode(node, path)}
 | 
			
		||||
        ?track=${path in this.trace.trace}
 | 
			
		||||
        ?active=${this.selected === path}
 | 
			
		||||
        .notEnabled=${disabled || node.enabled === false}
 | 
			
		||||
      >
 | 
			
		||||
        <hat-graph-node
 | 
			
		||||
          .graphStart=${graphStart}
 | 
			
		||||
          .iconPath=${mdiRefresh}
 | 
			
		||||
          ?track=${path in this.trace.trace}
 | 
			
		||||
          ?active=${this.selected === path}
 | 
			
		||||
          .notEnabled=${disabled || node.enabled === false}
 | 
			
		||||
          slot="head"
 | 
			
		||||
          nofocus
 | 
			
		||||
        ></hat-graph-node>
 | 
			
		||||
@@ -329,12 +458,18 @@ export class HatScriptGraph extends LitElement {
 | 
			
		||||
          .iconPath=${mdiArrowUp}
 | 
			
		||||
          ?track=${repeats > 1}
 | 
			
		||||
          ?active=${this.selected === path}
 | 
			
		||||
          .notEnabled=${disabled || node.enabled === false}
 | 
			
		||||
          nofocus
 | 
			
		||||
          .badge=${repeats > 1 ? repeats : undefined}
 | 
			
		||||
        ></hat-graph-node>
 | 
			
		||||
        <div ?track=${trace}>
 | 
			
		||||
          ${ensureArray(node.repeat.sequence).map((action, i) =>
 | 
			
		||||
            this.render_action_node(action, `${path}/repeat/sequence/${i}`)
 | 
			
		||||
            this.render_action_node(
 | 
			
		||||
              action,
 | 
			
		||||
              `${path}/repeat/sequence/${i}`,
 | 
			
		||||
              false,
 | 
			
		||||
              disabled || node.enabled === false
 | 
			
		||||
            )
 | 
			
		||||
          )}
 | 
			
		||||
        </div>
 | 
			
		||||
      </hat-graph-branch>
 | 
			
		||||
@@ -344,7 +479,8 @@ export class HatScriptGraph extends LitElement {
 | 
			
		||||
  private render_scene_node(
 | 
			
		||||
    node: SceneAction,
 | 
			
		||||
    path: string,
 | 
			
		||||
    graphStart = false
 | 
			
		||||
    graphStart = false,
 | 
			
		||||
    disabled = false
 | 
			
		||||
  ) {
 | 
			
		||||
    return html`
 | 
			
		||||
      <hat-graph-node
 | 
			
		||||
@@ -353,6 +489,7 @@ export class HatScriptGraph extends LitElement {
 | 
			
		||||
        @focus=${this.selectNode(node, path)}
 | 
			
		||||
        ?track=${path in this.trace.trace}
 | 
			
		||||
        ?active=${this.selected === path}
 | 
			
		||||
        .notEnabled=${disabled || node.enabled === false}
 | 
			
		||||
        tabindex=${this.trace && path in this.trace.trace ? "0" : "-1"}
 | 
			
		||||
      ></hat-graph-node>
 | 
			
		||||
    `;
 | 
			
		||||
@@ -361,7 +498,8 @@ export class HatScriptGraph extends LitElement {
 | 
			
		||||
  private render_service_node(
 | 
			
		||||
    node: ServiceAction,
 | 
			
		||||
    path: string,
 | 
			
		||||
    graphStart = false
 | 
			
		||||
    graphStart = false,
 | 
			
		||||
    disabled = false
 | 
			
		||||
  ) {
 | 
			
		||||
    return html`
 | 
			
		||||
      <hat-graph-node
 | 
			
		||||
@@ -370,6 +508,7 @@ export class HatScriptGraph extends LitElement {
 | 
			
		||||
        @focus=${this.selectNode(node, path)}
 | 
			
		||||
        ?track=${path in this.trace.trace}
 | 
			
		||||
        ?active=${this.selected === path}
 | 
			
		||||
        .notEnabled=${disabled || node.enabled === false}
 | 
			
		||||
        tabindex=${this.trace && path in this.trace.trace ? "0" : "-1"}
 | 
			
		||||
      ></hat-graph-node>
 | 
			
		||||
    `;
 | 
			
		||||
@@ -378,7 +517,8 @@ export class HatScriptGraph extends LitElement {
 | 
			
		||||
  private render_wait_node(
 | 
			
		||||
    node: WaitAction | WaitForTriggerAction,
 | 
			
		||||
    path: string,
 | 
			
		||||
    graphStart = false
 | 
			
		||||
    graphStart = false,
 | 
			
		||||
    disabled = false
 | 
			
		||||
  ) {
 | 
			
		||||
    return html`
 | 
			
		||||
      <hat-graph-node
 | 
			
		||||
@@ -387,12 +527,87 @@ export class HatScriptGraph extends LitElement {
 | 
			
		||||
        @focus=${this.selectNode(node, path)}
 | 
			
		||||
        ?track=${path in this.trace.trace}
 | 
			
		||||
        ?active=${this.selected === path}
 | 
			
		||||
        .notEnabled=${disabled || node.enabled === false}
 | 
			
		||||
        tabindex=${this.trace && path in this.trace.trace ? "0" : "-1"}
 | 
			
		||||
      ></hat-graph-node>
 | 
			
		||||
    `;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private render_other_node(node: Action, path: string, graphStart = false) {
 | 
			
		||||
  private render_parallel_node(
 | 
			
		||||
    node: ParallelAction,
 | 
			
		||||
    path: string,
 | 
			
		||||
    graphStart = false,
 | 
			
		||||
    disabled = false
 | 
			
		||||
  ) {
 | 
			
		||||
    const trace: any = this.trace.trace[path];
 | 
			
		||||
    return html`
 | 
			
		||||
      <hat-graph-branch
 | 
			
		||||
        tabindex=${trace === undefined ? "-1" : "0"}
 | 
			
		||||
        @focus=${this.selectNode(node, path)}
 | 
			
		||||
        ?track=${path in this.trace.trace}
 | 
			
		||||
        ?active=${this.selected === path}
 | 
			
		||||
        .notEnabled=${disabled || node.enabled === false}
 | 
			
		||||
      >
 | 
			
		||||
        <hat-graph-node
 | 
			
		||||
          .graphStart=${graphStart}
 | 
			
		||||
          .iconPath=${mdiShuffleDisabled}
 | 
			
		||||
          ?track=${path in this.trace.trace}
 | 
			
		||||
          ?active=${this.selected === path}
 | 
			
		||||
          .notEnabled=${disabled || node.enabled === false}
 | 
			
		||||
          slot="head"
 | 
			
		||||
          nofocus
 | 
			
		||||
        ></hat-graph-node>
 | 
			
		||||
        ${ensureArray(node.parallel).map((action, i) =>
 | 
			
		||||
          "sequence" in action
 | 
			
		||||
            ? html`<div ?track=${path in this.trace.trace}>
 | 
			
		||||
                ${ensureArray((action as ManualScriptConfig).sequence).map(
 | 
			
		||||
                  (sAction, j) =>
 | 
			
		||||
                    this.render_action_node(
 | 
			
		||||
                      sAction,
 | 
			
		||||
                      `${path}/parallel/${i}/sequence/${j}`,
 | 
			
		||||
                      false,
 | 
			
		||||
                      disabled || node.enabled === false
 | 
			
		||||
                    )
 | 
			
		||||
                )}
 | 
			
		||||
              </div>`
 | 
			
		||||
            : this.render_action_node(
 | 
			
		||||
                action,
 | 
			
		||||
                `${path}/parallel/${i}/sequence/0`,
 | 
			
		||||
                false,
 | 
			
		||||
                disabled || node.enabled === false
 | 
			
		||||
              )
 | 
			
		||||
        )}
 | 
			
		||||
      </hat-graph-branch>
 | 
			
		||||
    `;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private render_stop_node(
 | 
			
		||||
    node: Action,
 | 
			
		||||
    path: string,
 | 
			
		||||
    graphStart = false,
 | 
			
		||||
    disabled = false
 | 
			
		||||
  ) {
 | 
			
		||||
    const trace = this.trace.trace[path] as StopActionTraceStep[] | undefined;
 | 
			
		||||
    return html`
 | 
			
		||||
      <hat-graph-node
 | 
			
		||||
        .graphStart=${graphStart}
 | 
			
		||||
        .iconPath=${trace?.[0].result?.error
 | 
			
		||||
          ? mdiAlertOctagon
 | 
			
		||||
          : mdiCloseOctagon}
 | 
			
		||||
        @focus=${this.selectNode(node, path)}
 | 
			
		||||
        ?track=${path in this.trace.trace}
 | 
			
		||||
        ?active=${this.selected === path}
 | 
			
		||||
        .notEnabled=${disabled || node.enabled === false}
 | 
			
		||||
      ></hat-graph-node>
 | 
			
		||||
    `;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private render_other_node(
 | 
			
		||||
    node: Action,
 | 
			
		||||
    path: string,
 | 
			
		||||
    graphStart = false,
 | 
			
		||||
    disabled = false
 | 
			
		||||
  ) {
 | 
			
		||||
    return html`
 | 
			
		||||
      <hat-graph-node
 | 
			
		||||
        .graphStart=${graphStart}
 | 
			
		||||
@@ -400,6 +615,7 @@ export class HatScriptGraph extends LitElement {
 | 
			
		||||
        @focus=${this.selectNode(node, path)}
 | 
			
		||||
        ?track=${path in this.trace.trace}
 | 
			
		||||
        ?active=${this.selected === path}
 | 
			
		||||
        .notEnabled=${disabled || node.enabled === false}
 | 
			
		||||
      ></hat-graph-node>
 | 
			
		||||
    `;
 | 
			
		||||
  }
 | 
			
		||||
@@ -538,6 +754,8 @@ export class HatScriptGraph extends LitElement {
 | 
			
		||||
        --track-clr: var(--track-color, var(--accent-color));
 | 
			
		||||
        --hover-clr: var(--hover-color, var(--primary-color));
 | 
			
		||||
        --disabled-clr: var(--disabled-color, var(--disabled-text-color));
 | 
			
		||||
        --disabled-active-clr: rgba(var(--rgb-primary-color), 0.5);
 | 
			
		||||
        --disabled-hover-clr: rgba(var(--rgb-primary-color), 0.7);
 | 
			
		||||
        --default-trigger-color: 3, 169, 244;
 | 
			
		||||
        --rgb-trigger-color: var(--trigger-color, var(--default-trigger-color));
 | 
			
		||||
        --background-clr: var(--background-color, white);
 | 
			
		||||
 
 | 
			
		||||
@@ -25,12 +25,17 @@ import {
 | 
			
		||||
  ChooseAction,
 | 
			
		||||
  ChooseActionChoice,
 | 
			
		||||
  getActionType,
 | 
			
		||||
  IfAction,
 | 
			
		||||
  ParallelAction,
 | 
			
		||||
  RepeatAction,
 | 
			
		||||
} from "../../data/script";
 | 
			
		||||
import { describeAction } from "../../data/script_i18n";
 | 
			
		||||
import {
 | 
			
		||||
  ActionTraceStep,
 | 
			
		||||
  AutomationTraceExtended,
 | 
			
		||||
  ChooseActionTraceStep,
 | 
			
		||||
  getDataFromPath,
 | 
			
		||||
  IfActionTraceStep,
 | 
			
		||||
  isTriggerPath,
 | 
			
		||||
  TriggerTraceStep,
 | 
			
		||||
} from "../../data/trace";
 | 
			
		||||
@@ -105,7 +110,7 @@ class LogbookRenderer {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  get hasNext() {
 | 
			
		||||
    return this.curIndex !== this.logbookEntries.length;
 | 
			
		||||
    return this.curIndex < this.logbookEntries.length;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  maybeRenderItem() {
 | 
			
		||||
@@ -201,7 +206,7 @@ class ActionRenderer {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  get hasNext() {
 | 
			
		||||
    return this.curIndex !== this.keys.length;
 | 
			
		||||
    return this.curIndex < this.keys.length;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  renderItem() {
 | 
			
		||||
@@ -214,15 +219,31 @@ class ActionRenderer {
 | 
			
		||||
 | 
			
		||||
  private _renderItem(
 | 
			
		||||
    index: number,
 | 
			
		||||
    actionType?: ReturnType<typeof getActionType>
 | 
			
		||||
    actionType?: ReturnType<typeof getActionType>,
 | 
			
		||||
    renderAllIterations?: boolean
 | 
			
		||||
  ): number {
 | 
			
		||||
    const value = this._getItem(index);
 | 
			
		||||
 | 
			
		||||
    if (isTriggerPath(value[0].path)) {
 | 
			
		||||
      return this._handleTrigger(index, value[0] as TriggerTraceStep);
 | 
			
		||||
    if (renderAllIterations) {
 | 
			
		||||
      let i;
 | 
			
		||||
      value.forEach((item) => {
 | 
			
		||||
        i = this._renderIteration(index, item, actionType);
 | 
			
		||||
      });
 | 
			
		||||
      return i;
 | 
			
		||||
    }
 | 
			
		||||
    return this._renderIteration(index, value[0], actionType);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private _renderIteration(
 | 
			
		||||
    index: number,
 | 
			
		||||
    value: ActionTraceStep,
 | 
			
		||||
    actionType?: ReturnType<typeof getActionType>
 | 
			
		||||
  ) {
 | 
			
		||||
    if (isTriggerPath(value.path)) {
 | 
			
		||||
      return this._handleTrigger(index, value as TriggerTraceStep);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    const timestamp = new Date(value[0].timestamp);
 | 
			
		||||
    const timestamp = new Date(value.timestamp);
 | 
			
		||||
 | 
			
		||||
    // Render all logbook items that are in front of this item.
 | 
			
		||||
    while (
 | 
			
		||||
@@ -235,7 +256,7 @@ class ActionRenderer {
 | 
			
		||||
    this.logbookRenderer.flush();
 | 
			
		||||
    this.timeTracker.maybeRenderTime(timestamp);
 | 
			
		||||
 | 
			
		||||
    const path = value[0].path;
 | 
			
		||||
    const path = value.path;
 | 
			
		||||
    let data;
 | 
			
		||||
    try {
 | 
			
		||||
      data = getDataFromPath(this.trace.config, path);
 | 
			
		||||
@@ -263,7 +284,24 @@ class ActionRenderer {
 | 
			
		||||
      return this._handleChoose(index);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    this._renderEntry(path, describeAction(this.hass, data, actionType));
 | 
			
		||||
    if (actionType === "repeat") {
 | 
			
		||||
      return this._handleRepeat(index);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (actionType === "if") {
 | 
			
		||||
      return this._handleIf(index);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (actionType === "parallel") {
 | 
			
		||||
      return this._handleParallel(index);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    this._renderEntry(
 | 
			
		||||
      path,
 | 
			
		||||
      describeAction(this.hass, data, actionType),
 | 
			
		||||
      undefined,
 | 
			
		||||
      data.enabled === false
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    let i = index + 1;
 | 
			
		||||
 | 
			
		||||
@@ -316,10 +354,16 @@ class ActionRenderer {
 | 
			
		||||
    const chooseConfig = this._getDataFromPath(
 | 
			
		||||
      this.keys[index]
 | 
			
		||||
    ) as ChooseAction;
 | 
			
		||||
    const disabled = chooseConfig.enabled === false;
 | 
			
		||||
    const name = chooseConfig.alias || "Choose";
 | 
			
		||||
 | 
			
		||||
    if (defaultExecuted) {
 | 
			
		||||
      this._renderEntry(choosePath, `${name}: Default action executed`);
 | 
			
		||||
      this._renderEntry(
 | 
			
		||||
        choosePath,
 | 
			
		||||
        `${name}: Default action executed`,
 | 
			
		||||
        undefined,
 | 
			
		||||
        disabled
 | 
			
		||||
      );
 | 
			
		||||
    } else if (chooseTrace.result) {
 | 
			
		||||
      const choiceNumeric =
 | 
			
		||||
        chooseTrace.result.choice !== "default"
 | 
			
		||||
@@ -331,9 +375,19 @@ class ActionRenderer {
 | 
			
		||||
      const choiceName = choiceConfig
 | 
			
		||||
        ? `${choiceConfig.alias || `Option ${choiceNumeric}`} executed`
 | 
			
		||||
        : `Error: ${chooseTrace.error}`;
 | 
			
		||||
      this._renderEntry(choosePath, `${name}: ${choiceName}`);
 | 
			
		||||
      this._renderEntry(
 | 
			
		||||
        choosePath,
 | 
			
		||||
        `${name}: ${choiceName}`,
 | 
			
		||||
        undefined,
 | 
			
		||||
        disabled
 | 
			
		||||
      );
 | 
			
		||||
    } else {
 | 
			
		||||
      this._renderEntry(choosePath, `${name}: No action taken`);
 | 
			
		||||
      this._renderEntry(
 | 
			
		||||
        choosePath,
 | 
			
		||||
        `${name}: No action taken`,
 | 
			
		||||
        undefined,
 | 
			
		||||
        disabled
 | 
			
		||||
      );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    let i;
 | 
			
		||||
@@ -374,14 +428,130 @@ class ActionRenderer {
 | 
			
		||||
    return i;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private _handleRepeat(index: number): number {
 | 
			
		||||
    const repeatPath = this.keys[index];
 | 
			
		||||
    const startLevel = repeatPath.split("/").length;
 | 
			
		||||
 | 
			
		||||
    const repeatConfig = this._getDataFromPath(
 | 
			
		||||
      this.keys[index]
 | 
			
		||||
    ) as RepeatAction;
 | 
			
		||||
    const disabled = repeatConfig.enabled === false;
 | 
			
		||||
 | 
			
		||||
    const name = repeatConfig.alias || describeAction(this.hass, repeatConfig);
 | 
			
		||||
 | 
			
		||||
    this._renderEntry(repeatPath, name, undefined, disabled);
 | 
			
		||||
 | 
			
		||||
    let i;
 | 
			
		||||
 | 
			
		||||
    for (i = index + 1; i < this.keys.length; i++) {
 | 
			
		||||
      const path = this.keys[i];
 | 
			
		||||
      const parts = path.split("/");
 | 
			
		||||
 | 
			
		||||
      // We're done if no more sequence in current level
 | 
			
		||||
      if (parts.length <= startLevel) {
 | 
			
		||||
        return i;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      i = this._renderItem(i, getActionType(this._getDataFromPath(path)), true);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return i;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private _handleIf(index: number): number {
 | 
			
		||||
    const ifPath = this.keys[index];
 | 
			
		||||
    const startLevel = ifPath.split("/").length;
 | 
			
		||||
 | 
			
		||||
    const ifTrace = this._getItem(index)[0] as IfActionTraceStep;
 | 
			
		||||
    const ifConfig = this._getDataFromPath(this.keys[index]) as IfAction;
 | 
			
		||||
    const disabled = ifConfig.enabled === false;
 | 
			
		||||
    const name = ifConfig.alias || "If";
 | 
			
		||||
 | 
			
		||||
    if (ifTrace.result?.choice) {
 | 
			
		||||
      const choiceConfig = this._getDataFromPath(
 | 
			
		||||
        `${this.keys[index]}/${ifTrace.result.choice}/`
 | 
			
		||||
      ) as any;
 | 
			
		||||
      const choiceName = choiceConfig
 | 
			
		||||
        ? `${choiceConfig.alias || `${ifTrace.result.choice} action executed`}`
 | 
			
		||||
        : `Error: ${ifTrace.error}`;
 | 
			
		||||
      this._renderEntry(ifPath, `${name}: ${choiceName}`, undefined, disabled);
 | 
			
		||||
    } else {
 | 
			
		||||
      this._renderEntry(
 | 
			
		||||
        ifPath,
 | 
			
		||||
        `${name}: No action taken`,
 | 
			
		||||
        undefined,
 | 
			
		||||
        disabled
 | 
			
		||||
      );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    let i;
 | 
			
		||||
 | 
			
		||||
    // Skip over conditions
 | 
			
		||||
    for (i = index + 1; i < this.keys.length; i++) {
 | 
			
		||||
      const path = this.keys[i];
 | 
			
		||||
      const parts = this.keys[i].split("/");
 | 
			
		||||
 | 
			
		||||
      // We're done if no more sequence in current level
 | 
			
		||||
      if (parts.length <= startLevel) {
 | 
			
		||||
        return i;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      // We're going to skip all conditions
 | 
			
		||||
      if (
 | 
			
		||||
        parts[startLevel + 1] === "condition" ||
 | 
			
		||||
        parts.length < startLevel + 2
 | 
			
		||||
      ) {
 | 
			
		||||
        continue;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      i = this._renderItem(i, getActionType(this._getDataFromPath(path)));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return i;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private _handleParallel(index: number): number {
 | 
			
		||||
    const parallelPath = this.keys[index];
 | 
			
		||||
    const startLevel = parallelPath.split("/").length;
 | 
			
		||||
 | 
			
		||||
    const parallelConfig = this._getDataFromPath(
 | 
			
		||||
      this.keys[index]
 | 
			
		||||
    ) as ParallelAction;
 | 
			
		||||
 | 
			
		||||
    const disabled = parallelConfig.enabled === false;
 | 
			
		||||
 | 
			
		||||
    const name = parallelConfig.alias || "Execute in parallel";
 | 
			
		||||
 | 
			
		||||
    this._renderEntry(parallelPath, name, undefined, disabled);
 | 
			
		||||
 | 
			
		||||
    let i;
 | 
			
		||||
 | 
			
		||||
    for (i = index + 1; i < this.keys.length; i++) {
 | 
			
		||||
      const path = this.keys[i];
 | 
			
		||||
      const parts = path.split("/");
 | 
			
		||||
 | 
			
		||||
      // We're done if no more sequence in current level
 | 
			
		||||
      if (parts.length <= startLevel) {
 | 
			
		||||
        return i;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      i = this._renderItem(i, getActionType(this._getDataFromPath(path)));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return i;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private _renderEntry(
 | 
			
		||||
    path: string,
 | 
			
		||||
    description: string,
 | 
			
		||||
    icon = mdiRecordCircleOutline
 | 
			
		||||
    icon = mdiRecordCircleOutline,
 | 
			
		||||
    disabled = false
 | 
			
		||||
  ) {
 | 
			
		||||
    this.entries.push(html`
 | 
			
		||||
      <ha-timeline .icon=${icon} data-path=${path}>
 | 
			
		||||
        ${description}
 | 
			
		||||
      <ha-timeline .icon=${icon} data-path=${path} .notEnabled=${disabled}>
 | 
			
		||||
        ${description}${disabled
 | 
			
		||||
          ? html`<span class="disabled"> (disabled)</span>`
 | 
			
		||||
          : ""}
 | 
			
		||||
      </ha-timeline>
 | 
			
		||||
    `);
 | 
			
		||||
  }
 | 
			
		||||
 
 | 
			
		||||
@@ -65,6 +65,7 @@ export interface BaseTrigger {
 | 
			
		||||
  platform: string;
 | 
			
		||||
  id?: string;
 | 
			
		||||
  variables?: Record<string, unknown>;
 | 
			
		||||
  enabled?: boolean;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface StateTrigger extends BaseTrigger {
 | 
			
		||||
@@ -178,6 +179,7 @@ export type Trigger =
 | 
			
		||||
interface BaseCondition {
 | 
			
		||||
  condition: string;
 | 
			
		||||
  alias?: string;
 | 
			
		||||
  enabled?: boolean;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface LogicalCondition extends BaseCondition {
 | 
			
		||||
@@ -233,6 +235,24 @@ export interface TriggerCondition extends BaseCondition {
 | 
			
		||||
  id: string;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type ShorthandBaseCondition = Omit<BaseCondition, "condition">;
 | 
			
		||||
 | 
			
		||||
export interface ShorthandAndConditionList extends ShorthandBaseCondition {
 | 
			
		||||
  condition: Condition[];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface ShorthandAndCondition extends ShorthandBaseCondition {
 | 
			
		||||
  and: Condition[];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface ShorthandOrCondition extends ShorthandBaseCondition {
 | 
			
		||||
  or: Condition[];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface ShorthandNotCondition extends ShorthandBaseCondition {
 | 
			
		||||
  not: Condition[];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export type Condition =
 | 
			
		||||
  | StateCondition
 | 
			
		||||
  | NumericStateCondition
 | 
			
		||||
@@ -244,6 +264,35 @@ export type Condition =
 | 
			
		||||
  | LogicalCondition
 | 
			
		||||
  | TriggerCondition;
 | 
			
		||||
 | 
			
		||||
export type ConditionWithShorthand =
 | 
			
		||||
  | Condition
 | 
			
		||||
  | ShorthandAndConditionList
 | 
			
		||||
  | ShorthandAndCondition
 | 
			
		||||
  | ShorthandOrCondition
 | 
			
		||||
  | ShorthandNotCondition;
 | 
			
		||||
 | 
			
		||||
export const expandConditionWithShorthand = (
 | 
			
		||||
  cond: ConditionWithShorthand
 | 
			
		||||
): Condition => {
 | 
			
		||||
  if ("condition" in cond && Array.isArray(cond.condition)) {
 | 
			
		||||
    return {
 | 
			
		||||
      condition: "and",
 | 
			
		||||
      conditions: cond.condition,
 | 
			
		||||
    };
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  for (const condition of ["and", "or", "not"]) {
 | 
			
		||||
    if (condition in cond) {
 | 
			
		||||
      return {
 | 
			
		||||
        condition,
 | 
			
		||||
        conditions: cond[condition],
 | 
			
		||||
      } as Condition;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return cond as Condition;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const triggerAutomationActions = (
 | 
			
		||||
  hass: HomeAssistant,
 | 
			
		||||
  entityId: string
 | 
			
		||||
 
 | 
			
		||||
@@ -11,6 +11,8 @@ export interface DeviceAutomation {
 | 
			
		||||
  type?: string;
 | 
			
		||||
  subtype?: string;
 | 
			
		||||
  event?: string;
 | 
			
		||||
  enabled?: boolean;
 | 
			
		||||
  metadata?: { secondary: boolean };
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface DeviceAction extends DeviceAutomation {
 | 
			
		||||
@@ -179,3 +181,16 @@ export const localizeDeviceAutomationTrigger = (
 | 
			
		||||
    (trigger.subtype ? `"${trigger.subtype}" ${trigger.type}` : trigger.type!)
 | 
			
		||||
  );
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const sortDeviceAutomations = (
 | 
			
		||||
  automationA: DeviceAutomation,
 | 
			
		||||
  automationB: DeviceAutomation
 | 
			
		||||
) => {
 | 
			
		||||
  if (automationA.metadata?.secondary && !automationB.metadata?.secondary) {
 | 
			
		||||
    return 1;
 | 
			
		||||
  }
 | 
			
		||||
  if (!automationA.metadata?.secondary && automationB.metadata?.secondary) {
 | 
			
		||||
    return -1;
 | 
			
		||||
  }
 | 
			
		||||
  return 0;
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,9 @@
 | 
			
		||||
import { HomeAssistant } from "../types";
 | 
			
		||||
 | 
			
		||||
export interface LogProvider {
 | 
			
		||||
  key: string;
 | 
			
		||||
  name: string;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export const fetchErrorLog = (hass: HomeAssistant) =>
 | 
			
		||||
  hass.callApi<string>("GET", "error_log");
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										22
									
								
								src/data/hardware.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								src/data/hardware.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,22 @@
 | 
			
		||||
// Keep in sync with https://github.com/home-assistant/analytics.home-assistant.io/blob/dev/site/src/analytics-os-boards.ts#L6-L24
 | 
			
		||||
export const BOARD_NAMES: Record<string, string> = {
 | 
			
		||||
  "odroid-n2": "Home Assistant Blue / ODROID-N2",
 | 
			
		||||
  "odroid-xu4": "ODROID-XU4",
 | 
			
		||||
  "odroid-c2": "ODROID-C2",
 | 
			
		||||
  "odroid-c4": "ODROID-C4",
 | 
			
		||||
  rpi: "Raspberry Pi",
 | 
			
		||||
  rpi0: "Raspberry Pi Zero",
 | 
			
		||||
  "rpi0-w": "Raspberry Pi Zero W",
 | 
			
		||||
  rpi2: "Raspberry Pi 2",
 | 
			
		||||
  rpi3: "Raspberry Pi 3 (32-bit)",
 | 
			
		||||
  "rpi3-64": "Raspberry Pi 3",
 | 
			
		||||
  rpi4: "Raspberry Pi 4 (32-bit)",
 | 
			
		||||
  "rpi4-64": "Raspberry Pi 4",
 | 
			
		||||
  tinker: "ASUS Tinker Board",
 | 
			
		||||
  "khadas-vim3": "Khadas VIM3",
 | 
			
		||||
  "generic-aarch64": "Generic AArch64",
 | 
			
		||||
  ova: "Virtual Machine",
 | 
			
		||||
  "generic-x86-64": "Generic x86-64",
 | 
			
		||||
  "intel-nuc": "Intel NUC",
 | 
			
		||||
  yellow: "Home Assistant Yellow",
 | 
			
		||||
};
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
import { atLeastVersion } from "../../common/config/version";
 | 
			
		||||
import { HomeAssistant, PanelInfo } from "../../types";
 | 
			
		||||
import { SupervisorArch } from "../supervisor/supervisor";
 | 
			
		||||
import { HassioAddonInfo, HassioAddonRepository } from "./addon";
 | 
			
		||||
import { HassioAddonInfo } from "./addon";
 | 
			
		||||
import { hassioApiResultExtractor, HassioResponse } from "./common";
 | 
			
		||||
 | 
			
		||||
export type HassioHomeAssistantInfo = {
 | 
			
		||||
@@ -23,7 +23,7 @@ export type HassioHomeAssistantInfo = {
 | 
			
		||||
 | 
			
		||||
export type HassioSupervisorInfo = {
 | 
			
		||||
  addons: HassioAddonInfo[];
 | 
			
		||||
  addons_repositories: HassioAddonRepository[];
 | 
			
		||||
  addons_repositories: string[];
 | 
			
		||||
  arch: SupervisorArch;
 | 
			
		||||
  channel: string;
 | 
			
		||||
  debug: boolean;
 | 
			
		||||
@@ -179,7 +179,10 @@ export const fetchHassioInfo = async (
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const fetchHassioLogs = async (hass: HomeAssistant, provider: string) =>
 | 
			
		||||
  hass.callApi<string>("GET", `hassio/${provider}/logs`);
 | 
			
		||||
  hass.callApi<string>(
 | 
			
		||||
    "GET",
 | 
			
		||||
    `hassio/${provider.includes("_") ? `addons/${provider}` : provider}/logs`
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
export const setSupervisorOption = async (
 | 
			
		||||
  hass: HomeAssistant,
 | 
			
		||||
 
 | 
			
		||||
@@ -13,11 +13,18 @@ import {
 | 
			
		||||
  literal,
 | 
			
		||||
  is,
 | 
			
		||||
  Describe,
 | 
			
		||||
  boolean,
 | 
			
		||||
} from "superstruct";
 | 
			
		||||
import { computeObjectId } from "../common/entity/compute_object_id";
 | 
			
		||||
import { navigate } from "../common/navigate";
 | 
			
		||||
import { HomeAssistant } from "../types";
 | 
			
		||||
import { Condition, Trigger } from "./automation";
 | 
			
		||||
import {
 | 
			
		||||
  Condition,
 | 
			
		||||
  ShorthandAndCondition,
 | 
			
		||||
  ShorthandNotCondition,
 | 
			
		||||
  ShorthandOrCondition,
 | 
			
		||||
  Trigger,
 | 
			
		||||
} from "./automation";
 | 
			
		||||
import { BlueprintInput } from "./blueprint";
 | 
			
		||||
 | 
			
		||||
export const MODES = ["single", "restart", "queued", "parallel"] as const;
 | 
			
		||||
@@ -25,6 +32,7 @@ export const MODES_MAX = ["queued", "parallel"];
 | 
			
		||||
 | 
			
		||||
export const baseActionStruct = object({
 | 
			
		||||
  alias: optional(string()),
 | 
			
		||||
  enabled: optional(boolean()),
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
const targetStruct = object({
 | 
			
		||||
@@ -88,15 +96,18 @@ export interface BlueprintScriptConfig extends ManualScriptConfig {
 | 
			
		||||
  use_blueprint: { path: string; input?: BlueprintInput };
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface EventAction {
 | 
			
		||||
interface BaseAction {
 | 
			
		||||
  alias?: string;
 | 
			
		||||
  enabled?: boolean;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface EventAction extends BaseAction {
 | 
			
		||||
  event: string;
 | 
			
		||||
  event_data?: Record<string, any>;
 | 
			
		||||
  event_data_template?: Record<string, any>;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface ServiceAction {
 | 
			
		||||
  alias?: string;
 | 
			
		||||
export interface ServiceAction extends BaseAction {
 | 
			
		||||
  service?: string;
 | 
			
		||||
  service_template?: string;
 | 
			
		||||
  entity_id?: string;
 | 
			
		||||
@@ -104,55 +115,48 @@ export interface ServiceAction {
 | 
			
		||||
  data?: Record<string, unknown>;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface DeviceAction {
 | 
			
		||||
  alias?: string;
 | 
			
		||||
export interface DeviceAction extends BaseAction {
 | 
			
		||||
  type: string;
 | 
			
		||||
  device_id: string;
 | 
			
		||||
  domain: string;
 | 
			
		||||
  entity_id: string;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface DelayActionParts {
 | 
			
		||||
export interface DelayActionParts extends BaseAction {
 | 
			
		||||
  milliseconds?: number;
 | 
			
		||||
  seconds?: number;
 | 
			
		||||
  minutes?: number;
 | 
			
		||||
  hours?: number;
 | 
			
		||||
  days?: number;
 | 
			
		||||
}
 | 
			
		||||
export interface DelayAction {
 | 
			
		||||
  alias?: string;
 | 
			
		||||
export interface DelayAction extends BaseAction {
 | 
			
		||||
  delay: number | Partial<DelayActionParts> | string;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface ServiceSceneAction {
 | 
			
		||||
  alias?: string;
 | 
			
		||||
export interface ServiceSceneAction extends BaseAction {
 | 
			
		||||
  service: "scene.turn_on";
 | 
			
		||||
  target?: { entity_id?: string };
 | 
			
		||||
  entity_id?: string;
 | 
			
		||||
  metadata: Record<string, unknown>;
 | 
			
		||||
}
 | 
			
		||||
export interface LegacySceneAction {
 | 
			
		||||
  alias?: string;
 | 
			
		||||
export interface LegacySceneAction extends BaseAction {
 | 
			
		||||
  scene: string;
 | 
			
		||||
}
 | 
			
		||||
export type SceneAction = ServiceSceneAction | LegacySceneAction;
 | 
			
		||||
 | 
			
		||||
export interface WaitAction {
 | 
			
		||||
  alias?: string;
 | 
			
		||||
export interface WaitAction extends BaseAction {
 | 
			
		||||
  wait_template: string;
 | 
			
		||||
  timeout?: number;
 | 
			
		||||
  continue_on_timeout?: boolean;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface WaitForTriggerAction {
 | 
			
		||||
  alias?: string;
 | 
			
		||||
export interface WaitForTriggerAction extends BaseAction {
 | 
			
		||||
  wait_for_trigger: Trigger | Trigger[];
 | 
			
		||||
  timeout?: number;
 | 
			
		||||
  continue_on_timeout?: boolean;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface PlayMediaAction {
 | 
			
		||||
  alias?: string;
 | 
			
		||||
export interface PlayMediaAction extends BaseAction {
 | 
			
		||||
  service: "media_player.play_media";
 | 
			
		||||
  target?: { entity_id?: string };
 | 
			
		||||
  entity_id?: string;
 | 
			
		||||
@@ -160,13 +164,11 @@ export interface PlayMediaAction {
 | 
			
		||||
  metadata: Record<string, unknown>;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface RepeatAction {
 | 
			
		||||
  alias?: string;
 | 
			
		||||
  repeat: CountRepeat | WhileRepeat | UntilRepeat;
 | 
			
		||||
export interface RepeatAction extends BaseAction {
 | 
			
		||||
  repeat: CountRepeat | WhileRepeat | UntilRepeat | ForEachRepeat;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
interface BaseRepeat {
 | 
			
		||||
  alias?: string;
 | 
			
		||||
interface BaseRepeat extends BaseAction {
 | 
			
		||||
  sequence: Action | Action[];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -182,38 +184,40 @@ export interface UntilRepeat extends BaseRepeat {
 | 
			
		||||
  until: Condition[];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface ChooseActionChoice {
 | 
			
		||||
  alias?: string;
 | 
			
		||||
export interface ForEachRepeat extends BaseRepeat {
 | 
			
		||||
  for_each: string | any[];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface ChooseActionChoice extends BaseAction {
 | 
			
		||||
  conditions: string | Condition[];
 | 
			
		||||
  sequence: Action | Action[];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface ChooseAction {
 | 
			
		||||
  alias?: string;
 | 
			
		||||
export interface ChooseAction extends BaseAction {
 | 
			
		||||
  choose: ChooseActionChoice | ChooseActionChoice[] | null;
 | 
			
		||||
  default?: Action | Action[];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface IfAction {
 | 
			
		||||
  alias?: string;
 | 
			
		||||
export interface IfAction extends BaseAction {
 | 
			
		||||
  if: string | Condition[];
 | 
			
		||||
  then: Action | Action[];
 | 
			
		||||
  else?: Action | Action[];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface VariablesAction {
 | 
			
		||||
  alias?: string;
 | 
			
		||||
export interface VariablesAction extends BaseAction {
 | 
			
		||||
  variables: Record<string, unknown>;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface StopAction {
 | 
			
		||||
  alias?: string;
 | 
			
		||||
export interface StopAction extends BaseAction {
 | 
			
		||||
  stop: string;
 | 
			
		||||
  error?: boolean;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
interface UnknownAction {
 | 
			
		||||
  alias?: string;
 | 
			
		||||
export interface ParallelAction extends BaseAction {
 | 
			
		||||
  parallel: ManualScriptConfig | Action | (ManualScriptConfig | Action)[];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
interface UnknownAction extends BaseAction {
 | 
			
		||||
  [key: string]: unknown;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -222,6 +226,9 @@ export type Action =
 | 
			
		||||
  | DeviceAction
 | 
			
		||||
  | ServiceAction
 | 
			
		||||
  | Condition
 | 
			
		||||
  | ShorthandAndCondition
 | 
			
		||||
  | ShorthandOrCondition
 | 
			
		||||
  | ShorthandNotCondition
 | 
			
		||||
  | DelayAction
 | 
			
		||||
  | SceneAction
 | 
			
		||||
  | WaitAction
 | 
			
		||||
@@ -232,6 +239,7 @@ export type Action =
 | 
			
		||||
  | VariablesAction
 | 
			
		||||
  | PlayMediaAction
 | 
			
		||||
  | StopAction
 | 
			
		||||
  | ParallelAction
 | 
			
		||||
  | UnknownAction;
 | 
			
		||||
 | 
			
		||||
export interface ActionTypes {
 | 
			
		||||
@@ -249,6 +257,7 @@ export interface ActionTypes {
 | 
			
		||||
  service: ServiceAction;
 | 
			
		||||
  play_media: PlayMediaAction;
 | 
			
		||||
  stop: StopAction;
 | 
			
		||||
  parallel: ParallelAction;
 | 
			
		||||
  unknown: UnknownAction;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -298,7 +307,7 @@ export const getActionType = (action: Action): ActionType => {
 | 
			
		||||
  if ("wait_template" in action) {
 | 
			
		||||
    return "wait_template";
 | 
			
		||||
  }
 | 
			
		||||
  if ("condition" in action) {
 | 
			
		||||
  if (["condition", "and", "or", "not"].some((key) => key in action)) {
 | 
			
		||||
    return "check_condition";
 | 
			
		||||
  }
 | 
			
		||||
  if ("event" in action) {
 | 
			
		||||
@@ -328,6 +337,9 @@ export const getActionType = (action: Action): ActionType => {
 | 
			
		||||
  if ("stop" in action) {
 | 
			
		||||
    return "stop";
 | 
			
		||||
  }
 | 
			
		||||
  if ("parallel" in action) {
 | 
			
		||||
    return "parallel";
 | 
			
		||||
  }
 | 
			
		||||
  if ("service" in action) {
 | 
			
		||||
    if ("metadata" in action) {
 | 
			
		||||
      if (is(action, activateSceneActionStruct)) {
 | 
			
		||||
 
 | 
			
		||||
@@ -8,12 +8,17 @@ import { describeCondition, describeTrigger } from "./automation_i18n";
 | 
			
		||||
import {
 | 
			
		||||
  ActionType,
 | 
			
		||||
  ActionTypes,
 | 
			
		||||
  ChooseAction,
 | 
			
		||||
  DelayAction,
 | 
			
		||||
  DeviceAction,
 | 
			
		||||
  EventAction,
 | 
			
		||||
  getActionType,
 | 
			
		||||
  IfAction,
 | 
			
		||||
  ParallelAction,
 | 
			
		||||
  PlayMediaAction,
 | 
			
		||||
  RepeatAction,
 | 
			
		||||
  SceneAction,
 | 
			
		||||
  StopAction,
 | 
			
		||||
  VariablesAction,
 | 
			
		||||
  WaitForTriggerAction,
 | 
			
		||||
} from "./script";
 | 
			
		||||
@@ -161,6 +166,81 @@ export const describeAction = <T extends ActionType>(
 | 
			
		||||
    return `Test ${describeCondition(action as Condition)}`;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (actionType === "stop") {
 | 
			
		||||
    const config = action as StopAction;
 | 
			
		||||
    return `Stopped${config.stop ? ` because: ${config.stop}` : ""}`;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (actionType === "if") {
 | 
			
		||||
    const config = action as IfAction;
 | 
			
		||||
    return `If ${
 | 
			
		||||
      typeof config.if === "string"
 | 
			
		||||
        ? config.if
 | 
			
		||||
        : ensureArray(config.if)
 | 
			
		||||
            .map((condition) => describeCondition(condition))
 | 
			
		||||
            .join(", ")
 | 
			
		||||
    } then ${ensureArray(config.then).map((thenAction) =>
 | 
			
		||||
      describeAction(hass, thenAction)
 | 
			
		||||
    )}${
 | 
			
		||||
      config.else
 | 
			
		||||
        ? ` else ${ensureArray(config.else).map((elseAction) =>
 | 
			
		||||
            describeAction(hass, elseAction)
 | 
			
		||||
          )}`
 | 
			
		||||
        : ""
 | 
			
		||||
    }`;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (actionType === "choose") {
 | 
			
		||||
    const config = action as ChooseAction;
 | 
			
		||||
    return config.choose
 | 
			
		||||
      ? `If ${ensureArray(config.choose)
 | 
			
		||||
          .map(
 | 
			
		||||
            (chooseAction) =>
 | 
			
		||||
              `${
 | 
			
		||||
                typeof chooseAction.conditions === "string"
 | 
			
		||||
                  ? chooseAction.conditions
 | 
			
		||||
                  : ensureArray(chooseAction.conditions)
 | 
			
		||||
                      .map((condition) => describeCondition(condition))
 | 
			
		||||
                      .join(", ")
 | 
			
		||||
              } then ${ensureArray(chooseAction.sequence)
 | 
			
		||||
                .map((chooseSeq) => describeAction(hass, chooseSeq))
 | 
			
		||||
                .join(", ")}`
 | 
			
		||||
          )
 | 
			
		||||
          .join(", else if ")}${
 | 
			
		||||
          config.default
 | 
			
		||||
            ? `. If none match: ${ensureArray(config.default)
 | 
			
		||||
                .map((dAction) => describeAction(hass, dAction))
 | 
			
		||||
                .join(", ")}`
 | 
			
		||||
            : ""
 | 
			
		||||
        }`
 | 
			
		||||
      : "Choose";
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (actionType === "repeat") {
 | 
			
		||||
    const config = action as RepeatAction;
 | 
			
		||||
    return `Repeat ${ensureArray(config.repeat.sequence).map((repeatAction) =>
 | 
			
		||||
      describeAction(hass, repeatAction)
 | 
			
		||||
    )} ${"count" in config.repeat ? `${config.repeat.count} times` : ""}${
 | 
			
		||||
      "while" in config.repeat
 | 
			
		||||
        ? `while ${ensureArray(config.repeat.while)
 | 
			
		||||
            .map((condition) => describeCondition(condition))
 | 
			
		||||
            .join(", ")} is true`
 | 
			
		||||
        : "until" in config.repeat
 | 
			
		||||
        ? `until ${ensureArray(config.repeat.until)
 | 
			
		||||
            .map((condition) => describeCondition(condition))
 | 
			
		||||
            .join(", ")} is true`
 | 
			
		||||
        : "for_each" in config.repeat
 | 
			
		||||
        ? `for every item: ${ensureArray(config.repeat.for_each)
 | 
			
		||||
            .map((item) => JSON.stringify(item))
 | 
			
		||||
            .join(", ")}`
 | 
			
		||||
        : ""
 | 
			
		||||
    }`;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (actionType === "check_condition") {
 | 
			
		||||
    return `Test ${describeCondition(action as Condition)}`;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (actionType === "device_action") {
 | 
			
		||||
    const config = action as DeviceAction;
 | 
			
		||||
    const stateObj = hass.states[config.entity_id as string];
 | 
			
		||||
@@ -169,5 +249,12 @@ export const describeAction = <T extends ActionType>(
 | 
			
		||||
    }`;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (actionType === "parallel") {
 | 
			
		||||
    const config = action as ParallelAction;
 | 
			
		||||
    return `Run in parallel: ${ensureArray(config.parallel)
 | 
			
		||||
      .map((pAction) => describeAction(hass, pAction))
 | 
			
		||||
      .join(", ")}`;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return actionType;
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
@@ -44,6 +44,14 @@ export interface ChooseActionTraceStep extends BaseTraceStep {
 | 
			
		||||
  result?: { choice: number | "default" };
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface IfActionTraceStep extends BaseTraceStep {
 | 
			
		||||
  result?: { choice: "then" | "else" };
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface StopActionTraceStep extends BaseTraceStep {
 | 
			
		||||
  result?: { stop: string; error: boolean };
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface ChooseChoiceActionTraceStep extends BaseTraceStep {
 | 
			
		||||
  result?: { result: boolean };
 | 
			
		||||
}
 | 
			
		||||
@@ -177,7 +185,11 @@ export const getDataFromPath = (
 | 
			
		||||
    const asNumber = Number(raw);
 | 
			
		||||
 | 
			
		||||
    if (isNaN(asNumber)) {
 | 
			
		||||
      result = result[raw];
 | 
			
		||||
      const tempResult = result[raw];
 | 
			
		||||
      if (!tempResult && raw === "sequence") {
 | 
			
		||||
        continue;
 | 
			
		||||
      }
 | 
			
		||||
      result = tempResult;
 | 
			
		||||
      continue;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,10 +1,17 @@
 | 
			
		||||
import type {
 | 
			
		||||
  HassEntities,
 | 
			
		||||
  HassEntityAttributeBase,
 | 
			
		||||
  HassEntityBase,
 | 
			
		||||
  HassEvent,
 | 
			
		||||
} from "home-assistant-js-websocket";
 | 
			
		||||
import { BINARY_STATE_ON } from "../common/const";
 | 
			
		||||
import { computeDomain } from "../common/entity/compute_domain";
 | 
			
		||||
import { computeStateDomain } from "../common/entity/compute_state_domain";
 | 
			
		||||
import { supportsFeature } from "../common/entity/supports-feature";
 | 
			
		||||
import { caseInsensitiveStringCompare } from "../common/string/compare";
 | 
			
		||||
import { showAlertDialog } from "../dialogs/generic/show-dialog-box";
 | 
			
		||||
import { HomeAssistant } from "../types";
 | 
			
		||||
import { showToast } from "../util/toast";
 | 
			
		||||
 | 
			
		||||
export const UPDATE_SUPPORT_INSTALL = 1;
 | 
			
		||||
export const UPDATE_SUPPORT_SPECIFIC_VERSION = 2;
 | 
			
		||||
@@ -31,8 +38,12 @@ export const updateUsesProgress = (entity: UpdateEntity): boolean =>
 | 
			
		||||
  supportsFeature(entity, UPDATE_SUPPORT_PROGRESS) &&
 | 
			
		||||
  typeof entity.attributes.in_progress === "number";
 | 
			
		||||
 | 
			
		||||
export const updateCanInstall = (entity: UpdateEntity): boolean =>
 | 
			
		||||
  entity.state === BINARY_STATE_ON &&
 | 
			
		||||
export const updateCanInstall = (
 | 
			
		||||
  entity: UpdateEntity,
 | 
			
		||||
  showSkipped = false
 | 
			
		||||
): boolean =>
 | 
			
		||||
  (entity.state === BINARY_STATE_ON ||
 | 
			
		||||
    (showSkipped && Boolean(entity.attributes.skipped_version))) &&
 | 
			
		||||
  supportsFeature(entity, UPDATE_SUPPORT_INSTALL);
 | 
			
		||||
 | 
			
		||||
export const updateIsInstalling = (entity: UpdateEntity): boolean =>
 | 
			
		||||
@@ -43,3 +54,92 @@ export const updateReleaseNotes = (hass: HomeAssistant, entityId: string) =>
 | 
			
		||||
    type: "update/release_notes",
 | 
			
		||||
    entity_id: entityId,
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
export const filterUpdateEntities = (entities: HassEntities) =>
 | 
			
		||||
  (
 | 
			
		||||
    Object.values(entities).filter(
 | 
			
		||||
      (entity) => computeStateDomain(entity) === "update"
 | 
			
		||||
    ) as UpdateEntity[]
 | 
			
		||||
  ).sort((a, b) => {
 | 
			
		||||
    if (a.attributes.title === "Home Assistant Core") {
 | 
			
		||||
      return -3;
 | 
			
		||||
    }
 | 
			
		||||
    if (b.attributes.title === "Home Assistant Core") {
 | 
			
		||||
      return 3;
 | 
			
		||||
    }
 | 
			
		||||
    if (a.attributes.title === "Home Assistant Operating System") {
 | 
			
		||||
      return -2;
 | 
			
		||||
    }
 | 
			
		||||
    if (b.attributes.title === "Home Assistant Operating System") {
 | 
			
		||||
      return 2;
 | 
			
		||||
    }
 | 
			
		||||
    if (a.attributes.title === "Home Assistant Supervisor") {
 | 
			
		||||
      return -1;
 | 
			
		||||
    }
 | 
			
		||||
    if (b.attributes.title === "Home Assistant Supervisor") {
 | 
			
		||||
      return 1;
 | 
			
		||||
    }
 | 
			
		||||
    return caseInsensitiveStringCompare(
 | 
			
		||||
      a.attributes.title || a.attributes.friendly_name || "",
 | 
			
		||||
      b.attributes.title || b.attributes.friendly_name || ""
 | 
			
		||||
    );
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
export const filterUpdateEntitiesWithInstall = (
 | 
			
		||||
  entities: HassEntities,
 | 
			
		||||
  showSkipped = false
 | 
			
		||||
) =>
 | 
			
		||||
  filterUpdateEntities(entities).filter((entity) =>
 | 
			
		||||
    updateCanInstall(entity, showSkipped)
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
export const checkForEntityUpdates = async (
 | 
			
		||||
  element: HTMLElement,
 | 
			
		||||
  hass: HomeAssistant
 | 
			
		||||
) => {
 | 
			
		||||
  const entities = filterUpdateEntities(hass.states).map(
 | 
			
		||||
    (entity) => entity.entity_id
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
  if (!entities.length) {
 | 
			
		||||
    showAlertDialog(element, {
 | 
			
		||||
      title: hass.localize("ui.panel.config.updates.no_update_entities.title"),
 | 
			
		||||
      text: hass.localize(
 | 
			
		||||
        "ui.panel.config.updates.no_update_entities.description"
 | 
			
		||||
      ),
 | 
			
		||||
      warning: true,
 | 
			
		||||
    });
 | 
			
		||||
    return;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  let updated = 0;
 | 
			
		||||
 | 
			
		||||
  const unsubscribeEvents = await hass.connection.subscribeEvents<HassEvent>(
 | 
			
		||||
    (event) => {
 | 
			
		||||
      if (computeDomain(event.data.entity_id) === "update") {
 | 
			
		||||
        updated++;
 | 
			
		||||
        showToast(element, {
 | 
			
		||||
          message: hass.localize("ui.panel.config.updates.updates_refreshed", {
 | 
			
		||||
            count: updated,
 | 
			
		||||
          }),
 | 
			
		||||
        });
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    "state_changed"
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
  await hass.callService("homeassistant", "update_entity", {
 | 
			
		||||
    entity_id: entities,
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  // there is no reliable way to know if all the updates are done updating, so we just wait a bit for now...
 | 
			
		||||
  await new Promise((r) => setTimeout(r, 10000));
 | 
			
		||||
 | 
			
		||||
  unsubscribeEvents();
 | 
			
		||||
 | 
			
		||||
  if (updated === 0) {
 | 
			
		||||
    showToast(element, {
 | 
			
		||||
      message: hass.localize("ui.panel.config.updates.no_new_updates"),
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
@@ -312,6 +312,7 @@ class DataEntryFlowDialog extends LitElement {
 | 
			
		||||
                        .flowConfig=${this._params.flowConfig}
 | 
			
		||||
                        .step=${this._step}
 | 
			
		||||
                        .hass=${this.hass}
 | 
			
		||||
                        .domain=${this._step.handler}
 | 
			
		||||
                      ></step-flow-abort>
 | 
			
		||||
                    `
 | 
			
		||||
                  : this._step.type === "progress"
 | 
			
		||||
 
 | 
			
		||||
@@ -146,14 +146,14 @@ export const showOptionsFlowDialog = (
 | 
			
		||||
      renderMenuHeader(hass, step) {
 | 
			
		||||
        return (
 | 
			
		||||
          hass.localize(
 | 
			
		||||
            `component.${step.handler}.option.step.${step.step_id}.title`
 | 
			
		||||
          ) || hass.localize(`component.${step.handler}.title`)
 | 
			
		||||
            `component.${configEntry.domain}.options.step.${step.step_id}.title`
 | 
			
		||||
          ) || hass.localize(`component.${configEntry.domain}.title`)
 | 
			
		||||
        );
 | 
			
		||||
      },
 | 
			
		||||
 | 
			
		||||
      renderMenuDescription(hass, step) {
 | 
			
		||||
        const description = hass.localize(
 | 
			
		||||
          `component.${step.handler}.option.step.${step.step_id}.description`,
 | 
			
		||||
          `component.${configEntry.domain}.options.step.${step.step_id}.description`,
 | 
			
		||||
          step.description_placeholders
 | 
			
		||||
        );
 | 
			
		||||
        return description
 | 
			
		||||
@@ -169,7 +169,7 @@ export const showOptionsFlowDialog = (
 | 
			
		||||
 | 
			
		||||
      renderMenuOption(hass, step, option) {
 | 
			
		||||
        return hass.localize(
 | 
			
		||||
          `component.${step.handler}.options.step.${step.step_id}.menu_options.${option}`,
 | 
			
		||||
          `component.${configEntry.domain}.options.step.${step.step_id}.menu_options.${option}`,
 | 
			
		||||
          step.description_placeholders
 | 
			
		||||
        );
 | 
			
		||||
      },
 | 
			
		||||
 
 | 
			
		||||
@@ -15,13 +15,11 @@ class StepFlowAbort extends LitElement {
 | 
			
		||||
 | 
			
		||||
  @property({ attribute: false }) public step!: DataEntryFlowStepAbort;
 | 
			
		||||
 | 
			
		||||
  @property({ attribute: false }) public domain!: string;
 | 
			
		||||
 | 
			
		||||
  protected render(): TemplateResult {
 | 
			
		||||
    return html`
 | 
			
		||||
      <h2>
 | 
			
		||||
        ${this.hass.localize(
 | 
			
		||||
          "ui.panel.config.integrations.config_flow.aborted"
 | 
			
		||||
        )}
 | 
			
		||||
      </h2>
 | 
			
		||||
      <h2>${this.hass.localize(`component.${this.domain}.title`)}</h2>
 | 
			
		||||
      <div class="content">
 | 
			
		||||
        ${this.flowConfig.renderAbortDescription(this.hass, this.step)}
 | 
			
		||||
      </div>
 | 
			
		||||
 
 | 
			
		||||
@@ -1,12 +1,13 @@
 | 
			
		||||
import "@material/mwc-button/mwc-button";
 | 
			
		||||
import { mdiAlertOutline } from "@mdi/js";
 | 
			
		||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
 | 
			
		||||
import { customElement, property, state } from "lit/decorators";
 | 
			
		||||
import { customElement, property, query, state } from "lit/decorators";
 | 
			
		||||
import { ifDefined } from "lit/directives/if-defined";
 | 
			
		||||
import { fireEvent } from "../../common/dom/fire_event";
 | 
			
		||||
import "../../components/ha-dialog";
 | 
			
		||||
import "../../components/ha-svg-icon";
 | 
			
		||||
import "../../components/ha-switch";
 | 
			
		||||
import "../../components/ha-textfield";
 | 
			
		||||
import { HaTextField } from "../../components/ha-textfield";
 | 
			
		||||
import { haStyleDialog } from "../../resources/styles";
 | 
			
		||||
import { HomeAssistant } from "../../types";
 | 
			
		||||
import { DialogBoxParams } from "./show-dialog-box";
 | 
			
		||||
@@ -17,13 +18,10 @@ class DialogBox extends LitElement {
 | 
			
		||||
 | 
			
		||||
  @state() private _params?: DialogBoxParams;
 | 
			
		||||
 | 
			
		||||
  @state() private _value?: string;
 | 
			
		||||
  @query("ha-textfield") private _textField?: HaTextField;
 | 
			
		||||
 | 
			
		||||
  public async showDialog(params: DialogBoxParams): Promise<void> {
 | 
			
		||||
    this._params = params;
 | 
			
		||||
    if (params.prompt) {
 | 
			
		||||
      this._value = params.defaultValue;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public closeDialog(): boolean {
 | 
			
		||||
@@ -75,9 +73,7 @@ class DialogBox extends LitElement {
 | 
			
		||||
            ? html`
 | 
			
		||||
                <ha-textfield
 | 
			
		||||
                  dialogInitialFocus
 | 
			
		||||
                  .value=${this._value || ""}
 | 
			
		||||
                  @keyup=${this._handleKeyUp}
 | 
			
		||||
                  @input=${this._valueChanged}
 | 
			
		||||
                  value=${ifDefined(this._params.defaultValue)}
 | 
			
		||||
                  .label=${this._params.inputLabel
 | 
			
		||||
                    ? this._params.inputLabel
 | 
			
		||||
                    : ""}
 | 
			
		||||
@@ -109,10 +105,6 @@ class DialogBox extends LitElement {
 | 
			
		||||
    `;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private _valueChanged(ev) {
 | 
			
		||||
    this._value = ev.target.value;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private _dismiss(): void {
 | 
			
		||||
    if (this._params?.cancel) {
 | 
			
		||||
      this._params.cancel();
 | 
			
		||||
@@ -120,15 +112,9 @@ class DialogBox extends LitElement {
 | 
			
		||||
    this._close();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private _handleKeyUp(ev: KeyboardEvent) {
 | 
			
		||||
    if (ev.keyCode === 13) {
 | 
			
		||||
      this._confirm();
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private _confirm(): void {
 | 
			
		||||
    if (this._params!.confirm) {
 | 
			
		||||
      this._params!.confirm(this._value);
 | 
			
		||||
      this._params!.confirm(this._textField?.value);
 | 
			
		||||
    }
 | 
			
		||||
    this._close();
 | 
			
		||||
  }
 | 
			
		||||
 
 | 
			
		||||
@@ -17,6 +17,7 @@ import { styleMap } from "lit/directives/style-map";
 | 
			
		||||
import memoizeOne from "memoize-one";
 | 
			
		||||
import { canShowPage } from "../../common/config/can_show_page";
 | 
			
		||||
import { componentsWithService } from "../../common/config/components_with_service";
 | 
			
		||||
import { isComponentLoaded } from "../../common/config/is_component_loaded";
 | 
			
		||||
import { fireEvent } from "../../common/dom/fire_event";
 | 
			
		||||
import { computeDomain } from "../../common/entity/compute_domain";
 | 
			
		||||
import { computeStateName } from "../../common/entity/compute_state_name";
 | 
			
		||||
@@ -33,6 +34,7 @@ import "../../components/ha-circular-progress";
 | 
			
		||||
import "../../components/ha-header-bar";
 | 
			
		||||
import "../../components/ha-icon-button";
 | 
			
		||||
import "../../components/ha-textfield";
 | 
			
		||||
import { fetchHassioSupervisorInfo } from "../../data/hassio/supervisor";
 | 
			
		||||
import { domainToName } from "../../data/integration";
 | 
			
		||||
import { getPanelNameTranslationKey } from "../../data/panel";
 | 
			
		||||
import { PageNavigation } from "../../layouts/hass-tabs-subpage";
 | 
			
		||||
@@ -245,9 +247,10 @@ export class QuickBar extends LitElement {
 | 
			
		||||
    `;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private _initializeItemsIfNeeded() {
 | 
			
		||||
  private async _initializeItemsIfNeeded() {
 | 
			
		||||
    if (this._commandMode) {
 | 
			
		||||
      this._commandItems = this._commandItems || this._generateCommandItems();
 | 
			
		||||
      this._commandItems =
 | 
			
		||||
        this._commandItems || (await this._generateCommandItems());
 | 
			
		||||
    } else {
 | 
			
		||||
      this._entityItems = this._entityItems || this._generateEntityItems();
 | 
			
		||||
    }
 | 
			
		||||
@@ -485,11 +488,11 @@ export class QuickBar extends LitElement {
 | 
			
		||||
      );
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private _generateCommandItems(): CommandItem[] {
 | 
			
		||||
  private async _generateCommandItems(): Promise<CommandItem[]> {
 | 
			
		||||
    return [
 | 
			
		||||
      ...this._generateReloadCommands(),
 | 
			
		||||
      ...this._generateServerControlCommands(),
 | 
			
		||||
      ...this._generateNavigationCommands(),
 | 
			
		||||
      ...(await this._generateNavigationCommands()),
 | 
			
		||||
    ].sort((a, b) =>
 | 
			
		||||
      caseInsensitiveStringCompare(a.strings.join(" "), b.strings.join(" "))
 | 
			
		||||
    );
 | 
			
		||||
@@ -578,11 +581,40 @@ export class QuickBar extends LitElement {
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private _generateNavigationCommands(): CommandItem[] {
 | 
			
		||||
  private async _generateNavigationCommands(): Promise<CommandItem[]> {
 | 
			
		||||
    const panelItems = this._generateNavigationPanelCommands();
 | 
			
		||||
    const sectionItems = this._generateNavigationConfigSectionCommands();
 | 
			
		||||
    const supervisorItems: BaseNavigationCommand[] = [];
 | 
			
		||||
    if (isComponentLoaded(this.hass, "hassio")) {
 | 
			
		||||
      const supervisorInfo = await fetchHassioSupervisorInfo(this.hass);
 | 
			
		||||
      supervisorItems.push({
 | 
			
		||||
        path: "/hassio/store",
 | 
			
		||||
        primaryText: this.hass.localize(
 | 
			
		||||
          "ui.dialogs.quick-bar.commands.navigation.addon_store"
 | 
			
		||||
        ),
 | 
			
		||||
      });
 | 
			
		||||
      supervisorItems.push({
 | 
			
		||||
        path: "/hassio/dashboard",
 | 
			
		||||
        primaryText: this.hass.localize(
 | 
			
		||||
          "ui.dialogs.quick-bar.commands.navigation.addon_dashboard"
 | 
			
		||||
        ),
 | 
			
		||||
      });
 | 
			
		||||
      for (const addon of supervisorInfo.addons) {
 | 
			
		||||
        supervisorItems.push({
 | 
			
		||||
          path: `/hassio/addon/${addon.slug}`,
 | 
			
		||||
          primaryText: this.hass.localize(
 | 
			
		||||
            "ui.dialogs.quick-bar.commands.navigation.addon_info",
 | 
			
		||||
            { addon: addon.name }
 | 
			
		||||
          ),
 | 
			
		||||
        });
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return this._finalizeNavigationCommands([...panelItems, ...sectionItems]);
 | 
			
		||||
    return this._finalizeNavigationCommands([
 | 
			
		||||
      ...panelItems,
 | 
			
		||||
      ...sectionItems,
 | 
			
		||||
      ...supervisorItems,
 | 
			
		||||
    ]);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private _generateNavigationPanelCommands(): BaseNavigationCommand[] {
 | 
			
		||||
@@ -610,20 +642,14 @@ export class QuickBar extends LitElement {
 | 
			
		||||
        if (!canShowPage(this.hass, page)) {
 | 
			
		||||
          continue;
 | 
			
		||||
        }
 | 
			
		||||
        if (!page.component) {
 | 
			
		||||
          continue;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        const info = this._getNavigationInfoFromConfig(page);
 | 
			
		||||
 | 
			
		||||
        if (!info) {
 | 
			
		||||
          continue;
 | 
			
		||||
        }
 | 
			
		||||
        // Add to list, but only if we do not already have an entry for the same path and component
 | 
			
		||||
        if (
 | 
			
		||||
          items.some(
 | 
			
		||||
            (e) => e.path === info.path && e.component === info.component
 | 
			
		||||
          )
 | 
			
		||||
        ) {
 | 
			
		||||
        if (items.some((e) => e.path === info.path)) {
 | 
			
		||||
          continue;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@@ -637,14 +663,19 @@ export class QuickBar extends LitElement {
 | 
			
		||||
  private _getNavigationInfoFromConfig(
 | 
			
		||||
    page: PageNavigation
 | 
			
		||||
  ): NavigationInfo | undefined {
 | 
			
		||||
    if (!page.component) {
 | 
			
		||||
      return undefined;
 | 
			
		||||
    }
 | 
			
		||||
    const caption = this.hass.localize(
 | 
			
		||||
      `ui.dialogs.quick-bar.commands.navigation.${page.component}`
 | 
			
		||||
    );
 | 
			
		||||
    const path = page.path.substring(1);
 | 
			
		||||
 | 
			
		||||
    if (page.translationKey && caption) {
 | 
			
		||||
    let name = path.substring(path.indexOf("/") + 1);
 | 
			
		||||
    name = name.indexOf("/") > -1 ? name.substring(0, name.indexOf("/")) : name;
 | 
			
		||||
 | 
			
		||||
    const caption =
 | 
			
		||||
      (name &&
 | 
			
		||||
        this.hass.localize(
 | 
			
		||||
          `ui.dialogs.quick-bar.commands.navigation.${name}`
 | 
			
		||||
        )) ||
 | 
			
		||||
      (page.translationKey && this.hass.localize(page.translationKey));
 | 
			
		||||
 | 
			
		||||
    if (caption) {
 | 
			
		||||
      return { ...page, primaryText: caption };
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -99,6 +99,7 @@ class HassSubpage extends LitElement {
 | 
			
		||||
      ha-icon-button-arrow-prev,
 | 
			
		||||
      ::slotted([slot="toolbar-icon"]) {
 | 
			
		||||
        pointer-events: auto;
 | 
			
		||||
        color: var(--sidebar-icon-color);
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      .main-title {
 | 
			
		||||
 
 | 
			
		||||
@@ -130,7 +130,7 @@ export class HaTabsSubpageDataTable extends LitElement {
 | 
			
		||||
   * Array of tabs to show on the page.
 | 
			
		||||
   * @type {Array}
 | 
			
		||||
   */
 | 
			
		||||
  @property() public tabs!: PageNavigation[];
 | 
			
		||||
  @property() public tabs: PageNavigation[] = [];
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Force hides the filter menu.
 | 
			
		||||
@@ -283,6 +283,9 @@ export class HaTabsSubpageDataTable extends LitElement {
 | 
			
		||||
        height: calc(100vh - 1px - var(--header-height));
 | 
			
		||||
        display: block;
 | 
			
		||||
      }
 | 
			
		||||
      :host([narrow]) hass-tabs-subpage {
 | 
			
		||||
        --main-title-margin: 0;
 | 
			
		||||
      }
 | 
			
		||||
      .table-header {
 | 
			
		||||
        display: flex;
 | 
			
		||||
        align-items: center;
 | 
			
		||||
 
 | 
			
		||||
@@ -82,6 +82,16 @@ class HassTabsSubpage extends LitElement {
 | 
			
		||||
          (!page.advancedOnly || showAdvanced)
 | 
			
		||||
      );
 | 
			
		||||
 | 
			
		||||
      if (shownTabs.length < 2) {
 | 
			
		||||
        if (shownTabs.length === 1) {
 | 
			
		||||
          const page = shownTabs[0];
 | 
			
		||||
          return [
 | 
			
		||||
            page.translationKey ? localizeFunc(page.translationKey) : page.name,
 | 
			
		||||
          ];
 | 
			
		||||
        }
 | 
			
		||||
        return [""];
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      return shownTabs.map(
 | 
			
		||||
        (page) =>
 | 
			
		||||
          html`
 | 
			
		||||
@@ -134,7 +144,7 @@ class HassTabsSubpage extends LitElement {
 | 
			
		||||
      this.narrow,
 | 
			
		||||
      this.localizeFunc || this.hass.localize
 | 
			
		||||
    );
 | 
			
		||||
    const showTabs = tabs.length > 1 || !this.narrow;
 | 
			
		||||
    const showTabs = tabs.length > 1;
 | 
			
		||||
    return html`
 | 
			
		||||
      <div class="toolbar">
 | 
			
		||||
        ${this.mainPage || (!this.backPath && history.state?.root)
 | 
			
		||||
@@ -159,8 +169,10 @@ class HassTabsSubpage extends LitElement {
 | 
			
		||||
                @click=${this._backTapped}
 | 
			
		||||
              ></ha-icon-button-arrow-prev>
 | 
			
		||||
            `}
 | 
			
		||||
        ${this.narrow
 | 
			
		||||
          ? html`<div class="main-title"><slot name="header"></slot></div>`
 | 
			
		||||
        ${this.narrow || !showTabs
 | 
			
		||||
          ? html`<div class="main-title">
 | 
			
		||||
              <slot name="header">${!showTabs ? tabs[0] : ""}</slot>
 | 
			
		||||
            </div>`
 | 
			
		||||
          : ""}
 | 
			
		||||
        ${showTabs
 | 
			
		||||
          ? html`
 | 
			
		||||
@@ -283,6 +295,7 @@ class HassTabsSubpage extends LitElement {
 | 
			
		||||
        max-height: var(--header-height);
 | 
			
		||||
        line-height: 20px;
 | 
			
		||||
        color: var(--sidebar-text-color);
 | 
			
		||||
        margin: var(--main-title-margin, 0 0 0 24px);
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      .content {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,11 +1,11 @@
 | 
			
		||||
import "@material/mwc-button/mwc-button";
 | 
			
		||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
 | 
			
		||||
import { customElement, property } from "lit/decorators";
 | 
			
		||||
import "../../hassio/src/components/hassio-ansi-to-html";
 | 
			
		||||
import { showBackupUploadDialog } from "../../hassio/src/dialogs/backup/show-dialog-backup-upload";
 | 
			
		||||
import { showHassioBackupDialog } from "../../hassio/src/dialogs/backup/show-dialog-hassio-backup";
 | 
			
		||||
import type { LocalizeFunc } from "../common/translations/localize";
 | 
			
		||||
import "../components/ha-card";
 | 
			
		||||
import "../components/ha-ansi-to-html";
 | 
			
		||||
import { fetchInstallationType } from "../data/onboarding";
 | 
			
		||||
import { makeDialogManager } from "../dialogs/make-dialog-manager";
 | 
			
		||||
import { ProvideHassLitMixin } from "../mixins/provide-hass-lit-mixin";
 | 
			
		||||
@@ -86,7 +86,7 @@ class OnboardingRestoreBackup extends ProvideHassLitMixin(LitElement) {
 | 
			
		||||
          padding: 4px;
 | 
			
		||||
          margin-top: 8px;
 | 
			
		||||
        }
 | 
			
		||||
        hassio-ansi-to-html {
 | 
			
		||||
        ha-ansi-to-html {
 | 
			
		||||
          display: block;
 | 
			
		||||
          line-height: 22px;
 | 
			
		||||
          padding: 0 8px;
 | 
			
		||||
 
 | 
			
		||||
@@ -11,14 +11,7 @@ import listPlugin from "@fullcalendar/list";
 | 
			
		||||
// @ts-ignore
 | 
			
		||||
import listStyle from "@fullcalendar/list/main.css";
 | 
			
		||||
import "@material/mwc-button";
 | 
			
		||||
import {
 | 
			
		||||
  mdiChevronLeft,
 | 
			
		||||
  mdiChevronRight,
 | 
			
		||||
  mdiViewAgenda,
 | 
			
		||||
  mdiViewDay,
 | 
			
		||||
  mdiViewModule,
 | 
			
		||||
  mdiViewWeek,
 | 
			
		||||
} from "@mdi/js";
 | 
			
		||||
import { mdiViewAgenda, mdiViewDay, mdiViewModule, mdiViewWeek } from "@mdi/js";
 | 
			
		||||
import {
 | 
			
		||||
  css,
 | 
			
		||||
  CSSResultGroup,
 | 
			
		||||
@@ -33,7 +26,6 @@ import memoize from "memoize-one";
 | 
			
		||||
import { useAmPm } from "../../common/datetime/use_am_pm";
 | 
			
		||||
import { fireEvent } from "../../common/dom/fire_event";
 | 
			
		||||
import "../../components/ha-button-toggle-group";
 | 
			
		||||
import "../../components/ha-icon-button";
 | 
			
		||||
import "../../components/ha-icon-button-prev";
 | 
			
		||||
import "../../components/ha-icon-button-next";
 | 
			
		||||
import { haStyle } from "../../resources/styles";
 | 
			
		||||
@@ -152,20 +144,18 @@ export class HAFullCalendar extends LitElement {
 | 
			
		||||
                    <div class="controls">
 | 
			
		||||
                      <h1>${this.calendar.view.title}</h1>
 | 
			
		||||
                      <div>
 | 
			
		||||
                        <ha-icon-button
 | 
			
		||||
                        <ha-icon-button-prev
 | 
			
		||||
                          .label=${this.hass.localize("ui.common.previous")}
 | 
			
		||||
                          .path=${mdiChevronLeft}
 | 
			
		||||
                          class="prev"
 | 
			
		||||
                          @click=${this._handlePrev}
 | 
			
		||||
                        >
 | 
			
		||||
                        </ha-icon-button>
 | 
			
		||||
                        <ha-icon-button
 | 
			
		||||
                        </ha-icon-button-prev>
 | 
			
		||||
                        <ha-icon-button-next
 | 
			
		||||
                          .label=${this.hass.localize("ui.common.next")}
 | 
			
		||||
                          .path=${mdiChevronRight}
 | 
			
		||||
                          class="next"
 | 
			
		||||
                          @click=${this._handleNext}
 | 
			
		||||
                        >
 | 
			
		||||
                        </ha-icon-button>
 | 
			
		||||
                        </ha-icon-button-next>
 | 
			
		||||
                      </div>
 | 
			
		||||
                    </div>
 | 
			
		||||
                    <div class="controls">
 | 
			
		||||
 
 | 
			
		||||
@@ -259,6 +259,7 @@ class HaConfigAreaPage extends LitElement {
 | 
			
		||||
                  <ha-svg-icon .path=${mdiImagePlus} slot="icon"></ha-svg-icon>
 | 
			
		||||
                </mwc-button>`}
 | 
			
		||||
            <ha-card
 | 
			
		||||
              outlined
 | 
			
		||||
              .header=${this.hass.localize("ui.panel.config.devices.caption")}
 | 
			
		||||
              >${devices.length
 | 
			
		||||
                ? devices.map(
 | 
			
		||||
@@ -281,6 +282,7 @@ class HaConfigAreaPage extends LitElement {
 | 
			
		||||
                  `}
 | 
			
		||||
            </ha-card>
 | 
			
		||||
            <ha-card
 | 
			
		||||
              outlined
 | 
			
		||||
              .header=${this.hass.localize(
 | 
			
		||||
                "ui.panel.config.areas.editor.linked_entities_caption"
 | 
			
		||||
              )}
 | 
			
		||||
@@ -314,6 +316,7 @@ class HaConfigAreaPage extends LitElement {
 | 
			
		||||
            ${isComponentLoaded(this.hass, "automation")
 | 
			
		||||
              ? html`
 | 
			
		||||
                  <ha-card
 | 
			
		||||
                    outlined
 | 
			
		||||
                    .header=${this.hass.localize(
 | 
			
		||||
                      "ui.panel.config.devices.automation.automations_heading"
 | 
			
		||||
                    )}
 | 
			
		||||
@@ -361,6 +364,7 @@ class HaConfigAreaPage extends LitElement {
 | 
			
		||||
            ${isComponentLoaded(this.hass, "scene")
 | 
			
		||||
              ? html`
 | 
			
		||||
                  <ha-card
 | 
			
		||||
                    outlined
 | 
			
		||||
                    .header=${this.hass.localize(
 | 
			
		||||
                      "ui.panel.config.devices.scene.scenes_heading"
 | 
			
		||||
                    )}
 | 
			
		||||
@@ -400,6 +404,7 @@ class HaConfigAreaPage extends LitElement {
 | 
			
		||||
            ${isComponentLoaded(this.hass, "script")
 | 
			
		||||
              ? html`
 | 
			
		||||
                  <ha-card
 | 
			
		||||
                    outlined
 | 
			
		||||
                    .header=${this.hass.localize(
 | 
			
		||||
                      "ui.panel.config.devices.script.scripts_heading"
 | 
			
		||||
                    )}
 | 
			
		||||
 
 | 
			
		||||
@@ -33,6 +33,7 @@ import "./types/ha-automation-action-delay";
 | 
			
		||||
import "./types/ha-automation-action-device_id";
 | 
			
		||||
import "./types/ha-automation-action-event";
 | 
			
		||||
import "./types/ha-automation-action-if";
 | 
			
		||||
import "./types/ha-automation-action-parallel";
 | 
			
		||||
import "./types/ha-automation-action-play_media";
 | 
			
		||||
import "./types/ha-automation-action-repeat";
 | 
			
		||||
import "./types/ha-automation-action-service";
 | 
			
		||||
@@ -54,6 +55,7 @@ const OPTIONS = [
 | 
			
		||||
  "if",
 | 
			
		||||
  "device_id",
 | 
			
		||||
  "stop",
 | 
			
		||||
  "parallel",
 | 
			
		||||
];
 | 
			
		||||
 | 
			
		||||
const getType = (action: Action | undefined) => {
 | 
			
		||||
@@ -63,6 +65,9 @@ const getType = (action: Action | undefined) => {
 | 
			
		||||
  if ("service" in action || "scene" in action) {
 | 
			
		||||
    return getActionType(action);
 | 
			
		||||
  }
 | 
			
		||||
  if (["and", "or", "not"].some((key) => key in action)) {
 | 
			
		||||
    return "condition";
 | 
			
		||||
  }
 | 
			
		||||
  return OPTIONS.find((option) => option in action);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@@ -159,63 +164,83 @@ export default class HaAutomationActionRow extends LitElement {
 | 
			
		||||
    const yamlMode = this._yamlMode;
 | 
			
		||||
 | 
			
		||||
    return html`
 | 
			
		||||
      <ha-card>
 | 
			
		||||
        <div class="card-content">
 | 
			
		||||
          <div class="card-menu">
 | 
			
		||||
            ${this.index !== 0
 | 
			
		||||
              ? html`
 | 
			
		||||
                  <ha-icon-button
 | 
			
		||||
                    .label=${this.hass.localize(
 | 
			
		||||
                      "ui.panel.config.automation.editor.move_up"
 | 
			
		||||
                    )}
 | 
			
		||||
                    .path=${mdiArrowUp}
 | 
			
		||||
                    @click=${this._moveUp}
 | 
			
		||||
                  ></ha-icon-button>
 | 
			
		||||
                `
 | 
			
		||||
              : ""}
 | 
			
		||||
            ${this.index !== this.totalActions - 1
 | 
			
		||||
              ? html`
 | 
			
		||||
                  <ha-icon-button
 | 
			
		||||
                    .label=${this.hass.localize(
 | 
			
		||||
                      "ui.panel.config.automation.editor.move_down"
 | 
			
		||||
                    )}
 | 
			
		||||
                    .path=${mdiArrowDown}
 | 
			
		||||
                    @click=${this._moveDown}
 | 
			
		||||
                  ></ha-icon-button>
 | 
			
		||||
                `
 | 
			
		||||
              : ""}
 | 
			
		||||
            <ha-button-menu corner="BOTTOM_START" @action=${this._handleAction}>
 | 
			
		||||
              <ha-icon-button
 | 
			
		||||
                slot="trigger"
 | 
			
		||||
                .label=${this.hass.localize("ui.common.menu")}
 | 
			
		||||
                .path=${mdiDotsVertical}
 | 
			
		||||
              ></ha-icon-button>
 | 
			
		||||
              <mwc-list-item>
 | 
			
		||||
                ${this.hass.localize(
 | 
			
		||||
                  "ui.panel.config.automation.editor.actions.run_action"
 | 
			
		||||
                )}
 | 
			
		||||
              </mwc-list-item>
 | 
			
		||||
              <mwc-list-item .disabled=${!this._uiModeAvailable}>
 | 
			
		||||
                ${yamlMode
 | 
			
		||||
                  ? this.hass.localize(
 | 
			
		||||
                      "ui.panel.config.automation.editor.edit_ui"
 | 
			
		||||
                    )
 | 
			
		||||
                  : this.hass.localize(
 | 
			
		||||
                      "ui.panel.config.automation.editor.edit_yaml"
 | 
			
		||||
                    )}
 | 
			
		||||
              </mwc-list-item>
 | 
			
		||||
              <mwc-list-item>
 | 
			
		||||
                ${this.hass.localize(
 | 
			
		||||
                  "ui.panel.config.automation.editor.actions.duplicate"
 | 
			
		||||
                )}
 | 
			
		||||
              </mwc-list-item>
 | 
			
		||||
              <mwc-list-item class="warning">
 | 
			
		||||
                ${this.hass.localize(
 | 
			
		||||
                  "ui.panel.config.automation.editor.actions.delete"
 | 
			
		||||
                )}
 | 
			
		||||
              </mwc-list-item>
 | 
			
		||||
            </ha-button-menu>
 | 
			
		||||
          </div>
 | 
			
		||||
      <ha-card outlined>
 | 
			
		||||
        ${this.action.enabled === false
 | 
			
		||||
          ? html`<div class="disabled-bar">
 | 
			
		||||
              ${this.hass.localize(
 | 
			
		||||
                "ui.panel.config.automation.editor.actions.disabled"
 | 
			
		||||
              )}
 | 
			
		||||
            </div>`
 | 
			
		||||
          : ""}
 | 
			
		||||
        <div class="card-menu">
 | 
			
		||||
          ${this.index !== 0
 | 
			
		||||
            ? html`
 | 
			
		||||
                <ha-icon-button
 | 
			
		||||
                  .label=${this.hass.localize(
 | 
			
		||||
                    "ui.panel.config.automation.editor.move_up"
 | 
			
		||||
                  )}
 | 
			
		||||
                  .path=${mdiArrowUp}
 | 
			
		||||
                  @click=${this._moveUp}
 | 
			
		||||
                ></ha-icon-button>
 | 
			
		||||
              `
 | 
			
		||||
            : ""}
 | 
			
		||||
          ${this.index !== this.totalActions - 1
 | 
			
		||||
            ? html`
 | 
			
		||||
                <ha-icon-button
 | 
			
		||||
                  .label=${this.hass.localize(
 | 
			
		||||
                    "ui.panel.config.automation.editor.move_down"
 | 
			
		||||
                  )}
 | 
			
		||||
                  .path=${mdiArrowDown}
 | 
			
		||||
                  @click=${this._moveDown}
 | 
			
		||||
                ></ha-icon-button>
 | 
			
		||||
              `
 | 
			
		||||
            : ""}
 | 
			
		||||
          <ha-button-menu corner="BOTTOM_START" @action=${this._handleAction}>
 | 
			
		||||
            <ha-icon-button
 | 
			
		||||
              slot="trigger"
 | 
			
		||||
              .label=${this.hass.localize("ui.common.menu")}
 | 
			
		||||
              .path=${mdiDotsVertical}
 | 
			
		||||
            ></ha-icon-button>
 | 
			
		||||
            <mwc-list-item>
 | 
			
		||||
              ${this.hass.localize(
 | 
			
		||||
                "ui.panel.config.automation.editor.actions.run_action"
 | 
			
		||||
              )}
 | 
			
		||||
            </mwc-list-item>
 | 
			
		||||
            <mwc-list-item .disabled=${!this._uiModeAvailable}>
 | 
			
		||||
              ${yamlMode
 | 
			
		||||
                ? this.hass.localize(
 | 
			
		||||
                    "ui.panel.config.automation.editor.edit_ui"
 | 
			
		||||
                  )
 | 
			
		||||
                : this.hass.localize(
 | 
			
		||||
                    "ui.panel.config.automation.editor.edit_yaml"
 | 
			
		||||
                  )}
 | 
			
		||||
            </mwc-list-item>
 | 
			
		||||
            <mwc-list-item>
 | 
			
		||||
              ${this.hass.localize(
 | 
			
		||||
                "ui.panel.config.automation.editor.actions.duplicate"
 | 
			
		||||
              )}
 | 
			
		||||
            </mwc-list-item>
 | 
			
		||||
            <mwc-list-item>
 | 
			
		||||
              ${this.action.enabled === false
 | 
			
		||||
                ? this.hass.localize(
 | 
			
		||||
                    "ui.panel.config.automation.editor.actions.enable"
 | 
			
		||||
                  )
 | 
			
		||||
                : this.hass.localize(
 | 
			
		||||
                    "ui.panel.config.automation.editor.actions.disable"
 | 
			
		||||
                  )}
 | 
			
		||||
            </mwc-list-item>
 | 
			
		||||
            <mwc-list-item class="warning">
 | 
			
		||||
              ${this.hass.localize(
 | 
			
		||||
                "ui.panel.config.automation.editor.actions.delete"
 | 
			
		||||
              )}
 | 
			
		||||
            </mwc-list-item>
 | 
			
		||||
          </ha-button-menu>
 | 
			
		||||
        </div>
 | 
			
		||||
        <div
 | 
			
		||||
          class="card-content ${this.action.enabled === false
 | 
			
		||||
            ? "disabled"
 | 
			
		||||
            : ""}"
 | 
			
		||||
        >
 | 
			
		||||
          ${this._warnings
 | 
			
		||||
            ? html`<ha-alert
 | 
			
		||||
                alert-type="warning"
 | 
			
		||||
@@ -314,11 +339,23 @@ export default class HaAutomationActionRow extends LitElement {
 | 
			
		||||
        fireEvent(this, "duplicate");
 | 
			
		||||
        break;
 | 
			
		||||
      case 3:
 | 
			
		||||
        this._onDisable();
 | 
			
		||||
        break;
 | 
			
		||||
      case 4:
 | 
			
		||||
        this._onDelete();
 | 
			
		||||
        break;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private _onDisable() {
 | 
			
		||||
    const enabled = !(this.action.enabled ?? true);
 | 
			
		||||
    const value = { ...this.action, enabled };
 | 
			
		||||
    fireEvent(this, "value-changed", { value });
 | 
			
		||||
    if (this._yamlMode) {
 | 
			
		||||
      this._yamlEditor?.setValue(value);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private async _runAction() {
 | 
			
		||||
    const validated = await validateConfig(this.hass, {
 | 
			
		||||
      action: this.action,
 | 
			
		||||
@@ -408,11 +445,27 @@ export default class HaAutomationActionRow extends LitElement {
 | 
			
		||||
    return [
 | 
			
		||||
      haStyle,
 | 
			
		||||
      css`
 | 
			
		||||
        .disabled {
 | 
			
		||||
          opacity: 0.5;
 | 
			
		||||
          pointer-events: none;
 | 
			
		||||
        }
 | 
			
		||||
        .card-content {
 | 
			
		||||
          padding-top: 16px;
 | 
			
		||||
          margin-top: 0;
 | 
			
		||||
        }
 | 
			
		||||
        .disabled-bar {
 | 
			
		||||
          background: var(--divider-color, #e0e0e0);
 | 
			
		||||
          text-align: center;
 | 
			
		||||
          border-top-right-radius: var(--ha-card-border-radius);
 | 
			
		||||
          border-top-left-radius: var(--ha-card-border-radius);
 | 
			
		||||
        }
 | 
			
		||||
        .card-menu {
 | 
			
		||||
          position: absolute;
 | 
			
		||||
          right: 16px;
 | 
			
		||||
          float: right;
 | 
			
		||||
          z-index: 3;
 | 
			
		||||
          margin: 4px;
 | 
			
		||||
          --mdc-theme-text-primary-on-background: var(--primary-text-color);
 | 
			
		||||
          display: flex;
 | 
			
		||||
          align-items: center;
 | 
			
		||||
        }
 | 
			
		||||
        :host-context([style*="direction: rtl;"]) .card-menu {
 | 
			
		||||
          right: initial;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,4 @@
 | 
			
		||||
import deepClone from "deep-clone-simple";
 | 
			
		||||
import "@material/mwc-button";
 | 
			
		||||
import { css, CSSResultGroup, html, LitElement } from "lit";
 | 
			
		||||
import { customElement, property } from "lit/decorators";
 | 
			
		||||
@@ -32,7 +33,7 @@ export default class HaAutomationAction extends LitElement {
 | 
			
		||||
          ></ha-automation-action-row>
 | 
			
		||||
        `
 | 
			
		||||
      )}
 | 
			
		||||
      <ha-card>
 | 
			
		||||
      <ha-card outlined>
 | 
			
		||||
        <div class="card-actions add-card">
 | 
			
		||||
          <mwc-button @click=${this._addAction}>
 | 
			
		||||
            ${this.hass.localize(
 | 
			
		||||
@@ -83,7 +84,7 @@ export default class HaAutomationAction extends LitElement {
 | 
			
		||||
    ev.stopPropagation();
 | 
			
		||||
    const index = (ev.target as any).index;
 | 
			
		||||
    fireEvent(this, "value-changed", {
 | 
			
		||||
      value: this.actions.concat(this.actions[index]),
 | 
			
		||||
      value: this.actions.concat(deepClone(this.actions[index])),
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -69,7 +69,7 @@ export class HaChooseAction extends LitElement implements ActionElement {
 | 
			
		||||
          </div>
 | 
			
		||||
        </ha-card>`
 | 
			
		||||
      )}
 | 
			
		||||
      <ha-card>
 | 
			
		||||
      <ha-card outlined>
 | 
			
		||||
        <div class="card-actions add-card">
 | 
			
		||||
          <mwc-button @click=${this._addOption}>
 | 
			
		||||
            ${this.hass.localize(
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,56 @@
 | 
			
		||||
import { CSSResultGroup, html, LitElement } from "lit";
 | 
			
		||||
import { customElement, property } from "lit/decorators";
 | 
			
		||||
import { fireEvent } from "../../../../../common/dom/fire_event";
 | 
			
		||||
import { Action, ParallelAction } from "../../../../../data/script";
 | 
			
		||||
import { HaDeviceAction } from "./ha-automation-action-device_id";
 | 
			
		||||
import { haStyle } from "../../../../../resources/styles";
 | 
			
		||||
import type { HomeAssistant } from "../../../../../types";
 | 
			
		||||
import "../ha-automation-action";
 | 
			
		||||
import "../../../../../components/ha-textfield";
 | 
			
		||||
import type { ActionElement } from "../ha-automation-action-row";
 | 
			
		||||
 | 
			
		||||
@customElement("ha-automation-action-parallel")
 | 
			
		||||
export class HaParallelAction extends LitElement implements ActionElement {
 | 
			
		||||
  @property({ attribute: false }) public hass!: HomeAssistant;
 | 
			
		||||
 | 
			
		||||
  @property({ attribute: false }) public action!: ParallelAction;
 | 
			
		||||
 | 
			
		||||
  public static get defaultConfig() {
 | 
			
		||||
    return {
 | 
			
		||||
      parallel: [HaDeviceAction.defaultConfig],
 | 
			
		||||
    };
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  protected render() {
 | 
			
		||||
    const action = this.action;
 | 
			
		||||
 | 
			
		||||
    return html`
 | 
			
		||||
      <ha-automation-action
 | 
			
		||||
        .actions=${action.parallel}
 | 
			
		||||
        @value-changed=${this._actionsChanged}
 | 
			
		||||
        .hass=${this.hass}
 | 
			
		||||
      ></ha-automation-action>
 | 
			
		||||
    `;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private _actionsChanged(ev: CustomEvent) {
 | 
			
		||||
    ev.stopPropagation();
 | 
			
		||||
    const value = ev.detail.value as Action[];
 | 
			
		||||
    fireEvent(this, "value-changed", {
 | 
			
		||||
      value: {
 | 
			
		||||
        ...this.action,
 | 
			
		||||
        parallel: value,
 | 
			
		||||
      },
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  static get styles(): CSSResultGroup {
 | 
			
		||||
    return haStyle;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
declare global {
 | 
			
		||||
  interface HTMLElementTagNameMap {
 | 
			
		||||
    "ha-automation-action-parallel": HaParallelAction;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@@ -33,7 +33,7 @@ export class HaWaitAction extends LitElement implements ActionElement {
 | 
			
		||||
  @property({ attribute: false }) public action!: WaitAction;
 | 
			
		||||
 | 
			
		||||
  public static get defaultConfig() {
 | 
			
		||||
    return { wait_template: "" };
 | 
			
		||||
    return { wait_template: "", continue_on_timeout: true };
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  protected render() {
 | 
			
		||||
 
 | 
			
		||||
@@ -75,7 +75,7 @@ export class HaBlueprintAutomationEditor extends LitElement {
 | 
			
		||||
            "ui.panel.config.automation.editor.introduction"
 | 
			
		||||
          )}
 | 
			
		||||
        </span>
 | 
			
		||||
        <ha-card>
 | 
			
		||||
        <ha-card outlined>
 | 
			
		||||
          <div class="card-content">
 | 
			
		||||
            <ha-textfield
 | 
			
		||||
              .label=${this.hass.localize(
 | 
			
		||||
@@ -145,6 +145,7 @@ export class HaBlueprintAutomationEditor extends LitElement {
 | 
			
		||||
      </ha-config-section>
 | 
			
		||||
 | 
			
		||||
      <ha-card
 | 
			
		||||
        outlined
 | 
			
		||||
        class="blueprint"
 | 
			
		||||
        .header=${this.hass.localize(
 | 
			
		||||
          "ui.panel.config.automation.editor.blueprint.header"
 | 
			
		||||
@@ -332,6 +333,7 @@ export class HaBlueprintAutomationEditor extends LitElement {
 | 
			
		||||
        ha-settings-row {
 | 
			
		||||
          --paper-time-input-justify-content: flex-end;
 | 
			
		||||
          --settings-row-content-width: 100%;
 | 
			
		||||
          --settings-row-prefix-display: contents;
 | 
			
		||||
          border-top: 1px solid var(--divider-color);
 | 
			
		||||
        }
 | 
			
		||||
      `,
 | 
			
		||||
 
 | 
			
		||||
@@ -5,11 +5,11 @@ import { dynamicElement } from "../../../../common/dom/dynamic-element-directive
 | 
			
		||||
import { fireEvent } from "../../../../common/dom/fire_event";
 | 
			
		||||
import { stringCompare } from "../../../../common/string/compare";
 | 
			
		||||
import type { LocalizeFunc } from "../../../../common/translations/localize";
 | 
			
		||||
import "../../../../components/ha-card";
 | 
			
		||||
import "../../../../components/ha-select";
 | 
			
		||||
import type { HaSelect } from "../../../../components/ha-select";
 | 
			
		||||
import "../../../../components/ha-yaml-editor";
 | 
			
		||||
import type { Condition } from "../../../../data/automation";
 | 
			
		||||
import { expandConditionWithShorthand } from "../../../../data/automation";
 | 
			
		||||
import { haStyle } from "../../../../resources/styles";
 | 
			
		||||
import type { HomeAssistant } from "../../../../types";
 | 
			
		||||
import "./types/ha-automation-condition-and";
 | 
			
		||||
@@ -42,10 +42,14 @@ const OPTIONS = [
 | 
			
		||||
export default class HaAutomationConditionEditor extends LitElement {
 | 
			
		||||
  @property({ attribute: false }) public hass!: HomeAssistant;
 | 
			
		||||
 | 
			
		||||
  @property() public condition!: Condition;
 | 
			
		||||
  @property() condition!: Condition;
 | 
			
		||||
 | 
			
		||||
  @property() public yamlMode = false;
 | 
			
		||||
 | 
			
		||||
  private _processedCondition = memoizeOne((condition) =>
 | 
			
		||||
    expandConditionWithShorthand(condition)
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
  private _processedTypes = memoizeOne(
 | 
			
		||||
    (localize: LocalizeFunc): [string, string][] =>
 | 
			
		||||
      OPTIONS.map(
 | 
			
		||||
@@ -60,7 +64,8 @@ export default class HaAutomationConditionEditor extends LitElement {
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
  protected render() {
 | 
			
		||||
    const selected = OPTIONS.indexOf(this.condition.condition);
 | 
			
		||||
    const condition = this._processedCondition(this.condition);
 | 
			
		||||
    const selected = OPTIONS.indexOf(condition.condition);
 | 
			
		||||
    const yamlMode = this.yamlMode || selected === -1;
 | 
			
		||||
    return html`
 | 
			
		||||
      ${yamlMode
 | 
			
		||||
@@ -70,7 +75,7 @@ export default class HaAutomationConditionEditor extends LitElement {
 | 
			
		||||
                  ${this.hass.localize(
 | 
			
		||||
                    "ui.panel.config.automation.editor.conditions.unsupported_condition",
 | 
			
		||||
                    "condition",
 | 
			
		||||
                    this.condition.condition
 | 
			
		||||
                    condition.condition
 | 
			
		||||
                  )}
 | 
			
		||||
                `
 | 
			
		||||
              : ""}
 | 
			
		||||
@@ -90,7 +95,7 @@ export default class HaAutomationConditionEditor extends LitElement {
 | 
			
		||||
              .label=${this.hass.localize(
 | 
			
		||||
                "ui.panel.config.automation.editor.conditions.type_select"
 | 
			
		||||
              )}
 | 
			
		||||
              .value=${this.condition.condition}
 | 
			
		||||
              .value=${condition.condition}
 | 
			
		||||
              naturalMenuWidth
 | 
			
		||||
              @selected=${this._typeChanged}
 | 
			
		||||
            >
 | 
			
		||||
@@ -103,8 +108,8 @@ export default class HaAutomationConditionEditor extends LitElement {
 | 
			
		||||
 | 
			
		||||
            <div>
 | 
			
		||||
              ${dynamicElement(
 | 
			
		||||
                `ha-automation-condition-${this.condition.condition}`,
 | 
			
		||||
                { hass: this.hass, condition: this.condition }
 | 
			
		||||
                `ha-automation-condition-${condition.condition}`,
 | 
			
		||||
                { hass: this.hass, condition: condition }
 | 
			
		||||
              )}
 | 
			
		||||
            </div>
 | 
			
		||||
          `}
 | 
			
		||||
@@ -124,7 +129,7 @@ export default class HaAutomationConditionEditor extends LitElement {
 | 
			
		||||
      defaultConfig: Omit<Condition, "condition">;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    if (type !== this.condition.condition) {
 | 
			
		||||
    if (type !== this._processedCondition(this.condition).condition) {
 | 
			
		||||
      fireEvent(this, "value-changed", {
 | 
			
		||||
        value: {
 | 
			
		||||
          condition: type,
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@ import { ActionDetail } from "@material/mwc-list/mwc-list-foundation";
 | 
			
		||||
import "@material/mwc-list/mwc-list-item";
 | 
			
		||||
import { mdiDotsVertical } from "@mdi/js";
 | 
			
		||||
import { css, CSSResultGroup, html, LitElement } from "lit";
 | 
			
		||||
import { customElement, property, state } from "lit/decorators";
 | 
			
		||||
import { customElement, property, query, state } from "lit/decorators";
 | 
			
		||||
import { fireEvent } from "../../../../common/dom/fire_event";
 | 
			
		||||
import { handleStructError } from "../../../../common/structs/handle-errors";
 | 
			
		||||
import "../../../../components/ha-button-menu";
 | 
			
		||||
@@ -19,6 +19,7 @@ import { haStyle } from "../../../../resources/styles";
 | 
			
		||||
import { HomeAssistant } from "../../../../types";
 | 
			
		||||
import "./ha-automation-condition-editor";
 | 
			
		||||
import { validateConfig } from "../../../../data/config";
 | 
			
		||||
import { HaYamlEditor } from "../../../../components/ha-yaml-editor";
 | 
			
		||||
 | 
			
		||||
export interface ConditionElement extends LitElement {
 | 
			
		||||
  condition: Condition;
 | 
			
		||||
@@ -59,47 +60,69 @@ export default class HaAutomationConditionRow extends LitElement {
 | 
			
		||||
 | 
			
		||||
  @state() private _warnings?: string[];
 | 
			
		||||
 | 
			
		||||
  @query("ha-yaml-editor") private _yamlEditor?: HaYamlEditor;
 | 
			
		||||
 | 
			
		||||
  protected render() {
 | 
			
		||||
    if (!this.condition) {
 | 
			
		||||
      return html``;
 | 
			
		||||
    }
 | 
			
		||||
    return html`
 | 
			
		||||
      <ha-card>
 | 
			
		||||
        <div class="card-content">
 | 
			
		||||
          <div class="card-menu">
 | 
			
		||||
            <ha-progress-button @click=${this._testCondition}>
 | 
			
		||||
      <ha-card outlined>
 | 
			
		||||
        ${this.condition.enabled === false
 | 
			
		||||
          ? html`<div class="disabled-bar">
 | 
			
		||||
              ${this.hass.localize(
 | 
			
		||||
                "ui.panel.config.automation.editor.conditions.test"
 | 
			
		||||
                "ui.panel.config.automation.editor.actions.disabled"
 | 
			
		||||
              )}
 | 
			
		||||
            </ha-progress-button>
 | 
			
		||||
            <ha-button-menu corner="BOTTOM_START" @action=${this._handleAction}>
 | 
			
		||||
              <ha-icon-button
 | 
			
		||||
                slot="trigger"
 | 
			
		||||
                .label=${this.hass.localize("ui.common.menu")}
 | 
			
		||||
                .path=${mdiDotsVertical}
 | 
			
		||||
              >
 | 
			
		||||
              </ha-icon-button>
 | 
			
		||||
              <mwc-list-item>
 | 
			
		||||
                ${this._yamlMode
 | 
			
		||||
                  ? this.hass.localize(
 | 
			
		||||
                      "ui.panel.config.automation.editor.edit_ui"
 | 
			
		||||
                    )
 | 
			
		||||
                  : this.hass.localize(
 | 
			
		||||
                      "ui.panel.config.automation.editor.edit_yaml"
 | 
			
		||||
                    )}
 | 
			
		||||
              </mwc-list-item>
 | 
			
		||||
              <mwc-list-item>
 | 
			
		||||
                ${this.hass.localize(
 | 
			
		||||
                  "ui.panel.config.automation.editor.actions.duplicate"
 | 
			
		||||
                )}
 | 
			
		||||
              </mwc-list-item>
 | 
			
		||||
              <mwc-list-item class="warning">
 | 
			
		||||
                ${this.hass.localize(
 | 
			
		||||
                  "ui.panel.config.automation.editor.actions.delete"
 | 
			
		||||
                )}
 | 
			
		||||
              </mwc-list-item>
 | 
			
		||||
            </ha-button-menu>
 | 
			
		||||
          </div>
 | 
			
		||||
            </div>`
 | 
			
		||||
          : ""}
 | 
			
		||||
        <div class="card-menu">
 | 
			
		||||
          <ha-progress-button @click=${this._testCondition}>
 | 
			
		||||
            ${this.hass.localize(
 | 
			
		||||
              "ui.panel.config.automation.editor.conditions.test"
 | 
			
		||||
            )}
 | 
			
		||||
          </ha-progress-button>
 | 
			
		||||
          <ha-button-menu corner="BOTTOM_START" @action=${this._handleAction}>
 | 
			
		||||
            <ha-icon-button
 | 
			
		||||
              slot="trigger"
 | 
			
		||||
              .label=${this.hass.localize("ui.common.menu")}
 | 
			
		||||
              .path=${mdiDotsVertical}
 | 
			
		||||
            >
 | 
			
		||||
            </ha-icon-button>
 | 
			
		||||
            <mwc-list-item>
 | 
			
		||||
              ${this._yamlMode
 | 
			
		||||
                ? this.hass.localize(
 | 
			
		||||
                    "ui.panel.config.automation.editor.edit_ui"
 | 
			
		||||
                  )
 | 
			
		||||
                : this.hass.localize(
 | 
			
		||||
                    "ui.panel.config.automation.editor.edit_yaml"
 | 
			
		||||
                  )}
 | 
			
		||||
            </mwc-list-item>
 | 
			
		||||
            <mwc-list-item>
 | 
			
		||||
              ${this.hass.localize(
 | 
			
		||||
                "ui.panel.config.automation.editor.actions.duplicate"
 | 
			
		||||
              )}
 | 
			
		||||
            </mwc-list-item>
 | 
			
		||||
            <mwc-list-item>
 | 
			
		||||
              ${this.condition.enabled === false
 | 
			
		||||
                ? this.hass.localize(
 | 
			
		||||
                    "ui.panel.config.automation.editor.actions.enable"
 | 
			
		||||
                  )
 | 
			
		||||
                : this.hass.localize(
 | 
			
		||||
                    "ui.panel.config.automation.editor.actions.disable"
 | 
			
		||||
                  )}
 | 
			
		||||
            </mwc-list-item>
 | 
			
		||||
            <mwc-list-item class="warning">
 | 
			
		||||
              ${this.hass.localize(
 | 
			
		||||
                "ui.panel.config.automation.editor.actions.delete"
 | 
			
		||||
              )}
 | 
			
		||||
            </mwc-list-item>
 | 
			
		||||
          </ha-button-menu>
 | 
			
		||||
        </div>
 | 
			
		||||
        <div
 | 
			
		||||
          class="card-content ${this.condition.enabled === false
 | 
			
		||||
            ? "disabled"
 | 
			
		||||
            : ""}"
 | 
			
		||||
        >
 | 
			
		||||
          ${this._warnings
 | 
			
		||||
            ? html`<ha-alert
 | 
			
		||||
                alert-type="warning"
 | 
			
		||||
@@ -153,11 +176,23 @@ export default class HaAutomationConditionRow extends LitElement {
 | 
			
		||||
        fireEvent(this, "duplicate");
 | 
			
		||||
        break;
 | 
			
		||||
      case 2:
 | 
			
		||||
        this._onDisable();
 | 
			
		||||
        break;
 | 
			
		||||
      case 3:
 | 
			
		||||
        this._onDelete();
 | 
			
		||||
        break;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private _onDisable() {
 | 
			
		||||
    const enabled = !(this.condition.enabled ?? true);
 | 
			
		||||
    const value = { ...this.condition, enabled };
 | 
			
		||||
    fireEvent(this, "value-changed", { value });
 | 
			
		||||
    if (this._yamlMode) {
 | 
			
		||||
      this._yamlEditor?.setValue(value);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private _onDelete() {
 | 
			
		||||
    showConfirmationDialog(this, {
 | 
			
		||||
      text: this.hass.localize(
 | 
			
		||||
@@ -238,9 +273,24 @@ export default class HaAutomationConditionRow extends LitElement {
 | 
			
		||||
    return [
 | 
			
		||||
      haStyle,
 | 
			
		||||
      css`
 | 
			
		||||
        .disabled {
 | 
			
		||||
          opacity: 0.5;
 | 
			
		||||
          pointer-events: none;
 | 
			
		||||
        }
 | 
			
		||||
        .card-content {
 | 
			
		||||
          padding-top: 16px;
 | 
			
		||||
          margin-top: 0;
 | 
			
		||||
        }
 | 
			
		||||
        .disabled-bar {
 | 
			
		||||
          background: var(--divider-color, #e0e0e0);
 | 
			
		||||
          text-align: center;
 | 
			
		||||
          border-top-right-radius: var(--ha-card-border-radius);
 | 
			
		||||
          border-top-left-radius: var(--ha-card-border-radius);
 | 
			
		||||
        }
 | 
			
		||||
        .card-menu {
 | 
			
		||||
          float: right;
 | 
			
		||||
          z-index: 3;
 | 
			
		||||
          margin: 4px;
 | 
			
		||||
          --mdc-theme-text-primary-on-background: var(--primary-text-color);
 | 
			
		||||
          display: flex;
 | 
			
		||||
          align-items: center;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,4 @@
 | 
			
		||||
import deepClone from "deep-clone-simple";
 | 
			
		||||
import "@material/mwc-button";
 | 
			
		||||
import { css, CSSResultGroup, html, LitElement, PropertyValues } from "lit";
 | 
			
		||||
import { customElement, property } from "lit/decorators";
 | 
			
		||||
@@ -56,7 +57,7 @@ export default class HaAutomationCondition extends LitElement {
 | 
			
		||||
          ></ha-automation-condition-row>
 | 
			
		||||
        `
 | 
			
		||||
      )}
 | 
			
		||||
      <ha-card>
 | 
			
		||||
      <ha-card outlined>
 | 
			
		||||
        <div class="card-actions add-card">
 | 
			
		||||
          <mwc-button @click=${this._addCondition}>
 | 
			
		||||
            ${this.hass.localize(
 | 
			
		||||
@@ -96,7 +97,7 @@ export default class HaAutomationCondition extends LitElement {
 | 
			
		||||
    ev.stopPropagation();
 | 
			
		||||
    const index = (ev.target as any).index;
 | 
			
		||||
    fireEvent(this, "value-changed", {
 | 
			
		||||
      value: this.conditions.concat(this.conditions[index]),
 | 
			
		||||
      value: this.conditions.concat(deepClone(this.conditions[index])),
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -3,7 +3,6 @@ import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
 | 
			
		||||
import { customElement, property, state } from "lit/decorators";
 | 
			
		||||
import { fireEvent } from "../../../common/dom/fire_event";
 | 
			
		||||
import "../../../components/ha-blueprint-picker";
 | 
			
		||||
import "../../../components/ha-card";
 | 
			
		||||
import "../../../components/ha-circular-progress";
 | 
			
		||||
import { createCloseHeading } from "../../../components/ha-dialog";
 | 
			
		||||
import { showAutomationEditor } from "../../../data/automation";
 | 
			
		||||
 
 | 
			
		||||
@@ -239,8 +239,8 @@ export class HaAutomationEditor extends KeyboardShortcutMixin(LitElement) {
 | 
			
		||||
                  ? html`
 | 
			
		||||
                      ${!this.narrow
 | 
			
		||||
                        ? html`
 | 
			
		||||
                            <ha-card
 | 
			
		||||
                              ><div class="card-header">
 | 
			
		||||
                            <ha-card outlined>
 | 
			
		||||
                              <div class="card-header">
 | 
			
		||||
                                ${this._config.alias}
 | 
			
		||||
                              </div>
 | 
			
		||||
                              ${stateObj
 | 
			
		||||
@@ -275,8 +275,8 @@ export class HaAutomationEditor extends KeyboardShortcutMixin(LitElement) {
 | 
			
		||||
                        .defaultValue=${this._preprocessYaml()}
 | 
			
		||||
                        @value-changed=${this._yamlChanged}
 | 
			
		||||
                      ></ha-yaml-editor>
 | 
			
		||||
                      <ha-card
 | 
			
		||||
                        ><div class="card-actions">
 | 
			
		||||
                      <ha-card outlined>
 | 
			
		||||
                        <div class="card-actions">
 | 
			
		||||
                          <mwc-button @click=${this._copyYaml}>
 | 
			
		||||
                            ${this.hass.localize(
 | 
			
		||||
                              "ui.panel.config.automation.editor.copy_to_clipboard"
 | 
			
		||||
 
 | 
			
		||||
@@ -47,7 +47,7 @@ export class HaManualAutomationEditor extends LitElement {
 | 
			
		||||
            "ui.panel.config.automation.editor.introduction"
 | 
			
		||||
          )}
 | 
			
		||||
        </span>
 | 
			
		||||
        <ha-card>
 | 
			
		||||
        <ha-card outlined>
 | 
			
		||||
          <div class="card-content">
 | 
			
		||||
            <ha-textfield
 | 
			
		||||
              .label=${this.hass.localize(
 | 
			
		||||
 
 | 
			
		||||
@@ -1,8 +1,9 @@
 | 
			
		||||
import { object, optional, number, string } from "superstruct";
 | 
			
		||||
import { object, optional, number, string, boolean } from "superstruct";
 | 
			
		||||
 | 
			
		||||
export const baseTriggerStruct = object({
 | 
			
		||||
  platform: string(),
 | 
			
		||||
  id: optional(string()),
 | 
			
		||||
  enabled: optional(boolean()),
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
export const forDictStruct = object({
 | 
			
		||||
 
 | 
			
		||||
@@ -3,7 +3,7 @@ import "@material/mwc-list/mwc-list-item";
 | 
			
		||||
import { mdiDotsVertical } from "@mdi/js";
 | 
			
		||||
import type { UnsubscribeFunc } from "home-assistant-js-websocket";
 | 
			
		||||
import { css, CSSResultGroup, html, LitElement, PropertyValues } from "lit";
 | 
			
		||||
import { customElement, property, state } from "lit/decorators";
 | 
			
		||||
import { customElement, property, query, state } from "lit/decorators";
 | 
			
		||||
import { classMap } from "lit/directives/class-map";
 | 
			
		||||
import memoizeOne from "memoize-one";
 | 
			
		||||
import { dynamicElement } from "../../../../common/dom/dynamic-element-directive";
 | 
			
		||||
@@ -16,7 +16,7 @@ import "../../../../components/ha-alert";
 | 
			
		||||
import "../../../../components/ha-button-menu";
 | 
			
		||||
import "../../../../components/ha-card";
 | 
			
		||||
import "../../../../components/ha-icon-button";
 | 
			
		||||
import "../../../../components/ha-yaml-editor";
 | 
			
		||||
import { HaYamlEditor } from "../../../../components/ha-yaml-editor";
 | 
			
		||||
import "../../../../components/ha-select";
 | 
			
		||||
import type { HaSelect } from "../../../../components/ha-select";
 | 
			
		||||
import "../../../../components/ha-textfield";
 | 
			
		||||
@@ -104,6 +104,8 @@ export default class HaAutomationTriggerRow extends LitElement {
 | 
			
		||||
 | 
			
		||||
  @state() private _triggerColor = false;
 | 
			
		||||
 | 
			
		||||
  @query("ha-yaml-editor") private _yamlEditor?: HaYamlEditor;
 | 
			
		||||
 | 
			
		||||
  private _triggerUnsub?: Promise<UnsubscribeFunc>;
 | 
			
		||||
 | 
			
		||||
  private _processedTypes = memoizeOne(
 | 
			
		||||
@@ -125,41 +127,61 @@ export default class HaAutomationTriggerRow extends LitElement {
 | 
			
		||||
    const showId = "id" in this.trigger || this._requestShowId;
 | 
			
		||||
 | 
			
		||||
    return html`
 | 
			
		||||
      <ha-card>
 | 
			
		||||
        <div class="card-content">
 | 
			
		||||
          <div class="card-menu">
 | 
			
		||||
            <ha-button-menu corner="BOTTOM_START" @action=${this._handleAction}>
 | 
			
		||||
              <ha-icon-button
 | 
			
		||||
                slot="trigger"
 | 
			
		||||
                .label=${this.hass.localize("ui.common.menu")}
 | 
			
		||||
                .path=${mdiDotsVertical}
 | 
			
		||||
              ></ha-icon-button>
 | 
			
		||||
              <mwc-list-item>
 | 
			
		||||
                ${this.hass.localize(
 | 
			
		||||
                  "ui.panel.config.automation.editor.triggers.edit_id"
 | 
			
		||||
                )}
 | 
			
		||||
              </mwc-list-item>
 | 
			
		||||
              <mwc-list-item .disabled=${selected === -1}>
 | 
			
		||||
                ${yamlMode
 | 
			
		||||
                  ? this.hass.localize(
 | 
			
		||||
                      "ui.panel.config.automation.editor.edit_ui"
 | 
			
		||||
                    )
 | 
			
		||||
                  : this.hass.localize(
 | 
			
		||||
                      "ui.panel.config.automation.editor.edit_yaml"
 | 
			
		||||
                    )}
 | 
			
		||||
              </mwc-list-item>
 | 
			
		||||
              <mwc-list-item>
 | 
			
		||||
                ${this.hass.localize(
 | 
			
		||||
                  "ui.panel.config.automation.editor.actions.duplicate"
 | 
			
		||||
                )}
 | 
			
		||||
              </mwc-list-item>
 | 
			
		||||
              <mwc-list-item class="warning">
 | 
			
		||||
                ${this.hass.localize(
 | 
			
		||||
                  "ui.panel.config.automation.editor.actions.delete"
 | 
			
		||||
                )}
 | 
			
		||||
              </mwc-list-item>
 | 
			
		||||
            </ha-button-menu>
 | 
			
		||||
          </div>
 | 
			
		||||
      <ha-card outlined>
 | 
			
		||||
        ${this.trigger.enabled === false
 | 
			
		||||
          ? html`<div class="disabled-bar">
 | 
			
		||||
              ${this.hass.localize(
 | 
			
		||||
                "ui.panel.config.automation.editor.actions.disabled"
 | 
			
		||||
              )}
 | 
			
		||||
            </div>`
 | 
			
		||||
          : ""}
 | 
			
		||||
        <div class="card-menu">
 | 
			
		||||
          <ha-button-menu corner="BOTTOM_START" @action=${this._handleAction}>
 | 
			
		||||
            <ha-icon-button
 | 
			
		||||
              slot="trigger"
 | 
			
		||||
              .label=${this.hass.localize("ui.common.menu")}
 | 
			
		||||
              .path=${mdiDotsVertical}
 | 
			
		||||
            ></ha-icon-button>
 | 
			
		||||
            <mwc-list-item>
 | 
			
		||||
              ${this.hass.localize(
 | 
			
		||||
                "ui.panel.config.automation.editor.triggers.edit_id"
 | 
			
		||||
              )}
 | 
			
		||||
            </mwc-list-item>
 | 
			
		||||
            <mwc-list-item .disabled=${selected === -1}>
 | 
			
		||||
              ${yamlMode
 | 
			
		||||
                ? this.hass.localize(
 | 
			
		||||
                    "ui.panel.config.automation.editor.edit_ui"
 | 
			
		||||
                  )
 | 
			
		||||
                : this.hass.localize(
 | 
			
		||||
                    "ui.panel.config.automation.editor.edit_yaml"
 | 
			
		||||
                  )}
 | 
			
		||||
            </mwc-list-item>
 | 
			
		||||
            <mwc-list-item>
 | 
			
		||||
              ${this.hass.localize(
 | 
			
		||||
                "ui.panel.config.automation.editor.actions.duplicate"
 | 
			
		||||
              )}
 | 
			
		||||
            </mwc-list-item>
 | 
			
		||||
            <mwc-list-item>
 | 
			
		||||
              ${this.trigger.enabled === false
 | 
			
		||||
                ? this.hass.localize(
 | 
			
		||||
                    "ui.panel.config.automation.editor.actions.enable"
 | 
			
		||||
                  )
 | 
			
		||||
                : this.hass.localize(
 | 
			
		||||
                    "ui.panel.config.automation.editor.actions.disable"
 | 
			
		||||
                  )}
 | 
			
		||||
            </mwc-list-item>
 | 
			
		||||
            <mwc-list-item class="warning">
 | 
			
		||||
              ${this.hass.localize(
 | 
			
		||||
                "ui.panel.config.automation.editor.actions.delete"
 | 
			
		||||
              )}
 | 
			
		||||
            </mwc-list-item>
 | 
			
		||||
          </ha-button-menu>
 | 
			
		||||
        </div>
 | 
			
		||||
        <div
 | 
			
		||||
          class="card-content ${this.trigger.enabled === false
 | 
			
		||||
            ? "disabled"
 | 
			
		||||
            : ""}"
 | 
			
		||||
        >
 | 
			
		||||
          ${this._warnings
 | 
			
		||||
            ? html`<ha-alert
 | 
			
		||||
                alert-type="warning"
 | 
			
		||||
@@ -214,7 +236,6 @@ export default class HaAutomationTriggerRow extends LitElement {
 | 
			
		||||
                    `
 | 
			
		||||
                  )}
 | 
			
		||||
                </ha-select>
 | 
			
		||||
 | 
			
		||||
                ${showId
 | 
			
		||||
                  ? html`
 | 
			
		||||
                      <ha-textfield
 | 
			
		||||
@@ -250,7 +271,7 @@ export default class HaAutomationTriggerRow extends LitElement {
 | 
			
		||||
    `;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  protected override updated(changedProps: PropertyValues): void {
 | 
			
		||||
  protected override updated(changedProps: PropertyValues<this>): void {
 | 
			
		||||
    super.updated(changedProps);
 | 
			
		||||
    if (changedProps.has("trigger")) {
 | 
			
		||||
      this._subscribeTrigger();
 | 
			
		||||
@@ -347,6 +368,9 @@ export default class HaAutomationTriggerRow extends LitElement {
 | 
			
		||||
        fireEvent(this, "duplicate");
 | 
			
		||||
        break;
 | 
			
		||||
      case 3:
 | 
			
		||||
        this._onDisable();
 | 
			
		||||
        break;
 | 
			
		||||
      case 4:
 | 
			
		||||
        this._onDelete();
 | 
			
		||||
        break;
 | 
			
		||||
    }
 | 
			
		||||
@@ -365,6 +389,15 @@ export default class HaAutomationTriggerRow extends LitElement {
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private _onDisable() {
 | 
			
		||||
    const enabled = !(this.trigger.enabled ?? true);
 | 
			
		||||
    const value = { ...this.trigger, enabled };
 | 
			
		||||
    fireEvent(this, "value-changed", { value });
 | 
			
		||||
    if (this._yamlMode) {
 | 
			
		||||
      this._yamlEditor?.setValue(value);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private _typeChanged(ev: CustomEvent) {
 | 
			
		||||
    const type = (ev.target as HaSelect).value;
 | 
			
		||||
 | 
			
		||||
@@ -439,10 +472,27 @@ export default class HaAutomationTriggerRow extends LitElement {
 | 
			
		||||
    return [
 | 
			
		||||
      haStyle,
 | 
			
		||||
      css`
 | 
			
		||||
        .disabled {
 | 
			
		||||
          opacity: 0.5;
 | 
			
		||||
          pointer-events: none;
 | 
			
		||||
        }
 | 
			
		||||
        .card-content {
 | 
			
		||||
          padding-top: 16px;
 | 
			
		||||
          margin-top: 0;
 | 
			
		||||
        }
 | 
			
		||||
        .disabled-bar {
 | 
			
		||||
          background: var(--divider-color, #e0e0e0);
 | 
			
		||||
          text-align: center;
 | 
			
		||||
          border-top-right-radius: var(--ha-card-border-radius);
 | 
			
		||||
          border-top-left-radius: var(--ha-card-border-radius);
 | 
			
		||||
        }
 | 
			
		||||
        .card-menu {
 | 
			
		||||
          float: right;
 | 
			
		||||
          z-index: 3;
 | 
			
		||||
          margin: 4px;
 | 
			
		||||
          --mdc-theme-text-primary-on-background: var(--primary-text-color);
 | 
			
		||||
          display: flex;
 | 
			
		||||
          align-items: center;
 | 
			
		||||
        }
 | 
			
		||||
        :host-context([style*="direction: rtl;"]) .card-menu {
 | 
			
		||||
          float: left;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,4 @@
 | 
			
		||||
import deepClone from "deep-clone-simple";
 | 
			
		||||
import "@material/mwc-button";
 | 
			
		||||
import { css, CSSResultGroup, html, LitElement } from "lit";
 | 
			
		||||
import { customElement, property } from "lit/decorators";
 | 
			
		||||
@@ -27,7 +28,7 @@ export default class HaAutomationTrigger extends LitElement {
 | 
			
		||||
          ></ha-automation-trigger-row>
 | 
			
		||||
        `
 | 
			
		||||
      )}
 | 
			
		||||
      <ha-card>
 | 
			
		||||
      <ha-card outlined>
 | 
			
		||||
        <div class="card-actions add-card">
 | 
			
		||||
          <mwc-button @click=${this._addTrigger}>
 | 
			
		||||
            ${this.hass.localize(
 | 
			
		||||
@@ -67,7 +68,7 @@ export default class HaAutomationTrigger extends LitElement {
 | 
			
		||||
    ev.stopPropagation();
 | 
			
		||||
    const index = (ev.target as any).index;
 | 
			
		||||
    fireEvent(this, "value-changed", {
 | 
			
		||||
      value: this.triggers.concat(this.triggers[index]),
 | 
			
		||||
      value: this.triggers.concat(deepClone(this.triggers[index])),
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -80,6 +80,7 @@ class HaConfigBackup extends LitElement {
 | 
			
		||||
      actions: {
 | 
			
		||||
        title: "",
 | 
			
		||||
        width: "15%",
 | 
			
		||||
        type: "overflow-menu",
 | 
			
		||||
        template: (_: string, backup: BackupContent) =>
 | 
			
		||||
          html`<ha-icon-overflow-menu
 | 
			
		||||
            .hass=${this.hass}
 | 
			
		||||
@@ -126,17 +127,23 @@ class HaConfigBackup extends LitElement {
 | 
			
		||||
 | 
			
		||||
    return html`
 | 
			
		||||
      <hass-tabs-subpage-data-table
 | 
			
		||||
        .tabs=${[
 | 
			
		||||
          {
 | 
			
		||||
            translationKey: "ui.panel.config.backup.caption",
 | 
			
		||||
            path: `/config/backup`,
 | 
			
		||||
          },
 | 
			
		||||
        ]}
 | 
			
		||||
        .hass=${this.hass}
 | 
			
		||||
        .narrow=${this.narrow}
 | 
			
		||||
        back-path="/config/system"
 | 
			
		||||
        .route=${this.route}
 | 
			
		||||
        .columns=${this._columns(this.narrow, this.hass.language)}
 | 
			
		||||
        .data=${this._getItems(this._backupData.backups)}
 | 
			
		||||
        .noDataText=${this.hass.localize("ui.panel.config.backup.no_bakcups")}
 | 
			
		||||
        .noDataText=${this.hass.localize("ui.panel.config.backup.no_backups")}
 | 
			
		||||
        .searchLabel=${this.hass.localize(
 | 
			
		||||
          "ui.panel.config.backup.picker.search"
 | 
			
		||||
        )}
 | 
			
		||||
      >
 | 
			
		||||
        <span slot="header"
 | 
			
		||||
          >${this.hass.localize("ui.panel.config.backup.caption")}</span
 | 
			
		||||
        >
 | 
			
		||||
        <ha-fab
 | 
			
		||||
          slot="fab"
 | 
			
		||||
          ?disabled=${this._backupData.backing_up}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,26 +1,28 @@
 | 
			
		||||
import "@material/mwc-button";
 | 
			
		||||
import "@material/mwc-list/mwc-list-item";
 | 
			
		||||
import type { ActionDetail } from "@material/mwc-list";
 | 
			
		||||
import "@polymer/paper-item/paper-item-body";
 | 
			
		||||
import "@material/mwc-list/mwc-list-item";
 | 
			
		||||
import { mdiDotsVertical } from "@mdi/js";
 | 
			
		||||
import { LitElement, css, html, PropertyValues } from "lit";
 | 
			
		||||
import "@polymer/paper-item/paper-item-body";
 | 
			
		||||
import { css, html, LitElement, PropertyValues } from "lit";
 | 
			
		||||
import { customElement, property, state } from "lit/decorators";
 | 
			
		||||
import { formatDateTime } from "../../../../common/datetime/format_date_time";
 | 
			
		||||
import { fireEvent } from "../../../../common/dom/fire_event";
 | 
			
		||||
import { computeRTLDirection } from "../../../../common/util/compute_rtl";
 | 
			
		||||
import { debounce } from "../../../../common/util/debounce";
 | 
			
		||||
import "../../../../components/buttons/ha-call-api-button";
 | 
			
		||||
import "../../../../components/ha-card";
 | 
			
		||||
import "../../../../components/ha-alert";
 | 
			
		||||
import "../../../../components/ha-button-menu";
 | 
			
		||||
import "../../../../components/ha-card";
 | 
			
		||||
import "../../../../components/ha-icon-button";
 | 
			
		||||
import { debounce } from "../../../../common/util/debounce";
 | 
			
		||||
import {
 | 
			
		||||
  cloudLogout,
 | 
			
		||||
  CloudStatusLoggedIn,
 | 
			
		||||
  fetchCloudSubscriptionInfo,
 | 
			
		||||
  SubscriptionInfo,
 | 
			
		||||
} from "../../../../data/cloud";
 | 
			
		||||
import { showConfirmationDialog } from "../../../../dialogs/generic/show-dialog-box";
 | 
			
		||||
import "../../../../layouts/hass-subpage";
 | 
			
		||||
import { SubscribeMixin } from "../../../../mixins/subscribe-mixin";
 | 
			
		||||
import { HomeAssistant } from "../../../../types";
 | 
			
		||||
import "../../ha-config-section";
 | 
			
		||||
import "./cloud-alexa-pref";
 | 
			
		||||
@@ -28,8 +30,6 @@ import "./cloud-google-pref";
 | 
			
		||||
import "./cloud-remote-pref";
 | 
			
		||||
import "./cloud-tts-pref";
 | 
			
		||||
import "./cloud-webhooks";
 | 
			
		||||
import { SubscribeMixin } from "../../../../mixins/subscribe-mixin";
 | 
			
		||||
import { showConfirmationDialog } from "../../../../dialogs/generic/show-dialog-box";
 | 
			
		||||
 | 
			
		||||
@customElement("cloud-account")
 | 
			
		||||
export class CloudAccount extends SubscribeMixin(LitElement) {
 | 
			
		||||
@@ -81,6 +81,7 @@ export class CloudAccount extends SubscribeMixin(LitElement) {
 | 
			
		||||
            </div>
 | 
			
		||||
 | 
			
		||||
            <ha-card
 | 
			
		||||
              outlined
 | 
			
		||||
              .header=${this.hass.localize(
 | 
			
		||||
                "ui.panel.config.cloud.account.nabu_casa_account"
 | 
			
		||||
              )}
 | 
			
		||||
@@ -210,6 +211,7 @@ export class CloudAccount extends SubscribeMixin(LitElement) {
 | 
			
		||||
 | 
			
		||||
            <cloud-webhooks
 | 
			
		||||
              .hass=${this.hass}
 | 
			
		||||
              .narrow=${this.narrow}
 | 
			
		||||
              .cloudStatus=${this.cloudStatus}
 | 
			
		||||
              dir=${this._rtlDirection}
 | 
			
		||||
            ></cloud-webhooks>
 | 
			
		||||
 
 | 
			
		||||
@@ -26,6 +26,7 @@ export class CloudAlexaPref extends LitElement {
 | 
			
		||||
 | 
			
		||||
    return html`
 | 
			
		||||
      <ha-card
 | 
			
		||||
        outlined
 | 
			
		||||
        header=${this.hass!.localize(
 | 
			
		||||
          "ui.panel.config.cloud.account.alexa.title"
 | 
			
		||||
        )}
 | 
			
		||||
 
 | 
			
		||||
@@ -31,6 +31,7 @@ export class CloudGooglePref extends LitElement {
 | 
			
		||||
 | 
			
		||||
    return html`
 | 
			
		||||
      <ha-card
 | 
			
		||||
        outlined
 | 
			
		||||
        header=${this.hass.localize(
 | 
			
		||||
          "ui.panel.config.cloud.account.google.title"
 | 
			
		||||
        )}
 | 
			
		||||
 
 | 
			
		||||
@@ -34,6 +34,7 @@ export class CloudRemotePref extends LitElement {
 | 
			
		||||
    if (!remote_certificate) {
 | 
			
		||||
      return html`
 | 
			
		||||
        <ha-card
 | 
			
		||||
          outlined
 | 
			
		||||
          header=${this.hass.localize(
 | 
			
		||||
            "ui.panel.config.cloud.account.remote.title"
 | 
			
		||||
          )}
 | 
			
		||||
@@ -49,6 +50,7 @@ export class CloudRemotePref extends LitElement {
 | 
			
		||||
 | 
			
		||||
    return html`
 | 
			
		||||
      <ha-card
 | 
			
		||||
        outlined
 | 
			
		||||
        header=${this.hass.localize(
 | 
			
		||||
          "ui.panel.config.cloud.account.remote.title"
 | 
			
		||||
        )}
 | 
			
		||||
 
 | 
			
		||||
@@ -44,6 +44,7 @@ export class CloudTTSPref extends LitElement {
 | 
			
		||||
 | 
			
		||||
    return html`
 | 
			
		||||
      <ha-card
 | 
			
		||||
        outlined
 | 
			
		||||
        header=${this.hass.localize("ui.panel.config.cloud.account.tts.title")}
 | 
			
		||||
      >
 | 
			
		||||
        <div class="card-content">
 | 
			
		||||
 
 | 
			
		||||
@@ -40,6 +40,7 @@ export class CloudWebhooks extends LitElement {
 | 
			
		||||
  protected render() {
 | 
			
		||||
    return html`
 | 
			
		||||
      <ha-card
 | 
			
		||||
        outlined
 | 
			
		||||
        header=${this.hass!.localize(
 | 
			
		||||
          "ui.panel.config.cloud.account.webhooks.title"
 | 
			
		||||
        )}
 | 
			
		||||
 
 | 
			
		||||
@@ -153,7 +153,7 @@ class CloudAlexa extends SubscribeMixin(LitElement) {
 | 
			
		||||
      ></ha-icon-button>`;
 | 
			
		||||
 | 
			
		||||
      target.push(html`
 | 
			
		||||
        <ha-card>
 | 
			
		||||
        <ha-card outlined>
 | 
			
		||||
          <div class="card-content">
 | 
			
		||||
            <div class="top-line">
 | 
			
		||||
              <state-info
 | 
			
		||||
 
 | 
			
		||||
@@ -36,6 +36,7 @@ export class CloudForgotPassword extends LitElement {
 | 
			
		||||
      >
 | 
			
		||||
        <div class="content">
 | 
			
		||||
          <ha-card
 | 
			
		||||
            outlined
 | 
			
		||||
            .header=${this.hass.localize(
 | 
			
		||||
              "ui.panel.config.cloud.forgot_password.subtitle"
 | 
			
		||||
            )}
 | 
			
		||||
 
 | 
			
		||||
@@ -159,7 +159,7 @@ class CloudGoogleAssistant extends SubscribeMixin(LitElement) {
 | 
			
		||||
      ></ha-icon-button>`;
 | 
			
		||||
 | 
			
		||||
      target.push(html`
 | 
			
		||||
        <ha-card>
 | 
			
		||||
        <ha-card outlined>
 | 
			
		||||
          <div class="card-content">
 | 
			
		||||
            <div class="top-line">
 | 
			
		||||
              <state-info
 | 
			
		||||
 
 | 
			
		||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user