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

Sitemap: Add parameters to control slider behavior #3430

Closed
6 tasks
mueller-ma opened this issue Mar 7, 2023 · 23 comments
Closed
6 tasks

Sitemap: Add parameters to control slider behavior #3430

mueller-ma opened this issue Mar 7, 2023 · 23 comments
Labels
enhancement An enhancement or new feature of the Core sitemap

Comments

@mueller-ma
Copy link
Member

mueller-ma commented Mar 7, 2023

Let's try the new issue template (#3427):

Is your feature request related to a problem? Please describe.

In openHAB two different behavior exist for sending updates:

  1. Send the update when the mouse click/finger touch is released.
  2. Send the update while the slider is still changed.

I tested these sliders:

  • Basic UI: Option 1
  • Config page of Dimmer items in Main UI: Option 2
  • Android app: Recently changed from 1 to 2
  • iOS app has a setting to set option 1 or 2 globally

Option 2 is good for things that can change quickly, e.g. brightness or volume, but not for rollershutters as they cannot move so fast. This option may also cause issues when too many updates are sent in a short time, e.g. here: openhab/openhab-android#3241

Describe the solution you'd like

Add two new parameters to the Slider, Color and Setpoint widgets, similar to those in the oh-slider-card widget in Main UI:

value: ""
config:
  releaseOnly: false             # Send while sliding
  commandInterval: 300         # But only every 300 (ms?)

The Color widget may have a slider for brightness and the Setpoint widget has a bottom sheet with a slider on Android.

Describe alternatives you've considered

Additional context

https://community.openhab.org/t/define-slider-behavior/144714

Coordination between maintainers

Notify maintainers of other UIs:
@openhab/webui-maintainers
@openhab/android-maintainers
@openhab/ios-maintainers

Checklist for implementation:

  • Core
  • Basic UI
  • Main UI
  • Android app
  • iOS app
  • Docs
@wborn wborn added enhancement An enhancement or new feature of the Core sitemap labels Mar 11, 2023
@mueller-ma
Copy link
Member Author

@openhab/core-maintainers Can you comment in this issue? The current behavior of the sliders in the Android app is causing issues for some users and I want to fix it the right way. IMO the right way are two new parameters in the sitemap syntax, similar to the slider parameters in Main UI.

@kaikreuzer
Copy link
Member

Adding a releaseOnly optional parameter might indeed be the most flexible solution. If it is not given, I would say that option 2 should be the default.
I wouldn't necessarily add commandInterval - in the past we used 300ms everywhere where this was needed and I think this is a suitable value - no real need to make this configurable (and change the code everywhere to take the configuration into account).

@lolodomo
Copy link
Contributor

If default is option 2, the most impacted UI would then be Basic UI and this will require someone to implement the change.
As a side note, the behaviour of the slider is not working well in Basic UI, sometimes the new value when you release the mouse is just not considered.
Regarding the setpoint widget, having a slider was not really in the original way this widget was defined. Maybe a specific option has to be introduced for that widget to let the user choose between a slider and the up/down buttons ? I have to check how it now renders in Android app. But adding option(s) about sliding to the setpoint widget also means enhancing the setpoint widget in all UIs to add the (optional) slider. Or we assume that this will be used only by the Android app ?

@maniac103
Copy link
Contributor

maniac103 commented Apr 10, 2023

For setpoints (and roller shutters), it's only a detail view, the up/down buttons are the default. openhab/openhab-android#3247 has a screenshot of it.
For that reason, I'd keep those two items aside in the discussion here and imply releaseOnly for them in said detail view.
There's also a third option: imply behavior from widget and/or item type, like I suggested in openhab/openhab-android#3244
Maybe that kind of logic could also be used if the user didn't give a value. We'll need it in the Android app in any case when dealing with older servers.

@mueller-ma
Copy link
Member Author

For that reason, I'd keep those two items aside in the discussion here and imply releaseOnly for them in said detail view.

That seems like a good compromise 👍

