Last active
June 23, 2021 18:19
-
-
Save nayelyzarazua-bluetrail/43705341da226d1d4054aba08c2abf93 to your computer and use it in GitHub Desktop.
Precondition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "Sample for precondition", | |
"actions": [ | |
{ | |
"if":{ | |
"equals": { | |
"left":{ | |
"string": "pushed" | |
}, | |
"right":{ | |
"device":{ | |
"devices":["button-device-id"], | |
"component": "main", | |
"capability":"button", | |
"attribute":"button", | |
"trigger":"Always" | |
} | |
} | |
}, | |
"then":[ | |
{ | |
"if": { | |
"equals": { | |
"left": { | |
"device": { | |
"devices": [ | |
"switch1-device-id" | |
], | |
"component": "main", | |
"capability": "switch", | |
"attribute": "switch", | |
"trigger":"Never" | |
} | |
}, | |
"right": { | |
"string": "on" | |
} | |
},"then":[ | |
{ | |
"command": { | |
"devices": [ | |
"switch2-device-id" | |
], | |
"commands": [ | |
{ | |
"component": "main", | |
"capability": "switch", | |
"command": "on", | |
"arguments": [] | |
} | |
] | |
} | |
}],"else":[{ | |
"command": { | |
"devices": [ | |
"switch2-device-id" | |
], | |
"commands": [ | |
{ | |
"component": "main", | |
"capability": "switch", | |
"command": "off", | |
"arguments": [] | |
} | |
] | |
} | |
}] | |
} | |
} | |
] | |
} | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "Sample for precondition scenario 2", | |
"actions": [ | |
{ | |
"if": { | |
"and": [ | |
{ | |
"equals": { | |
"left": { | |
"string": "pushed" | |
}, | |
"right": { | |
"device": { | |
"devices": [ | |
"button-device-id" | |
], | |
"component": "main", | |
"capability": "button", | |
"attribute": "button" | |
} | |
} | |
} | |
}, | |
{ | |
"equals": { | |
"left": { | |
"device": { | |
"devices": [ | |
"switch1-device-id" | |
], | |
"component": "main", | |
"capability": "switch", | |
"attribute": "switch", | |
"trigger": "Never" | |
} | |
}, | |
"right": { | |
"string": "on" | |
} | |
} | |
} | |
], | |
"then": [ | |
{ | |
"command": { | |
"devices": [ | |
"switch2-device-id" | |
], | |
"commands": [ | |
{ | |
"component": "main", | |
"capability": "switch", | |
"command": "on" | |
} | |
] | |
} | |
} | |
], | |
"else": [ | |
{ | |
"command": { | |
"devices": [ | |
"switch2-device-id" | |
], | |
"commands": [ | |
{ | |
"component": "main", | |
"capability": "switch", | |
"command": "off" | |
} | |
] | |
} | |
} | |
] | |
} | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment