CoRE On/Off Light if motion/no motion since

(Vincent Arancio) #1


I want to switch ON kitchen light if there is a motion detect and illuminance is less 20lux (this part is ok), but I want to turn off if there are no motion since 3 minutes.

I use IF/Then but my light turn OFF after 3 minutes with or whithout motion detection :frowning:

But Core is just amazing, I discover today ST and it’s so friendly use (before I’m on Vera)

Thank you

(Bob) #2

This will do it for you.
Note the cancel on piston state change
This means that whilst there is motion the light will not turn off.
In your piston when you go to the action for wait and turm off, scroll down and enable cancel on piston state change.

(Dustin Clark) #3

There are several ways to skin a cat. Here is another way you can accomplish your end result. This is a latching piston. Instead of setting a timer initially to turn the light off and relying on the cancel to stop it I am monitoring the motion for staying inactive for my desired time.

(Robin) #4

I like @bobbles method as it allows for the lux conditions you asked for!

Note that he has built his example in expert mode (which gives ‘when true’ / ‘when false’ fields), but you may prefer to build it in normal mode?

In normal mode it is basically the same but you would use a ‘simple’ piston and then put the ‘when true’ items under ‘then’ and the ‘when false’ items under ‘else’

In my home we often like to lock our lights on or off (overriding the motion). This can be done easily using a simulated switch and then setting a restriction on the then/else actions to only execute when switch is ‘on’.

I went a bit further and used a custom CoRE variable instead (toggled by a wall switch sending scene ID’s), but maybe that’s another level you don’t want to get into yet!

  • One click of the wall switch (scene 24) toggles the light (and turns off the lock variable)
  • Double click of the wall switch (scene 26) locks the light in its present state.
  • Motion turns on the light (if lock is off)
  • No motion for 5mins turns off the light (if lock is off)

(Dustin Clark) #5

I do not have any lux sensors. I uploaded my example to show how a latching piston could be used instead of adding all those restrictions. They already figured out how to get the light to do what they wanted but could not get it to turn off properly. So this would probably be the easiest to edit their current piston.

(Vincent Arancio) #6

Perfect I try the 2 solution.
C1arkbar I try your solution now it s work but I wait to test more.
I have a fibaro sensor :slight_smile:
I am happy to see its working nice.
I like this kind of solution.

@RobinWinbourne Thank for your explanation I search because i’m in Normal mode more easy with this explanation

(Vincent Arancio) #7

@bobbles I try your solution but I have a problem if my sensor is inactive 3min after my light switch off but I’m now again in the kitchen and my light turn on again.

I want my light turn off stay inactive 3min only but I keep your process to use in a other room, I’m not a expert but my wife knows what she wants (not a misogynist message because is Kitchen, It’s just a coincidence)

(Robin) #8

I would imagine this is because you are using lux levels… when you enter the room the lights are off and lux is low so the motion turns I the lights. But then lux levels increase above the set levels and the piston condition becomes false turning off the lights.

If I were you I would not use lux as a condition… Instead add restrictions within the action section so lights only turn on between sunset and sunrise.

If you use the CoRE dashboard you can view your Pistons in realtime, as things become true they turn blue and you can also see the wait timers start / stop. It’s a massive help for debugging.


I have done something similar but using both CoRE and the smart lighting smart app. I set smart lighting to turn on my daughter’s bathroom light when there’s motion and to turn it off 2 minutes after motion stops. The problem I was having was if the light was turned on manually and no one walked into the bathroom, then smart light would not turn the light off as smart light turns does its thing after motion stops but it doesn’t register doing that unless motion started in the first place.

I set up CoRE to turn the light off after a period of time if the motion sensor shows as inactive which allows the automation to run wether motion had started or not. I also noticed that using the toilet when people aren’t very active, the lights would go off without warning. To fix this I set CoRE to dim the lights to 2% for 10 seconds before turning the lights off, letting you know if you don’t move soon the lights will go out. Any movement after that restores the light to its previous level.

The Piston looks so complicated but it’s really simple and it works rock solid 100% of the time and evolved over time and trial and error.

Also, the reason I use smart lighting to turn on the lights is that my motion sensor and light are both run locally along with smart lighting, so that basic automation will run even if I don’t have an Internet connection. CoRE is there to do the heavy lifting when there is Internet but it’s good having a backup automation.

(Daisy Daisy give me your answer do) #10

How do you run the Core Piston and the smart lighting together? Won’t there be a conflict?


Core will turn off the lights at 115 seconds and if it does Smart lights won’t run, but without core running smart lights turns it off at 2 minutes (120 seconds) so they don’t conflict.

(Craig) #12

Here is how I typically set up my motion controls. It uses a second “OR” condition to guarantee a state change, which prevents the light from turning off if someone is moving around.

It also allows the lights to come on at a specific color temperature and brightness depending on time of day or mode, checks for lux, and is only active if the lights weren’t turned on by a switch or some other method (the “turnedOnByMe” variable). It also checks the status of a simulated “MotionEnabled” switch, which automatically gets turned off when nobody is home to shut down all the motion sensors. (I don’t want the silly cat tripping lights on and off all day :slight_smile: )

I’m still experimenting between using the “Wait” task, and “Stays inactive for…” to determine which I like better. I’m leaning towards the Stays function for simplicity, but the Wait works fine.

(sapstar) #13

Sorry for hijacking the thread. @bobbles, I have used a modified version of your piston as below.

I am trying to achieve the following.

  1. Turn on light on motion, only if outside lux value is <=1500.
  2. Turn off the light if no motion for 5 mins between sunrise and sunset.
  3. I would like the light to stay on for 5 mins and then turn off if manually turned on and not triggered by motion sensor.

Can you please let me know how I can amend the above piston to satisfy No.3? I haven’t tested 1 and 2 yet as I am away from home.

(Bob) #14

You could put in another group in the IF statement.
So you have:-

First group.
Kitchen Motion is active
smartweather etc. etc.
Second Group
Kitchen Light changes to on

Using Kitchen Light
Turn On.

As you have already specified.

I would also on the first page of the piston, scroll down to advanced options.
Click on the + symbol
Where it says ‘Disable command optimisation’ put the slider to the right so that it is active.
This way the piston will ignore whatever state the device is in and run.
I’m not sure if you need expert mode enabled for this or not. I always have this active anyway.
This can be done in the settings for CoRE.

You will have an issue though if it is not between sunset and sunrise and the light gets turned on. It will not turn off. You might want to get rid of that restriction.

(sapstar) #15

@bobbles thanks for the help. I will try this. I don’t want the light to automatically turn off between sunset and sunrise. I want to handle this manually.

(sapstar) #16

@bobbles, I have now changed the piston based on your inputs. I have changed CoRE to expert mode, but couldn’t find anything under Advance options to ‘Disable command optimisation’. Can you please help me where this exactly will be? I looked under each condition screen and the screen which shows all the groups. Below is how the piston looks now.

(Bob) #17

When you go into
Automation -> SmartApps
you will see the CoRE app.
Click on it and open your piston,
Scroll down and you will find Advanced Options.
Click on it and you will see Disable command optimisations.

If it doesn’t appear you may need expert mode enabled.
To do this->
Automation -> SmartApps
you will see the CoRE app.
Click on it and scroll down and open settings.
You enable expert mode there.

(sapstar) #18

Legend. All sorted now :).

(Bob) #19

I just hope the piston works OK. :relaxed:

(sapstar) #20

I can only properly test it on Friday as I am home all day. Hopefully it should be fine :slight_smile:.