diff --git a/CHANGELOG.md b/CHANGELOG.md index adda864..84db7f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## [0.1.9] - Fixed up invalid types for various triggers + +- Some triggers had invalid types and were causing a false-positive validation + ## [0.1.8] - Support for Malformed Automations - API will no longer error out on missing values or invalid lists diff --git a/config.yaml b/config.yaml index ea5b288..df1f916 100644 --- a/config.yaml +++ b/config.yaml @@ -1,5 +1,5 @@ name: Shortumation -version: 0.1.8 +version: 0.1.9 slug: shortumation image: asosnovsky/shortumation-{arch} url: "https://github.com/asosnovsky/Shortumation" diff --git a/webapp/src/components/AutomationList/AutomationList.stories.tsx b/webapp/src/components/AutomationList/AutomationList.stories.tsx index e0d5d2e..0a98f97 100644 --- a/webapp/src/components/AutomationList/AutomationList.stories.tsx +++ b/webapp/src/components/AutomationList/AutomationList.stories.tsx @@ -62,6 +62,198 @@ FewAutos.args = { createMockAuto({ "Room": "Office", "Type": "Lights" }), createMockAuto({ "Room": "Office" }), createMockAuto(), + { + "metadata": { + "id": "1649947692702", + "alias": "Bed Remote", + "description": "", + "trigger_variables": null, + "mode": "single" + }, + "trigger": [ + { + "device_id": "asdasdasdas", + "domain": "zha", + "platform": "device", + "type": "remote_button_short_press", + "subtype": "turn_on", + "id": "turn_on" + }, + { + "device_id": "asdasdasdas", + "domain": "zha", + "platform": "device", + "type": "remote_button_short_press", + "subtype": "turn_off", + "id": "turn_off" + }, + { + "device_id": "asdasdasdas", + "domain": "zha", + "platform": "device", + "type": "remote_button_short_press", + "subtype": "dim_up", + "id": "dim_up" + }, + { + "device_id": "asdasdasdas", + "domain": "zha", + "platform": "device", + "type": "remote_button_short_press", + "subtype": "dim_down", + "id": "dim_down" + }, + { + "device_id": "asdasdasdas", + "domain": "zha", + "platform": "device", + "type": "remote_button_double_press", + "subtype": "turn_on", + "id": "up_dbclk" + } + ], + "condition": [], + "sequence": [ + { + "choose": [ + { + "conditions": [ + { + "condition": "trigger", + "id": "turn_off" + } + ], + "sequence": [ + { + "type": "turn_off", + "device_id": "asdasdasdasdas", + "entity_id": "light.bulb_ari_lamp", + "domain": "light" + } + ] + }, + { + "conditions": [ + { + "condition": "trigger", + "id": "turn_on" + } + ], + "sequence": [ + { + "service": "light.turn_on", + "data": { + "color_temp": 153, + "brightness_pct": 100 + }, + "target": { + "device_id": "asdasdasdasdas" + } + } + ] + }, + { + "conditions": [ + { + "condition": "trigger", + "id": "dim_up" + } + ], + "sequence": [ + { + "device_id": "asdasdasdasdas", + "domain": "light", + "entity_id": "light.bulb_ari_lamp", + "type": "brightness_increase" + } + ] + }, + { + "conditions": [ + { + "condition": "trigger", + "id": "dim_down" + } + ], + "sequence": [ + { + "device_id": "asdasdasdasdas", + "domain": "light", + "entity_id": "light.bulb_ari_lamp", + "type": "brightness_decrease" + } + ] + }, + { + "conditions": [ + { + "condition": "trigger", + "id": "up_dbclk" + } + ], + "sequence": [ + { + "service": "light.turn_on", + "data": { + "color_temp": 500, + "brightness_pct": 100 + }, + "target": { + "device_id": "asdasdasdasdas" + } + } + ] + } + ], + "default": [] + } + ], + "tags": { + "Type": "Remote", + "Room": "Bedroom" + } + }, + { + "metadata": { + "id": "1641617168123", + "alias": "Ensure On", + "description": "", + "trigger_variables": null, + "mode": "single" + }, + "trigger": [ + { + "platform": "device", + "type": "turned_off", + "device_id": "tasdasdasdasdasdasda", + "entity_id": "switch.power_washer", + "domain": "switch" + }, + { + "platform": "device", + "type": "turned_off", + "device_id": "dasdasdasdasdas", + "entity_id": "switch.plug_living_room_tv", + "domain": "switch" + } + ], + "condition": [], + "sequence": [ + { + "type": "turn_on", + "device_id": "tasdasdasdasdasdasda", + "entity_id": "switch.power_washer", + "domain": "switch" + }, + { + "type": "turn_on", + "device_id": "dasdasdasdasdas", + "entity_id": "switch.plug_living_room_tv", + "domain": "switch" + } + ], + "tags": {} + } ], } diff --git a/webapp/src/components/NodeEditor/OptionManager/TriggerDevice.tsx b/webapp/src/components/NodeEditor/OptionManager/TriggerDevice.tsx index 78e7454..0285a3f 100644 --- a/webapp/src/components/NodeEditor/OptionManager/TriggerDevice.tsx +++ b/webapp/src/components/NodeEditor/OptionManager/TriggerDevice.tsx @@ -11,6 +11,7 @@ export const TriggerDevice: OptionManager = { "type": "", "subtype": "", "device_id": "", + "entity_id": "", }), isReady: ({ alias }) => { return (alias !== '') @@ -33,6 +34,10 @@ export const TriggerDevice: OptionManager = { ...state, device_id })} /> + setState({ + ...state, + entity_id + })} /> } } diff --git a/webapp/src/types/validators/triggers.ts b/webapp/src/types/validators/triggers.ts index 4079dfa..c9e87fb 100644 --- a/webapp/src/types/validators/triggers.ts +++ b/webapp/src/types/validators/triggers.ts @@ -3,7 +3,8 @@ import { AutomationTime } from './common' const AutomationTriggerBase = { - alias: st.optional(st.string()) + alias: st.optional(st.string()), + id: st.optional(st.string()), } export const AutomationTriggerEvent = st.object({ @@ -94,10 +95,11 @@ export const AutomationTriggerZone = st.object({ export const AutomationTriggerDevice = st.object({ ...AutomationTriggerBase, platform: st.literal('device'), + entity_id: st.string(), device_id: st.string(), domain: st.string(), type: st.string(), - subtype: st.string(), + subtype: st.optional(st.string()), })