Dynamic Temperature Rule

Hey Guys,

I’m finally at a point where I can start planing to make my house actually smart not only time triggered for days per week… :slight_smile:

I’ve got (currently, but to expanded) 2 heating actuators with which I can set a target temperature. So, currently the target temperature 21° shall be achieved between 7-9 and 19-21 and the rest of the time 17°C.
This works perfectly nice, but it’s not what I want. Some days I have to get out of bed at 6 and other days I have to get out of bed at 10. So obviously I don’t want to heat from 5-10 in the morning to have a nice temperature to get out of bed. My Idea was to create an input on the overview website where I can set the temperature when it should start heating the next day (and in the end to check my calendar and then calculate when I’ve got to get up). But that’s not how I can set a trigger for a rule, the trigger for the rule has to be done through the rules interface and I want, that it only sets it for the next day and them jumps back to a default value.

My Idea was to create a rule that triggers every 15 Minutes in the morning, checks if it should start heating now and if so, set the temperature to heating. But I’m not sure if this a good practice.

Can someone help me with ideas here? I’m not experienced enough with Openhab so I’m not quite sure what is possible and what not. I’ve got some programming experience, so programming a complex rule wouldn’t be the issue.

Thank you in Advance,
Autchi

You’ll probably get some tips if you search “alarm clock” threads on this forum.

No need for that; from a rule you can create a timer for a given target clock time.
So, you might run a rule once at 04:30 that looks to see if there’s a target time for the coming morning, uses a default if not, and sets up a timer for 06:30 or whatever.

Long Time ago i had a rule like this to turn on my coffemachine.
I used Tasker on my phone to watch my alarm clock. with the help of a tutorial i was able to trigger a task 5min befor the alarm started.
You could also create a task that triggers every midnight (or later) an send the time of the next wake up call.
This task triggered a rule in openhab and started my coffemachine. so the only thing i had to do was, to set my alarm clock.

One of the weaker portions of OH right now (but it’s getting better over time) is setting schedules like this. In addition to the alarm clock examples rossko57 points out I recommend looking at the JavaScript or Python versions of [Deprecated] Design Pattern: Time Of Day. Either of these allow you to define a series of DateTime Items with Item metadata and it will drive a TimeOfDay Item. you can have a different set of times of day for different day types as defined in Ephemeris (e.g. a different start time for MORNING on weekends and holidays, weekdays have an extra LUNCH time of day, etc). Then you can trigger a rule with something like Item TimeOfDay changed to MORNING to trigger your heater and what time that happens will differ based on the times of day.

If you do go down the alarm clock routes, be aware that the biggest problem those example overcome is the lack of a way to enter a time into a sitemap or HABPanel. In OH 3 there is now a way to configure a Date Time picker or text entry field to set the time for the alarm. See OH 3 Examples: How to boot strap the state of an Item (look at the full thread for other ideas). So it’s no longer required to create a bunch of separate Items (one for seconds, another for minutes, and so on) to define a single date time. The TimeOfDay rules will show how to advance a date time to today to set a timer using it.

If you are using the Android app, you can configure it to push your Android alarm time to an Item in openHAB. you could use that to set a timer to start the heater.

Generally a polling approach like that would be used as a last resort. It’s almost always better to use events and timers.

I use Sleep as Android (SaA) on my phone for sleep tracking and alarms. SaA has a user-defined period of time before your defined alarm time when it tries to detect the optimal time to gently wake you from light sleep, so the alarm could go off at any time in that period. As a result, I don’t want to just forward my alarm times to OH via the Android app.

SaA functions as a Tasker/Automate plugin, so you can use it directly to trigger tasks with these apps. However, a recent update added MQTT, so you can now use it to send commands directly to OH. I haven’t tried this, as I have some other logic that works best through Tasker. For example, the Tasker routine is only triggered if OH is in a specific mode and my phone is connected to my WiFi SSID. This ensures that stuff only happens when I’m actually at home.

Hi,
I searched the method to do this, but did not find the example. Unfortunately I only speak DSL - if this is only possible in “not DSL” I will be gratefull to know if I can stop seaching :-).

If it is possible with DSL - a small hint would be great.

Thank you !

Best regards
Peter

1 Like

Thank you.

I was searching this topic for a long time. As I hoped for a solution in Rules DSL I did not dig down into the rules-tools.

The rules tools are very interesting - I think I will have to learn JavaScrips soon :slight_smile:

For anybody who currently sticks to RulesDSL, I found the solution of my problem here combined with here

val MyJavaTimeFromDateTimeItem = (MyDateTimeItem.state as DateTimeType).getZonedDateTime()
var TimeOfToday = MyJavaTimeFromDateTimeItem.withYear(now.getYear()).withMonth(now.getMonthValue()).withDayOfMonth(now.getDayOfMonth())
logInfo("Test", "The new time is: " + TimeOfToday )

BR Peter

Thank you for your Answers and please excuse my delayed response, I had a different issue with my home automation and completely forgot about this.
Thank you all for your input, I already had a look into the “alarm clock” thread, this looks pretty good to me.