Enter Time with setpoint?

Hi There,

deep in my mind i have the view that ist is possoble to Enter/Change a time value with setpoint. Idea is to have a setpoint that increases oder decreases a time value maybe by 15 minutes and this should be displayes linke: 12:30

Is that possible?

Thomas

1 Like

Found the solution:

Create a Number Item, Create a map file wich maps Value from 0 to 1439 to 00:00 upto 23:59, Create the setpoint with the mapping

Thats it.

Anyone a smarter simple solution?

Thomas

Hi
Did you implement the set time as descripted above? I think thats a good idea.
Can you post possibly an example of the implementation?
That would be very nice, thanks

Did that to control my christmas tree. I will see if i find the rules etc. and post them here, but that will take some time

You could try something like:

Item:

Number myClock

Transformation (JS):

(function(i) {
    var hours = Math.floor(i / 60);
    var minutes = i % 60;

    hours = (hours < 10) ? "0" + hours : hours;
    minutes = (minutes < 10) ? "0" + minutes : minutes;

    return hours + ":" + minutes;
})(input)

Sitemap:

Setpoint item=myClock label="Clock [JS(numberToClock.js):%s]" minValue=0 maxValue=1425 step=15

In BasicUI, this works fine. But unfortunately, in the iOS app the transformation on a Setpoint item doesn’t work: it just shows you the number instead of the time (hh:mm). Related issue that is already reported for that is:

10 Likes

This is much more elegant than my solution with a map

Thanks!
Though I have no immediate use for it, I entered it in my OH anyway, just in case I need it.
I saw that in the android app, it works fine, albeit that the “choice wheel” shows the untransformed numbers, the outcome though shows time formatted numbers.
Not sure how easy it is to use it as a specific time, but I’ ll cross that bridge when I get there. For now, a big thanks

Works perfect thanks! Works on iPhone now too (am running OH2.5)

Good but how convert now.getHourOfDay()

I need rule like this:
if (now.getHourOfDay()==Testclock.state)
{
sendBroadcastNotification(“TEST”)
}

First, you would have to decide when to run your rule.

A more efficient approach is to run a completely different kind of rule, when your test Item changes, perhaps also at each midnight etc. That rule can calculate when you want the thing to happen, and set up a timer for that target time.

I know all code:
rule “test”
when Time cron “0 */5 * ? * *” // Every 5 minutes
then
if (now.getHourOfDay()==Testclock.state)
{
sendBroadcastNotification(“działa!”)
}
end