Regarding the setpoint widget, having a slider was not really in the original way this widget was defined.

The detail view of the Setpoint widget has been implemented in the Android app years ago and AFAIK users really like it. Maybe enhance Basic UI, but that's a bit off-topic here.

There's also a third option: imply behavior from widget and/or item type

As you said I think it's a good idea to use this as fallback.

@lolodomo
Copy link
Contributor

lolodomo commented Oct 9, 2023

I can easily enhance the sitemap syntax to add this new parameter. I suppose we also need to enhance the REST API response?
I am just asking myself if the default should not be rather mode 1 (send the update when the mouse click/finger touch is released). Remember that for items in a group, when opening the group, you will get the default without any way to adjust it. So the default should be a behaviour that will work for all use cases. And you mentioned use cases for which mode 2 is inappropriate.

@mueller-ma
Copy link
Member Author

Yes, the REST API needs to be enhanced as well. I don't have a strong opinion on the default setting.

@maniac103
Copy link
Contributor

So the default should be a behaviour that will work for all use cases.

How about my option 3 mentioned above?

@lolodomo
Copy link
Contributor

lolodomo commented Feb 11, 2024

releaseOnly will just be a boolean. It will be set to true if "releaseOnly" is present in the element properties and to false if not.
So the default would then be behaviour 2 and users should adjust their sitemaps if they want behaviour 1.
For the default slider created automatically for groups or when using "Default" element (most critical case as users cannot customise it), I would suggest to keep behaviour 1 as it is OK in all situations while behaviour 2 is not. Is it ok for you ?

I am going to create the core PR enhancing the sitemap syntax and the REST API.

lolodomo added a commit to lolodomo/openhab-core that referenced this issue Feb 11, 2024
Related to openhab#3430

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
J-N-K pushed a commit that referenced this issue Feb 12, 2024
Related to #3430

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
@lolodomo
Copy link
Contributor

lolodomo commented Apr 8, 2024

@maniac103 @mueller-ma : did you already start something in Android app for this new option ?
I am going to start for Basic UI after fixing the current slider misbehaviour.

@mueller-ma
Copy link
Member Author

No, I haven't started implementing it. Is this already supported by the Main UI Sitemap generator?

@lolodomo
Copy link
Contributor

Is this already supported by the Main UI Sitemap generator?

I just searched and did not find any PR for that

@lolodomo
Copy link
Contributor

@mherwege : any chance that you add this new attribute in the sitemap generator ?

@mherwege
Copy link
Contributor

@mherwege : any chance that you add this new attribute in the sitemap generator ?

Yes, I will.

mueller-ma added a commit to mueller-ma/openhab.android that referenced this issue Apr 14, 2024
See openhab/openhab-core#3430

Signed-off-by: mueller-ma <mueller-ma@users.noreply.github.com>
mueller-ma added a commit to mueller-ma/openhab.android that referenced this issue Apr 16, 2024
See openhab/openhab-core#3430

Signed-off-by: mueller-ma <mueller-ma@users.noreply.github.com>
maniac103 pushed a commit to openhab/openhab-android that referenced this issue Apr 17, 2024
See openhab/openhab-core#3430

Signed-off-by: mueller-ma <mueller-ma@users.noreply.github.com>
@mherwege
Copy link
Contributor

mherwege commented Apr 17, 2024

I forgot about it, but I did already create the PR for it in the sitemap creator: openhab/openhab-webui#2345. It has been merged a while already.

lolodomo added a commit to lolodomo/openhab-webui that referenced this issue Apr 19, 2024
Fix openhab#2525
Also related to openhab/openhab-core#4084 and openhab/openhab-core#3430

Two behaviour modes are now supported.
- If releaseOnly attribute is set, the new value is sent to the item only when the slider is released.
- If releaseOnly attribute is unset, new values are sent to the item while moving the slider. Events are sent at a certain frequency, this frequency is defined by the sendFrequency attribute if set or every 200 ms by default.

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
lolodomo added a commit to lolodomo/openhab-webui that referenced this issue Apr 19, 2024
Fix openhab#2525
Also related to openhab/openhab-core#4084 and openhab/openhab-core#3430

