Compare commits

..

1 Commits

Author SHA1 Message Date
Zack
191f81d9fe Add Redirect for Server Controls 2022-04-27 16:54:17 -05:00
55 changed files with 627 additions and 1466 deletions

View File

@@ -62,45 +62,6 @@ 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")

View File

@@ -20,10 +20,6 @@ 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] },
@@ -32,15 +28,11 @@ 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")
@@ -94,6 +86,6 @@ class DemoHaAutomationEditorAction extends LitElement {
declare global {
interface HTMLElementTagNameMap {
"demo-automation-editor-action": DemoHaAutomationEditorAction;
"demo-ha-automation-editor-action": DemoHaAutomationEditorAction;
}
}

View File

@@ -17,9 +17,7 @@ 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";
@@ -168,42 +166,6 @@ 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(

View File

@@ -74,11 +74,7 @@ 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;
}
document.body.addEventListener("keydown", (ev) => {
// @ts-ignore
fireEvent(mainWindow, "hass-quick-bar-trigger", ev, {
bubbles: false,

View File

@@ -42,9 +42,6 @@ export const REDIRECTS: Redirects = {
params: {
addon: "string",
},
optional_params: {
repository_url: "url",
},
},
supervisor_ingress: {
redirect: "/hassio/ingress",
@@ -127,14 +124,6 @@ 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)}`;
}

View File

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

View File

@@ -5,7 +5,6 @@ import { fireEvent } from "../../common/dom/fire_event";
import {
DeviceAutomation,
deviceAutomationsEqual,
sortDeviceAutomations,
} from "../../data/device_automation";
import { HomeAssistant } from "../../types";
import "../ha-select";
@@ -128,9 +127,7 @@ export abstract class HaDeviceAutomationPicker<
private async _updateDeviceInfo() {
this._automations = this.deviceId
? (await this._fetchDeviceAutomations(this.hass, this.deviceId)).sort(
sortDeviceAutomations
)
? await this._fetchDeviceAutomations(this.hass, this.deviceId)
: // No device, clear the list of automations
[];
@@ -164,9 +161,8 @@ export abstract class HaDeviceAutomationPicker<
if (this.value && deviceAutomationsEqual(automation, this.value)) {
return;
}
const value = { ...automation };
delete value.metadata;
fireEvent(this, "value-changed", { value });
fireEvent(this, "change");
fireEvent(this, "value-changed", { value: automation });
}
static get styles(): CSSResultGroup {

View File

@@ -12,8 +12,6 @@ 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() {
@@ -22,12 +20,7 @@ export class HaClickableListItem extends ListItemBase {
return html`${this.disableHref
? html`<a aria-role="option">${r}</a>`
: html`<a
aria-role="option"
target=${this.openNewTab ? "_blank" : ""}
href=${href}
>${r}</a
>`}`;
: html`<a aria-role="option" href=${href}>${r}</a>`}`;
}
firstUpdated() {
@@ -62,7 +55,6 @@ 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;
}
`,
];

View File

@@ -132,11 +132,6 @@ 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;
}
`;
}
}

View File

@@ -59,6 +59,13 @@ class HaNavigationList extends LitElement {
:host {
--mdc-list-vertical-padding: 0;
}
a {
text-decoration: none;
color: var(--primary-text-color);
position: relative;
display: block;
outline: 0;
}
ha-svg-icon,
ha-icon-next {
color: var(--secondary-text-color);

View File

@@ -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}

View File

@@ -302,10 +302,6 @@ class DialogMediaManage extends LitElement {
--mdc-theme-primary: var(--mdc-theme-on-primary);
}
mwc-list {
direction: ltr;
}
.danger {
--mdc-theme-primary: var(--error-color);
}
@@ -314,11 +310,6 @@ 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;

View File

@@ -152,7 +152,6 @@ 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) {

View File

@@ -59,11 +59,6 @@ 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;
}
`;
}

View File

@@ -119,11 +119,6 @@ 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;
}
`;
}

View File

