minor clean up

This commit is contained in:
ari committed 2022-08-08 20:53:31 -04:00
1 parent 107def4fac
commit e6a835a5f3
3 files changed
+49 -41

No files matched your search

+8 -5
View File
@@ -52,14 +52,17 @@ export type ParallelAction = AutomationActionNodeBase<{
}>; }>;
export type ActionTypeMapping = { export type ActionTypeMapping = {
service: ServiceAction; service: ServiceAction;
repeat: RepeatAction;
wait: WaitAction | DelayAction;
event: FireEventAction;
device: DeviceAction; device: DeviceAction;
stop: StopAction;
event: FireEventAction;
scene: SceneAction;
repeat: RepeatAction;
choose: ChooseAction; choose: ChooseAction;
parallel: ParallelAction; parallel: ParallelAction;
scene: SceneAction;
wait: WaitAction | DelayAction;
stop: StopAction;
}; };
export type AutomationAction = export type AutomationAction =
| ServiceAction | ServiceAction
+10 -7
View File
@@ -32,19 +32,22 @@ export type AutomationTriggerCalendar = st.Infer<
>; >;
export type ActionTriggerMapping = { export type ActionTriggerMapping = {
homeassistant: AutomationTriggerHA;
device: AutomationTriggerDevice; device: AutomationTriggerDevice;
event: AutomationTriggerEvent; event: AutomationTriggerEvent;
mqtt: AutomationTriggerMQTT; mqtt: AutomationTriggerMQTT;
numeric_state: AutomationTriggerNumericState; homeassistant: AutomationTriggerHA;
state: AutomationTriggerState;
tag: AutomationTriggerTag; tag: AutomationTriggerTag;
template: AutomationTriggerTemplate;
time: AutomationTriggerTime;
webhook: AutomationTriggerWebhook;
zone: AutomationTriggerZone;
sun: AutomationTriggerSun; sun: AutomationTriggerSun;
calendar: AutomationTriggerCalendar; calendar: AutomationTriggerCalendar;
webhook: AutomationTriggerWebhook;
numeric_state: AutomationTriggerNumericState;
state: AutomationTriggerState;
zone: AutomationTriggerZone;
template: AutomationTriggerTemplate;
time: AutomationTriggerTime;
}; };
export type TriggerType = keyof ActionTriggerMapping; export type TriggerType = keyof ActionTriggerMapping;
+31 -29
View File
@@ -13,15 +13,7 @@ export const AutomationActionNodeBase = st.type({
continue_on_error: st.optional(st.boolean()), continue_on_error: st.optional(st.boolean()),
}); });
export const ServiceAction = st.intersection([ // Flow Actions
AutomationActionNodeBase,
st.type({
data: st.any(),
target: st.any(),
service: st.string(),
}),
]);
export const RepeatAction = st.intersection([ export const RepeatAction = st.intersection([
AutomationActionNodeBase, AutomationActionNodeBase,
st.type({ 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( export const StopAction = st.assign(
AutomationActionNodeBase, AutomationActionNodeBase,
st.type({ 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([ export const OriginalChooseAction = st.intersection([
AutomationActionNodeBase, AutomationActionNodeBase,
st.type({ st.type({
@@ -116,3 +88,33 @@ export const ParallelAction = st.intersection([
parallel: st.array(st.object()), 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(),
})
);