From 8a90b56ac321a770a28243f558cf77dca3af8b55 Mon Sep 17 00:00:00 2001 From: Ari Date: Mon, 30 May 2022 15:20:42 -0400 Subject: [PATCH] fixed tsc --- .../NodeEditor/OptionManager/ActionDevice.tsx | 27 +++++-------------- webapp/src/haService/connection.ts | 2 +- webapp/src/types/validators/actions.ts | 6 ++--- 3 files changed, 11 insertions(+), 24 deletions(-) diff --git a/webapp/src/components/NodeEditor/OptionManager/ActionDevice.tsx b/webapp/src/components/NodeEditor/OptionManager/ActionDevice.tsx index ebf5599..543fd62 100644 --- a/webapp/src/components/NodeEditor/OptionManager/ActionDevice.tsx +++ b/webapp/src/components/NodeEditor/OptionManager/ActionDevice.tsx @@ -7,42 +7,29 @@ import { OptionManager, updateActionData } from './OptionManager'; export const ActionDeviceState: OptionManager = { defaultState: () => ({ alias: "", - type: "", - entity_id: "", - device_id: "", - domain: "", }), - isReady: ({ - alias, - type, - entity_id, - device_id, - domain, - }) => ( - alias !== '' && - type !== "" && - entity_id !== "" && - device_id !== "" && - domain !== "" - ), + isReady: () => true, renderOptionList: (state, setState) => { const update = updateActionData(state, setState); return <> update({ device_id })} /> update({ type })} /> update({ entity_id, domain: entity_id.split('.')[0] })} + onChange={entity_id => update({ + entity_id: entity_id ? entity_id : undefined, + domain: entity_id ? entity_id.split('.')[0] : "" + })} /> } diff --git a/webapp/src/haService/connection.ts b/webapp/src/haService/connection.ts index d875fb0..9d8bcc5 100644 --- a/webapp/src/haService/connection.ts +++ b/webapp/src/haService/connection.ts @@ -79,7 +79,7 @@ async function startHAConnection() { } catch (error) { haConnection = { status: 'error', - error: translateErrorCodes(error), + error: translateErrorCodes(error as any), } throw error } diff --git a/webapp/src/types/validators/actions.ts b/webapp/src/types/validators/actions.ts index 1e5f0a9..ee51cbc 100644 --- a/webapp/src/types/validators/actions.ts +++ b/webapp/src/types/validators/actions.ts @@ -46,10 +46,10 @@ export const FireEventAction = st.intersection([ export const DeviceAction = st.intersection([ AutomationActionNodeBase, st.type({ - type: st.string(), - device_id: st.string(), + type: st.optional(st.string()), + device_id: st.optional(st.string()), entity_id: st.optional(st.string()), - domain: st.string(), + domain: st.optional(st.string()), }) ]);