fixed up alias issues
This commit is contained in:
1 parent
98133607ca
commit
cdf67aa1a9
20 files changed
+52
-76
No files matched your search
@@ -6,7 +6,6 @@ import { InputEntity } from 'components/Inputs/InputTextBubble';
|
||||
|
||||
export const TriggerDevice: OptionManager<AutomationTriggerDevice> = {
|
||||
defaultState: () => ({
|
||||
"alias": "",
|
||||
"platform": 'device',
|
||||
"domain": "",
|
||||
"type": "",
|
||||
@@ -14,8 +13,8 @@ export const TriggerDevice: OptionManager<AutomationTriggerDevice> = {
|
||||
"device_id": "",
|
||||
"entity_id": "",
|
||||
}),
|
||||
isReady: ({ alias }) => {
|
||||
return (alias !== '')
|
||||
isReady: ({ }) => {
|
||||
return true
|
||||
},
|
||||
renderOptionList: (state, setState) => {
|
||||
return <>
|
||||
|
||||
@@ -6,14 +6,13 @@ import InputYaml from "components/Inputs/InputYaml";
|
||||
|
||||
export const TriggerEventState: OptionManager<AutomationTriggerEvent> = {
|
||||
defaultState: () => ({
|
||||
"alias": "",
|
||||
"platform": "event",
|
||||
"event_type": "",
|
||||
"event_data": {},
|
||||
"context": {},
|
||||
}),
|
||||
isReady: ({ alias, event_type }) => {
|
||||
return (alias !== '') && (event_type !== "")
|
||||
isReady: ({ event_type }) => {
|
||||
return (event_type !== "")
|
||||
},
|
||||
renderOptionList: (state, setState) => {
|
||||
return <>
|
||||
|
||||
@@ -5,12 +5,11 @@ import { InputList } from "components/Inputs/InputList";
|
||||
|
||||
export const TriggerHAState: OptionManager<AutomationTriggerHA> = {
|
||||
defaultState: () => ({
|
||||
"alias": "HA Starts",
|
||||
"platform": "homeassistant",
|
||||
"event": "start",
|
||||
}),
|
||||
isReady: ({ alias }) => {
|
||||
return (alias !== '')
|
||||
isReady: ({ }) => {
|
||||
return true
|
||||
},
|
||||
renderOptionList: (state, setState) => {
|
||||
return <>
|
||||
@@ -20,7 +19,6 @@ export const TriggerHAState: OptionManager<AutomationTriggerHA> = {
|
||||
options={['start', 'shutdown']}
|
||||
onChange={event => setState({
|
||||
...state, event,
|
||||
alias: event === 'shutdown' ? "HA Shutdown" : "HA Starts"
|
||||
})}
|
||||
/>
|
||||
</>
|
||||
|
||||
@@ -5,14 +5,13 @@ import InputText from 'components/Inputs/InputText';
|
||||
|
||||
export const TriggerMQTTState: OptionManager<AutomationTriggerMQTT> = {
|
||||
defaultState: () => ({
|
||||
"alias": "",
|
||||
"platform": "mqtt",
|
||||
"payload": "",
|
||||
"topic": "",
|
||||
"value_template": ""
|
||||
}),
|
||||
isReady: ({ alias }) => {
|
||||
return (alias !== '')
|
||||
isReady: ({ }) => {
|
||||
return true
|
||||
},
|
||||
renderOptionList: (state, setState) => {
|
||||
return <>
|
||||
|
||||
@@ -9,12 +9,11 @@ import InputYaml from 'components/Inputs/InputYaml';
|
||||
|
||||
export const TriggerNumericState: OptionManager<AutomationTriggerNumericState> = {
|
||||
defaultState: () => ({
|
||||
"alias": "",
|
||||
"platform": 'numeric_state',
|
||||
"entity_id": "",
|
||||
}),
|
||||
isReady: ({ alias }) => {
|
||||
return (alias !== '')
|
||||
isReady: ({ }) => {
|
||||
return true
|
||||
},
|
||||
renderOptionList: (state, setState) => {
|
||||
return <>
|
||||
|
||||
@@ -7,12 +7,11 @@ import InputTime from 'components/Inputs/InputTime';
|
||||
|
||||
export const TriggerState: OptionManager<AutomationTriggerState> = {
|
||||
defaultState: () => ({
|
||||
"alias": "",
|
||||
"platform": 'state',
|
||||
"entity_id": "",
|
||||
}),
|
||||
isReady: ({ alias }) => {
|
||||
return (alias !== '')
|
||||
isReady: ({ }) => {
|
||||
return true
|
||||
},
|
||||
renderOptionList: (state, setState) => {
|
||||
return <>
|
||||
|
||||
@@ -6,12 +6,11 @@ import InputTime from 'components/Inputs/InputTime';
|
||||
|
||||
export const TriggerTemplate: OptionManager<AutomationTriggerTemplate> = {
|
||||
defaultState: () => ({
|
||||
"alias": "",
|
||||
"platform": 'template',
|
||||
"value_template": "",
|
||||
}),
|
||||
isReady: ({ alias }) => {
|
||||
return (alias !== '')
|
||||
isReady: ({ }) => {
|
||||
return true
|
||||
},
|
||||
renderOptionList: (state, setState) => {
|
||||
return <>
|
||||
|
||||
@@ -6,12 +6,11 @@ import { convertObjectToAutomationTimeString } from 'utils/time';
|
||||
|
||||
export const TriggerTime: OptionManager<AutomationTriggerTime> = {
|
||||
defaultState: () => ({
|
||||
"alias": "",
|
||||
"platform": 'time',
|
||||
"at": "",
|
||||
}),
|
||||
isReady: ({ alias }) => {
|
||||
return (alias !== '')
|
||||
isReady: ({ }) => {
|
||||
return true
|
||||
},
|
||||
renderOptionList: (state, setState) => {
|
||||
return <>
|
||||
|
||||
@@ -5,11 +5,10 @@ import InputText from 'components/Inputs/InputText';
|
||||
|
||||
export const TriggerTimePattern: OptionManager<AutomationTriggerTimePattern> = {
|
||||
defaultState: () => ({
|
||||
"alias": "",
|
||||
"platform": 'time_pattern',
|
||||
}),
|
||||
isReady: ({ alias }) => {
|
||||
return (alias !== '')
|
||||
isReady: ({ }) => {
|
||||
return true
|
||||
},
|
||||
renderOptionList: (state, setState) => {
|
||||
return <>
|
||||
|
||||
@@ -5,12 +5,11 @@ import InputText from 'components/Inputs/InputText';
|
||||
|
||||
export const TriggerWebhook: OptionManager<AutomationTriggerWebhook> = {
|
||||
defaultState: () => ({
|
||||
"alias": "",
|
||||
"platform": 'webhook',
|
||||
"webhook_id": "",
|
||||
}),
|
||||
isReady: ({ alias }) => {
|
||||
return (alias !== '')
|
||||
isReady: ({ }) => {
|
||||
return true
|
||||
},
|
||||
renderOptionList: (state, setState) => {
|
||||
return <>
|
||||
|
||||
@@ -7,14 +7,13 @@ import { InputEntity } from 'components/Inputs/InputTextBubble';
|
||||
|
||||
export const TriggerZone: OptionManager<AutomationTriggerZone> = {
|
||||
defaultState: () => ({
|
||||
"alias": "",
|
||||
"platform": 'zone',
|
||||
"zone": "",
|
||||
"event": "enter",
|
||||
"entity_id": "",
|
||||
}),
|
||||
isReady: ({ alias }) => {
|
||||
return (alias !== '')
|
||||
isReady: ({ }) => {
|
||||
return true
|
||||
},
|
||||
renderOptionList: (state, setState) => {
|
||||
return <>
|
||||
|
||||
@@ -59,10 +59,27 @@ export const useEditorNodeState = (originalNode: AutomationNode, isErrored: bool
|
||||
return currentNode
|
||||
},
|
||||
renderOptionList() {
|
||||
const aliasEditor = <InputText label="Alias" value={getDescriptionFromAutomationNode(allState.node)} onChange={alias => setState({
|
||||
...allState.node,
|
||||
alias
|
||||
})} />
|
||||
let aliasEditor = <></>
|
||||
if (nodeType === 'trigger') {
|
||||
aliasEditor = <InputText
|
||||
label="Trigger ID"
|
||||
value={(allState.node as any).id}
|
||||
onChange={id => setState({
|
||||
...allState.node,
|
||||
id
|
||||
} as any)}
|
||||
/>
|
||||
}
|
||||
if (nodeType === 'action') {
|
||||
aliasEditor = <InputText
|
||||
label="Alias"
|
||||
value={getDescriptionFromAutomationNode(allState.node)}
|
||||
onChange={alias => setState({
|
||||
...allState.node,
|
||||
alias
|
||||
} as any)}
|
||||
/>
|
||||
}
|
||||
if (yamlMode || allState.isErrored) {
|
||||
return <>
|
||||
{aliasEditor}
|
||||
|
||||
@@ -52,7 +52,7 @@ export const NodeEditor: FC<NodeEditorProps> = ({
|
||||
onChange={state.setNodeType}
|
||||
/> : <></>}
|
||||
{state.nodeType !== 'condition' ? <InputList
|
||||
label={`${state.nodeType} type`}
|
||||
label={`${state.nodeType.slice(0, 1).toUpperCase()}${state.nodeType.slice(1)} Type`}
|
||||
current={state.subType as any}
|
||||
options={state.subTypes}
|
||||
onChange={state.setSubType}
|
||||
|
||||
Reference in new issue
Block a user