minor clean up
This commit is contained in:
1 parent
107def4fac
commit
e6a835a5f3
3 files changed
+49
-41
No files matched your search
@@ -52,14 +52,17 @@ export type ParallelAction = AutomationActionNodeBase<{
|
||||
}>;
|
||||
export type ActionTypeMapping = {
|
||||
service: ServiceAction;
|
||||
repeat: RepeatAction;
|
||||
wait: WaitAction | DelayAction;
|
||||
event: FireEventAction;
|
||||
device: DeviceAction;
|
||||
stop: StopAction;
|
||||
|
||||
event: FireEventAction;
|
||||
scene: SceneAction;
|
||||
|
||||
repeat: RepeatAction;
|
||||
choose: ChooseAction;
|
||||
parallel: ParallelAction;
|
||||
scene: SceneAction;
|
||||
|
||||
wait: WaitAction | DelayAction;
|
||||
stop: StopAction;
|
||||
};
|
||||
export type AutomationAction =
|
||||
| ServiceAction
|
||||
|
||||
@@ -32,19 +32,22 @@ export type AutomationTriggerCalendar = st.Infer<
|
||||
>;
|
||||
|
||||
export type ActionTriggerMapping = {
|
||||
homeassistant: AutomationTriggerHA;
|
||||
device: AutomationTriggerDevice;
|
||||
|
||||
event: AutomationTriggerEvent;
|
||||
mqtt: AutomationTriggerMQTT;
|
||||
numeric_state: AutomationTriggerNumericState;
|
||||
state: AutomationTriggerState;
|
||||
homeassistant: AutomationTriggerHA;
|
||||
tag: AutomationTriggerTag;
|
||||
template: AutomationTriggerTemplate;
|
||||
time: AutomationTriggerTime;
|
||||
webhook: AutomationTriggerWebhook;
|
||||
zone: AutomationTriggerZone;
|
||||
sun: AutomationTriggerSun;
|
||||
calendar: AutomationTriggerCalendar;
|
||||
webhook: AutomationTriggerWebhook;
|
||||
|
||||
numeric_state: AutomationTriggerNumericState;
|
||||
state: AutomationTriggerState;
|
||||
zone: AutomationTriggerZone;
|
||||
|
||||
template: AutomationTriggerTemplate;
|
||||
time: AutomationTriggerTime;
|
||||
};
|
||||
|
||||
export type TriggerType = keyof ActionTriggerMapping;
|
||||
|
||||
@@ -13,15 +13,7 @@ export const AutomationActionNodeBase = st.type({
|
||||
continue_on_error: st.optional(st.boolean()),
|
||||
});
|
||||
|
||||
export const ServiceAction = st.intersection([
|
||||
AutomationActionNodeBase,
|
||||
st.type({
|
||||
data: st.any(),
|
||||
target: st.any(),
|
||||
service: st.string(),
|
||||
}),
|
||||
]);
|
||||
|
||||
// Flow Actions
|
||||
export const RepeatAction = st.intersection([
|
||||
AutomationActionNodeBase,
|
||||
st.type({
|
||||
@@ -59,19 +51,6 @@ export const DelayAction = st.intersection([
|
||||
}),
|
||||
]);
|
||||
|
||||
export const FireEventAction = st.intersection([
|
||||
AutomationActionNodeBase,
|
||||
st.type({
|
||||
event: st.string(),
|
||||
event_data: st.any(),
|
||||
}),
|
||||
]);
|
||||
|
||||
export const DeviceAction = st.assign(
|
||||
AutomationActionNodeBase,
|
||||
st.partial(AutomationDeviceState)
|
||||
);
|
||||
|
||||
export const StopAction = st.assign(
|
||||
AutomationActionNodeBase,
|
||||
st.type({
|
||||
@@ -79,13 +58,6 @@ export const StopAction = st.assign(
|
||||
})
|
||||
);
|
||||
|
||||
export const SceneAction = st.assign(
|
||||
AutomationActionNodeBase,
|
||||
st.type({
|
||||
scene: st.string(),
|
||||
})
|
||||
);
|
||||
|
||||
export const OriginalChooseAction = st.intersection([
|
||||
AutomationActionNodeBase,
|
||||
st.type({
|
||||
@@ -116,3 +88,33 @@ export const ParallelAction = st.intersection([
|
||||
parallel: st.array(st.object()),
|
||||
}),
|
||||
]);
|
||||
|
||||
// Real Actions
|
||||
export const ServiceAction = st.intersection([
|
||||
AutomationActionNodeBase,
|
||||
st.type({
|
||||
data: st.any(),
|
||||
target: st.any(),
|
||||
service: st.string(),
|
||||
}),
|
||||
]);
|
||||
|
||||
export const FireEventAction = st.intersection([
|
||||
AutomationActionNodeBase,
|
||||
st.type({
|
||||
event: st.string(),
|
||||
event_data: st.any(),
|
||||
}),
|
||||
]);
|
||||
|
||||
export const DeviceAction = st.assign(
|
||||
AutomationActionNodeBase,
|
||||
st.partial(AutomationDeviceState)
|
||||
);
|
||||
|
||||
export const SceneAction = st.assign(
|
||||
AutomationActionNodeBase,
|
||||
st.type({
|
||||
scene: st.string(),
|
||||
})
|
||||
);
|
||||
Reference in new issue
Block a user