Jump to content
C4 Forums | Control4

Lights triggered by motion - timer code


JGLI

Recommended Posts

I wrote some code to turn on my garage door light if the garage door motion sensor senses motion.  I want it to turn off the light if there is no motion for five minutes.  My question is will those code keep resetting the timer every time it senses motion?

Did I setup the If statements properly (not sure if the nesting is correct)

GarageMotion1.tiff

GarageMotion2.tiff

Link to comment
Share on other sites


 

You have the right idea, however what you want to do is as follows.

 

 

When motion sensed

 

 

?If Shabbat false

 

-> turn on overhead light

 

-> reset timer 5 min

 

 

 

Then go to timer on left side and select when timer expires.

 

 

When timer 5 min expires

 

-> turn off overhead light

 

 

Then delete any other programming. Note that there is only one timer. Named garage 5 min. I noticed that you have another timer on the stop sensing script. Only one is needed. And note that you want to reset the timer. Not start it. That way every time it senses motion, it will reset the timer to zero again.

 

 

Happy Automating!

 

Link to comment
Share on other sites

b6c09c1a4dd9069f7b311a2ee8830a4e.jpg

 

The reason this won't work well is that it will not turn off the light unless the motion sensor stops sensing after the timer expires. If you have left the room after one minutes then it will have stopped sensing motion and would have nothing to trigger the event "when stops sensing motion"

 

That is why we program to the timer. When the timer expires, it will have the event. That is when you ask it to turn off the light.

 

 

Happy Automating!

Link to comment
Share on other sites

I am glad it works for you.

Use this logic for other things as well. Like media is on in a room and off. You can program your lights to dim to different level when watching a different source. Like cable tv is bright but movies is dim.

 

 

Happy Automating!

Link to comment
Share on other sites

So this morning when I wasn't at the house (guy was working in garage), the lights were flickering on and off.  Seems to be OK now.  If the timer is at 0 and you choose Reset Timer does it start it?  If no, do I need a Start Timer and t hen and If Timer does not equal 0 Reset Timer?

Link to comment
Share on other sites

5 minutes ago, JGLI said:

Timer is set for 15 minutes.  So reset timer will definitely start a timer that has expired. If so, when would you use "Start" timer?

RESET and START work very similar. START will also "set a timer back to zero and run it" but on a RUNNING timer, it will NOT trigger a start and stop event (meaning, programming based on those events do not get triggered) whereas RESET WILL trigger both does events on a running timer (and programming attached to it will trigger again).

To round it up: BOTH START and RESET will trigger (only!, so no stop) a Start event.

Link to comment
Share on other sites

This is one thing i would love to see added to composer... would be nice when testing at least to be able to see time remaining on a timer... I suppose in a large deployment with touch pads I could see showing a timer for certain things.

Link to comment
Share on other sites

Everyone the problem seems to happen when you press the light switch for the light (i.e, if its not triggered by motion).  Lights flicker like crazy.

There is no code related to the light when I click on it from the Programming interface.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.