added more trigger managers
This commit is contained in:
1 parent
7296a2c518
commit
d77f079a23
5 files changed
+122
-12
No files matched your search
@@ -24,18 +24,6 @@ export const ActionChooseState: OptionManager<ChooseAction> = {
|
|||||||
value={state.action_data.alias ?? ""}
|
value={state.action_data.alias ?? ""}
|
||||||
onChange={alias => update({ alias })}
|
onChange={alias => update({ alias })}
|
||||||
/>
|
/>
|
||||||
{/* <InputYaml
|
|
||||||
label="Choose Sequence"
|
|
||||||
value={state.action_data.choose}
|
|
||||||
onChange={choose => update({ choose })}
|
|
||||||
resizable
|
|
||||||
/>
|
|
||||||
<InputYaml
|
|
||||||
label="Default Sequence"
|
|
||||||
value={state.action_data.default}
|
|
||||||
onChange={d => update({ default: d })}
|
|
||||||
resizable
|
|
||||||
/> */}
|
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
import InputText from "components/Inputs/InputText";
|
||||||
|
import { OptionManager } from './OptionManager';
|
||||||
|
import { AutomationTriggerEvent } from '../../../types/automations/triggers';
|
||||||
|
import InputYaml from "components/Inputs/InputYaml";
|
||||||
|
|
||||||
|
|
||||||
|
export const TriggerEventState: OptionManager<AutomationTriggerEvent> = {
|
||||||
|
defaultState: () => ({
|
||||||
|
$smType: 'trigger',
|
||||||
|
"alias": "",
|
||||||
|
"platform": "event",
|
||||||
|
"event_type": "",
|
||||||
|
"event_data": {},
|
||||||
|
"context": {},
|
||||||
|
}),
|
||||||
|
isReady: ({ alias, event_type }) => {
|
||||||
|
return (alias !== '') && (event_type !== "")
|
||||||
|
},
|
||||||
|
renderOptionList: (state, setState) => {
|
||||||
|
return <>
|
||||||
|
<InputText
|
||||||
|
label="Description"
|
||||||
|
value={state.alias ?? ""}
|
||||||
|
onChange={alias => setState({ ...state, alias })}
|
||||||
|
/>
|
||||||
|
<InputText
|
||||||
|
label="Event Type"
|
||||||
|
value={String(state.event_type)}
|
||||||
|
onChange={event_type => setState({ ...state, event_type })}
|
||||||
|
/>
|
||||||
|
<InputYaml
|
||||||
|
label="Data"
|
||||||
|
value={state.event_data ?? {}}
|
||||||
|
onChange={event_data => setState({ ...state, event_data })}
|
||||||
|
/>
|
||||||
|
<InputYaml
|
||||||
|
label="Context"
|
||||||
|
value={state.event_data ?? {}}
|
||||||
|
onChange={context => setState({ ...state, context })}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
import { OptionManager } from './OptionManager';
|
||||||
|
import { AutomationTriggerHA } from 'types/automations/triggers';
|
||||||
|
import InputList from "components/Inputs/InputList";
|
||||||
|
|
||||||
|
|
||||||
|
export const TriggerHAState: OptionManager<AutomationTriggerHA> = {
|
||||||
|
defaultState: () => ({
|
||||||
|
$smType: 'trigger',
|
||||||
|
"alias": "HA Starts",
|
||||||
|
"platform": "homeassistant",
|
||||||
|
"event": "start",
|
||||||
|
}),
|
||||||
|
isReady: ({ alias }) => {
|
||||||
|
return (alias !== '')
|
||||||
|
},
|
||||||
|
renderOptionList: (state, setState) => {
|
||||||
|
return <>
|
||||||
|
<InputList
|
||||||
|
label="Event Type"
|
||||||
|
current={state.event}
|
||||||
|
options={['start', 'shutdown']}
|
||||||
|
onChange={event => setState({
|
||||||
|
...state, event,
|
||||||
|
alias: event === 'shutdown' ? "HA Shutdown" : "HA Starts"
|
||||||
|
})}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
import { OptionManager } from './OptionManager';
|
||||||
|
import { AutomationTriggerMQTT } from 'types/automations/triggers';
|
||||||
|
import InputText from 'components/Inputs/InputText';
|
||||||
|
|
||||||
|
|
||||||
|
export const TriggerMQTTState: OptionManager<AutomationTriggerMQTT> = {
|
||||||
|
defaultState: () => ({
|
||||||
|
$smType: 'trigger',
|
||||||
|
"alias": "",
|
||||||
|
"platform": "mqtt",
|
||||||
|
"payload": "",
|
||||||
|
"topic": "",
|
||||||
|
"value_template": ""
|
||||||
|
}),
|
||||||
|
isReady: ({ alias }) => {
|
||||||
|
return (alias !== '')
|
||||||
|
},
|
||||||
|
renderOptionList: (state, setState) => {
|
||||||
|
return <>
|
||||||
|
<InputText
|
||||||
|
label='Payload'
|
||||||
|
value={state.payload}
|
||||||
|
onChange={payload => setState({ ...state, payload })}
|
||||||
|
/>
|
||||||
|
<InputText
|
||||||
|
label='Topic'
|
||||||
|
value={state.topic}
|
||||||
|
onChange={topic => setState({ ...state, topic })}
|
||||||
|
/>
|
||||||
|
<InputText
|
||||||
|
label='Template'
|
||||||
|
value={state.value_template}
|
||||||
|
onChange={value_template => setState({ ...state, value_template })}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,6 +8,9 @@ import { Generic } from "./Generic";
|
|||||||
import { ActionRepeatState } from "./ActionRepeat";
|
import { ActionRepeatState } from "./ActionRepeat";
|
||||||
import { ActionWaitState } from "./ActionWait";
|
import { ActionWaitState } from "./ActionWait";
|
||||||
import { ActionEventState } from "./ActionEvent";
|
import { ActionEventState } from "./ActionEvent";
|
||||||
|
import { TriggerEventState } from "./TriggerEvent";
|
||||||
|
import { TriggerHAState } from "./TriggerHA";
|
||||||
|
import { TriggerMQTTState } from "./TriggerMQTT";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -34,5 +37,15 @@ export const getOptionManager = <T extends AutomationNodeTypes>(
|
|||||||
if (nodeType === 'condition') {
|
if (nodeType === 'condition') {
|
||||||
return ConditionLogicState
|
return ConditionLogicState
|
||||||
}
|
}
|
||||||
|
if (nodeType === "trigger") {
|
||||||
|
switch (nodeSubtype) {
|
||||||
|
case "event":
|
||||||
|
return TriggerEventState
|
||||||
|
case "homeassistant":
|
||||||
|
return TriggerHAState
|
||||||
|
case "mqtt":
|
||||||
|
return TriggerMQTTState
|
||||||
|
}
|
||||||
|
}
|
||||||
return Generic
|
return Generic
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user