I’m running OpenHab 2 on a Windows 10 computer. Everything is working fine but there is something I would like to be able to set dynamically. Here’s my setup.
I use Chamberlain MyQ bindings to query my garage door, have alert when it’s open/closed and remotly open/close it. This work fine. I also have a rule. When my garage door is open, it create a timer for 30 minutes. The timer trigger a close command on the garage door so I don’t leave it open by mistake. All the check in the rules are in place to prevent a false trigger (when the door is closed, the timer is canceled). I also have a switch item called garageDoorPermaOpen that when true prevent the activation of the timer (for summer day’s where it’s hot and I want to work with the garage door open).
All of this work fine. Where I’m trying to have some fine tuning is in the value of the timer. I would like to set a setpoint on my sitemap, with value from 1 to 60 (or more, then maximum value isn’t a problem) that is used by the timer. On the sitemap, it would be “auto-close door timer” and this value would be the value used by the timer. I tried creating a setpoint without any binding, didn’t worked. I’m unsure what to do here and how to have it update the timer in consequence.
var Timer bedroomSleepTimer = null
rule SqueezeBedroomSleepTimer
Item SleepTimer received command ON
then
val turnOffTime = now.plusMinutes((SleepTime.state as DecimalType).intValue)
if(bedroomSleepTimer != null)
bedroomSleepTimer.cancel()
bedroomSleepTimer = createTimer(turnOffTime, [| sendCommand(sq_bedroom_control, PAUSE)])
end
Yeah there is. You can initialize items on startup either from persistence or with a hardcoded value. I haven’t gotten around to it yet and haven’t done it before so you will have to check the forum for how exactly to do it.
Persistence:
I order the get back the last value of all items persist all items using MapDB using the strateies everychange and restoreonstartup. That way MapDB will persist every change on each item and restore it on startup.
Set a default after start:
Use a rule that is triggered on system started in which you set the desired value.
I’ll have to check on how persistence works. Right now I’ve used a default with the system started event and it work great. I’ll check for the persistence later, it will be better that way.