Keep the light display OFF when AC turns ON?

You can also check the ST Advanced Web App to see what/how many Rules you have created.

3 Likes

Hi,

Thank you, i didn’t know about this website.
I had 6 rules running at the same time ^^’

Thank again for all !
Now, all is cleared, i just have one rule.

It’s very hot here this week so i’ll be able to see if all is working as intended.

Thanks again, have a nice day :slight_smile:

1 Like

Thank you so much for the suggestion, @h0ckeysk8er
I’m so used to the CLI and the API directly that I forgot the Advanced Users app can modify Rules.

You can also use the community developed ST API Browser+ to manage Rules.

1 Like

Hi,

Sorry, it’s me again…^^’
I don’t understand why but my routine doesn’t work even if all appears to be OK.

If i try to execute it from API Browser +, it says this :
{
“actionId”: “DeviceID xxx”,
“if”: {
“result”: “False”
}
}

If it can helps, i did the routine through my phone to see what the json look like then and here it is :
[
{
“if”: {
“and”: [
{
“between”: {
“value”: {
“time”: {
“reference”: “Now”
},
“type”: “time”
},
“start”: {
“time”: {
“timeZoneId”: “Europe/Paris”,
“daysOfWeek”: [
“Sun”,
“Mon”,
“Tue”,
“Wed”,
“Thu”,
“Fri”,
“Sat”
],
“reference”: “Midnight”,
“offset”: {
“value”: {
“integer”: 0,
“type”: “integer”
},
“unit”: “Minute”
}
},
“type”: “time”
},
“end”: {
“time”: {
“timeZoneId”: “Europe/Paris”,
“daysOfWeek”: [
“Sun”,
“Mon”,
“Tue”,
“Wed”,
“Thu”,
“Fri”,
“Sat”
],
“reference”: “Midnight”,
“offset”: {
“value”: {
“integer”: 420,
“type”: “integer”
},
“unit”: “Minute”
}
},
“type”: “time”
},
“aggregation”: “Any”,
“changesOnly”: false
},
“type”: “between”
},
{
“greaterThanOrEquals”: {
“left”: {
“device”: {
“devices”: [
“DeviceID”
],
“component”: “main”,
“capability”: “temperatureMeasurement”,
“attribute”: “temperature”,
“trigger”: “Always”
},
“type”: “device”
},
“right”: {
“decimal”: 23,
“type”: “decimal”
},
“aggregation”: “Any”,
“changesOnly”: true
},
“type”: “greaterThanOrEquals”
}
],
“type”: “and”,
“then”: [
{
“group”: {
“actions”: [
{
“command”: {
“devices”: [
“DeviceID”
],
“commands”: [
{
“component”: “main”,
“capability”: “switch”,
“command”: “on”
},
{
“component”: “main”,
“capability”: “thermostatCoolingSetpoint”,
“command”: “setCoolingSetpoint”,
“arguments”: [
{
“decimal”: 19,
“type”: “decimal”
}
]
},
{
“component”: “main”,
“capability”: “airConditionerMode”,
“command”: “setAirConditionerMode”,
“arguments”: [
{
“string”: “cool”,
“type”: “string”
}
]
},
{
“component”: “main”,
“capability”: “custom.airConditionerOptionalMode”,
“command”: “setAcOptionalMode”,
“arguments”: [
{
“string”: “windFree”,
“type”: “string”
}
]
}
],
“sequence”: {
“commands”: “Serial”,
“devices”: “Serial”
}
},
“type”: “command”
},
{
“sleep”: {
“duration”: {
“value”: {
“integer”: 1500,
“type”: “integer”
},
“unit”: “Second”
},
“strategy”: “Interrupt”
},
“type”: “sleep”
},
{
“command”: {
“devices”: [
“DeviceID”
],
“commands”: [
{
“component”: “main”,
“capability”: “switch”,
“command”: “off”
}
],
“sequence”: {
“commands”: “Serial”,
“devices”: “Serial”
}
},
“type”: “command”
}
],
“sequence”: {
“actions”: “Serial”
}
},
“type”: “group”
}
],
“sequence”: {
“then”: “Parallel”,
“else”: “Parallel”
}
},
“type”: “if”
}
]