Two behaviour modes are now supported.
- If releaseOnly attribute is set, the new value is sent to the item only when the slider is released.
- If releaseOnly attribute is unset, new values are sent to the item while moving the slider. Events are sent at a certain frequency, this frequency is defined by the sendFrequency attribute if set or every 200 ms by default.

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
lolodomo added a commit to lolodomo/openhab-webui that referenced this issue Apr 19, 2024
Fix openhab#2525
Also related to openhab/openhab-core#4084 and openhab/openhab-core#3430

Two behaviour modes are now supported.
- If releaseOnly attribute is set, the new value is sent to the item only when the slider is released.
- If releaseOnly attribute is unset, new values are sent to the item while moving the slider. Events are sent at a certain frequency, this frequency is defined by the sendFrequency attribute if set or every 200 ms by default.

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
@lolodomo
Copy link
Contributor

lolodomo commented Apr 20, 2024

I wouldn't necessarily add commandInterval - in the past we used 300ms everywhere where this was needed and I think this is a suitable value

@kaikreuzer : in my proposed implementation for Basic UI, I reused the existing parameter sendFrequency as command interval and considered 200 ms as default value (the value which was there before).
@mueller-ma : what was your choice in the Android app ? Did you consider this parameter or hardcode an interval ?

I will be in favour of using this parameter sendFrequency but in case we decide to not use it, I would suggest to remove it from the sitemap documentation.

lolodomo added a commit to lolodomo/openhab-webui that referenced this issue Apr 20, 2024
Fix openhab#2525
Also related to openhab/openhab-core#4084 and openhab/openhab-core#3430

Two behaviour modes are now supported.
- If releaseOnly parameter is set, the new value is sent to the item only when the slider is released.
- If releaseOnly parameter is not set, new values are sent to the item while moving the slider. Events are sent at a certain frequency, this frequency is defined by the sendFrequency parameter if set or every 200 ms by default. Event is not sent when the value is is unchanged (when stopping the move but keeping the mouse pressed).

The brightness slider of the colorpicker widget is also updated to send regular new color commands when moving the slider.

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
@maniac103
Copy link
Contributor

Did you consider this parameter or hardcode an interval ?

We hard coded it (to 200ms). I don't see a compelling reason for making this configurable - do you?

@lolodomo
Copy link
Contributor

lolodomo commented Apr 21, 2024

I don't see a compelling reason for making this configurable - do you?

Maybe some devices do not accept commands at such frequency?

But if you all think it is useless, I will also keep the hardcoded value of 200ms in Basic UI and remove this parameter from the syntax.

@kaikreuzer
Copy link
Member

I think the 200ms is fine and I do not remember that anybody ever asked to have it configurable. So I'd go the simple way and simply leave it at this default and remove the parameter from the syntax.

@lolodomo
Copy link
Contributor

I already removed the usage of this parameter from my PR.

kaikreuzer pushed a commit to openhab/openhab-webui that referenced this issue Apr 21, 2024
Fix #2525
Also related to openhab/openhab-core#4084 and openhab/openhab-core#3430

Two behaviour modes are now supported.
- If releaseOnly parameter is set, the new value is sent to the item
only when the slider is released.
- If releaseOnly parameter is not set, new values are sent to the item
while moving the slider. Events are sent at a certain frequency, this
frequency is defined by the sendFrequency parameter if set or every 200
ms by default. Event is not sent when the value is is unchanged (when
stopping the move but keeping the mouse pressed).

The brightness slider of the colorpicker widget is also updated to send
regular new color commands when moving the slider.

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
@lolodomo
Copy link
Contributor

Remains documentation to update.

@mueller-ma
Copy link
Member Author

@lolodomo
Copy link
Contributor

@openhab/core-maintainers : I believe we can now close this feature request as implemented. Only support in iOS app is not yet done.

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

No branches or pull requests

7 participants