Skip to content

Instantly share code, notes, and snippets.

@nayelyzarazua-bluetrail
Last active June 23, 2021 18:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nayelyzarazua-bluetrail/43705341da226d1d4054aba08c2abf93 to your computer and use it in GitHub Desktop.
Save nayelyzarazua-bluetrail/43705341da226d1d4054aba08c2abf93 to your computer and use it in GitHub Desktop.
Precondition
{
"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": []
}
]
}
}]
}
}
]
}
}
]
}
{
"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