@@ -1,11 +1,7 @@
import {
mdiAbTesting,
mdiAlertOctagon,
mdiArrowDecision,
mdiArrowUp,
mdiAsterisk,
mdiCallMissed,
mdiCallReceived,
mdiCallSplit,
mdiCheckboxBlankOutline,
mdiCheckboxMarkedOutline,
@@ -13,12 +9,10 @@ import {
mdiChevronRight,
mdiChevronUp,
mdiClose,
mdiCloseOctagon,
mdiCodeBrackets,
mdiDevices,
mdiExclamation,
mdiRefresh,
mdiShuffleDisabled,
mdiTimerOutline,
mdiTrafficLight,
} from "@mdi/js";
@@ -33,9 +27,6 @@ import {
DelayAction,
DeviceAction,
EventAction,
IfAction,
ManualScriptConfig,
ParallelAction,
RepeatAction,
SceneAction,
ServiceAction,
@@ -45,8 +36,6 @@ import {
import {
ChooseActionTraceStep,
ConditionTraceStep,
IfActionTraceStep,
StopActionTraceStep,
TraceExtended,
} from "../../data/trace";
import "../ha-icon-button";
@@ -112,9 +101,6 @@ 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,
@@ -124,9 +110,6 @@ 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,
};
@@ -163,7 +146,7 @@ export class HatScriptGraph extends LitElement {
>
<hat-graph-node
.graphStart=${graphStart}
.iconPath=${mdiArrowDecision}
.iconPath=${mdiCallSplit}
?track=${trace !== undefined}
?active=${this.selected === path}
slot="head"
@@ -213,64 +196,6 @@ export class HatScriptGraph extends LitElement {
`;
}
private render_if_node(config: IfAction, path: string, graphStart = 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}
>
<hat-graph-node
.graphStart=${graphStart}
.iconPath=${mdiCallSplit}
?track=${trace !== undefined}
?active=${this.selected === path}
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}
nofocus
></hat-graph-node
>${ensureArray(config.else).map((action, j) =>
this.render_action_node(action, `${path}/else/${j}`)
)}
</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}
nofocus
></hat-graph-node>
${ensureArray(config.then).map((action, j) =>
this.render_action_node(action, `${path}/then/${j}`)
)}
</div>
</hat-graph-branch>
`;
}
private render_condition_node(
node: Condition,
path: string,
@@ -467,62 +392,6 @@ export class HatScriptGraph extends LitElement {
`;
}
private render_parallel_node(
node: ParallelAction,
path: string,
graphStart = 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}
>
<hat-graph-node
.graphStart=${graphStart}
.iconPath=${mdiShuffleDisabled}
?track=${path in this.trace.trace}
?active=${this.selected === path}
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}`
)
)}
</div>`
: this.render_action_node(
action,
`${path}/parallel/${i}/sequence/0`
)
)}
</hat-graph-branch>
`;
}
private render_stop_node(node: Action, path: string, graphStart = 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}
></hat-graph-node>
`;
}
private render_other_node(node: Action, path: string, graphStart = false) {
return html`
<hat-graph-node

View File

@@ -25,17 +25,12 @@ 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";
@@ -110,7 +105,7 @@ class LogbookRenderer {
}
get hasNext() {
return this.curIndex < this.logbookEntries.length;
return this.curIndex !== this.logbookEntries.length;
}
maybeRenderItem() {
@@ -206,7 +201,7 @@ class ActionRenderer {
}
get hasNext() {
return this.curIndex < this.keys.length;
return this.curIndex !== this.keys.length;
}
renderItem() {
@@ -219,31 +214,15 @@ class ActionRenderer {
private _renderItem(
index: number,
actionType?: ReturnType<typeof getActionType>,
renderAllIterations?: boolean
actionType?: ReturnType<typeof getActionType>
): number {
const value = this._getItem(index);
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);
if (isTriggerPath(value[0].path)) {
return this._handleTrigger(index, value[0] as TriggerTraceStep);
}
const timestamp = new Date(value.timestamp);
const timestamp = new Date(value[0].timestamp);
// Render all logbook items that are in front of this item.
while (
@@ -256,7 +235,7 @@ class ActionRenderer {
this.logbookRenderer.flush();
this.timeTracker.maybeRenderTime(timestamp);
const path = value.path;
const path = value[0].path;
let data;
try {
data = getDataFromPath(this.trace.config, path);
@@ -284,18 +263,6 @@ class ActionRenderer {
return this._handleChoose(index);
}
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));
let i = index + 1;
@@ -407,109 +374,6 @@ 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 name = repeatConfig.alias || describeAction(this.hass, repeatConfig);
this._renderEntry(repeatPath, name);
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 name = ifConfig.alias || "If";
if (ifTrace.result) {
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}`);
} else {
this._renderEntry(ifPath, `${name}: No action taken`);
}
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 name = parallelConfig.alias || "Execute in parallel";
this._renderEntry(parallelPath, name);
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,

View File

@@ -65,7 +65,6 @@ export interface BaseTrigger {
platform: string;
id?: string;
variables?: Record<string, unknown>;
enabled?: boolean;
}
export interface StateTrigger extends BaseTrigger {
@@ -179,7 +178,6 @@ export type Trigger =
interface BaseCondition {
condition: string;
alias?: string;
enabled?: boolean;
}
export interface LogicalCondition extends BaseCondition {
@@ -237,10 +235,6 @@ export interface TriggerCondition extends BaseCondition {
type ShorthandBaseCondition = Omit<BaseCondition, "condition">;
export interface ShorthandAndConditionList extends ShorthandBaseCondition {
condition: Condition[];
}
export interface ShorthandAndCondition extends ShorthandBaseCondition {
and: Condition[];
}
@@ -266,33 +260,10 @@ export type Condition =
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

View File

@@ -11,8 +11,6 @@ export interface DeviceAutomation {
type?: string;
subtype?: string;
event?: string;
enabled?: boolean;
metadata?: { secondary: boolean };
}
export interface DeviceAction extends DeviceAutomation {
@@ -181,16 +179,3 @@ 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;
};

View File

@@ -1,22 +0,0 @@
// 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",
};

View File

@@ -1,7 +1,7 @@
import { atLeastVersion } from "../../common/config/version";
import { HomeAssistant, PanelInfo } from "../../types";
import { SupervisorArch } from "../supervisor/supervisor";
import { HassioAddonInfo } from "./addon";
import { HassioAddonInfo, HassioAddonRepository } from "./addon";
import { hassioApiResultExtractor, HassioResponse } from "./common";
export type HassioHomeAssistantInfo = {
@@ -23,7 +23,7 @@ export type HassioHomeAssistantInfo = {
export type HassioSupervisorInfo = {
addons: HassioAddonInfo[];
addons_repositories: string[];
addons_repositories: HassioAddonRepository[];
arch: SupervisorArch;
channel: string;
debug: boolean;

View File

@@ -13,18 +13,11 @@ 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,
ShorthandAndCondition,
ShorthandNotCondition,
ShorthandOrCondition,
Trigger,
} from "./automation";
import { Condition, Trigger } from "./automation";
import { BlueprintInput } from "./blueprint";
export const MODES = ["single", "restart", "queued", "parallel"] as const;
@@ -32,7 +25,6 @@ export const MODES_MAX = ["queued", "parallel"];
export const baseActionStruct = object({
alias: optional(string()),
enabled: optional(boolean()),
});
const targetStruct = object({
@@ -96,18 +88,15 @@ export interface BlueprintScriptConfig extends ManualScriptConfig {
use_blueprint: { path: string; input?: BlueprintInput };
}
interface BaseAction {
export interface EventAction {
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 extends BaseAction {
export interface ServiceAction {
alias?: string;
service?: string;
service_template?: string;
entity_id?: string;
@@ -115,48 +104,55 @@ export interface ServiceAction extends BaseAction {
data?: Record<string, unknown>;
}
export interface DeviceAction extends BaseAction {
export interface DeviceAction {
alias?: string;
type: string;
device_id: string;
domain: string;
entity_id: string;
}
export interface DelayActionParts extends BaseAction {
export interface DelayActionParts {
milliseconds?: number;
seconds?: number;
minutes?: number;
hours?: number;
days?: number;
}
export interface DelayAction extends BaseAction {
export interface DelayAction {
alias?: string;
delay: number | Partial<DelayActionParts> | string;
}
export interface ServiceSceneAction extends BaseAction {
export interface ServiceSceneAction {
alias?: string;
service: "scene.turn_on";
target?: { entity_id?: string };
entity_id?: string;
metadata: Record<string, unknown>;
}
export interface LegacySceneAction extends BaseAction {
export interface LegacySceneAction {
alias?: string;
scene: string;
}
export type SceneAction = ServiceSceneAction | LegacySceneAction;
export interface WaitAction extends BaseAction {
export interface WaitAction {
alias?: string;
wait_template: string;
timeout?: number;
continue_on_timeout?: boolean;
}
export interface WaitForTriggerAction extends BaseAction {
export interface WaitForTriggerAction {
alias?: string;
wait_for_trigger: Trigger | Trigger[];
timeout?: number;
continue_on_timeout?: boolean;
}
export interface PlayMediaAction extends BaseAction {
export interface PlayMediaAction {
alias?: string;
service: "media_player.play_media";
target?: { entity_id?: string };
entity_id?: string;
@@ -164,11 +160,13 @@ export interface PlayMediaAction extends BaseAction {
metadata: Record<string, unknown>;
}
export interface RepeatAction extends BaseAction {
repeat: CountRepeat | WhileRepeat | UntilRepeat | ForEachRepeat;
export interface RepeatAction {
alias?: string;
repeat: CountRepeat | WhileRepeat | UntilRepeat;
}
interface BaseRepeat extends BaseAction {
interface BaseRepeat {
alias?: string;
sequence: Action | Action[];
}
@@ -184,40 +182,38 @@ export interface UntilRepeat extends BaseRepeat {
until: Condition[];
}
export interface ForEachRepeat extends BaseRepeat {
for_each: string | any[];
}
export interface ChooseActionChoice extends BaseAction {
export interface ChooseActionChoice {
alias?: string;
conditions: string | Condition[];
sequence: Action | Action[];
}
export interface ChooseAction extends BaseAction {
export interface ChooseAction {
alias?: string;
choose: ChooseActionChoice | ChooseActionChoice[] | null;
default?: Action | Action[];
}
export interface IfAction extends BaseAction {
export interface IfAction {
alias?: string;
if: string | Condition[];
then: Action | Action[];
else?: Action | Action[];
}
export interface VariablesAction extends BaseAction {
export interface VariablesAction {
alias?: string;
variables: Record<string, unknown>;
}
export interface StopAction extends BaseAction {
export interface StopAction {
alias?: string;
stop: string;
error?: boolean;
}
export interface ParallelAction extends BaseAction {
parallel: ManualScriptConfig | Action | (ManualScriptConfig | Action)[];
}
interface UnknownAction extends BaseAction {
interface UnknownAction {
alias?: string;
[key: string]: unknown;
}
@@ -226,9 +222,6 @@ export type Action =
| DeviceAction
| ServiceAction
| Condition
| ShorthandAndCondition
| ShorthandOrCondition
| ShorthandNotCondition
| DelayAction
| SceneAction
| WaitAction
@@ -239,7 +232,6 @@ export type Action =
| VariablesAction
| PlayMediaAction
| StopAction
| ParallelAction
| UnknownAction;
export interface ActionTypes {
@@ -257,7 +249,6 @@ export interface ActionTypes {
service: ServiceAction;
play_media: PlayMediaAction;
stop: StopAction;
parallel: ParallelAction;
unknown: UnknownAction;
}
@@ -307,7 +298,7 @@ export const getActionType = (action: Action): ActionType => {
if ("wait_template" in action) {
return "wait_template";
}
if (["condition", "and", "or", "not"].some((key) => key in action)) {
if ("condition" in action) {
return "check_condition";
}
if ("event" in action) {
@@ -337,9 +328,6 @@ 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)) {

View File

@@ -8,17 +8,12 @@ import { describeCondition, describeTrigger } from "./automation_i18n";
import {
ActionType,
ActionTypes,
ChooseAction,
DelayAction,
DeviceAction,
EventAction,
getActionType,
IfAction,
ParallelAction,
PlayMediaAction,
RepeatAction,
SceneAction,
StopAction,
VariablesAction,
WaitForTriggerAction,
} from "./script";
@@ -166,81 +161,6 @@ 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];
@@ -249,12 +169,5 @@ 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;
};

View File

@@ -44,14 +44,6 @@ 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 };
}
@@ -185,11 +177,7 @@ export const getDataFromPath = (
const asNumber = Number(raw);
if (isNaN(asNumber)) {
const tempResult = result[raw];
if (!tempResult && raw === "sequence") {
continue;
}
result = tempResult;
result = result[raw];
continue;
}

View File

@@ -312,7 +312,6 @@ 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"

View File

@@ -15,11 +15,13 @@ 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(`component.${this.domain}.title`)}</h2>
<h2>
${this.hass.localize(
"ui.panel.config.integrations.config_flow.aborted"
)}
</h2>
<div class="content">
${this.flowConfig.renderAbortDescription(this.hass, this.step)}
</div>

View File

@@ -11,7 +11,14 @@ import listPlugin from "@fullcalendar/list";
// @ts-ignore
import listStyle from "@fullcalendar/list/main.css";
import "@material/mwc-button";
import { mdiViewAgenda, mdiViewDay, mdiViewModule, mdiViewWeek } from "@mdi/js";
import {
mdiChevronLeft,
mdiChevronRight,
mdiViewAgenda,
mdiViewDay,
mdiViewModule,
mdiViewWeek,
} from "@mdi/js";
import {
css,
CSSResultGroup,
@@ -26,6 +33,7 @@ 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";
@@ -144,18 +152,20 @@ export class HAFullCalendar extends LitElement {
<div class="controls">
<h1>${this.calendar.view.title}</h1>
<div>
<ha-icon-button-prev
<ha-icon-button
.label=${this.hass.localize("ui.common.previous")}
.path=${mdiChevronLeft}
class="prev"
@click=${this._handlePrev}
>
</ha-icon-button-prev>
<ha-icon-button-next
</ha-icon-button>
<ha-icon-button
.label=${this.hass.localize("ui.common.next")}
.path=${mdiChevronRight}
class="next"
@click=${this._handleNext}
>
</ha-icon-button-next>
</ha-icon-button>
</div>
</div>
<div class="controls">

View File

@@ -33,7 +33,6 @@ 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";
@@ -55,7 +54,6 @@ const OPTIONS = [
"if",
"device_id",
"stop",
"parallel",
];
const getType = (action: Action | undefined) => {
@@ -65,9 +63,6 @@ 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);
};
@@ -165,82 +160,62 @@ export default class HaAutomationActionRow extends LitElement {
return html`
<ha-card>
${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"
: ""}"
>
<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>
${this._warnings
? html`<ha-alert
alert-type="warning"
@@ -339,23 +314,11 @@ 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,
@@ -445,27 +408,11 @@ 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 {
float: right;
position: absolute;
right: 16px;
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;

View File

@@ -1,56 +0,0 @@
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;
}
}

View File

@@ -33,7 +33,7 @@ export class HaWaitAction extends LitElement implements ActionElement {
@property({ attribute: false }) public action!: WaitAction;
public static get defaultConfig() {
return { wait_template: "", continue_on_timeout: true };
return { wait_template: "" };
}
protected render() {

View File

@@ -10,7 +10,6 @@ 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";
@@ -43,14 +42,10 @@ const OPTIONS = [
export default class HaAutomationConditionEditor extends LitElement {
@property({ attribute: false }) public hass!: HomeAssistant;
@property() condition!: Condition;
@property() public condition!: Condition;
@property() public yamlMode = false;
private _processedCondition = memoizeOne((condition) =>
expandConditionWithShorthand(condition)
);
private _processedTypes = memoizeOne(
(localize: LocalizeFunc): [string, string][] =>
OPTIONS.map(
@@ -65,8 +60,7 @@ export default class HaAutomationConditionEditor extends LitElement {
);
protected render() {
const condition = this._processedCondition(this.condition);
const selected = OPTIONS.indexOf(condition.condition);
const selected = OPTIONS.indexOf(this.condition.condition);
const yamlMode = this.yamlMode || selected === -1;
return html`
${yamlMode
@@ -76,7 +70,7 @@ export default class HaAutomationConditionEditor extends LitElement {
${this.hass.localize(
"ui.panel.config.automation.editor.conditions.unsupported_condition",
"condition",
condition.condition
this.condition.condition
)}
`
: ""}
@@ -96,7 +90,7 @@ export default class HaAutomationConditionEditor extends LitElement {
.label=${this.hass.localize(
"ui.panel.config.automation.editor.conditions.type_select"
)}
.value=${condition.condition}
.value=${this.condition.condition}
naturalMenuWidth
@selected=${this._typeChanged}
>
@@ -109,8 +103,8 @@ export default class HaAutomationConditionEditor extends LitElement {
<div>
${dynamicElement(
`ha-automation-condition-${condition.condition}`,
{ hass: this.hass, condition: condition }
`ha-automation-condition-${this.condition.condition}`,
{ hass: this.hass, condition: this.condition }
)}
</div>
`}
@@ -130,7 +124,7 @@ export default class HaAutomationConditionEditor extends LitElement {
defaultConfig: Omit<Condition, "condition">;
};
if (type !== this._processedCondition(this.condition).condition) {
if (type !== this.condition.condition) {
fireEvent(this, "value-changed", {
value: {
condition: type,

View File

@@ -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, query, state } from "lit/decorators";
import { customElement, property, state } from "lit/decorators";
import { fireEvent } from "../../../../common/dom/fire_event";
import { handleStructError } from "../../../../common/structs/handle-errors";
import "../../../../components/ha-button-menu";
@@ -19,7 +19,6 @@ 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;
@@ -60,69 +59,47 @@ 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>
${this.condition.enabled === false
? html`<div class="disabled-bar">
<div class="card-content">
<div class="card-menu">
<ha-progress-button @click=${this._testCondition}>
${this.hass.localize(
"ui.panel.config.automation.editor.actions.disabled"
"ui.panel.config.automation.editor.conditions.test"
)}
</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"
: ""}"
>
</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>
${this._warnings
? html`<ha-alert
alert-type="warning"
@@ -176,23 +153,11 @@ 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(
@@ -273,24 +238,9 @@ 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;

View File

@@ -1,9 +1,8 @@
import { object, optional, number, string, boolean } from "superstruct";
import { object, optional, number, string } from "superstruct";
export const baseTriggerStruct = object({
platform: string(),
id: optional(string()),
enabled: optional(boolean()),
});
export const forDictStruct = object({

View File

@@ -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, query, state } from "lit/decorators";
import { customElement, property, 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 { HaYamlEditor } from "../../../../components/ha-yaml-editor";
import "../../../../components/ha-yaml-editor";
import "../../../../components/ha-select";
import type { HaSelect } from "../../../../components/ha-select";
import "../../../../components/ha-textfield";
@@ -104,8 +104,6 @@ export default class HaAutomationTriggerRow extends LitElement {
@state() private _triggerColor = false;
@query("ha-yaml-editor") private _yamlEditor?: HaYamlEditor;
private _triggerUnsub?: Promise<UnsubscribeFunc>;
private _processedTypes = memoizeOne(
@@ -128,60 +126,40 @@ export default class HaAutomationTriggerRow extends LitElement {
return html`
<ha-card>
${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"
: ""}"
>
<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>
${this._warnings
? html`<ha-alert
alert-type="warning"
@@ -236,6 +214,7 @@ export default class HaAutomationTriggerRow extends LitElement {
`
)}
</ha-select>
${showId
? html`
<ha-textfield
@@ -271,7 +250,7 @@ export default class HaAutomationTriggerRow extends LitElement {
`;
}
protected override updated(changedProps: PropertyValues<this>): void {
protected override updated(changedProps: PropertyValues): void {
super.updated(changedProps);
if (changedProps.has("trigger")) {
this._subscribeTrigger();
@@ -368,9 +347,6 @@ export default class HaAutomationTriggerRow extends LitElement {
fireEvent(this, "duplicate");
break;
case 3:
this._onDisable();
break;
case 4:
this._onDelete();
break;
}
@@ -389,15 +365,6 @@ 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;
@@ -472,27 +439,10 @@ 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;

View File

@@ -110,9 +110,7 @@ class ConfigAnalytics extends LitElement {
ha-settings-row {
padding: 0;
}
p {
margin-top: 0;
}
.card-actions {
display: flex;
flex-direction: row-reverse;

View File

@@ -187,7 +187,6 @@ class HaConfigSectionGeneral extends LitElement {
href="https://en.wikipedia.org/wiki/ISO_4217#Active_codes"
target="_blank"
rel="noopener noreferrer"
class="find-value"
>${this.hass.localize(
"ui.panel.config.core.section.core.core_config.find_currency_value"
)}</a
@@ -346,10 +345,6 @@ class HaConfigSectionGeneral extends LitElement {
ha-select {
display: block;
}
a.find-value {
margin-top: 8px;
display: inline-block;
}
ha-locations-editor {
display: block;
height: 400px;

View File

@@ -1,13 +1,12 @@
import { ActionDetail } from "@material/mwc-list";
import { mdiDotsVertical } from "@mdi/js";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { customElement, property } from "lit/decorators";
import { canShowPage } from "../../../common/config/can_show_page";
import "../../../components/ha-card";
import "../../../components/ha-navigation-list";
import { CloudStatus } from "../../../data/cloud";
import {
showAlertDialog,
showConfirmationDialog,
} from "../../../dialogs/generic/show-dialog-box";
import { showConfirmationDialog } from "../../../dialogs/generic/show-dialog-box";
import "../../../layouts/hass-subpage";
import { haStyle } from "../../../resources/styles";
import type { HomeAssistant } from "../../../types";
@@ -42,13 +41,22 @@ class HaConfigSystemNavigation extends LitElement {
back-path="/config"
.header=${this.hass.localize("ui.panel.config.dashboard.system.main")}
>
<mwc-button
<ha-button-menu
corner="BOTTOM_START"
@action=${this._handleAction}
slot="toolbar-icon"
.label=${this.hass.localize(
"ui.panel.config.system_dashboard.restart_homeassistant_short"
)}
@click=${this._restart}
></mwc-button>
>
<ha-icon-button
slot="trigger"
.label=${this.hass.localize("ui.common.overflow_menu")}
.path=${mdiDotsVertical}
></ha-icon-button>
<mwc-list-item>
${this.hass.localize(
"ui.panel.config.system_dashboard.restart_homeassistant"
)}
</mwc-list-item>
</ha-button-menu>
<ha-config-section
.narrow=${this.narrow}
.isWide=${this.isWide}
@@ -61,34 +69,24 @@ class HaConfigSystemNavigation extends LitElement {
.pages=${pages}
></ha-navigation-list>
</ha-card>
<div class="yaml-config">Looking for YAML Configuration? It has moved to <a href="/developer-tools/yaml">Developer Tools</a></a></div>
</ha-config-section>
</hass-subpage>
`;
}
private _restart() {
showConfirmationDialog(this, {
title: this.hass.localize(
"ui.panel.config.system_dashboard.confirm_restart_title"
),
text: this.hass.localize(
"ui.panel.config.system_dashboard.confirm_restart_text"
),
confirmText: this.hass.localize(
"ui.panel.config.system_dashboard.restart_homeassistant_short"
),
confirm: () => {
this.hass.callService("homeassistant", "restart").catch((reason) => {
showAlertDialog(this, {
title: this.hass.localize(
"ui.panel.config.system_dashboard.restart_error"
),
text: reason.message,
});
private _handleAction(ev: CustomEvent<ActionDetail>) {
switch (ev.detail.index) {
case 0:
showConfirmationDialog(this, {
text: this.hass.localize(
"ui.panel.config.system_dashboard.confirm_restart"
),
confirm: () => {
this.hass.callService("homeassistant", "restart");
},
});
},
});
break;
}
}
static get styles(): CSSResultGroup {
@@ -122,26 +120,19 @@ class HaConfigSystemNavigation extends LitElement {
padding-bottom: 0;
}
@media all and (max-width: 600px) {
ha-card {
border-width: 1px 0;
border-radius: 0;
box-shadow: unset;
}
ha-config-section {
margin-top: -42px;
}
:host([narrow]) ha-card {
border-radius: 0;
box-shadow: unset;
}
:host([narrow]) ha-config-section {
margin-top: -42px;
}
ha-navigation-list {
--navigation-list-item-title-font-size: 16px;
--navigation-list-item-padding: 4px;
}
.yaml-config {
margin-bottom: max(env(safe-area-inset-bottom), 24px);
text-align: center;
font-style: italic;
}
`,
];
}

View File

@@ -39,9 +39,9 @@ import { configSections } from "../ha-panel-config";
import "./ha-config-navigation";
import "./ha-config-updates";
const randomTip = (hass: HomeAssistant, narrow: boolean) => {
const randomTip = (hass: HomeAssistant) => {
const weighted: string[] = [];
let tips = [
const tips = [
{
content: hass.localize(
"ui.panel.config.tips.join",
@@ -84,16 +84,11 @@ const randomTip = (hass: HomeAssistant, narrow: boolean) => {
</span>`
),
weight: 2,
narrow: true,
},
{ content: hass.localize("ui.tips.key_c_hint"), weight: 1, narrow: false },
{ content: hass.localize("ui.tips.key_m_hint"), weight: 1, narrow: false },
{ content: hass.localize("ui.tips.key_c_hint"), weight: 1 },
{ content: hass.localize("ui.tips.key_m_hint"), weight: 1 },
];
if (narrow) {
tips = tips.filter((tip) => tip.narrow);
}
tips.forEach((tip) => {
for (let i = 0; i < tip.weight; i++) {
weighted.push(tip.content);
@@ -195,6 +190,11 @@ class HaConfigDashboard extends LitElement {
</ha-card>`
: ""}
<ha-card outlined>
${this.narrow && canInstallUpdates.length
? html`<div class="title">
${this.hass.localize("panel.config")}
</div>`
: ""}
<ha-config-navigation
.hass=${this.hass}
.narrow=${this.narrow}
@@ -215,7 +215,7 @@ class HaConfigDashboard extends LitElement {
super.updated(changedProps);
if (!this._tip && changedProps.has("hass")) {
this._tip = randomTip(this.hass, this.narrow);
this._tip = randomTip(this.hass);
}
}
@@ -277,16 +277,13 @@ class HaConfigDashboard extends LitElement {
padding: 16px;
padding-bottom: 0;
}
:host([narrow]) ha-card {
border-radius: 0;
box-shadow: unset;
}
@media all and (max-width: 600px) {
ha-card {
border-width: 1px 0;
border-radius: 0;
box-shadow: unset;
}
ha-config-section {
margin-top: -42px;
}
:host([narrow]) ha-config-section {
margin-top: -42px;
}
ha-tip {

View File

@@ -1,5 +1,5 @@
import { css, html, LitElement, TemplateResult } from "lit";
import { property, state } from "lit/decorators";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { property } from "lit/decorators";
import { fireEvent } from "../../../../common/dom/fire_event";
import "../../../../components/ha-card";
import "../../../../components/ha-chip";
@@ -10,7 +10,6 @@ import {
DeviceAutomation,
} from "../../../../data/device_automation";
import { showScriptEditor } from "../../../../data/script";
import { buttonLinkStyle } from "../../../../resources/styles";
import { HomeAssistant } from "../../../../types";
declare global {
@@ -30,8 +29,6 @@ export abstract class HaDeviceAutomationCard<
@property() public automations: T[] = [];
@state() public _showSecondary = false;
protected headerKey = "";
protected type = "";
@@ -63,47 +60,28 @@ export abstract class HaDeviceAutomationCard<
if (this.automations.length === 0) {
return html``;
}
const automations = this._showSecondary
? this.automations
: this.automations.filter(
(automation) => automation.metadata?.secondary === false
);
return html`
<h3>${this.hass.localize(this.headerKey)}</h3>
<div class="content">
<ha-chip-set>
${automations.map(
${this.automations.map(
(automation, idx) =>
html`
<ha-chip
.index=${idx}
@click=${this._handleAutomationClicked}
class=${automation.metadata?.secondary ? "secondary" : ""}
>
<ha-chip .index=${idx} @click=${this._handleAutomationClicked}>
${this._localizeDeviceAutomation(this.hass, automation)}
</ha-chip>
`
)}
</ha-chip-set>
${!this._showSecondary && automations.length < this.automations.length
? html`<button class="link" @click=${this._toggleSecondary}>
Show ${this.automations.length - automations.length} more...
</button>`
: ""}
</div>
`;
}
private _toggleSecondary() {
this._showSecondary = !this._showSecondary;
}
private _handleAutomationClicked(ev: CustomEvent) {
const automation = { ...this.automations[(ev.currentTarget as any).index] };
const automation = this.automations[(ev.currentTarget as any).index];
if (!automation) {
return;
}
delete automation.metadata;
if (this.script) {
showScriptEditor({ sequence: [automation as DeviceAction] });
fireEvent(this, "entry-selected");
@@ -115,18 +93,11 @@ export abstract class HaDeviceAutomationCard<
fireEvent(this, "entry-selected");
}
static styles = [
buttonLinkStyle,
css`
static get styles(): CSSResultGroup {
return css`
h3 {
color: var(--primary-text-color);
}
.secondary {
--ha-chip-background-color: rgba(var(--rgb-primary-text-color), 0.07);
}
button.link {
color: var(--primary-color);
}
`,
];
`;
}
}

View File

@@ -10,7 +10,6 @@ import {
fetchDeviceActions,
fetchDeviceConditions,
fetchDeviceTriggers,
sortDeviceAutomations,
} from "../../../../data/device_automation";
import { haStyleDialog } from "../../../../resources/styles";
import { HomeAssistant } from "../../../../types";
@@ -64,16 +63,16 @@ export class DialogDeviceAutomation extends LitElement {
const { device, script } = this._params;
fetchDeviceActions(this.hass, device.id).then((actions) => {
this._actions = actions.sort(sortDeviceAutomations);
this._actions = actions;
});
if (script) {
return;
}
fetchDeviceTriggers(this.hass, device.id).then((triggers) => {
this._triggers = triggers.sort(sortDeviceAutomations);
this._triggers = triggers;
});
fetchDeviceConditions(this.hass, device.id).then((conditions) => {
this._conditions = conditions.sort(sortDeviceAutomations);
this._conditions = conditions;
});
}

View File

@@ -93,7 +93,7 @@ export const configSections: { [name: string]: PageNavigation[] } = {
path: "/config/person",
translationKey: "people",
iconPath: mdiAccount,
iconColor: "#5A87FA",
iconColor: "#832EA6",
components: ["person", "users"],
},
{
@@ -224,14 +224,14 @@ export const configSections: { [name: string]: PageNavigation[] } = {
path: "/config/person",
translationKey: "ui.panel.config.person.caption",
iconPath: mdiAccount,
iconColor: "#5A87FA",
iconColor: "#E48629",
},
{
component: "users",
path: "/config/users",
translationKey: "ui.panel.config.users.caption",
iconPath: mdiBadgeAccountHorizontal,
iconColor: "#5A87FA",
iconColor: "#E48629",
core: true,
advancedOnly: true,
},
@@ -254,13 +254,6 @@ export const configSections: { [name: string]: PageNavigation[] } = {
},
],
general: [
{
path: "/config/general",
translationKey: "ui.panel.config.core.caption",
iconPath: mdiCog,
iconColor: "#653249",
core: true,
},
{
path: "/config/updates",
translationKey: "ui.panel.config.updates.caption",
@@ -322,6 +315,13 @@ export const configSections: { [name: string]: PageNavigation[] } = {
iconColor: "#507FfE",
components: ["system_health", "hassio"],
},
{
path: "/config/general",
translationKey: "ui.panel.config.core.caption",
iconPath: mdiCog,
iconColor: "#653249",
core: true,
},
],
about: [
{
@@ -345,6 +345,8 @@ class HaPanelConfig extends HassRouterPage {
protected routerOptions: RouterOptions = {
defaultPage: "dashboard",
beforeRender: (page) =>
page === "server_control" ? "../developer-tools/yaml" : undefined,
routes: {
analytics: {
tag: "ha-config-section-analytics",

View File

@@ -8,7 +8,6 @@ import "../../../components/ha-alert";
import "../../../components/ha-button-menu";
import "../../../components/ha-card";
import "../../../components/ha-settings-row";
import { BOARD_NAMES } from "../../../data/hardware";
import {
extractApiErrorMessage,
ignoreSupervisorError,
@@ -57,18 +56,6 @@ class HaConfigHardware extends LitElement {
.narrow=${this.narrow}
.header=${this.hass.localize("ui.panel.config.hardware.caption")}
>
<ha-button-menu corner="BOTTOM_START" slot="toolbar-icon">
<ha-icon-button
.label=${this.hass.localize("ui.common.menu")}
.path=${mdiDotsVertical}
slot="trigger"
></ha-icon-button>
<mwc-list-item @click=${this._openHardware}
>${this.hass.localize(
"ui.panel.config.hardware.available_hardware.title"
)}</mwc-list-item
>
</ha-button-menu>
${this._error
? html`
<ha-alert alert-type="error"
@@ -76,57 +63,65 @@ class HaConfigHardware extends LitElement {
>
`
: ""}
${this._OSData || this._hostData
${this._OSData && this._hostData
? html`
<div class="content">
<ha-card outlined>
${this._OSData?.board
? html`
<div class="card-content">
<ha-settings-row>
<span slot="heading"
>${BOARD_NAMES[this._OSData.board] ||
this.hass.localize(
"ui.panel.config.hardware.board"
)}</span
<div class="card-content">
<ha-settings-row>
<span slot="heading"
>${this.hass.localize(
"ui.panel.config.hardware.board"
)}</span
>
<div slot="description">
<span class="value">${this._OSData.board}</span>
</div>
</ha-settings-row>
</div>
<div class="card-actions">
<div class="buttons">
${this._hostData.features.includes("reboot")
? html`
<ha-progress-button
class="warning"
@click=${this._hostReboot}
>
<div slot="description">
<span class="value">${this._OSData.board}</span>
</div>
</ha-settings-row>
</div>
`
: ""}
${this._hostData
? html`
<div class="card-actions">
${this._hostData.features.includes("reboot")
? html`
<ha-progress-button
class="warning"
@click=${this._hostReboot}
>
${this.hass.localize(
"ui.panel.config.hardware.reboot_host"
)}
</ha-progress-button>
`
: ""}
${this._hostData.features.includes("shutdown")
? html`
<ha-progress-button
class="warning"
@click=${this._hostShutdown}
>
${this.hass.localize(
"ui.panel.config.hardware.shutdown_host"
)}
</ha-progress-button>
`
: ""}
</div>
`
: ""}
${this.hass.localize(
"ui.panel.config.hardware.reboot_host"
)}
</ha-progress-button>
`
: ""}
${this._hostData.features.includes("shutdown")
? html`
<ha-progress-button
class="warning"
@click=${this._hostShutdown}
>
${this.hass.localize(
"ui.panel.config.hardware.shutdown_host"
)}
</ha-progress-button>
`
: ""}
</div>
<ha-button-menu corner="BOTTOM_START">
<ha-icon-button
.label=${this.hass.localize("common.menu")}
.path=${mdiDotsVertical}
slot="trigger"
></ha-icon-button>
<mwc-list-item
.action=${"hardware"}
@click=${this._openHardware}
>
${this.hass.localize(
"ui.panel.config.hardware.available_hardware.title"
)}
</mwc-list-item>
</ha-button-menu>
</div>
</ha-card>
</div>
`
@@ -246,6 +241,10 @@ class HaConfigHardware extends LitElement {
justify-content: space-between;
align-items: center;
}
.buttons {
display: flex;
align-items: center;
}
`,
];
}

View File

@@ -3,16 +3,17 @@ import { property, state } from "lit/decorators";
import { isComponentLoaded } from "../../../common/config/is_component_loaded";
import "../../../components/ha-logo-svg";
import {
fetchHassioHassOsInfo,
fetchHassioHostInfo,
fetchHassioHassOsInfo,
HassioHassOSInfo,
HassioHostInfo,
} from "../../../data/hassio/host";
import { fetchHassioInfo, HassioInfo } from "../../../data/hassio/supervisor";
import { HassioInfo, fetchHassioInfo } from "../../../data/hassio/supervisor";
import "../../../layouts/hass-subpage";
import { haStyle } from "../../../resources/styles";
import { HomeAssistant, Route } from "../../../types";
import { documentationUrl } from "../../../util/documentation-url";
import "./integrations-card";
const JS_TYPE = __BUILD__;
const JS_VERSION = __VERSION__;
@@ -20,13 +21,13 @@ const JS_VERSION = __VERSION__;
class HaConfigInfo extends LitElement {
@property({ attribute: false }) public hass!: HomeAssistant;
@property({ type: Boolean }) public narrow!: boolean;
@property() public narrow!: boolean;
@property({ type: Boolean }) public isWide!: boolean;
@property() public isWide!: boolean;
@property({ type: Boolean }) public showAdvanced!: boolean;
@property() public showAdvanced!: boolean;
@property({ attribute: false }) public route!: Route;
@property() public route!: Route;
@state() private _hostInfo?: HassioHostInfo;
@@ -60,22 +61,18 @@ class HaConfigInfo extends LitElement {
</ha-logo-svg>
</a>
<br />
<h3>Home Assistant Core ${hass.connection.haVersion}</h3>
<h2>Home Assistant Core ${hass.connection.haVersion}</h2>
${this._hassioInfo
? html`
<h3>
Home Assistant Supervisor ${this._hassioInfo.supervisor}
</h3>
`
? html`<h2>
Home Assistant Supervisor ${this._hassioInfo.supervisor}
</h2>`
: ""}
${this._osInfo?.version
? html`<h3>Home Assistant OS ${this._osInfo.version}</h3>`
? html`<h2>Home Assistant OS ${this._osInfo.version}</h2>`
: ""}
${this._hostInfo
? html`
<h4>Kernel version ${this._hostInfo.kernel}</h4>
<h4>Agent version ${this._hostInfo.agent_version}</h4>
`
? html`<h4>Kernel version ${this._hostInfo.kernel}</h4>
<h4>Agent version ${this._hostInfo.agent_version}</h4>`
: ""}
<p>
${this.hass.localize(
@@ -156,6 +153,12 @@ class HaConfigInfo extends LitElement {
: ""}
</p>
</div>
<div>
<integrations-card
.hass=${this.hass}
.narrow=${this.narrow}
></integrations-card>
</div>
</hass-subpage>
`;
}
@@ -214,15 +217,18 @@ class HaConfigInfo extends LitElement {
.about a {
color: var(--primary-color);
}
integrations-card {
display: block;
max-width: 600px;
margin: 0 auto;
padding-bottom: 16px;
}
ha-logo-svg {
padding: 12px;
height: 180px;
width: 180px;
}
h4 {
font-weight: 400;
}
`,
];
}

View File

@@ -0,0 +1,210 @@
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { customElement, property, state } from "lit/decorators";
import memoizeOne from "memoize-one";
import "../../../components/ha-card";
import {
domainToName,
fetchIntegrationManifests,
fetchIntegrationSetups,
integrationIssuesUrl,
IntegrationManifest,
IntegrationSetup,
} from "../../../data/integration";
import { HomeAssistant } from "../../../types";
import { brandsUrl } from "../../../util/brands-url";
import { documentationUrl } from "../../../util/documentation-url";
@customElement("integrations-card")
class IntegrationsCard extends LitElement {
@property({ attribute: false }) public hass!: HomeAssistant;
@property({ type: Boolean }) public narrow = false;
@state() private _manifests?: {
[domain: string]: IntegrationManifest;
};
@state() private _setups?: {
[domain: string]: IntegrationSetup;
};
private _sortedIntegrations = memoizeOne((components: string[]) =>
Array.from(
new Set(
components.map((comp) =>
comp.includes(".") ? comp.split(".")[1] : comp
)
)
).sort()
);
firstUpdated(changedProps) {
super.firstUpdated(changedProps);
this._fetchManifests();
this._fetchSetups();
}
protected render(): TemplateResult {
return html`
<ha-card
.header=${this.hass.localize("ui.panel.config.info.integrations")}
>
<table class="card-content">
<thead>
<tr>
<th></th>
${!this.narrow
? html`<th></th>
<th></th>
<th></th>`
: ""}
<th>${this.hass.localize("ui.panel.config.info.setup_time")}</th>
</tr>
</thead>
<tbody>
${this._sortedIntegrations(this.hass!.config.components).map(
(domain) => {
const manifest = this._manifests && this._manifests[domain];
const docLink = manifest
? html`<a
href=${manifest.is_built_in
? documentationUrl(
this.hass,
`/integrations/${manifest.domain}`
)
: manifest.documentation}
target="_blank"
rel="noreferrer"
>${this.hass.localize(
"ui.panel.config.info.documentation"
)}</a
>`
: "";
const issueLink =
manifest && (manifest.is_built_in || manifest.issue_tracker)
? html`
<a
href=${integrationIssuesUrl(domain, manifest)}
target="_blank"
rel="noreferrer"
>${this.hass.localize(
"ui.panel.config.info.issues"
)}</a
>
`
: "";
const setupSeconds =
this._setups?.[domain]?.seconds?.toFixed(2);
return html`
<tr>
<td>
<img
loading="lazy"
src=${brandsUrl({
domain: domain,
type: "icon",
useFallback: true,
darkOptimized: this.hass.themes?.darkMode,
})}
referrerpolicy="no-referrer"
/>
</td>
<td class="name">
${domainToName(
this.hass.localize,
domain,
manifest
)}<br />
<span class="domain">${domain}</span>
${this.narrow
? html`<div class="mobile-row">
<div>${docLink} ${issueLink}</div>
${setupSeconds ? html`${setupSeconds} s` : ""}
</div>`
: ""}
</td>
${this.narrow
? ""
: html`
<td>${docLink}</td>
<td>${issueLink}</td>
<td class="setup">
${setupSeconds ? html`${setupSeconds} s` : ""}
</td>
`}
</tr>
`;
}
)}
</tbody>
</table>
</ha-card>
`;
}
private async _fetchManifests() {
const manifests = {};
for (const manifest of await fetchIntegrationManifests(this.hass)) {
manifests[manifest.domain] = manifest;
}
this._manifests = manifests;
}
private async _fetchSetups() {
const setups = {};
for (const setup of await fetchIntegrationSetups(this.hass)) {
setups[setup.domain] = setup;
}
this._setups = setups;
}
static get styles(): CSSResultGroup {
return css`
table {
width: 100%;
}
td,
th {
padding: 0 8px;
}
td:first-child {
padding-left: 0;
}
td.name {
padding: 8px;
}
td.setup {
text-align: right;
white-space: nowrap;
direction: ltr;
}
th {
text-align: right;
}
.domain {
color: var(--secondary-text-color);
}
.mobile-row {
display: flex;
justify-content: space-between;
}
.mobile-row a:not(:last-of-type) {
margin-right: 4px;
}
img {
display: block;
max-height: 40px;
max-width: 40px;
}
a {
color: var(--primary-color);
}
`;
}
}
declare global {
interface HTMLElementTagNameMap {
"integrations-card": IntegrationsCard;
}
}

View File

@@ -252,8 +252,6 @@ class ConfigUrlForm extends LitElement {
this._cloudStatus = cloudStatus;
if (cloudStatus.logged_in) {
this._showCustomExternalUrl = this._externalUrlValue !== null;
} else {
this._showCustomExternalUrl = true;
}
});
} else {

View File

@@ -111,9 +111,6 @@ export class HassioHostname extends LitElement {
justify-content: space-between;
align-items: center;
}
ha-settings-row {
border-top: none;
}
`;
}

View File

@@ -46,7 +46,7 @@ class HaConfigSectionStorage extends LitElement {
<ha-button-menu corner="BOTTOM_START" slot="toolbar-icon">
<ha-icon-button
slot="trigger"
.label=${this.hass.localize("ui.common.menu")}
.label=${this.hass.localize("ui.common.overflow")}
.path=${mdiDotsVertical}
></ha-icon-button>
<mwc-list-item @click=${this._moveDatadisk}>

View File

@@ -30,7 +30,6 @@ import { SubscribeMixin } from "../../../mixins/subscribe-mixin";
import type { HomeAssistant } from "../../../types";
import { documentationUrl } from "../../../util/documentation-url";
import { showToast } from "../../../util/toast";
import "./integrations-card";
const sortKeys = (a: string, b: string) => {
if (a === "homeassistant") {
@@ -318,11 +317,6 @@ class HaConfigSystemHealth extends SubscribeMixin(LitElement) {
</div>
</ha-card>
`}
<integrations-card
.hass=${this.hass}
.narrow=${this.narrow}
></integrations-card>
</div>
</hass-subpage>
`;
@@ -456,20 +450,12 @@ class HaConfigSystemHealth extends SubscribeMixin(LitElement) {
max-width: 1040px;
margin: 0 auto;
}
integrations-card {
max-width: 600px;
display: block;
max-width: 600px;
margin: 0 auto;
margin-bottom: 24px;
margin-bottom: max(24px, env(safe-area-inset-bottom));
}
ha-card {
display: block;
max-width: 600px;
margin: 0 auto;
padding-bottom: 16px;
margin-bottom: 24px;
margin-bottom: max(24px, env(safe-area-inset-bottom));
}
ha-alert {
display: block;

View File

@@ -1,154 +0,0 @@
import "@material/mwc-list/mwc-list";
import {
css,
CSSResultGroup,
html,
LitElement,
PropertyValues,
TemplateResult,
} from "lit";
import { customElement, property, state } from "lit/decorators";
import "../../../components/ha-card";
import "../../../components/ha-clickable-list-item";
import {
domainToName,
fetchIntegrationManifests,
fetchIntegrationSetups,
IntegrationManifest,
IntegrationSetup,
} from "../../../data/integration";
import type { HomeAssistant } from "../../../types";
import { brandsUrl } from "../../../util/brands-url";
import { documentationUrl } from "../../../util/documentation-url";
@customElement("integrations-card")
class IntegrationsCard extends LitElement {
@property({ attribute: false }) public hass!: HomeAssistant;
@property({ type: Boolean }) public narrow = false;
@state() private _manifests?: {
[domain: string]: IntegrationManifest;
};
@state() private _setups?: IntegrationSetup[];
protected firstUpdated(changedProps: PropertyValues) {
super.firstUpdated(changedProps);
this._fetchManifests();
this._fetchSetups();
}
protected render(): TemplateResult {
if (!this._setups) {
return html``;
}
return html`
<ha-card
outlined
.header=${this.hass.localize(
"ui.panel.config.system_health.integration_start_time"
)}
>
<mwc-list>
${this._setups?.map((setup) => {
const manifest = this._manifests && this._manifests[setup.domain];
const docLink = manifest
? manifest.is_built_in
? documentationUrl(
this.hass,
`/integrations/${manifest.domain}`
)
: manifest.documentation
: "";
const setupSeconds = setup.seconds?.toFixed(2);
return html`
<ha-clickable-list-item
graphic="avatar"
twoline
hasMeta
openNewTab
@click=${this._entryClicked}
href=${docLink}
>
<img
loading="lazy"
src=${brandsUrl({
domain: setup.domain,
type: "icon",
useFallback: true,
darkOptimized: this.hass.themes?.darkMode,
})}
referrerpolicy="no-referrer"
slot="graphic"
/>
<span>
${domainToName(this.hass.localize, setup.domain, manifest)}
</span>
<span slot="secondary">${setup.domain}</span>
<div slot="meta">
${setupSeconds ? html`${setupSeconds} s` : ""}
</div>
</ha-clickable-list-item>
`;
})}
</mwc-list>
</ha-card>
`;
}
private async _fetchManifests() {
const manifests = {};
for (const manifest of await fetchIntegrationManifests(this.hass)) {
manifests[manifest.domain] = manifest;
}
this._manifests = manifests;
}
private async _fetchSetups() {
const setups = await fetchIntegrationSetups(this.hass);
this._setups = setups.sort((a, b) => {
if (a.seconds === b.seconds) {
return 0;
}
if (a.seconds === undefined) {
return 1;
}
if (b.seconds === undefined) {
return 1;
}
return b.seconds - a.seconds;
});
}
private _entryClicked(ev) {
ev.currentTarget.blur();
}
static get styles(): CSSResultGroup {
return css`
ha-clickable-list-item {
--mdc-list-item-meta-size: 64px;
--mdc-typography-caption-font-size: 12px;
}
img {
display: block;
max-height: 40px;
max-width: 40px;
}
div[slot="meta"] {
display: flex;
justify-content: center;
align-items: center;
}
`;
}
}
declare global {
interface HTMLElementTagNameMap {
"integrations-card": IntegrationsCard;
}
}

View File

@@ -27,10 +27,10 @@ export class DeveloperYamlConfig extends LitElement {
@state() private _reloadableDomains: string[] = [];
@state() private _isValid: boolean | null = null;
private _validateLog = "";
private _isValid: boolean | null = null;
protected updated(changedProperties) {
const oldHass = changedProperties.get("hass");
if (
@@ -167,20 +167,13 @@ export class DeveloperYamlConfig extends LitElement {
private _restart() {
showConfirmationDialog(this, {
title: this.hass.localize(
"ui.panel.developer-tools.tabs.yaml.section.server_management.confirm_restart_title"
),
text: this.hass.localize(
"ui.panel.developer-tools.tabs.yaml.section.server_management.confirm_restart_text"
),
confirmText: this.hass.localize(
"ui.panel.developer-tools.tabs.yaml.section.server_management.restart"
"ui.panel.developer-tools.tabs.yaml.section.server_management.confirm_restart"
),
confirmText: this.hass!.localize("ui.common.leave"),
dismissText: this.hass!.localize("ui.common.stay"),
confirm: () => {
this.hass.callService("homeassistant", "restart").catch((reason) => {
this._isValid = false;
this._validateLog = reason.message;
});
this.hass.callService("homeassistant", "restart");
},
});
}

View File

@@ -20,7 +20,7 @@ const cardConfigStruct = assign(
const SCHEMA: HaFormSchema[] = [
{ name: "title", selector: { text: {} } },
{ name: "content", required: true, selector: { template: {} } },
{ name: "content", required: true, selector: { text: { multiline: true } } },
{ name: "theme", selector: { theme: {} } },
];

View File

@@ -686,16 +686,6 @@ export class BarMediaPlayer extends LitElement {
mwc-list-item[selected] {
font-weight: bold;
}
:host-context([style*="direction: rtl;"]) ha-svg-icon[slot="icon"] {
margin-left: 8px !important;
margin-right: 8px !important;
}
:host-context([style*="direction: rtl;"])
ha-svg-icon[slot="trailingIcon"] {
margin-left: 0px !important;
margin-right: 8px !important;
}
`;
}
}

View File

@@ -16,7 +16,6 @@ import { fireEvent, HASSDomEvent } from "../../common/dom/fire_event";
import { navigate } from "../../common/navigate";
import "../../components/ha-menu-button";
import "../../components/ha-icon-button";
import "../../components/ha-icon-button-arrow-prev";
import "../../components/media-player/ha-media-player-browse";
import "../../components/media-player/ha-media-manage-button";
import type {
@@ -86,10 +85,10 @@ class PanelMediaBrowser extends LitElement {
<app-toolbar>
${this._navigateIds.length > 1
? html`
<ha-icon-button-arrow-prev
<ha-icon-button
.path=${mdiArrowLeft}
@click=${this._goBack}
></ha-icon-button-arrow-prev>
></ha-icon-button>
`
: html`
<ha-menu-button
@@ -279,7 +278,6 @@ class PanelMediaBrowser extends LitElement {
ha-media-player-browse {
height: calc(100vh - (100px + var(--header-height)));
direction: ltr;
}
:host([narrow]) ha-media-player-browse {

View File

@@ -34,9 +34,6 @@ export const getMyRedirects = (hasSupervisor: boolean): Redirects => ({
developer_statistics: {
redirect: "/developer-tools/statistics",
},
server_controls: {
redirect: "/developer-tools/yaml",
},
config: {
redirect: "/config/dashboard",
},
@@ -132,7 +129,10 @@ export const getMyRedirects = (hasSupervisor: boolean): Redirects => ({
redirect: "/config/users",
},
general: {
redirect: "/config/general",
redirect: "/config/core",
},
server_controls: {
redirect: "/developer-tools/yaml",
},
logs: {
redirect: "/config/logs",
@@ -140,27 +140,6 @@ export const getMyRedirects = (hasSupervisor: boolean): Redirects => ({
info: {
redirect: "/config/info",
},
system_health: {
redirect: "/config/system_health",
},
hardware: {
redirect: "/config/hardware",
},
storage: {
redirect: "/config/storage",
},
network: {
redirect: "/config/network",
},
analytics: {
redirect: "/config/analytics",
},
updates: {
redirect: "/config/updates",
},
system_dashboard: {
redirect: "/config/system",
},
customize: {
// customize was removed in 2021.12, fallback to dashboard
redirect: "/config/dashboard",
@@ -220,9 +199,6 @@ export interface Redirect {
params?: {
[key: string]: ParamType;
};
optional_params?: {
[key: string]: ParamType;
};
}
@customElement("ha-panel-my")

View File

@@ -2,7 +2,7 @@
"panel": {
"energy": "Energy",
"calendar": "Calendar",
"config": "Settings",
"config": "Configuration",
"states": "Overview",
"map": "Map",
"logbook": "Logbook",
@@ -1152,7 +1152,7 @@
},
"about": {
"main": "About",
"secondary": "Version information, credits and more"
"secondary": "Version, loaded integrations and links to documentation"
}
},
"common": {
@@ -1493,7 +1493,7 @@
"unit_system_metric": "Metric",
"imperial_example": "Fahrenheit, pounds",
"metric_example": "Celsius, kilograms",
"find_currency_value": "Find my value",
"find_currency_value": "Find your value",
"save_button": "Save",
"currency": "Currency",
"edit_location": "Edit location",
@@ -1519,7 +1519,7 @@
"caption": "Hardware",
"available_hardware": {
"failed_to_get": "Failed to get available hardware",
"title": "All Hardware",
"title": "Available hardware",
"subsystem": "Subsystem",
"device_path": "Device path",
"id": "ID",
@@ -1551,6 +1551,7 @@
"frontend_version": "Frontend version: {version} - {type}",
"custom_uis": "Custom UIs:",
"system_health_error": "System Health component is not loaded. Add 'system_health:' to configuration.yaml",
"integrations": "Integrations",
"documentation": "Documentation",
"issues": "Issues",
"setup_time": "Setup time",
@@ -1674,7 +1675,7 @@
"introduction": "The automation editor allows you to create and edit automations. Please follow the link below to read the instructions to make sure that you have configured Home Assistant correctly.",
"learn_more": "Learn more about automations",
"pick_automation": "Pick automation to edit",
"no_automations": "We couldn't find any automations",
"no_automations": "We couldnt find any automations",
"add_automation": "Create automation",
"only_editable": "Only automations in automations.yaml are editable.",
"dev_only_editable": "Only automations that have a unique ID assigned are debuggable.",
@@ -1960,9 +1961,6 @@
"run_action_error": "Error running action",
"run_action_success": "Action run successfully",
"duplicate": "[%key:ui::panel::config::automation::editor::triggers::duplicate%]",
"enable": "Enable",
"disable": "Disable",
"disabled": "Disabled",
"delete": "[%key:ui::panel::mailbox::delete_button%]",
"delete_confirm": "[%key:ui::panel::config::automation::editor::triggers::delete_confirm%]",
"unsupported_action": "No visual editor support for action: {action}",
@@ -2052,9 +2050,6 @@
"label": "Stop",
"stop": "Reason for stopping",
"error": "Stop because of an unexpected error"
},
"parallel": {
"label": "Run in parallel"
}
}
}
@@ -3163,17 +3158,14 @@
},
"system_health": {
"caption": "System Health",
"cpu_usage": "Processor Usage",
"cpu_usage": "Process Usage",
"ram_usage": "Memory Usage",
"core_stats": "Core Stats",
"supervisor_stats": "Supervisor Stats",
"integration_start_time": "Integration Startup Time"
"supervisor_stats": "Supervisor Stats"
},
"system_dashboard": {
"confirm_restart_text": "Restarting Home Assistant will stop all your active dashboards, automations and scripts.",
"confirm_restart_title": "Restart Home Assistant?",
"restart_homeassistant_short": "Restart",
"restart_error": "Failed to restart Home Assistant"
"confirm_restart": "Are you sure you want to restart Home Assistant?",
"restart_homeassistant": "Restart Home Assistant"
}
},
"lovelace": {
@@ -4155,7 +4147,7 @@
"adjust_sum": "Adjust sum"
},
"yaml": {
"title": "YAML",
"title": "YAML Configuration",
"section": {
"validation": {
"heading": "Configuration validation",
@@ -4204,12 +4196,12 @@
},
"server_management": {
"heading": "Home Assistant",
"confirm_restart_text": "Restarting Home Assistant will stop all your active dashboards, automations and scripts.",
"confirm_restart_title": "Restart Home Assistant?",
"introduction": "Restarting Home Assistant will stop your dashboard and automations. After the reboot, each configuration will be reloaded.",
"restart": "Restart",
"restart_home_assistant": "Restart Home Assistant",
"confirm_restart": "Are you sure you want to restart Home Assistant?",
"stop": "Stop",
"confirm_stop": "Are you sure you want to stop Home Assistant?",
"restart_error": "Failed to restart Home Assistant"
"confirm_stop": "Are you sure you want to stop Home Assistant?"
}
}
}
@@ -4480,7 +4472,6 @@
"cancel": "[%key:ui::common::cancel%]",
"yes": "[%key:ui::common::yes%]",
"no": "[%key:ui::common::no%]",
"add": "[%key:supervisor::dialog::repositories::add%]",
"description": "Description",
"failed_to_restart_name": "Failed to restart {name}",
"failed_to_update_name": "Failed to update {name}",
@@ -4550,11 +4541,8 @@
"my": {
"not_supported": "[%key:ui::panel::my::not_supported%]",
"faq_link": "[%key:ui::panel::my::faq_link%]",
"add_addon_repository_title": "Missing add-on repository",
"add_addon_repository_description": "The addon ''{addon}'' is a part of the add-on repository ''{repository}'', this repository is missing on your system, do you want to add that now?",
"error": "[%key:ui::panel::my::error%]",
"error_addon_not_found": "Add-on not found",
"error_repository_not_found": "The required repository for this Add-on was not found",
"error_addon_not_started": "The requested add-on is not running. Please start it first",
"error_addon_not_installed": "The requested add-on is not installed. Please install it first",
"error_addon_no_ingress": "The requested add-on does not support ingress"