Hello @Shanapadila,
You can achieve these two cases using the Rules API, below you can find the two samples:
Sample 1 - Turn off devices 20 min after closing the garage door.
Workflow:
- IF the door is closed
- THEN set a 20-minute timer and turn off the listed devices
{
"name":"Timer to turn devices off when garage door is closed",
"actions": [
{
"if":{
"equals": {
"left": {
"device": {
"devices": [
"door-deviceID"
],
"component": "main",
"capability": "doorControl",
"attribute": "door"
}
},
"right": {
"string": "closed"
}
},
"then":[
{
"sleep": {
"duration": {
"value": {
"integer": 20
},
"unit": "Minute"
}
}
},
{
"command": {
"devices": [
"switch-deviceID 1","switch-deviceID 2","switch-deviceID 3",...
],
"commands": [
{
"component": "main",
"capability": "switch",
"command": "off"
}
]
}
}
]
}
}
]
}
Sample 2 - Check that everything is closed when the AC is turned ON
Workflow:
- IF the AC is turned on
- THEN, IF ANY of the contact sensors has a state of “open”
- THEN turn on the virtual switch (now you can proceed with the steps for Alexa)
- Otherwise, turn Off the virtual switch
{
"name":"Check if everything is closed when the AC is turned on",
"actions": [
{
"if":{
"equals": {
"left": {
"device": {
"devices": [
"AC device-ID"
],
"component": "main",
"capability": "switch",
"attribute": "switch"
}
},
"right": {
"string": "on"
}
},
"then":[
{
"if": {
"or": [
{
"equals": {
"left": {
"device": {
"devices": [
"contact sensor device-ID 1","contact sensor device-ID 2",...
],
"component": "main",
"capability": "contactSensor",
"attribute": "contact"
}
},
"right": {
"string": "open"
}
}
}
],
"then":[
{
"command": {
"devices": [
"virtual switch device-ID"
],
"commands": [
{
"component": "main",
"capability": "switch",
"command": "on"
}
]
}
}
],
"else":[
{
"command": {
"devices": [
"virtual switch device-ID"
],
"commands": [
{
"component": "main",
"capability": "switch",
"command": "off"
}
]
}
}
]
}
}
]
}
}
]
}
The instructions to install the Rule can be found at this thread. As specified there, you need to replace the device IDs with the corresponding values.
For more information about capabilities, you can check this document
Let me know if you have any doubts.