But if i try to activate it from Postman, i get a 422 error.

I’m desperate lol…

Hi all. Firstly thanks to those contributing to the previous posts. I’m a complete newbie but was able to use postman to turn the light off my air con unit using the post command.

I’m now looking to find out how I go about executing this code automatically at say 10pm every day.

I’ve never written a rule and not sure how I go about it. Is it possible for a total newb to do such a thing?!

Ok, let’s go step by step:

  1. The trigger issue can also be due to the timezone used in the Rule, as I mentioned for the other user having a similar problem, it should use the one in the location but if it’s not configured, it will use UTC, which means it’s a different time and would mean that the conditions defined aren’t met. I’ll add that property just in case.
  2. Also, in my sample, I used “changes” which causes the Rule to be triggered only if the value was below 23 but then changes to 23 or a greater number. I’ll remove that and use only “greaterThanOrEquals” to see if it helps as well.
  3. I see in your routine you used an offset of 7 hours from midnight, is that the time you want this Rule to stop being effective? I mean it would work from 0:00 hours to 7:00 hours. I’ll update this part as well, you can increase/decrease it as you like, I used the unit of hours instead of minutes, both should work the same.
{
    "name": "If temp above or equals to 23 turn AC on and display off",
    "actions": [
        {
            "if": {
                "and": [
                    {
                        "greaterThanOrEquals": {
                            "left": {
                                "device": {
                                    "devices": [
                                        "AC deviceID"
                                    ],
                                    "component": "main",
                                    "capability": "temperatureMeasurement",
                                    "attribute": "temperature"
                                }
                            },
                            "right": {
                                "integer": 23
                            }
                        }
                    },
                    {
                        "between": {
                            "value": {
                                "time": {
                                    "reference": "Now"
                                }
                            },
                            "start": {
                                "time": {
                                    "timeZoneId":"Europe/Paris",
                                    "reference": "Midnight"
                                }
                            },
                            "end": {
                                "time": {
                                    "timeZoneId":"Europe/Paris",
                                    "reference": "Midnight",
                                    "offset": {
                                        "value": {
                                            "integer": 7
                                        },
                                        "unit": "Hour"
                                    }
                                }
                            }
                        }
                    }
                ],
                "then": [
                    {
                        "command": {
                            "devices": [
                               "AC-device-ID"
                            ],
                            "commands": [
                                {
                                    "component": "main",
                                    "capability": "switch",
                                    "command": "on"
                                },
                                {
                                    "component": "main",
                                    "capability": "thermostatCoolingSetpoint",
                                    "command": "setCoolingSetpoint",
                                    "arguments": [
                                        {
                                            "integer":20
                                        }
                                    ]
                                },
                                {
                                    "component": "main",
                                    "capability": "airConditionerFanMode",
                                    "command": "setFanMode",
                                    "arguments": [
                                        {
                                            "string":"windfree"
                                        }
                                    ]
                                },
                                {
                                    "component": "main",
                                    "capability": "execute",
                                    "command": "execute",
                                    "arguments": [
                                        {"string": "mode/vs/0"},
                                        {"map": {"x.com.samsung.da.options": {"string":"Light_On"}}}
                                    ]
                                }
                            ]
                        }
                    },
                    {
                        "sleep":{
                            "duration":{
                                "value":{
                                "integer":25
                                },
                                "unit":"Minute"
                            }
                        }
                    },
                    {
                        "command": {
                            "devices": [
                                "AC-device-ID"
                            ],
                            "commands": [
                                {
                                    "component": "main",
                                    "capability": "switch",
                                    "command": "off"
                                }
                            ]
                        }
                    }
                ]
            }
        }
    ]
}

