fixed trigger device validation
This commit is contained in:
1 parent
d22bba8c4d
commit
ab7f50d4aa
4 files changed
+18
-13
No files matched your search
@@ -104,6 +104,9 @@ export const createUpdater = (
|
||||
}),
|
||||
trigger: createBasicUpdater("trigger", {
|
||||
platform: "device",
|
||||
domain: "",
|
||||
type: "",
|
||||
device_id: "",
|
||||
})({
|
||||
trigger: args.trigger,
|
||||
openModal: args.openModal,
|
||||
|
||||
@@ -5,6 +5,9 @@ import { DeviceEditor } from "components/DeviceEditor";
|
||||
export const TriggerDevice: OptionManager<AutomationTriggerDevice> = {
|
||||
defaultState: () => ({
|
||||
platform: "device",
|
||||
device_id: "",
|
||||
domain: "",
|
||||
type: "",
|
||||
}),
|
||||
isReady: () => true,
|
||||
Component: ({ state, setState, ha }) => {
|
||||
@@ -27,6 +30,9 @@ export const TriggerDevice: OptionManager<AutomationTriggerDevice> = {
|
||||
setState={(s) =>
|
||||
setState({
|
||||
platform: "device",
|
||||
device_id: "",
|
||||
domain: "",
|
||||
type: "",
|
||||
...s,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -48,13 +48,14 @@ export const AutomationTimeObject = st.object({
|
||||
milliseconds: st.optional(st.number()),
|
||||
});
|
||||
export const AutomationTime = st.union([st.string(), AutomationTimeObject]);
|
||||
export const AutomationDeviceState = st.type({
|
||||
export const _AutomationDeviceState = {
|
||||
subtype: st.optional(st.string()),
|
||||
entity_id: st.optional(st.string()),
|
||||
type: st.string(),
|
||||
device_id: st.string(),
|
||||
domain: st.string(),
|
||||
});
|
||||
};
|
||||
export const AutomationDeviceState = st.type(_AutomationDeviceState);
|
||||
export const DayOfWeek = st.enums([
|
||||
"mon",
|
||||
"tue",
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
import * as st from "superstruct";
|
||||
import {
|
||||
AutomationTime,
|
||||
AutomationDeviceState,
|
||||
} from "./common";
|
||||
import { AutomationTime, _AutomationDeviceState } from "./common";
|
||||
|
||||
const AutomationTriggerBase = {
|
||||
id: st.optional(st.string()),
|
||||
@@ -99,13 +96,11 @@ export const AutomationTriggerZone = st.type({
|
||||
event: st.enums(["enter", "leave"]),
|
||||
});
|
||||
|
||||
export const AutomationTriggerDevice = st.assign(
|
||||
st.partial(AutomationDeviceState),
|
||||
st.type({
|
||||
...AutomationTriggerBase,
|
||||
platform: st.literal("device"),
|
||||
})
|
||||
);
|
||||
export const AutomationTriggerDevice = st.type({
|
||||
...AutomationTriggerBase,
|
||||
..._AutomationDeviceState,
|
||||
platform: st.literal("device"),
|
||||
});
|
||||
|
||||
export const AutomationTrigger = st.union([
|
||||
AutomationTriggerEvent,
|
||||
|
||||
Reference in new issue
Block a user