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