Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add sitemap Input type #3398

Merged
merged 1 commit into from
Feb 24, 2023
Merged

add sitemap Input type #3398

merged 1 commit into from
Feb 24, 2023

Conversation

mherwege
Copy link
Contributor

So far, it has not been possible to have text or numeric input in a sitemap. This can be useful to do simple updating of items, for instance for manual meter readings.
The workaround so far has been to use a Webview element and some javascript, see forum: https://community.openhab.org/t/input-field-for-number-free-text-for-openhab-uis/12461.

This PR adds an sitemap input widget. A second PR will add this to Basic UI.

If these PR's would be accepted, I will also update the main UI sitemap configuration pages to include the input widget. I have not done any app development (Android, IOS) so far, but would hope this is interesting enough for someone to also consider adding it to the apps.

Some configuration options could definitely be added in follow-up PR's for the input field, but my testing shows it is already working well in Basic UI for String, Number and QuantityType items.

Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
@lolodomo
Copy link
Contributor

I am a little surprised that nothing else than the sitemap syntax needs to be updated.
But if that is really the case, that us great.

@mherwege
Copy link
Contributor Author

I am a little surprised that nothing else than the sitemap syntax needs to be updated.

I was surprised as well. But all the required code is automatically generated from the syntax, and that just works. There is more additional code for Basic UI in the webui repository, but still not a lot.

@lolodomo
Copy link
Contributor

An update of the documentation will of course be required.

@mherwege
Copy link
Contributor Author

Of course.
Looking at the documentation, I can do the minimal change, or go through the sitemap documentation and do a more thourough update. E.g. documentation for the chart element talks about begin and end parameters that do not exist, there are links to wiki's on archived repositories for examples, and I feel the warning about preference for main UI is maybe worded a bit too strong. I think it is irrelevant it cannot be shown inside main UI, but it still can be configured there.

@lolodomo
Copy link
Contributor

I think it is irrelevant it cannot be shown inside main UI

You can access BasicUI (and other UIs) from MainUI through the "icon at top right" (don't know how it is properly described).

@mherwege
Copy link
Contributor Author

I have created a minimal documentation update, and will keep a broader update for later.

@seime
Copy link
Contributor

seime commented Feb 24, 2023

Great @mherwege !

If you could add support for DateTime input as well, I think many users will be happy as it then allows for simple scheduling of tasks (in combination with a rule).

@mherwege
Copy link
Contributor Author

support for DateTime input

Next on my list, but will be in another PR, and not sure how to do it yet. Material Design Lite does not have a pre-defined calendar and time input widget, and the default html data/time entry is not very good. In the main UI, that could be solved with a vue datepicker, but that's not an option here. I think it will have to be another input type to make it easier to handle in the mobile apps, where better support is available.

Copy link
Member

@J-N-K J-N-K left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks.

@J-N-K J-N-K merged commit ea20371 into openhab:main Feb 24, 2023
@J-N-K J-N-K added the enhancement An enhancement or new feature of the Core label Feb 24, 2023
@J-N-K J-N-K added this to the 4.0 milestone Feb 24, 2023
@J-N-K J-N-K added the sitemap label Feb 25, 2023
@maniac103
Copy link
Contributor

I think it will have to be another input type to make it easier to handle in the mobile apps, where better support is available.

No reason to do that, we (as in: mobile apps people) can check the item type for choosing the correct widget.

@mherwege
Copy link
Contributor Author

mherwege commented Feb 28, 2023

@maniac103

No reason to do that, we (as in: mobile apps people) can check the item type for choosing the correct widget.

That’s great. What about a parameter for date/time? In some cases, the time is the only thing to be updated (e.g. to update a daily schedule). Other cases you may only want to update the date. So I would thing there needs to be a parameter for that. What do you think?

florian-h05 pushed a commit to openhab/openhab-webui that referenced this pull request Feb 28, 2023
openhab/openhab-core#3398 added an Input element
to sitemaps.
This adds support for configuring this element to MainUI.
A PR for BasicUI to support input elements is in progress
(#1729).

Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
@maniac103
Copy link
Contributor

What about a parameter for date/time? In some cases, the time is the only thing to be updated (e.g. to update a daily schedule). Other cases you may only want to update the date.

That may be a good idea. In the case of the Android app, there's no date/time picker in Material Design 3 anyway, just date pickers and time pickers, but still, with an appropriate hint one could show either one, or both.
WHen introducing such a thing, my suggestion would be to keep the parameter as a generic string (inputHint or something like that?), so it's possible to have different types of hints for different types of input fields if needed at some later point.

@J-N-K
Copy link
Member

J-N-K commented Mar 1, 2023

Since that is essentially content description of the item it should be handled in item metadata.

@maniac103
Copy link
Contributor

Since that is essentially content description of the item it should be handled in item metadata

IMHO it isn't. It's presentation, similar to e.g. Slider min/max/step values, where one could argue to use the item's min/max/step values. The same thing here: why should there only be one possible presentation for a given item and not the choice of keeping date/time combined in one place and keeping it separate in another? A similar thing exists for Sliders, where people want different behaviors (apply during dragging vs. apply on release), but using item metadata for that is conceptually wrong because the option is about the presentation layer, not the item.

@mueller-ma
Copy link
Member

Should it be possible to change the unit of measurement of Number items, e.g. should the user be able to change 20 °C to 30 F? If not mobile apps could display a numeric keyboard which makes it easier to enter numbers, but makes it impossible to enter anything else, like units.

@mherwege
Copy link
Contributor Author

mherwege commented Mar 2, 2023

The implementation in Basic UI allows changing the UOM. And Basic UI does not impact keyboard layout on mobile. This might be another candidate for an inputHint value. If set to number or no UOM present in the numeric value, it would present a numeric keyboard, if not, present a default keyboard.

@lolodomo
Copy link
Contributor

lolodomo commented Mar 5, 2023

For information
@openhab/webui-maintainers
@openhab/android-maintainers
@openhab/ios-maintainers

lolodomo pushed a commit to openhab/openhab-webui that referenced this pull request Apr 8, 2023
Depends on [PR #3398](openhab/openhab-core#3398)

This adds support for an input widget in Basic UI. See Core PR for more
extensive description.

---------

Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
@openhab-bot
Copy link
Collaborator

This pull request has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/documentation-highlight-the-changes-between-version-3-4-4-and-4-0/147801/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement or new feature of the Core sitemap
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants