I am trying to create a Rule that will fire at 10:00pm and only if a door is locked and closed.
i wrote the following but got an error when trying to perform the rules:create function in the CLI
i first wrote this as an IF\AND with all three conditions in the add cluster (datetime, reference, offset, etc) but this didn’t trigger at the specified time, so i rewrote it with the every\Specific and put the test for the closed and lock as in IF inside the actions, which is throwing an error
1st approach
{
"if": {
"and": [
{
"equals": {
"left": {
"device": {
"devices": [
"616651dc-a473-4129-b051-661fcfe2ed5f"
],
"component": "main",
"capability": "lock",
"attribute": "lock"
}
},
"right": {
"string": "locked"
}
}
},
{
"equals": {
"left": {
"device": {
"devices": [
"a1df7c9b-2fcd-49e8-aa69-c9745c451e4c"
],
"component": "main",
"capability": "contactSensor",
"attribute": "contact"
}
},
"right": {
"string": "closed"
}
}
},
{
"equals": {
"left": {
"datetime": {
"reference": "Midnight",
"offset": {
"value": {
"integer": -120
},
"unit": "Minute"
}
}
},
"right": {
"datetime": {
"reference": "Now"
}
}
}
}
],
"then": [
{
"command": {
"devices": [
"49cdd33c-aa3d-4610-8c6e-a9ba701aabc0"
],
"commands": [
{
"component": "main",
"capability": "switch",
"command": "off",
"arguments": []
}
]
}
}
]
}
}
2nd Approach
{
"name": "ShutOffAtNight test",
"actions": [
{
"every": {
"specific": {
"reference": "Midnight",
"offset": {
"value": {
"integer": -120
},
"unit": "Minute"
}
},
"actions": [
{
"if": {
"and": [
{
"equals": {
"left": {
"device": {
"devices": [
"616651dc-a473-4129-b051-661fcfe2ed5f"
],
"component": "main",
"capability": "lock",
"attribute": "lock"
}
},
"right": {
"string": "locked"
}
}
},
{
"equals": {
"left": {
"device": {
"devices": [
"a1df7c9b-2fcd-49e8-aa69-c9745c451e4c"
],
"component": "main",
"capability": "contactSensor",
"attribute": "contact"
}
},
"right": {
"string": "closed"
}
}
}
],
"then": [
{
"command": {
"devices": [
"49cdd33c-aa3d-4610-8c6e-a9ba701aabc0"
],
"commands": [
{
"component": "main",
"capability": "switch",
"command": "off",
"arguments": []
}
]
}
}
]
}
}
]
}
}
]
}
and the error from the 2nd appoach,
? Select a location. 1
Error: Request failed with status code 500: {"requestId":"8868242A-FC72-46BF-89C0-3FB5627C7957","error":{"code":"UnexpectedError","message":"A non-recoverable error condition occurred.","details":[]}}
C:\Program Files (x86)\SmartThings>
what i am i doing wrong?