So yesterday I followed the PLTS Basics Simple motion activated light example but am struggling to work out how to code the following based on the following:
Fibaro motion sensor reports motion alarm for 30 seconds, motion during this time resets the internal 30 second timer and there is an 8 second ‘blind time’ also, so when at 22 seconds the sensor can reset the internal time. Both times are default and can be changed.
Ive tweaked the example slightly and removed the reference to day or night and used Luup code related to sunset and sunrise as i wanted an offset (im aware i can set this in day/night to, but havent) as my bathroom is darker than most of the other rooms at sunset so i wanted this light to come on earlier, not all of them.
What i want achieve is that the lights come on when motion is detected, starting the PLTS timer (set at 30 minutes) OR turns the lights off after motion has stopped being detected (!Motion in the OFF box), to save electricity (not leaving the lights on for 30 minutes if nobody is in the bathroom), whichever is effectively sooner.
Now the problem comes in that while moving around in the bathroom, for example taking a shower or brushing your teeth, this seemingly works ok (assuming you move at least a little. However if you were lying down in a bath relaxing then you wouldnt necessarily be moving or be seen by the sensor so after the motion sensor stops reporting motion (after 30 seconds) the lights turn off.
Im aware of the PLEG basics simple motion triggered light but this requires that the timer be set for the maximum time you expect to be in the bathroom, so if taking a bath for example you would put in 30 minutes. However 99% of the time i dont need the lights to be on for 30 minutes and would be wasting electricity.
Ive tried to formulate some logic as to how this could be achieve but have so far come up short. Suggestions appreciated.