Turning on Light, on Camera Motion or Tilt Sensor, but Not turning it off

Hi - Background. I have a tilt sensor on my garage. I am trying to have the outdoor lights come on when either the tilt is set to open OR motion is on the camera. Unfortunately, each light automation I try (either motion or open tilt sensor), it turns off the light when its closed. The problem this causes is at night, my outdoor lights are ON and if the garage door is opened and then closed, they remain off the rest of the night. I tried the following settings

  • Turn off lights when motion stops, still turns off right when garage door closes (which I have setup to start recording / motion on camera when opened)
  • I tried the turn off after x minutes, doesn’t solve the problem of turning off the lights if its past hours
  • I tried the rule hours, but it seems not work - does it all the time.

Any thoughts on a better way to accomplish this?

THANKS all!

Please show us screenshots of the automations you’re having trouble with.

Also, what are the brands and models of the various devices?

You may need to set up a separate automation for each of your conditions since it’s an “or” anyway, correct? So one automation for the camera and the other automation for the tilt sensor.

Did you by any chance use SmartLighting app and set “Turn off as well” toggle “on”?

1 Like

Hi Thank you. Few responses to the questions and also added in screenshots. One additional point, if I remove this lighting routine, the drive way lights don’t come on or off upon tilt. Also, the strange part - this lighting routine has turn off after 5 minutes AND only do the rule if the drive way light is ‘off’, neither is working!

Hi @itzfry! Have you checked the new Rules API? Even though is a bit more complex, it also allows you to create more complex rules as well, I recommend you to check the Rules Breakdown, and if it fits what you are looking for, we might help you over here to accomplish your goal!
Cheers!

Cool - will do. I have been waiting to take this more complicated step but honestly, it seems like it will be an easy rule once I get the hang of it. Will take a look is there a video or walkthrough for someone to quickly get started with using the APIs - where to set it up, tokens, etc. Video would be nice!

John

As this is a new API, there aren’t much videos yet, but I can recommend you the check this, which is the presentation of the Rules API at SDC.
The Engineering team has created a tool, to work with rules easily: Rules Manager, which allows you to sign into your account, and avoid the tokens and all that.
To start, you can check at the Rules Breakdown I mentioned above, which has clear examples as well.
Don’t hesitate on posting over here when you get stuck with your rules, so the community can help you!

OK! Had time to check this out. I did a few things, but encountering a few problems so questions below.

  • Hooked up POSTMAN and did some basic GET commands to understand the device IDs, etc.
  • When submitting rules through POSTMAN, I didn’t get a response. Not sure what’s up here. However, it does show me a couple of errors I corrected (red X on a line) that was helpful to move the code to the RULE MANAGER
  • Used RULE MANAGER. Works sporadically but got me further, see below.

Questions

  • SUBMITTING A RULE sometimes doesn’t work - no progress bar, no results, no error, just click submit and it stays there.
  • I did get a rule to work, so perhaps there is something wrong with my JSON on the new rule I am working on and that is the reason its not working? Is this normal behavior without an error code, etc?
  • For the rule I did get to work, I want to delete it - it was only a test. To delete a rule, I need a rule ID. Not sure what value this is. Thoughts?

THANKS!

PLEASE SEE PREVIOUS REPLY FOR INFO. However here is my sample code. I think one issue may be my reference to CONTACTSENSOR and OPEN. I haven’t found a good resource that shows how to denote the type of device and available references to the attribute or commands. Possibly an issue here?

{
“name”: “Garage Light - Turn on a light, after 1 Minute, turn the light off”,
“actions”: [
{
“if”: {
“equals”: {
“left”: {
“device”: {
“devices”: [
“de77ef87-d3ea-4d84-b087-0b217254816e”
],
“component”: “main”,
“capability”: “ContactSensor”,
“attribute”: “open”
}
},
“right”: {
“string”: “active”
}
},
“then”: [
{
“command”: {
“devices”: [
“75f5e6d8-a377-4881-bdb7-112cfd6c55da”
],
“commands”: [{
“component”: “main”,
“capability”: “switch”,
“command”: “on”,
“arguments”:
}]
}
},
{
“sleep”: {
“duration”: {
“value”: {
“integer”: 1
},
“unit”: “Minute”
}
}
},
{
“command”: {
“devices”: [
“75f5e6d8-a377-4881-bdb7-112cfd6c55da”
],
“commands”: [{
“component”: “main”,
“capability”: “switch”,
“command”: “off”,
“arguments”:
}]
}
}
]
}
}
]
}