How to display remaining time of a timer created with Blocky rule?

Hi everyone,

I am a beginner and spend quite some time looking for an answer in the forum… but was not successful yet.

Problem statement:
I want to display the remaining time of a timer I created within Blocky rule on one of my openHAB Pages. E.g. I have started a 15min timer and want to see how much time is left while the timer is running.
I think I have to “connect” the Blocky timer with a dedicated “Time remaining” item I have created. But I am not yet successful doing this.

Question:
Can someone please describe how to link a Blocky rule timer with a “remaining timer” item that can be displayed on a page?

Thanks so much for any hint or link,
Steffen

You cannot.

A hack might be to update a DateTime Item when the timer is started, and then perform maths in a separate rule to determine the remaining time. But the UI display updates on Item state changes, so this rule would have to run very frequently.

The core timer object has getExecutionTime which can be used to calculate the remaining time.

nice, a jruby example would be much appreciated

This is more about the UI component that can display a countdown. Might need some javascripting.

Of course, you generally know the target execution time when you start the timer anyway, but that would have uses if you were managing a whole bunch of timers, say.

You are on the right track. To display pretty much anything on the UI you need to use an Item.

Show what you’ve done so far and maybe we can more efficiently point you in the right direction.

In general you’ll need to implement something like Design Pattern : Expire Binding based Countdown timer which is using Expire but the over all approach would be the same.

  1. Update the time remaining Item with the amount of time on the timer.
  2. Create a timer that expires in a second.
  3. Inside the timer, subtract one second from the time remaining Item and update the Item
    4a. If the time is up update the Item to 0 and do the work of the timer.
    4b. if the time isn’t up, reschedule the timer for another second.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.