Using a User Input


i am currently trying to use a User Input (The user puts in 2 Dates). The goal is to put those Dates in to something like a variable and then use those variables in a rule to switch something on in when the current date is inbetween the 2 Dates.

How would someone do it who knows what hes doing? :smile:



Tutorials and Solutions is a place to post tutorials, not a place to ask for them. I’ve moved this to a more appropriate location.

I strongly recommend going through the Getting Started Tutorial because this is going to involve a lot of different pieces of OH to achieve and you need to know how they all work together.

You have two Dates so you’ll have DateTime Items.

You have something to turn ON which means you have a Switch Item and a Thing with a Switch Channel Linked to that Thing.

You want to do something so that means you need a rule.

Things have Channels. Channels get Linked to Items. Items can be manipulated using the UI (i.e. set the dates) or from rules.

Rules are event driven. “When this happens do that”.

So you need to create a rule that runs based on some event (midnight on the start date?) that commands some Item ON and one that turns it OFF when the second date happens (maybe two rules?). You may need to run the rule a bit more often because what’s it supposed to do if OH restarts between those two dates?

I can’t be more specific because you were not more specific. Also, we don’t tend to “do the homework” for you because then you are forever dependent for help on the forum and never learn how to build it yourself. So give it a try and when or if you run into trouble come back with specific questions with details and we will be happy to clear up any confusion or missing information for you or help you solve some problems.

1 Like

Thanks for the help!

My current Idea is that i set up a widget where the User can put in 2 Dates. Then the User clicks on the button which triggers a Switch Item and that triggers a Rule where those 2 Dates are saved in 2 DateTime Items. Besides that i have another Rule which checks every Day if the current Date is between those 2 saved Dates.

I already have the widget and the 1st rule is triggered when i click on the button. Problem is it wont save those 2 Dates.

Does my Plan make sense and how would i save those 2 Dates so i can compare them in the other rule with the current date?



Why this extra step?

Like I said above, the UI works with Items. Just have the user input the two dat6es into the Items from the UI. No rule required.

You don’t show the widget so :person_shrugging: . But the Widget should be able to just update the Items directly . There’s no need for a separate rule. The whole point of UI widgets is to update and command Items.

1 Like

Thanks for trying to help me. Your’re a great guy!

I am now trying to setup a datepicker input but the widget wont save.


do you see whats wrong?

What do you mean “won’t save”? Is there some error?

I’m not a computer so just looking at some YAML without the error message telling me what’s wrong is rarely productive.

Where did you come up with “datepicker” for the type? I think it should be just date. Clicking on the link under the “type” field shows: Inputs / Form Inputs | Framework7 Documentation

What type of Item is StartDatum?

Look at DateTime Standalone Widget and DateTime List Item for working examples using a full date and time picker. You should be able to just change the type to date.

You can’t just delete all the lines above component when creating a new widget. Your widget won’t save because it doesn’t have a uid; there is no identifier for the widget to be saved as.

At the very least you need to have:

uid: someAlphaNumericIdentifier

at the top of your widget. Even then, you will see that when you do save it, all the other lines get added back in as empty properties.

Hello Guys,

i am here again but with a different question. The other one is solved.

I am now trying to set up an input card with a DateTime Item. But i only want to show the Time. The problem now ist that if i just use the type “time”, the time is not shown after i e.g. reload the page. It is saved in the Item though with the correct time.

working with the item and all works, but it just doesnt show the time whats saved in the item.
Is the problem with the Type DateTime from the Item because it always needs a full input?

Do you guys have any idea on how to solve that?


Thats how it looks after reloading

I think you’re going to have to put in a feature request in the OH UI repository. It doesn’t look like the oh-input is currently configured for this. Right now the oh-input identifies any use of a date based input type and then performs specialized formatting of the item state to match that input type. However it bases that identification on whether the string "date" is found at the front of the type parameter. So, a type of time is not detected as a “date” input type and the pre-existing item state is not formatted.

The repository is here:

And if you’ve never filed an issue before then you may find this helpful:

1 Like

I will create a PR to fix this.


PR created: Support time in oh-input widget by mherwege · Pull Request #2214 · openhab/openhab-webui · GitHub

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