Please let me know if this helps.
Remember both conditions must be met:

  1. The AC must report a value of 23º or above
  2. The time is between 0:00 hours to 7:00 hours

Otherwise it won’t run.

Hi, @Paul_Wheeler. Welcome to the SmartThings Community!

Let me prepare a sample for you and some instructions now including the Advanced User’s app option to avoid you using Postman only.

Thank you. Can’t wait to see it!

ok, @Paul_Wheeler, here it is:

Rule’s configuration:

{
    "name": "Turn off a light at 10:00 pm",
    "actions": [
        {
            "every": {
                "specific": {
                    "timeZoneId":"yourTimezoneId",
                    "reference": "Midnight",
                    "offset": {
                        "value": {
                            "integer": -2
                        },
                        "unit": "Hour"
                    }
                },
                "actions": [
                    {
                        "command": {
                            "devices": [
                              "AC-DeviceID"
                            ],
                            "commands": [ 
                                {
                                    "component": "main",
                                    "capability": "execute",
                                    "command": "execute",
                                    "arguments": [
                                        {"string": "mode/vs/0"},
                                        {"map": {"x.com.samsung.da.options": {"string":"Light_On"}}}
                                    ]
                                }
                            ]
                        }
                    }    
                ]
            }
        }    
    ]
}

So, to create it on your location you need to follow these steps:

  1. Go to the Advanced Users app and log in to your SmartThings account.
  2. Go to the Locations section and find yours, enter its details, and see which timezone Id it has configured.
  3. Copy the Rule I shared above in a text editor (preferably something that won’t change its format like Notepad", quotes in the correct format (") are very important.
  4. Then, replace the text “yourTimezoneId” with the correct value.
  5. Now, go to the devices section and look for your AC device. Copy the device ID shown in the table next to its label and replace the text “AC-DeviceID” with that value.
  6. Now, make changes to the time reference if you need to. The current configuration is Noon+10 hours which means 10 PM.
  1. If everything is correct, go to the Rules section of the Advanced Users app and click on “Add a new Rule”
  2. Assign a name to the Rule and the location where it will be used (it must be the same as the AC device)
  3. Paste the JSON modified in the editor there but only the section after "actions:", for example:
  4. Click on “add” and test if it was created successfully.
1 Like

Wow thank you so much for that detailed reply! That is so helpful!

Sadly I am getting an error - at least one of the devices is not found in that location. However the device is definitely in that location. Do I need to define the room as well?

No, the room ID is not necessary. Can you share with me over DM the JSON you’re trying to save and a screen capture of the Device ID of the AC, please?

I appear to be failing at the most basic task. I can’t see an option to DM. Maybe the issue is because I’m on a phone, I’ll try again in a computer tomorrow. But the code is:

[
        {
            "every": {
                "specific": {
                    "timeZoneId":"Europe/London",
                    "reference": "Noon",
                    "offset": {
                        "value": {
                            "integer": 10
                        },
                        "unit": "Hour"
                    }
                },
                "actions": [
                    {
                        "command": {
                            "devices": [
                              "8df554f4-0c65-6927-36f5-de6372acOb4e"
                            ],
                            "commands": [ 
                                {
                                    "component": "main",
                                    "capability": "execute",
                                    "command": "execute",
                                    "arguments": [
                                        {"string": "mode/vs/0"},
                                        {"map": {"x.com.samsung.da.options": {"string":"Light_On"}}}
                                    ]
                                }
                            ]
                        }
                    }    
                ]
            }
        }    
    ]
}

And the error is:

Error adding rule “test”. 403 At least one device used is not found in the location

Mmm, this is curious, that error can happen only if you’re trying to use another’s location device or the deviceId is incorrect, I haven’t seen it in another case.
If you’ve verified this, please provide the following:

  1. Open the developer console of the browser (ctrl+shift+i), and go to the tab “Network”
  2. Then, replicate the error and you’ll see how a new element is added showing there was an error, click on it to see the response of the request and you’ll see a request ID, please share that value with me. Here’s an example of the page I mean:
  3. Take note of the time when you made this request and share it with me including your timezone. For example: 14:40 GMT-6

