Help creating time item from UI widget


I have a very basic OH2 set-up (just monitors items like temp, RH at the moment using Z-wave or MQTT), and I’m looking to migrate to OH3 and start using it to do things with rules. I’m really impressed with some of the pages people have created in OH3 (and with the potential of what OH3 offers), but I’m really struggling to use it as someone who has little coding experience and is completely new to YAML.

At the moment I’m trying to create an item that is a time (e.g. 09:30) that I can set using an input widget. Using this set-time, I then want to run a rule. Since this feels like a basic home automation requirement, I was hoping someone has got something I could copy/ edit. The steps I’m looking for:

  1. How do I create the DateTime item (i.e. the set-time)? I’m looking to move away from the .items file to using the UI. What binding do I use to link it to the input widget?

  2. Has anyone got a widget that can select the set-time? I don’t need the date, just a time picker (minutes only need to be to the nearest 15 mins). Below is as an image that shows as far as I can get with an Input Card:

  3. A simple example rule that compares current time to the set-time to do something.

Also, a couple of random questions having played around with OH3 :smiley:

  1. I’ve looked at the Layout pages in the Documentation but still don’t understand the difference between a Cell and a Card in the UI? When should I use one vs. the other?

  2. What is an oh-cell? What does the oh- prefix mean? Is it something to do with YAML?

Any help gratefully received :+1:

If you are seeking help, please do not post in the Tutorials&Examples section! Your question would better fit into the Setup, Configuration & Use section.

  1. What ever binding it’s linked to now. If it’s not linked to a Thing now, then you don’t link it to anything.

  2. See OH 3 Examples: How to boot strap the state of an Item. Be sure to read down and see the replies from Yannick which have some more options.

  3. Rules | openHAB

1 A card is usually a stand alone self contained widget that you’ll see on a Page. A cell you will usually see as part of a card or as a pop-up (e.g. in the developer sideboard when you hover over an Item the widget that pops up is a cell). I’ve never actually done much with cells yet.

2 All the widgets are based on the F7 framework. A number of widgets were custom made for openHAB. Those all start with oh.

All that YAML is is a file format which is intended to be used (and mainly used only in this way in OH) as configuration information.

a DateTime Item isn’t necessarily the best choice, since it must have a unique date etc.
Ideas -

Basically a simple Number can represent “minutes after midnight” for any given day, i.e. a daily clock time.

You have to go through a few layers of documentation to find this tidbit, but all HTML5 input types should be valid in the oh-input, so instead of datetime you can just use time

- component: oh-input
    name: Set Type
    type: time


But even then, as others have pointed out, you will have to do a bit of work before the value you get from that input will be a useful way to trigger a rule.

You are correct this is a fairly common automation request and there are many different ways to accomplish it. This is where some time spent searching the forum can really pay off. You also may be able to find a solution that fits your use beyond just a simple input widget. For example, if you use iOS ecosystem, I believe the iCalendar binding still works with OH3, or if you use the phone apps you may be able to use a phone alarm or tasker to trigger your rule at a set time.

Apologies - I see someone (you?) has already changed this!

Thanks all for the comments, I’ll work my way through them :+1:

@rlkoshak I came across the OH 3 Examples, but since I couldn’t even create the item (set-time parameter), I struggled with this.

I think the bigger issue is that when I started with OH2 (~18 months ago) it was well established, there were loads of you-tube videos & other website tutorials that I could use to get up to speed. This meant that I could find a guide similar to what I wanted to do, follow it and then edit it to suit my needs. And it filled in the gaps in my knowledge along the way.

OH3 feels quite different. I’m trying to embrace the UI and move away from text files (.items, etc). It also introduces YAML and f7, which is another level of stuff to learn from scratch.

Since OH3 is still new, there aren’t the various guides and tutorials out there yet that are for complete newbies (that show every mouse click, every keyboard entry - video tutorials are especially helpful for this). I feel that most of the forum examples all start assuming a base knowledge that is just a little higher than where I am at! And I understand why this is - the early adopters are generally more tech savvy. The tutorials I found on the documentation (Adding Things - Simple / Intermediate / Advanced) are very good, but for a specific task. And I can’t extrapolate from these to what I want to do.

The problem is that I can see how good OH3 is and want to start using it now! :smile: Please note, this is not meant as criticism of anyone or anything other than my own limitations (and resulting frustrations :angry: :laughing: ).

I’ve been successfully using DT Items and just paying attention to the time. If all you supply is the hh:mm:ss it will default the date part to 1970/01/01. And now that Pages support text entry for a DateTime (or even a special widget for entry) it really ends up working better than having to manage all the different parts of a time.

The only tricky part is needing to move the date to today (once changed and again each midnight) but that can be handled in a relatively simple rule. I do this in the Time of Day Python and JavaScript versions.

  /** Moves the passed in ZonedDateTime to today. */
  context.toToday = function(when) {
    var now =;
    var dt = toDateTime(when);
    return dt.withYear(now.getYear()).withMonth(now.getMonthValue()).withDayOfMonth(now.getDayOfMonth());

The above is the JS version of the function that handles doing that from my openhab-rules-tools timeUtils.js library. GitHub - rkoshak/openhab-rules-tools: Library functions, classes, and examples to reuse in the development of new Rules.. But the main part is that last line which is working with ZonedDateTime objects and therefore will work with any of the OH langauges.

Once you move it to today you can use it to schedule Timers.

Google Calendar and Nextcloud among others also support iCal.

It was me.

OH3 has a lot of new stuff. But you don’t have to use the new stuff. All that knowledge you gained with OH 2.5 is still valid. If the new OH 3 stuff is too much right now, ignore it until you are ready for it. And then go little by little.

Except for Pages, there are no new concepts in OH 3. An Item is an Item. A Thing is a Thing. You have some new ways to create and modify these through the UI but they are still the same old Items and Things you are used to.

Thanks :+1:

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