Update: Solved; this needed to be MotionLights (capital M & L). Running ok!
p.s. Would it be possible to add an extra âparameterâ for elevation to the config? Actually only want the automation to work when below is true (in this case):
and yeah, you can reuse this app as often as you like. thats the big advantage from appdaemon.
so just create a new block in your cfg file with a different name and you can use different args, so different rooms.
delay is seconds.
so it should turn off after 5 mins.
if it detects a second movement you should see that in your log or on screen.
and also after the timer ends you should get an entry in your log or on screen.
i added an off function to your version of motion_lights.py to reset the timer, when at least one entity is turned off manually. if this functionalty is missing, an entity that is being turned off in HA, wonât turn on when motion is detected, as long as the timer is still running.
Why do you specifically want new == on when setting up the timer? Wouldnât it be better to allow for off to also trigger the timer? Then I think you could clean up your light_off to not need to look for motion still detected right?
to post code correctly you need ` 3 times and then a new line. before and after the code.
not â and not " (sorry dont know the names from those symbols) the one you use to create è.
your question to diplix is right. that would be the way.
why do i want new= on?
i know that there are motion detectors which have there own timer. they keep on for the time they are set to, for instance between 5 an 30 seconds and you can set that with a potentiometer.
but my code has no way to detect that. so your delay would be affected by that.
the second thing you say is that you dont need to look after the motion detection is set to off.
and thats also not true. if you have an motion detector which goes to off after 5 seconds then you need to stay reel busy to make sure it still keeps detecting you.
suppose you use it for a bathroom. you want the light to stay on while you are on the toilet.
you dont move very much. lets say you move not at all for 60 seconds. allmost every motion detector would have gone to off by that time. but you still like the lights to stay on, untill your gone.
so thats why i think you need to keep checking untill the end off the delay. and only for movement.
thats also why the last line checks if the motion detector is still set to on at the end off the timer.
to use motion detection like this you want your motiondetector settings to be as short as possible.
Ok. Will try that out for posting code. Stay tuned!
Regarding what I meant with off is that new == off should also trigger the timer, not turn off the lights. Because then you will cover more more scenarios. E.g. When you move detection will go to on and timer will set but only at the beginning of movement. If the detection stays hi for longer than 60 seconds, the lights will turn off. But if you also care about the signal for new == off as in no motion detected and then also set the timer for countdown you will be less likely to actually need to check if sensors are still active.
Am I explaining it well enough or should I write a logical example of what I mean?
i think your logic is wrong.
actually the best motion detector you would have goes off diectly without any delay after the motion is detected.
but lets say you have 1 that stays high for 4 minutes.
the motion is detected and your timer is set to 5 mins. (bacause you like it to stay on for 5 mins after detection)
if your timer is influenced by your detector going to off, you lights would stay on for 9 minutes total.
going off is saying nothing about the motion, because of the fact that every motion detector is different.
it can say that there was no motion for some time (if you have a motion detector which stays high for repeated motion) but it can also say that just some time has passed since the first motion is detected.
and the some in some time is also unknown.
i set my detectors as low as possible. so it wont stay high for 60 seconds.
if you have a detector which stays high as long as it detects movement (and also has its own delay) you actually dont need an app like this. they you just would like your lights to go off when the detector goes to off.
so there is a hardware difference. some do have a decent program like this included in the hardware and some dont.
with this app you like the once that dont have any delay.
i use cheap motion detectors that i can connect to my arduinos.
i could also use arduino programming to set my delay. but if it is in the hardware or the arduino is the same.
i dont want that because i like to be able to change settings from my pc and not on my hardware
Havenât changed this for a long time but now I want to differentiate the same light for evening use and night use. With this I mean that, when after 0:00 until sunrise, I want the motionlight still to work but with a dimmed light. What is the easiest way to achieve this? Was think of just duplicating the current one and then use times that are adjacent and refer to different scene. Code below. Is that the easiest way and would that work?
Thanks! Also had to change some stuff on time notation but all fine now. Now when someone getâs up in the middle of the night they donât get blinded by the light. For completeness full code below: