I have a coffee machine I would like to turn on at 7:30am each weekday and stay on for 1 hour then turn off, I also have a button switch I would like to press on at any time and the coffee machine comes on but goes off after 30 minutes.
Ideally I would also like to use the button to turn OFF the cofffee machine if I am in the 1 hour morning sequence
I have experimented with rules and dummy switch items with expire bindings that have more rules looknig for OFF status to then turn off the coffee machine but I have got myself in a bit of a knot with expire bindings on the dummy items and rules all over the place.
Is anyone able to help with a set of cler rules, items and config that could support the scenario above?
Think you need 2 buttons
1 to turn on with 30min expire
1 to turn off
Are they physical buttons or on UI?
OK. Getting closer!
I get as a validation error:
Function0 is a raw type. References to generic type Function0 should be parameterized
on the line:
val Functions$Function4 <String, Map<String, Timer>, Functions$Function0, Functions$Function0, Boolean>
Cannot refer to the non-final variable dayName inside a lambda expression
as an error on:
val person1On = gAlarm.members.filter[s | s.name == person+dayName].head.state
I fixed this one by declaring dayName outside Function4
could try this or adaption there of.
I use it for my alarm clock with squeeze box
When you’ve got multiple expiring Items doing the same thing, it sometimes becomes a problem managing a ‘cancel’ feature. Might help -
Beginners with rules often come up against the need for a timer function soon after starting out.
The timer features available in the various rules languages are quite powerful, but this frightens new users off.
Frequently the use of the ‘expire’ feature built into openHAB3 Items is suggested for basic timing, but this does have limitations. These notes show a way to work around some of the limitations. They are written with old fashioned file-based Item and rule definitions, because it’s ea…
I would do the following:
Create one rule triggered by time (7.30am) and your button item
Within the rule you can differentiate if the rule is executed by time or by button (check if a triggering item is existing or not)
If the rule is triggered by time, then turn on the coffee machine and set a timer to 1 hour, which will turn the coffee machine off
If the rule is triggered by the button and the coffee machine is off, then turn on the coffee machine and sweet a timer to 30 min to turn off the coffee machine again
If the rule is triggered by the button and the coffee machine is on, then cancel any existing timer and turn off the coffee machine immediately
This cannot be done in Rules DSL though so beware.
Beyond that caution, this too is how I would do it.
Ok it sounds like I’m actually on the right track the only difference I can see in suggestions is I’m using the expire binding which itself seems to be unreliable to trigger rules
I will post all my items and rules shortly