12-10-2015, 08:19 PM
I\'m currently in the process of trying to write some responses to more elegantly control the management of lights being turned off in \"empty\" rooms.
The only inputs I have to determine room occupancy status are a CBUS wall switch and a PIR connected to a comfort zone. I can deduce if the CBUS switch in the room is operated then the room is occupied (at that point), but it\'s no use for determining on-going occupancy status, so for the purpose of this exercise I\'m pretty much ignoring that, and relying solely on the PIR.
In most (but not all) cases, I don\'t want lights ON to be automated based on motion; I prefer to have the occupant manually switch the light on if they want it. This discussion is specifically for the scenario where only the OFF is automated...
I don\'t want to rely on the users remembering to turn lights off when they leave the room, I want that to happen based on no motion observed for a set period.
However, there are cases where the user is just being very still in the room, so not being observed by the PIR, so I must allow for this... The lights OFF mechanism should occur regardless of time of day/outside light levels etc.
My approach currently, is as per the following pseudo code:
Attach response to PIR OFF event on the zone, response does:
Start timer 20 minutes
on timer expiry after 20 mins:
retrieve the current light dim level by reading the value of the CBUS mapped counter
store current light dim level by copying CBUS mapped counter to another counter
divide current dim level by 2
set CBUS counter to new value, thus dimming light to half whatever it was
start timer again for 10 mins (using same timer currently)
on timer expiry after 10 more minutes:
Set CBUS mapped counter value to zero, thus turning light off
This should produce the effect whereby so long as motion is observed nothing happens, but after 20 mins of no movement the light level halves... this allows the user (if one is there) to know the system is managing the light OFF function... then after 10 more minutes with no motion the light goes off.. so far so good.
What I now need to add into the mix is the ability for the user, once they are aware of the light level dimming by half, to \"do something\" to say \"hey, I\'m still here, don\'t mess with my light!\" - by moving enough to be seen by the PIR... this is the bit I\'m thinking about now...
I\'m thinking this should be via a response on the PIR ON event... the response needs to be aware of the current state of the above actions... so I think the best way would be to check if the timer is running; if not, do nothing, if it is, then restore the light level to the original by copying the counter value back from the one I copied to in the first response.
A couple of things I\'m not 100% sure of, & would appreciate insight:
- I don\'t think it should be necessary in my ON response to stop the timer; when the PIR is triggered ON, very shortly after it will go OFF, thus running the OFF response, which will restart the timer with the first 20 minute value - yes?
- Every time the OFF response is triggered by the PIR, following motion having been observed, the OFF response will run, and this will always restart the timer from the full 20 minutes, thus so long as motion is observed before the timer expires it will always be reset back to 20 mins and never actually expire - yes?
- I don\'t think it should matter that I reuse the same timer for both countdowns in this response (obviously it\'s not used in any other response!); it\'s only ever loaded with 10 minutes after the 20 minute initial countdown has expired, and if motion is seen in the 10 minute countdown, again the ON response restores the light level, followed immediately by the OFF response which restarts the timer from 20 minutes... - yes?
Thoughts? - is my approach sound? - anyone see any \"gotchas\" I haven\'t thought about?
Cheers
Paul G.
The only inputs I have to determine room occupancy status are a CBUS wall switch and a PIR connected to a comfort zone. I can deduce if the CBUS switch in the room is operated then the room is occupied (at that point), but it\'s no use for determining on-going occupancy status, so for the purpose of this exercise I\'m pretty much ignoring that, and relying solely on the PIR.
In most (but not all) cases, I don\'t want lights ON to be automated based on motion; I prefer to have the occupant manually switch the light on if they want it. This discussion is specifically for the scenario where only the OFF is automated...
I don\'t want to rely on the users remembering to turn lights off when they leave the room, I want that to happen based on no motion observed for a set period.
However, there are cases where the user is just being very still in the room, so not being observed by the PIR, so I must allow for this... The lights OFF mechanism should occur regardless of time of day/outside light levels etc.
My approach currently, is as per the following pseudo code:
Attach response to PIR OFF event on the zone, response does:
Start timer 20 minutes
on timer expiry after 20 mins:
retrieve the current light dim level by reading the value of the CBUS mapped counter
store current light dim level by copying CBUS mapped counter to another counter
divide current dim level by 2
set CBUS counter to new value, thus dimming light to half whatever it was
start timer again for 10 mins (using same timer currently)
on timer expiry after 10 more minutes:
Set CBUS mapped counter value to zero, thus turning light off
This should produce the effect whereby so long as motion is observed nothing happens, but after 20 mins of no movement the light level halves... this allows the user (if one is there) to know the system is managing the light OFF function... then after 10 more minutes with no motion the light goes off.. so far so good.
What I now need to add into the mix is the ability for the user, once they are aware of the light level dimming by half, to \"do something\" to say \"hey, I\'m still here, don\'t mess with my light!\" - by moving enough to be seen by the PIR... this is the bit I\'m thinking about now...
I\'m thinking this should be via a response on the PIR ON event... the response needs to be aware of the current state of the above actions... so I think the best way would be to check if the timer is running; if not, do nothing, if it is, then restore the light level to the original by copying the counter value back from the one I copied to in the first response.
A couple of things I\'m not 100% sure of, & would appreciate insight:
- I don\'t think it should be necessary in my ON response to stop the timer; when the PIR is triggered ON, very shortly after it will go OFF, thus running the OFF response, which will restart the timer with the first 20 minute value - yes?
- Every time the OFF response is triggered by the PIR, following motion having been observed, the OFF response will run, and this will always restart the timer from the full 20 minutes, thus so long as motion is observed before the timer expires it will always be reset back to 20 mins and never actually expire - yes?
- I don\'t think it should matter that I reuse the same timer for both countdowns in this response (obviously it\'s not used in any other response!); it\'s only ever loaded with 10 minutes after the 20 minute initial countdown has expired, and if motion is seen in the 10 minute countdown, again the ON response restores the light level, followed immediately by the OFF response which restarts the timer from 20 minutes... - yes?
Thoughts? - is my approach sound? - anyone see any \"gotchas\" I haven\'t thought about?
Cheers
Paul G.

