removed $smType for conditions and trigger
This commit is contained in:
1 parent
49fea3fabd
commit
429dfd5b50
41 files changed
+410
-723
No files matched your search
@@ -49,39 +49,28 @@ Simple.args = {
|
||||
...Simple.args,
|
||||
trigger: [
|
||||
{
|
||||
"$smType": undefined,
|
||||
"platform": "numeric_state",
|
||||
"entity_id": "test",
|
||||
},
|
||||
{
|
||||
"$smType": undefined,
|
||||
"platform": "homeassistant",
|
||||
"event": "start",
|
||||
}
|
||||
],
|
||||
sequence: [
|
||||
{
|
||||
$smType: "condition",
|
||||
condition: 'and',
|
||||
condition_data: {
|
||||
conditions: [
|
||||
{
|
||||
$smType: 'condition',
|
||||
condition: 'numeric_state',
|
||||
condition_data: {
|
||||
entity_id: 'sensor.temperature_kitchen',
|
||||
below: '15',
|
||||
}
|
||||
},
|
||||
{
|
||||
$smType: "condition",
|
||||
condition: 'template',
|
||||
condition_data: {
|
||||
value_template: 'states(switch.kitchen_light) == "on"'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
conditions: [
|
||||
{
|
||||
condition: 'numeric_state',
|
||||
entity_id: 'sensor.temperature_kitchen',
|
||||
below: '15',
|
||||
},
|
||||
{
|
||||
condition: 'template',
|
||||
value_template: 'states(switch.kitchen_light) == "on"'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
$smType: "action",
|
||||
@@ -107,39 +96,28 @@ Complex.args = {
|
||||
...Complex.args,
|
||||
trigger: [
|
||||
{
|
||||
"$smType": undefined,
|
||||
"platform": "numeric_state",
|
||||
"entity_id": "test",
|
||||
},
|
||||
{
|
||||
"$smType": undefined,
|
||||
"platform": "homeassistant",
|
||||
"event": "start",
|
||||
}
|
||||
],
|
||||
sequence: [
|
||||
{
|
||||
"$smType": "condition",
|
||||
"condition": "and",
|
||||
"condition_data": {
|
||||
"conditions": [
|
||||
{
|
||||
"$smType": "condition",
|
||||
"condition": "numeric_state",
|
||||
"condition_data": {
|
||||
"entity_id": "sensor.temperature_kitchen",
|
||||
"below": "15"
|
||||
}
|
||||
},
|
||||
{
|
||||
"$smType": "condition",
|
||||
"condition": "template",
|
||||
"condition_data": {
|
||||
"value_template": "states(switch.kitchen_light) == \"on\""
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
"conditions": [
|
||||
{
|
||||
"condition": "numeric_state",
|
||||
"entity_id": "sensor.temperature_kitchen",
|
||||
"below": "15"
|
||||
},
|
||||
{
|
||||
"condition": "template",
|
||||
"value_template": "states(switch.kitchen_light) == \"on\""
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"$smType": "action",
|
||||
@@ -164,12 +142,9 @@ Complex.args = {
|
||||
{
|
||||
"conditions": [
|
||||
{
|
||||
"$smType": "condition",
|
||||
"condition": "state",
|
||||
"condition_data": {
|
||||
"entity_id": "lights.bathroom",
|
||||
"state": "off",
|
||||
}
|
||||
"entity_id": "lights.bathroom",
|
||||
"state": "off",
|
||||
}
|
||||
],
|
||||
"sequence": [
|
||||
@@ -201,12 +176,9 @@ Complex.args = {
|
||||
{
|
||||
"conditions": [
|
||||
{
|
||||
"$smType": "condition",
|
||||
"condition": "state",
|
||||
"condition_data": {
|
||||
"entity_id": "lights.bedroom",
|
||||
"state": "off",
|
||||
}
|
||||
"entity_id": "lights.bedroom",
|
||||
"state": "off",
|
||||
}
|
||||
],
|
||||
"sequence": [
|
||||
@@ -272,11 +244,8 @@ Complex.args = {
|
||||
}
|
||||
},
|
||||
{
|
||||
"$smType": "condition",
|
||||
"condition": "and",
|
||||
"condition_data": {
|
||||
"conditions": []
|
||||
}
|
||||
"conditions": []
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -72,8 +72,7 @@ export const DAGAutomationFlow: FC<Props> = ({
|
||||
onAdd: () => onTriggerUpdate([
|
||||
...trigger, {
|
||||
platform: 'event',
|
||||
$smType: 'trigger',
|
||||
event_type: 'test',
|
||||
event_type: '',
|
||||
}
|
||||
]),
|
||||
onDelete: i => onTriggerUpdate([
|
||||
|
||||
@@ -5,6 +5,7 @@ import { XYPosition } from 'react-flow-renderer';
|
||||
import { ChooseAction } from 'types/automations/actions';
|
||||
import { makeFlowCircle } from './DAGCircle';
|
||||
import { createOnRemoveForChooseNode, SequenceUpdater } from './updater';
|
||||
import { getNodeType } from 'utils/automations';
|
||||
|
||||
|
||||
export const sequenceToFlow = (
|
||||
@@ -34,7 +35,7 @@ export const sequenceToFlow = (
|
||||
};
|
||||
}
|
||||
// draw node
|
||||
if (node.$smType === 'action') {
|
||||
if ('$smType' in node && node.$smType === 'action') {
|
||||
if (node.action === 'choose') {
|
||||
position = addChooseNode(flowData, node, position, nodeId, dims, updater, i)
|
||||
} else {
|
||||
@@ -102,7 +103,7 @@ const addSingleNode = (
|
||||
label: getDescriptionFromAutomationNode(node),
|
||||
height: nodeHeight,
|
||||
width: nodeWidth,
|
||||
color: node.$smType === 'action' ? 'green' : 'blue',
|
||||
color: getNodeType(node) === 'action' ? 'green' : 'blue',
|
||||
hasInput: true,
|
||||
...opts,
|
||||
},
|
||||
|
||||
@@ -73,11 +73,8 @@ test('update conditions for node', () => {
|
||||
expect((mock.modalStates[0].node as AutomationSequenceNode[]).length).toBe(0)
|
||||
mock.modalStates[0].update([
|
||||
{
|
||||
"$smType": "condition",
|
||||
"condition": "and",
|
||||
"condition_data": {
|
||||
"conditions": [],
|
||||
}
|
||||
"conditions": [],
|
||||
}
|
||||
] as any)
|
||||
expect((mock.state[0] as ChooseAction).action_data.choose[0].conditions.length).toBe(1)
|
||||
|
||||
@@ -53,7 +53,7 @@ export const makeSequenceUpdater = (
|
||||
},
|
||||
makeChildUpdaterForChooseAction(i: number, j: number | null) {
|
||||
const node = sequence[i];
|
||||
if ((node.$smType === 'action') && (node.action === 'choose')) {
|
||||
if (('$smType' in node) && (node.$smType === 'action') && (node.action === 'choose')) {
|
||||
if (j !== null) {
|
||||
return makeSequenceUpdater(
|
||||
node.action_data.choose[j].sequence,
|
||||
|
||||
Reference in new issue
Block a user