You were right. I had an error in the device id. The code has now been accepted, but sadly the light didn’t go off! I’ll have another look tomorrow, hopefully I’ll get there soon.

Thanks, let me know what happens. Remember the condition of being 10 PM must be met for it to run. If it still doesn’t work, I can open a report for the engineering team but I’d need extra info. I’ll be waiting on your feedback

Hi,

Sorry i couldn’t answer quicker.

With this rule, i still get a result “false” if i try to execute it througt API Browser + :
{
“actionId”: “xxx”,
“if”: {
“result”: “False”
}
}

How could i edit the rule to start at 9am instead of midnight, please ?
So i could check if it’s really works by settings 9am - 6pm, for exemple.

But i think if the rule says “false”, it’s not good :frowning:

In this sample, I changed the time range to 9 am and 6 pm. Please let me know if this works, if not, we can check with the engineering team what’s wrong.

{
    "name": "If temp above or equals to 23 turn AC on and display off",
    "actions": [
        {
            "if": {
                "and": [
                    {
                        "greaterThanOrEquals": {
                            "left": {
                                "device": {
                                    "devices": [
                                        "AC deviceID"
                                    ],
                                    "component": "main",
                                    "capability": "temperatureMeasurement",
                                    "attribute": "temperature"
                                }
                            },
                            "right": {
                                "integer": 23
                            }
                        }
                    },
                    {
                        "between": {
                            "value": {
                                "time": {
                                    "reference": "Now"
                                }
                            },
                            "start": {
                                "time": {
                                    "timeZoneId":"Europe/Paris",
                                    "reference": "Midnight",
                                    "offset": {
                                        "value": {
                                            "integer": 9
                                        },
                                        "unit": "Hour"
                                    }
                                }
                            },
                            "end": {
                                "time": {
                                    "timeZoneId":"Europe/Paris",
                                    "reference": "Noon",
                                    "offset": {
                                        "value": {
                                            "integer": 6
                                        },
                                        "unit": "Hour"
                                    }
                                }
                            }
                        }
                    }
                ],
                "then": [
                    {
                        "command": {
                            "devices": [
                               "AC-device-ID"
                            ],
                            "commands": [
                                {
                                    "component": "main",
                                    "capability": "switch",
                                    "command": "on"
                                },
                                {
                                    "component": "main",
                                    "capability": "thermostatCoolingSetpoint",
                                    "command": "setCoolingSetpoint",
                                    "arguments": [
                                        {
                                            "integer":20
                                        }
                                    ]
                                },
                                {
                                    "component": "main",
                                    "capability": "airConditionerFanMode",
                                    "command": "setFanMode",
                                    "arguments": [
                                        {
                                            "string":"windfree"
                                        }
                                    ]
                                },
                                {
                                    "component": "main",
                                    "capability": "execute",
                                    "command": "execute",
                                    "arguments": [
                                        {"string": "mode/vs/0"},
                                        {"map": {"x.com.samsung.da.options": {"string":"Light_On"}}}
                                    ]
                                }
                            ]
                        }
                    },
                    {
                        "sleep":{
                            "duration":{
                                "value":{
                                "integer":25
                                },
                                "unit":"Minute"
                            }
                        }
                    },
                    {
                        "command": {
                            "devices": [
                                "AC-device-ID"
                            ],
                            "commands": [
                                {
                                    "component": "main",
                                    "capability": "switch",
                                    "command": "off"
                                }
                            ]
                        }
                    }
                ]
            }
        }
    ]
}

Hi @nayelyz!

Is it possible to trigger a rule based on a scene?
For instance, I would like to turn off the display lights after a SceneID is executed

If so, can you provide an exemple?

Thank you!!