i just ran into an interesting issue due to not having the else if. i have a rule that if a light switch is double tapped down, then set the level at 1, if double tapped up, then set the level to 100. i have this for 8 rooms, and to avoid 16 rules, i added them in one as @nayelyz had suggested
actions
if (switch A double down) then…
if (switch A double up) then…
if (switch B double down) then…
if (switch B double up) then…
…
what actually happened was, if i hit switch A double down, then ALL THE OTHER LIGHTS TURNED on… certainly not what i would expect. now i need to break this into separate rules?
{
"name": "Switch DBL Click (Dim)",
"actions": [
{
"if": {
"equals": {
"left": {
"device": {
"devices": [
"{switch A UID}"
],
"component": "main",
"capability": "button",
"attribute": "button"
}
},
"right": {
"string": "down_2x"
}
},
"then": [
{
"command": {
"devices": [
"{switch A UID}"
],
"commands": [
{
"component": "main",
"capability": "switchLevel",
"command": "setLevel",
"arguments": [
{
"integer": 1
}
]
}
]
}
}
]
}
},
{
"if": {
"equals": {
"left": {
"device": {
"devices": [
"{switch A UID}"
],
"component": "main",
"capability": "button",
"attribute": "button"
}
},
"right": {
"string": "up_2x"
}
},
"then": [
{
"command": {
"devices": [
"{switch A UID}"
],
"commands": [
{
"component": "main",
"capability": "switchLevel",
"command": "setLevel",
"arguments": [
{
"integer": 100
}
]
}
]
}
}
]
}
},
{
"if": {
"equals": {
"left": {
"device": {
"devices": [
"{switch B UID}"
],
"component": "main",
"capability": "button",
"attribute": "button"
}
},
"right": {
"string": "down_2x"
}
},
"then": [
{
"command": {
"devices": [
"{switch B UID}"
],
"commands": [
{
"component": "main",
"capability": "switchLevel",
"command": "setLevel",
"arguments": [
{
"integer": 1
}
]
}
]
}
}
]
}
},
{
"if": {
"equals": {
"left": {
"device": {
"devices": [
"{switch B UID}"
],
"component": "main",
"capability": "button",
"attribute": "button"
}
},
"right": {
"string": "up_2x"
}
},
"then": [
{
"command": {
"devices": [
"{switch B UID}"
],
"commands": [
{
"component": "main",
"capability": "switchLevel",
"command": "setLevel",
"arguments": [
{
"integer": 100
}
]
}
]
}
}
]
}
},
{
"if": {
"equals": {
"left": {
"device": {
"devices": [
"{switch C UID}"
],
"component": "main",
"capability": "button",
"attribute": "button"
}
},
"right": {
"string": "down_2x"
}
},
"then": [
{
"command": {
"devices": [
"{switch C UID}"
],
"commands": [
{
"component": "main",
"capability": "switchLevel",
"command": "setLevel",
"arguments": [
{
"integer": 1
}
]
}
]
}
}
]
}
},
{
"if": {
"equals": {
"left": {
"device": {
"devices": [
"{switch C UID}"
],
"component": "main",
"capability": "button",
"attribute": "button"
}
},
"right": {
"string": "up_2x"
}
},
"then": [
{
"command": {
"devices": [
"{switch C UID}"
],
"commands": [
{
"component": "main",
"capability": "switchLevel",
"command": "setLevel",
"arguments": [
{
"integer": 100
}
]
}
]
}
}
]
}
},
{
"if": {
"equals": {
"left": {
"device": {
"devices": [
"{switch D UID}"
],
"component": "main",
"capability": "button",
"attribute": "button"
}
},
"right": {
"string": "down_2x"
}
},
"then": [
{
"command": {
"devices": [
"{switch D UID}"
],
"commands": [
{
"component": "main",
"capability": "switchLevel",
"command": "setLevel",
"arguments": [
{
"integer": 1
}
]
}
]
}
}
]
}
},
{
"if": {
"equals": {
"left": {
"device": {
"devices": [
"{switch D UID}"
],
"component": "main",
"capability": "button",
"attribute": "button"
}
},
"right": {
"string": "up_2x"
}
},
"then": [
{
"command": {
"devices": [
"{switch D UID}"
],
"commands": [
{
"component": "main",
"capability": "switchLevel",
"command": "setLevel",
"arguments": [
{
"integer": 100
}
]
}
]
}
}
]
}
},
{
"if": {
"equals": {
"left": {
"device": {
"devices": [
"{switch E UID}"
],
"component": "main",
"capability": "button",
"attribute": "button"
}
},
"right": {
"string": "down_2x"
}
},
"then": [
{
"command": {
"devices": [
"{switch E UID}"
],
"commands": [
{
"component": "main",
"capability": "switchLevel",
"command": "setLevel",
"arguments": [
{
"integer": 1
}
]
}
]
}
}
]
}
},
{
"if": {
"equals": {
"left": {
"device": {
"devices": [
"{switch E UID}"
],
"component": "main",
"capability": "button",
"attribute": "button"
}
},
"right": {
"string": "up_2x"
}
},
"then": [
{
"command": {
"devices": [
"{switch E UID}"
],
"commands": [
{
"component": "main",
"capability": "switchLevel",
"command": "setLevel",
"arguments": [
{
"integer": 100
}
]
}
]
}
}
]
}
},
{
"if": {
"equals": {
"left": {
"device": {
"devices": [
"{switch F UID}"
],
"component": "main",
"capability": "button",
"attribute": "button"
}
},
"right": {
"string": "down_2x"
}
},
"then": [
{
"command": {
"devices": [
"{switch F UID}"
],
"commands": [
{
"component": "main",
"capability": "switchLevel",
"command": "setLevel",
"arguments": [
{
"integer": 1
}
]
}
]
}
}
]
}
},
{
"if": {
"equals": {
"left": {
"device": {
"devices": [
"{switch F UID}"
],
"component": "main",
"capability": "button",
"attribute": "button"
}
},
"right": {
"string": "up_2x"
}
},
"then": [
{
"command": {
"devices": [
"{switch F UID}"
],
"commands": [
{
"component": "main",
"capability": "switchLevel",
"command": "setLevel",
"arguments": [
{
"integer": 100
}
]
}
]
}
}
]
}
},
{
"if": {
"equals": {
"left": {
"device": {
"devices": [
"{switch G UID}"
],
"component": "main",
"capability": "button",
"attribute": "button"
}
},
"right": {
"string": "down_2x"
}
},
"then": [
{
"command": {
"devices": [
"{switch G UID}"
],
"commands": [
{
"component": "main",
"capability": "switchLevel",
"command": "setLevel",
"arguments": [
{
"integer": 1
}
]
}
]
}
}
]
}
},
{
"if": {
"equals": {
"left": {
"device": {
"devices": [
"{switch G UID}"
],
"component": "main",
"capability": "button",
"attribute": "button"
}
},
"right": {
"string": "up_2x"
}
},
"then": [
{
"command": {
"devices": [
"{switch G UID}"
],
"commands": [
{
"component": "main",
"capability": "switchLevel",
"command": "setLevel",
"arguments": [
{
"integer": 100
}
]
}
]
}
}
]
}
},
{
"if": {
"equals": {
"left": {
"device": {
"devices": [
"{switch H UID}"
],
"component": "main",
"capability": "button",
"attribute": "button"
}
},
"right": {
"string": "down_2x"
}
},
"then": [
{
"command": {
"devices": [
"{switch H UID}"
],
"commands": [
{
"component": "main",
"capability": "switchLevel",
"command": "setLevel",
"arguments": [
{
"integer": 1
}
]
}
]
}
}
]
}
},
{
"if": {
"equals": {
"left": {
"device": {
"devices": [
"{switch H UID}"
],
"component": "main",
"capability": "button",
"attribute": "button"
}
},
"right": {
"string": "up_2x"
}
},
"then": [
{
"command": {
"devices": [
"{switch H UID}"
],
"commands": [
{
"component": "main",
"capability": "switchLevel",
"command": "setLevel",
"arguments": [
{
"integer": 100
}
]
}
]
}
}
]
}
}
]
}