Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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