displaying source file
This commit is contained in:
1 parent
9bafbf4e8c
commit
8792ed6ed8
15 files changed
+124
-12
No files matched your search
@@ -44,6 +44,9 @@ export const NoTags = make({
|
|||||||
wowo: "!",
|
wowo: "!",
|
||||||
},
|
},
|
||||||
mode: "single",
|
mode: "single",
|
||||||
|
source_file: "automation.yaml",
|
||||||
|
source_file_type: "list",
|
||||||
|
configuration_key: "automation",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -60,5 +63,8 @@ export const SomeTags = make({
|
|||||||
wowo: "!",
|
wowo: "!",
|
||||||
},
|
},
|
||||||
mode: "single",
|
mode: "single",
|
||||||
|
source_file: "automation.yaml",
|
||||||
|
source_file_type: "list",
|
||||||
|
configuration_key: "automation",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -53,6 +53,9 @@ Simple.args = {
|
|||||||
wowo: "!",
|
wowo: "!",
|
||||||
},
|
},
|
||||||
mode: "single",
|
mode: "single",
|
||||||
|
source_file: "automation.yaml",
|
||||||
|
source_file_type: "list",
|
||||||
|
configuration_key: "automation",
|
||||||
trigger: [
|
trigger: [
|
||||||
{
|
{
|
||||||
platform: "numeric_state",
|
platform: "numeric_state",
|
||||||
@@ -102,6 +105,9 @@ EmptyStart.args = {
|
|||||||
id: "random",
|
id: "random",
|
||||||
alias: "Random",
|
alias: "Random",
|
||||||
description: "Example Metadata",
|
description: "Example Metadata",
|
||||||
|
source_file: "automation.yaml",
|
||||||
|
source_file_type: "list",
|
||||||
|
configuration_key: "automation",
|
||||||
trigger_variables: {
|
trigger_variables: {
|
||||||
wowo: "!",
|
wowo: "!",
|
||||||
},
|
},
|
||||||
@@ -131,6 +137,9 @@ BadAutomationInvalidTriggers.args = {
|
|||||||
id: "random",
|
id: "random",
|
||||||
alias: "Random",
|
alias: "Random",
|
||||||
description: "Example Metadata",
|
description: "Example Metadata",
|
||||||
|
source_file: "automation.yaml",
|
||||||
|
source_file_type: "list",
|
||||||
|
configuration_key: "automation",
|
||||||
trigger_variables: {
|
trigger_variables: {
|
||||||
wowo: "!",
|
wowo: "!",
|
||||||
},
|
},
|
||||||
@@ -169,6 +178,9 @@ RepeatExample.args = {
|
|||||||
alias: "Get out of baby room",
|
alias: "Get out of baby room",
|
||||||
description: "",
|
description: "",
|
||||||
mode: "single",
|
mode: "single",
|
||||||
|
source_file: "automation.yaml",
|
||||||
|
source_file_type: "list",
|
||||||
|
configuration_key: "automation",
|
||||||
trigger: [
|
trigger: [
|
||||||
{
|
{
|
||||||
type: "opened",
|
type: "opened",
|
||||||
|
|||||||
@@ -26,6 +26,9 @@ const { make, componentMeta } = makeStory({
|
|||||||
description: "Amazing automation!",
|
description: "Amazing automation!",
|
||||||
tags: {},
|
tags: {},
|
||||||
state: "on",
|
state: "on",
|
||||||
|
source_file: "automation.yaml",
|
||||||
|
source_file_type: "list",
|
||||||
|
configuration_key: "automation",
|
||||||
flags: {
|
flags: {
|
||||||
isSelected: false,
|
isSelected: false,
|
||||||
isModified: false,
|
isModified: false,
|
||||||
@@ -37,6 +40,9 @@ const { make, componentMeta } = makeStory({
|
|||||||
entityId: "automation.2",
|
entityId: "automation.2",
|
||||||
description: "Cool!",
|
description: "Cool!",
|
||||||
state: "on",
|
state: "on",
|
||||||
|
source_file: "automation.yaml",
|
||||||
|
source_file_type: "list",
|
||||||
|
configuration_key: "automation",
|
||||||
flags: {
|
flags: {
|
||||||
isSelected: false,
|
isSelected: false,
|
||||||
isModified: false,
|
isModified: false,
|
||||||
@@ -84,6 +90,9 @@ export const Nested = make({
|
|||||||
description: "",
|
description: "",
|
||||||
title: "Automation #1",
|
title: "Automation #1",
|
||||||
state: "on",
|
state: "on",
|
||||||
|
source_file: "automation.yaml",
|
||||||
|
source_file_type: "list",
|
||||||
|
configuration_key: "automation",
|
||||||
flags: {
|
flags: {
|
||||||
isSelected: true,
|
isSelected: true,
|
||||||
isModified: false,
|
isModified: false,
|
||||||
@@ -96,6 +105,9 @@ export const Nested = make({
|
|||||||
description: "another one",
|
description: "another one",
|
||||||
title: "Automation #2",
|
title: "Automation #2",
|
||||||
state: "off",
|
state: "off",
|
||||||
|
source_file: "automation.yaml",
|
||||||
|
source_file_type: "list",
|
||||||
|
configuration_key: "automation",
|
||||||
flags: {
|
flags: {
|
||||||
isSelected: false,
|
isSelected: false,
|
||||||
isModified: false,
|
isModified: false,
|
||||||
@@ -108,6 +120,9 @@ export const Nested = make({
|
|||||||
description: "bad one",
|
description: "bad one",
|
||||||
title: "Automation #3",
|
title: "Automation #3",
|
||||||
state: "offing",
|
state: "offing",
|
||||||
|
source_file: "automation.yaml",
|
||||||
|
source_file_type: "list",
|
||||||
|
configuration_key: "automation",
|
||||||
flags: {
|
flags: {
|
||||||
isSelected: false,
|
isSelected: false,
|
||||||
isModified: false,
|
isModified: false,
|
||||||
@@ -146,6 +161,9 @@ export const Nested = make({
|
|||||||
isSelected: false,
|
isSelected: false,
|
||||||
isModified: false,
|
isModified: false,
|
||||||
},
|
},
|
||||||
|
source_file: "automation.yaml",
|
||||||
|
source_file_type: "list",
|
||||||
|
configuration_key: "automation",
|
||||||
state: "on",
|
state: "on",
|
||||||
tags: {
|
tags: {
|
||||||
type: "good",
|
type: "good",
|
||||||
|
|||||||
@@ -54,6 +54,9 @@ export const useAutomationDB = (
|
|||||||
tags: {},
|
tags: {},
|
||||||
issue: "New Automation",
|
issue: "New Automation",
|
||||||
isNew: true,
|
isNew: true,
|
||||||
|
source_file: auto.source_file,
|
||||||
|
source_file_type: auto.source_file_type,
|
||||||
|
configuration_key: auto.configuration_key,
|
||||||
},
|
},
|
||||||
auto,
|
auto,
|
||||||
]);
|
]);
|
||||||
@@ -88,11 +91,16 @@ const genMapping = (
|
|||||||
? undefined
|
? undefined
|
||||||
: `recived invalid state "${entityData.state}, this could be because you have a lingering automation that was not cleared by homeassistant, try to reboot HA or manually clear this automation from HA Database."`;
|
: `recived invalid state "${entityData.state}, this could be because you have a lingering automation that was not cleared by homeassistant, try to reboot HA or manually clear this automation from HA Database."`;
|
||||||
let found: AutomationData | null = null;
|
let found: AutomationData | null = null;
|
||||||
|
let source_file = "n/a";
|
||||||
|
let source_file_type = "n/a";
|
||||||
|
let configuration_key = "n/a";
|
||||||
if (configData[autoId]) {
|
if (configData[autoId]) {
|
||||||
found = configData[entityData.attributes.id];
|
found = configData[entityData.attributes.id];
|
||||||
title = found.alias ?? title;
|
title = found.alias ?? title;
|
||||||
description = found.description ?? description;
|
description = found.description ?? description;
|
||||||
|
source_file = found.source_file ?? source_file;
|
||||||
|
source_file_type = found.source_file_type ?? source_file_type;
|
||||||
|
configuration_key = found.configuration_key ?? configuration_key;
|
||||||
delete configData[autoId];
|
delete configData[autoId];
|
||||||
} else {
|
} else {
|
||||||
issue = "failed to find this automation in '/config' folder";
|
issue = "failed to find this automation in '/config' folder";
|
||||||
@@ -106,6 +114,9 @@ const genMapping = (
|
|||||||
description,
|
description,
|
||||||
state: entityData.state,
|
state: entityData.state,
|
||||||
tags: tagsDB.getTags(autoId),
|
tags: tagsDB.getTags(autoId),
|
||||||
|
source_file,
|
||||||
|
source_file_type,
|
||||||
|
configuration_key,
|
||||||
issue,
|
issue,
|
||||||
},
|
},
|
||||||
found,
|
found,
|
||||||
@@ -121,6 +132,9 @@ const genMapping = (
|
|||||||
description: auto.description ?? "",
|
description: auto.description ?? "",
|
||||||
state: "unregistered",
|
state: "unregistered",
|
||||||
tags: tagsDB.getTags(auto.id),
|
tags: tagsDB.getTags(auto.id),
|
||||||
|
source_file: auto.source_file,
|
||||||
|
source_file_type: auto.source_file_type,
|
||||||
|
configuration_key: auto.configuration_key,
|
||||||
issue:
|
issue:
|
||||||
"homeassistant did not load this automation, try to manually reload automations or restart homeassistant.",
|
"homeassistant did not load this automation, try to manually reload automations or restart homeassistant.",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -84,4 +84,14 @@
|
|||||||
font-size: 0.75em;
|
font-size: 0.75em;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
max-width: 5em;
|
max-width: 5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.automation-manager--metadatabox .metadatabox--title--source {
|
||||||
|
margin-bottom: -0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.automation-manager--metadatabox .metadatabox--title--source .MuiChip-root {
|
||||||
|
font-size: 0.85em;
|
||||||
|
height: 2em;
|
||||||
}
|
}
|
||||||
@@ -14,6 +14,7 @@ import { ButtonIcon } from "components/Icons/ButtonIcons";
|
|||||||
import { AutomationManagerAuto } from "../types";
|
import { AutomationManagerAuto } from "../types";
|
||||||
import { Tags } from "./Tags";
|
import { Tags } from "./Tags";
|
||||||
import { TagDB } from "../TagDB";
|
import { TagDB } from "../TagDB";
|
||||||
|
import { Chip } from "@mui/material";
|
||||||
|
|
||||||
export type MetadataBoxProps = AutomationManagerAuto & {
|
export type MetadataBoxProps = AutomationManagerAuto & {
|
||||||
onDelete: () => void;
|
onDelete: () => void;
|
||||||
@@ -53,6 +54,9 @@ export const MetadataBox: FC<MetadataBoxProps> = (props) => {
|
|||||||
className="metadatabox--title"
|
className="metadatabox--title"
|
||||||
title={`ID=${props.id}, EntityID=${props.entityId}`}
|
title={`ID=${props.id}, EntityID=${props.entityId}`}
|
||||||
>
|
>
|
||||||
|
<span className="metadatabox--title--source">
|
||||||
|
<Chip label={`@${props.source_file}`} />
|
||||||
|
</span>
|
||||||
<InputTextView
|
<InputTextView
|
||||||
className="title"
|
className="title"
|
||||||
placeholder="Title"
|
placeholder="Title"
|
||||||
|
|||||||
@@ -68,6 +68,9 @@ const story = makeStory({
|
|||||||
tags: {},
|
tags: {},
|
||||||
entityId: "automation." + id,
|
entityId: "automation." + id,
|
||||||
state: "on",
|
state: "on",
|
||||||
|
source_file: "automation.yaml",
|
||||||
|
source_file_type: "list",
|
||||||
|
configuration_key: "automation",
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
setSelAutoId(id);
|
setSelAutoId(id);
|
||||||
@@ -94,6 +97,9 @@ const makeAuto = (
|
|||||||
description: "",
|
description: "",
|
||||||
state: "on",
|
state: "on",
|
||||||
tags: {},
|
tags: {},
|
||||||
|
source_file: "automation.yaml",
|
||||||
|
source_file_type: "list",
|
||||||
|
configuration_key: "automation",
|
||||||
...data,
|
...data,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -40,6 +40,9 @@ const automations: AutomationManagerAuto[] = [
|
|||||||
tags: a.tags,
|
tags: a.tags,
|
||||||
id: a.id,
|
id: a.id,
|
||||||
isSelected: false,
|
isSelected: false,
|
||||||
|
source_file: "automation.yaml",
|
||||||
|
source_file_type: "list",
|
||||||
|
configuration_key: "automation",
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const bigList = bigMockAutoList.map<AutomationManagerAuto>((a) => ({
|
const bigList = bigMockAutoList.map<AutomationManagerAuto>((a) => ({
|
||||||
@@ -50,6 +53,9 @@ const bigList = bigMockAutoList.map<AutomationManagerAuto>((a) => ({
|
|||||||
tags: a.tags,
|
tags: a.tags,
|
||||||
id: a.id,
|
id: a.id,
|
||||||
isSelected: false,
|
isSelected: false,
|
||||||
|
source_file: "automation.yaml",
|
||||||
|
source_file_type: "list",
|
||||||
|
configuration_key: "automation",
|
||||||
}));
|
}));
|
||||||
|
|
||||||
test("no grouping", () => {
|
test("no grouping", () => {
|
||||||
|
|||||||
@@ -154,6 +154,9 @@ export const BadAutomation = make({
|
|||||||
mode: "single",
|
mode: "single",
|
||||||
alias: "Light.Tank_Day",
|
alias: "Light.Tank_Day",
|
||||||
description: "",
|
description: "",
|
||||||
|
source_file: "automation.yaml",
|
||||||
|
source_file_type: "list",
|
||||||
|
configuration_key: "automation",
|
||||||
trigger: [
|
trigger: [
|
||||||
{
|
{
|
||||||
platform: "sun",
|
platform: "sun",
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ export const AutomationManager: FC<AutomationManagerProps> = ({
|
|||||||
const invalidAutomations = configAutomationsValidated.filter(
|
const invalidAutomations = configAutomationsValidated.filter(
|
||||||
({ failures }) => failures !== null
|
({ failures }) => failures !== null
|
||||||
);
|
);
|
||||||
if (invalidAutomations.length > 0) {
|
if (invalidAutomations.length > 0 && !validationsShown.current) {
|
||||||
validationsShown.current = true;
|
validationsShown.current = true;
|
||||||
confirm({
|
confirm({
|
||||||
cancellationButtonProps: {
|
cancellationButtonProps: {
|
||||||
@@ -102,7 +102,7 @@ export const AutomationManager: FC<AutomationManagerProps> = ({
|
|||||||
.catch(console.error);
|
.catch(console.error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [api.state.automations, validationsShown.current]);
|
}, [api.state.automations, confirm]);
|
||||||
|
|
||||||
// handle bad states
|
// handle bad states
|
||||||
if (!haEntities.ready && haEntities.error) {
|
if (!haEntities.ready && haEntities.error) {
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ export type AutomationManagerAuto = AutomationManagerAutoUpdatable & {
|
|||||||
tags: Record<string, string>;
|
tags: Record<string, string>;
|
||||||
issue?: string;
|
issue?: string;
|
||||||
isNew?: boolean;
|
isNew?: boolean;
|
||||||
|
source_file: string;
|
||||||
|
source_file_type: string;
|
||||||
|
configuration_key: string;
|
||||||
};
|
};
|
||||||
export type AutomationManagerAutoItem = AutomationManagerAuto & {
|
export type AutomationManagerAutoItem = AutomationManagerAuto & {
|
||||||
flags: AutomationManagerItemFlags;
|
flags: AutomationManagerItemFlags;
|
||||||
|
|||||||
@@ -8,8 +8,13 @@ export const AutomationData = st.object({
|
|||||||
st.nullable(st.record(st.string(), st.string()))
|
st.nullable(st.record(st.string(), st.string()))
|
||||||
),
|
),
|
||||||
mode: st.enums(["single", "restart", "queued", "parallel"]),
|
mode: st.enums(["single", "restart", "queued", "parallel"]),
|
||||||
|
tags: st.record(st.string(), st.string()),
|
||||||
|
|
||||||
|
source_file: st.string(),
|
||||||
|
source_file_type: st.string(),
|
||||||
|
configuration_key: st.string(),
|
||||||
|
|
||||||
trigger: st.array(st.object()),
|
trigger: st.array(st.object()),
|
||||||
condition: st.array(st.object()),
|
condition: st.array(st.object()),
|
||||||
action: st.array(st.object()),
|
action: st.array(st.object()),
|
||||||
tags: st.record(st.string(), st.string()),
|
|
||||||
});
|
});
|
||||||
@@ -1,10 +1,14 @@
|
|||||||
import * as st from 'superstruct'
|
import * as st from "superstruct";
|
||||||
|
|
||||||
|
|
||||||
export const AutomationMetadata = st.object({
|
export const AutomationMetadata = st.object({
|
||||||
id: st.string(),
|
id: st.string(),
|
||||||
alias: st.optional(st.string()),
|
alias: st.optional(st.string()),
|
||||||
description: st.optional(st.string()),
|
description: st.optional(st.string()),
|
||||||
trigger_variables: st.optional(st.nullable(st.record(st.string(), st.string()))),
|
trigger_variables: st.optional(
|
||||||
mode: st.enums(["single", "restart", "queued", "parallel"]),
|
st.nullable(st.record(st.string(), st.string()))
|
||||||
})
|
),
|
||||||
|
mode: st.enums(["single", "restart", "queued", "parallel"]),
|
||||||
|
source_file: st.string(),
|
||||||
|
source_file_type: st.string(),
|
||||||
|
configuration_key: st.string(),
|
||||||
|
});
|
||||||
@@ -67,6 +67,9 @@ export const defaultAutomation = (id: string): AutomationData => ({
|
|||||||
alias: "New Automation",
|
alias: "New Automation",
|
||||||
description: "",
|
description: "",
|
||||||
mode: "single",
|
mode: "single",
|
||||||
|
source_file: "automation.yaml",
|
||||||
|
source_file_type: "list",
|
||||||
|
configuration_key: "automation",
|
||||||
tags: {},
|
tags: {},
|
||||||
trigger: [],
|
trigger: [],
|
||||||
action: [],
|
action: [],
|
||||||
|
|||||||
@@ -16,6 +16,9 @@ export const createMockAuto = ({
|
|||||||
mode: "single",
|
mode: "single",
|
||||||
tags,
|
tags,
|
||||||
condition: [],
|
condition: [],
|
||||||
|
source_file: "automation.yaml",
|
||||||
|
source_file_type: "list",
|
||||||
|
configuration_key: "automation",
|
||||||
trigger: [
|
trigger: [
|
||||||
{
|
{
|
||||||
platform: "numeric_state",
|
platform: "numeric_state",
|
||||||
@@ -82,6 +85,9 @@ export const bigMockAutoList: AutomationData[] = [
|
|||||||
description: "",
|
description: "",
|
||||||
trigger_variables: null,
|
trigger_variables: null,
|
||||||
mode: "single",
|
mode: "single",
|
||||||
|
source_file: "automation.yaml",
|
||||||
|
source_file_type: "list",
|
||||||
|
configuration_key: "automation",
|
||||||
trigger: [
|
trigger: [
|
||||||
{
|
{
|
||||||
device_id: "asdasdasdas",
|
device_id: "asdasdasdas",
|
||||||
@@ -231,6 +237,9 @@ export const bigMockAutoList: AutomationData[] = [
|
|||||||
description: "",
|
description: "",
|
||||||
trigger_variables: null,
|
trigger_variables: null,
|
||||||
mode: "single",
|
mode: "single",
|
||||||
|
source_file: "automation.yaml",
|
||||||
|
source_file_type: "list",
|
||||||
|
configuration_key: "automation",
|
||||||
trigger: [
|
trigger: [
|
||||||
{
|
{
|
||||||
platform: "device",
|
platform: "device",
|
||||||
@@ -271,6 +280,9 @@ export const bigMockAutoList: AutomationData[] = [
|
|||||||
"Ensures that the climate is always in sync with the house settings",
|
"Ensures that the climate is always in sync with the house settings",
|
||||||
trigger_variables: null,
|
trigger_variables: null,
|
||||||
mode: "single",
|
mode: "single",
|
||||||
|
source_file: "automation.yaml",
|
||||||
|
source_file_type: "list",
|
||||||
|
configuration_key: "automation",
|
||||||
trigger: [
|
trigger: [
|
||||||
{
|
{
|
||||||
platform: "state",
|
platform: "state",
|
||||||
@@ -403,6 +415,9 @@ export const bigMockAutoList: AutomationData[] = [
|
|||||||
description: "Configures max/min light settings for the baby ",
|
description: "Configures max/min light settings for the baby ",
|
||||||
trigger_variables: null,
|
trigger_variables: null,
|
||||||
mode: "single",
|
mode: "single",
|
||||||
|
source_file: "automation.yaml",
|
||||||
|
source_file_type: "list",
|
||||||
|
configuration_key: "automation",
|
||||||
trigger: [
|
trigger: [
|
||||||
{
|
{
|
||||||
platform: "time",
|
platform: "time",
|
||||||
@@ -463,6 +478,9 @@ export const bigMockAutoList: AutomationData[] = [
|
|||||||
id: "alarmanlage_an",
|
id: "alarmanlage_an",
|
||||||
alias: "alarmanlage_an (Uhrzeit)",
|
alias: "alarmanlage_an (Uhrzeit)",
|
||||||
mode: "single",
|
mode: "single",
|
||||||
|
source_file: "automation.yaml",
|
||||||
|
source_file_type: "list",
|
||||||
|
configuration_key: "automation",
|
||||||
tags: {},
|
tags: {},
|
||||||
trigger: [
|
trigger: [
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user