i have a zigbee button with which i wanna control the current mode which can be HOME, SLEEP or AWAY
The current mode should later be represented by a certain color by a color bulb near my entrance.
The problem is, i have to make it foolproof because some of my roommates are just pressing it randomly several times since they may find “nothing happens immediately when i push the button”
So, basically i wanna “log in” a certain state, wait a few seconds if nothing changed and THEN set it really.
To make it a bit more complex: The state itself could be changed immediately since i wanna for example change the state light immediately (to stop fools from further button pushing^^), but different other stuff like heating should be a bit more delayed like one minute or so …
is there a “built-in” mechanism to delay an items command trigger when its changed? How could this be solved?
Using the Debounce rule template, a proxy Item and two rules. The first rule triggers the rule that controls the light. The Debounce is configured to update a proxy Item after an amount of time. When the proxy Item changes that triggers a second rule to do the stuff that should be delayed.
Rule Templates can be installed from Settings → Automation. See Rules - Basic | openHAB for details.
A Rule Template is just that, a template. You have to instantiate and configure a rule based on that template.
Also, why is this state published as a date time? given the name of the Item and the state, that’s doesn’t make much sense. I’m not sure how the stateDescription options will work.
Also, keep in mind the debounce is only in one direction, from Sonoff_Mini_Switch_1_Button_State to Home_Operation_Mode. Not the other way.
Set the logger org.openhab.model.script.Rules.rules_tools.Debounce to DEBUG level in the karaf console or log4j2.xml file, or manually edit the logger statements in the script action of the rule itself to log at the INFO level so we can see what the rule is doing.
Something weird is going on with the state description for that Item or the binding or something else. It’s formatting it as if 1002 were 1002 seconds.
What type of Item does that Channel dictate should be used? You can’t just link a String Item to a Number Channel without errors or unexpected results.