Does Openhab offer a way to distinguish between a flick of a switch (by a user) versus a system generated command (from Rules / Code)?
Specifically, I am trying to automate lights to be switched “on” at dusk “&&” when user “presence” is detected. The Code for this is elsewhere on the forum.
However if user has decided they don’t want this feature to activate (i.e. going to bed early, yet still “present” for our purposes), is there a way to code this override?
Can consider a timer, but this gets unwieldy. For example, user switches lights off, yet a few minutes later the lights switch back on again as the system has identified that both Presence and Time Conditions are met. To solve this, if we have the user’s decision to switch the lights off being subject to a time limit - until the next day , that is fine, but what if they change their mind and switch the lights on again…?
Another alternative may be to create a variable “SystemTurnedOn=True/False”, however this seems tricky to implement in practice.
Please assume, for the sake of this question, that the solution does not lie in having a more sophisticated “Presence” condition (such as PIR in the room or similar) - though clearly this is a possibility I will need to think about.
Rules code so far as follows:
rule "lamp trigger to switch on when dark and someone home"
when
Item Presence changed
then
var Number hour = now.getHourOfDay
if ((hour >= 18) && (hour <= 23 ) && (Presence.state==ON))
{
lamp1_Color.sendCommand(myColor)
lamp2_Color.sendCommand(myColor)
lamp_Timer.sendCommand(ON)
logInfo("lamp_trigger.rules", "Presence and Time criteria are met: switching lamp on, with lamp timer")
}
end
Many thanks !