How to realize a generic "countdown X days until task" Thing?

Hi,

I realized there’s something I want to integrate in my Smart Home setup: Resettable countdown timers for certain tasks. Each timer should be given a task name and amount of days until this task should be done. It should alert me if the counter is 0 and I should be able to reset it every time (even if non-zero) to its initial value.

Let me give you an example: I need to descale several items in my household (coffee maker, washing machine etc.) on a regular basis. Each items needs to be descaled on a different interval. Whenever I have descaled an item I want to reset the timer and be notified when it need to be descaled again.

How would I proceed to realize this in way it

  • can be reused, so I don’t need copy & paste the code & configuration over and over again but only need to define the different name & interval
  • can be integrated in a sitemap / habpanel

Thanks in advance

Just a rough idea:

  • have a (or multiple) number item(s)
  • have a rule that executes around midnight and subtracts one from your number item (s)
  • have a rule that sends you an email / telegram / etc when your countdown reaches zero
  • display your number items as ‚Setpoint item‘ in your Sitemap to reset countdowns
  • or have a switch item and a rule to reset the countdown to default

You might find this gives a starting point


I think for a daily countdown I would do decrement with rule, not expire.
But the design principle there of separating command from state you should find useful.

Obviously the counter Items would need persist/restore.

In addition to the recommendations already made, I would recommend using the proper tool for the job. Just create a reminder in what ever calendar app you may use or personal assistant or the like. When ever I give the dogs their flea and worm treatments I say “Hey google, remind me to apply flea treatment in 90 days” or “hey google, remind my to give worm treatment in 30 days.” Alexa has similar capabilities as do most calendars I’ve used (Google Calendar, Outlook, NextCloud), just without the voice commands.

openHAB is pretty much capable of doing anything, but that doesn’t mean it’s good at everything. When it comes to sending a reminder like this, there are likely other tools that are much better suited to the task.

See Design Pattern: DRY, How Not to Repeat Yourself in Rules DSL.

thanks for your answers!

I’ll try to realize it and provide some feedback once I either got it running or despair of trying :wink: