trigger automation in metadata
This commit is contained in:
1 parent
ab7f50d4aa
commit
f1b99cad1c
11 files changed
+36
-10
No files matched your search
@@ -16,6 +16,7 @@ export type ListBoxGroupProps = AutomationManagerItem & {
|
||||
) => void;
|
||||
onAutomationDelete: (aid: string, eid: string) => void;
|
||||
onSelect: (aid: string) => void;
|
||||
onRun: (eid: string) => void;
|
||||
initialOpenState?: boolean;
|
||||
tagsDB: TagDB;
|
||||
};
|
||||
@@ -70,6 +71,7 @@ export const ListBoxGroup: FC<ListBoxGroupProps> = ({
|
||||
}
|
||||
isSelected={auto.flags.isSelected}
|
||||
onSelect={() => events.onSelect(auto.id)}
|
||||
onRun={() => events.onRun(auto.entityId)}
|
||||
onDescriptionUpdate={(description) =>
|
||||
events.onAutomationUpdate(
|
||||
{
|
||||
|
||||
@@ -32,6 +32,7 @@ export const AutomationManagerLoaded: FC<
|
||||
state.setSelectedAutomationId(null);
|
||||
}}
|
||||
onAutomationUpdate={state.sideBarUpdateAutomation}
|
||||
onRun={args.onAutomationRun}
|
||||
/>
|
||||
<div className={["automation-manager--editor"].join(" ")}>
|
||||
{state.currentAutomationId !== null ? (
|
||||
|
||||
@@ -15,6 +15,7 @@ export type UseAutomationManagerStateArgs = {
|
||||
onAutomationAdd: (auto: AutomationData) => void;
|
||||
onAutomationUpdate: (aid: string, auto: AutomationData) => void;
|
||||
onAutomationStateChange: (eid: string, on: boolean) => void;
|
||||
onAutomationRun: (eid: string) => void;
|
||||
};
|
||||
export const useAutomationManagerState = ({
|
||||
configAutomations,
|
||||
|
||||
@@ -42,12 +42,25 @@
|
||||
font-size: 0.9em;
|
||||
}
|
||||
|
||||
.automation-manager--metadatabox .buttons {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
gap: 0.25em;
|
||||
}
|
||||
|
||||
.automation-manager--metadatabox .delete:hover {
|
||||
cursor: pointer;
|
||||
color: var(--mui-error-light);
|
||||
color: var(--mui-error-contrastText);
|
||||
background-color: var(--mui-error-dark);
|
||||
}
|
||||
|
||||
.automation-manager--metadatabox .run:hover {
|
||||
cursor: pointer;
|
||||
color: var(--mui-success-contrastText);
|
||||
background-color: var(--mui-success-dark);
|
||||
}
|
||||
|
||||
.automation-manager--metadatabox .select:hover,
|
||||
.automation-manager--metadatabox.selected.automation-manager--metadatabox .select {
|
||||
cursor: pointer;
|
||||
|
||||
@@ -7,6 +7,7 @@ import Alert from "@mui/material/Alert";
|
||||
|
||||
import DeleteForeverIcon from "@mui/icons-material/DeleteForever";
|
||||
import SelectIcon from "@mui/icons-material/HighlightAltSharp";
|
||||
import RunIcon from "@mui/icons-material/RunCircleOutlined";
|
||||
|
||||
import { InputTextView } from "components/Inputs/InputTextView";
|
||||
import { ButtonIcon } from "components/Icons/ButtonIcons";
|
||||
@@ -17,6 +18,7 @@ import { TagDB } from "../TagDB";
|
||||
export type MetadataBoxProps = AutomationManagerAuto & {
|
||||
onDelete: () => void;
|
||||
onSelect: () => void;
|
||||
onRun: () => void;
|
||||
onStateUpdate: (s: "on" | "off") => void;
|
||||
onTitleUpdate: (t: string) => void;
|
||||
onDescriptionUpdate: (t: string) => void;
|
||||
@@ -80,6 +82,7 @@ export const MetadataBox: FC<MetadataBoxProps> = (props) => {
|
||||
icon={<SelectIcon />}
|
||||
onClick={props.onSelect}
|
||||
/>
|
||||
<ButtonIcon className="run" icon={<RunIcon />} onClick={props.onRun} />
|
||||
<ButtonIcon
|
||||
className="delete"
|
||||
icon={<DeleteForeverIcon />}
|
||||
|
||||
@@ -33,6 +33,7 @@ const story = makeStory({
|
||||
selectedAutomationId={selectedAutomationId}
|
||||
tagsDB={useTagDB(automations, (a, t) => onTagUpdate(t, a))}
|
||||
automations={automations}
|
||||
onRun={args.onRun}
|
||||
onSelectedAutomationId={(aid) => {
|
||||
args.onSelectedAutomationId(aid);
|
||||
setSelAutoId(aid);
|
||||
|
||||
@@ -31,6 +31,7 @@ export type AutomationManagerSidebarProps = {
|
||||
onAutomationDelete: (aid: string, eid: string) => void;
|
||||
onAutomationAdd: () => void;
|
||||
onSelectedAutomationId: (aid: string) => void;
|
||||
onRun: (eid: string) => void;
|
||||
};
|
||||
export const AutomationManagerSidebar: FC<AutomationManagerSidebarProps> = ({
|
||||
automations,
|
||||
|
||||
@@ -20,6 +20,7 @@ const { make, componentMeta } = makeStory({
|
||||
api={useMockApiService(args.automations ?? [], !args.automations)}
|
||||
haEntities={useMockHAEntities(haEntities)}
|
||||
refreshAutomations={() => {}}
|
||||
triggerAutomation={() => {}}
|
||||
forceDeleteAutomation={() => {}}
|
||||
onAutomationStateChange={(eid, on) => {
|
||||
if (!haEntities.loading && !haEntities.error) {
|
||||
|
||||
@@ -14,6 +14,7 @@ export type AutomationManagerProps = {
|
||||
onAutomationStateChange: (eid: string, on: boolean) => void;
|
||||
refreshAutomations: () => void;
|
||||
forceDeleteAutomation: (eid: string) => void;
|
||||
triggerAutomation: (eid: string) => void;
|
||||
haEntities: HAEntitiesState;
|
||||
api: ApiService;
|
||||
};
|
||||
@@ -24,6 +25,7 @@ export const AutomationManager: FC<AutomationManagerProps> = ({
|
||||
onAutomationStateChange,
|
||||
refreshAutomations,
|
||||
forceDeleteAutomation,
|
||||
triggerAutomation,
|
||||
}) => {
|
||||
const snackbr = useSnackbar();
|
||||
const [isSaving, setIsSaving] = useState(false);
|
||||
@@ -79,6 +81,7 @@ export const AutomationManager: FC<AutomationManagerProps> = ({
|
||||
<AutomationManagerLoaded
|
||||
configAutomations={configAutomations.data}
|
||||
hassEntities={hassEntities}
|
||||
onAutomationRun={triggerAutomation}
|
||||
onAutomationStateChange={onAutomationStateChange}
|
||||
onAutomationAdd={async (auto) => {
|
||||
await api.updateAutomation({
|
||||
|
||||
@@ -11,6 +11,16 @@ export const AutomationRoute: FC<{ api: ApiService }> = ({ api }) => {
|
||||
<AutomationManager
|
||||
api={api}
|
||||
refreshAutomations={() => ha.callService("automation", "reload")}
|
||||
triggerAutomation={(entity_id) =>
|
||||
ha.callService(
|
||||
"automation",
|
||||
"trigger",
|
||||
{},
|
||||
{
|
||||
entity_id,
|
||||
}
|
||||
)
|
||||
}
|
||||
forceDeleteAutomation={(eid) =>
|
||||
ha.callHA({
|
||||
entity_id: eid,
|
||||
|
||||
@@ -10472,16 +10472,6 @@ jss@10.9.0, jss@^10.8.2:
|
||||
is-in-browser "^1.1.3"
|
||||
tiny-warning "^1.0.2"
|
||||
|
||||
jss@10.9.1:
|
||||
version "10.9.1"
|
||||
resolved "https://registry.yarnpkg.com/jss/-/jss-10.9.1.tgz#43d95a964f68f31074470da8de5167aed4586311"
|
||||
integrity sha512-omDBQTYyIdYuHee1mkpqDyHw2NguCrURBU1izPPHmdtDK6SkP7P3buZt4ybHWOahTZ3+xd0C+zLPBBw7Hn3eYg==
|
||||
dependencies:
|
||||
"@babel/runtime" "^7.3.1"
|
||||
csstype "^3.0.2"
|
||||
is-in-browser "^1.1.3"
|
||||
tiny-warning "^1.0.2"
|
||||
|
||||
jss@10.9.2:
|
||||
version "10.9.2"
|
||||
resolved "https://registry.yarnpkg.com/jss/-/jss-10.9.2.tgz#9379be1f195ef98011dfd31f9448251bd61b95a9"
|
||||
|
||||
Reference in new issue
Block a user