这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@digitaldan
Copy link
Contributor

@digitaldan digitaldan commented Sep 4, 2023

This allows the local running instance of the UI to listen to an item for commands. Specifically it will understand the following commands.

  • navigate
  • popup
  • popover
  • sheet
  • close (closes all popups/sheets/popover)
  • back
  • reload
  • notification

Commands with arguments use a colon delimiter, mirroring widget actions in the UI, for example
navigate:/pages/page
popup:widget:customWidget
notification:Text:Title:Sub Title:Title Right:5000

I have this as a WIP as i play with this some more, but its very handy for tablets i have mounted around the house, i can easily pop up a camera, or a SIP call when the doorbell rings, trigger a reload when i have made UI changes or after a system update/restart, etc.....

users can select the item in the about menu, since we have other local options set there its seemed to be the best place.

image

@digitaldan digitaldan requested a review from a team as a code owner September 4, 2023 18:03
@relativeci
Copy link

relativeci bot commented Sep 4, 2023

Job #1175: Bundle Size — 15.79MiB (+0.18%).

732170a(current) vs b7270d2 main#1158(baseline)

Warning

Bundle contains 16 duplicate packages - View duplicate packages

Warning

Bundle introduced 13 new packages: @jsep-plugin/regex, @jsep-plugin/arrow, @jsep-plugin/object and 10 more - View changed packages

Bundle metrics (10 changes)
                 Current
Job #1175
     Baseline
Job #1158
Initial JS 1.85MiB(+10.9%) 1.67MiB
Initial CSS 608.95KiB(+0.01%) 608.89KiB
Cache Invalidation 93.81% 93.95%
Chunks 217(-0.91%) 219
Assets 683(-0.87%) 689
Modules 2987(+75.71%) 1700
Duplicate Modules 174(+93.33%) 90
Duplicate Code 1.63%(-16.41%) 1.95%
Packages 152(+10.14%) 138
Duplicate Packages 16(+6.67%) 15
Bundle size by type (3 changes)
                 Current
Job #1175
     Baseline
Job #1158
CSS 860.19KiB (+0.08%) 859.49KiB
Fonts 526.1KiB 526.1KiB
HTML 1.23KiB 1.23KiB
IMG 140.74KiB 140.74KiB
JS 9.27MiB (+0.21%) 9.25MiB
Media 295.6KiB 295.6KiB
Other 4.73MiB (+0.17%) 4.73MiB

View job #1175 reportView digitaldan:command-item branch activity

@ghys
Copy link
Member

ghys commented Sep 5, 2023

Thanks @digitaldan, this seems like a useful feature.

My main worry is the new SSE connection dedicated to it.

As you might know (https://news.ycombinator.com/item?id=30313844) there's a 4-connections limit per domain (not per tab) on these so as the Main UI uses two for normal operation (one for state updates and one for relevant event updates dependent on the current page), then there's the webaudio one (#1422) and now this would potentially introduce another one. So that's up to 4 connections just for one tab of the Main UI, and in that case, if you open another tab (even if it's Basic UI or HABPanel) then it'll start to fail. Won't happen if you dedicate a tablet to displaying the UI but still.

I would suggest trying to try to mitigate that by refactoring these two features (webaudio and UI commands) which rely on a permanent connection so they can share a single one (you can check which features are enabled in localCache and tweak the topics parameter according to it with comma-separated topics in case both are enabled; so it could be e.g.
topics=openhab/webaudio/playurl,openhab/items/${itemName}/command.
Of course all this would become a moot point when/if we eventually switch to a websocket.

This could be a good opportunity to move all this logic to other file(s) (either imported or a mixin) dedicated to these permanent listeners as app.vue is becoming quite messy IMO.

@ghys
Copy link
Member

ghys commented Sep 5, 2023

Update, I re-checked and apparently it's 6 concurrent EventSource connections, not 4 per domain like I always thought:

https://bugs.chromium.org/p/chromium/issues/detail?id=275955
https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#listening_for_custom_events

Warning: When not used over HTTP/2, SSE suffers from a limitation to the maximum number of open connections, which can be especially painful when opening multiple tabs, as the limit is per browser and is set to a very low number (6). The issue has been marked as "Won't fix" in Chrome and Firefox. This limit is per browser + domain, which means that you can open 6 SSE connections across all of the tabs to www.example1.com and another 6 SSE connections to www.example2.com (per Stackoverflow). When using HTTP/2, the maximum number of simultaneous HTTP streams is negotiated between the server and the client (defaults to 100).

@digitaldan
Copy link
Contributor Author

Yeah, the additional connection seems wasteful, i did not think about combining it with the audio sink one, thats a good idea until we can move to a websocket model. Agreed also to look at moving code outside of app.vue.

Signed-off-by: Dan Cunningham <dan@digitaldan.com>
@digitaldan digitaldan changed the title [WIP] Adds a UI Command Item Adds a UI Command Item Sep 24, 2023
@digitaldan
Copy link
Contributor Author

I still need to test that audio continues to work, but this is ready to be looked at for code review. I also will need to add documentation about these new features. I updated my first post with all supported commands and more examples.

@digitaldan
Copy link
Contributor Author

Confirmed that the audio sink works as well

Signed-off-by: Dan Cunningham <dan@digitaldan.com>
Copy link
Contributor

@florian-h05 florian-h05 left a comment

Choose a reason for hiding this comment

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

LGTM, and works fine!
Really good idea, probably you got inspired by HABPanel's "Switch dashboard with item value"?

Please have a look at my comments.

@florian-h05 florian-h05 added enhancement New feature or request main ui Main UI labels Sep 25, 2023
@digitaldan
Copy link
Contributor Author

LGTM, and works fine! Really good idea, probably you got inspired by HABPanel's "Switch dashboard with item value"?

Actually, i use https://github.com/vbier/habpanelviewer (well, a slightly modified version), but for our Main UI only, on a bunch of tablets around the house and use it's built in command item functionality extensively for reloading and navigating to pages on events, but this would replace most of that with the benefit of allowing me to use iPads if i need to ( my android tablets are very sluggish with our main UI).

Signed-off-by: Dan Cunningham <dan@digitaldan.com>
Signed-off-by: Dan Cunningham <dan@digitaldan.com>
Copy link
Contributor

@florian-h05 florian-h05 left a comment

Choose a reason for hiding this comment

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

LGTM, just two minor comments.
I will test this ASAP and then merge it.

Signed-off-by: Dan Cunningham <dan@digitaldan.com>
@digitaldan
Copy link
Contributor Author

Thank @florian-h05 for the review !

@digitaldan
Copy link
Contributor Author

Also, i probably need to write some documentation up on this, I guess adding this to https://github.com/openhab/openhab-docs/blob/main/ui/index.md would be the best path forward?

@florian-h05
Copy link
Contributor

Given that the title is "User Interface Design Overview", I would not expect the command Item there, however if the title is changed to "User Interface Overview", it could fit in there. If the docs are long, I would say introduce a new page.

Copy link
Contributor

@florian-h05 florian-h05 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! I will merge this when the milestone build finished.

@florian-h05 florian-h05 changed the title Adds a UI Command Item Adds an UI command Item Oct 8, 2023
@florian-h05 florian-h05 added this to the 4.1 milestone Oct 8, 2023
@florian-h05 florian-h05 merged commit 27c140a into openhab:main Oct 8, 2023
@digitaldan
Copy link
Contributor Author

I think https://www.openhab.org/docs/settings/aboutpage.html would probably be a better location

@florian-h05
Copy link
Contributor

Yeah, there already is a section about Web Audio sink support.
However IMHO the command Item should be promoted somewhere else - would be sad if no one notices it.

ghys pushed a commit that referenced this pull request Oct 9, 2023
Addresses
#2055 (comment).

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
florian-h05 added a commit that referenced this pull request Oct 30, 2023
…ing (#2157)

Fixes #2153.
Regression from #2055.

MainUI was broken on older iOS versions, e.g. 15.8, because RegEx
lookbehind assertions were introduced with Safari 16.4.
This uses split by string instead and adds an ESLint rule to forbid
the usage of RegEx lookbehind assertions.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
@OmegaQuest
Copy link

I noticed that the Audio Sink dosent work after a "Navigate to Page" Command UI is done after a short period of time, unless you manually click the new page. Its like the Audio Sink times out after a while when the Command UI is done (unless you click the page somewhere). This time-out dosent happen with the normal Navigate to Page or after you click somewhere on the screen "After" the Command UI navigated to a new page.

Server Side:
OpenHab: 4.2.0 M1
Ubuntu 22.04.4 LTS

Client/Web Side:
Windows 10
Chrome Browser

@florian-h05
Copy link
Contributor

florian-h05 commented Mar 29, 2024

That's a limitation of modern browsers:

Please note that due to limitations in Safari (and possibly Chrome as well), a user interaction is required after the first audio stream has been sent to actually play it. This means, that after opening Main UI, the first audio that should be played on the web audio sink is only played after the user interacts with Main UI in any way (i.e. touching the screen is enough). For subsequent audio playback the above is not required anymore and the audio is played immediately.

(https://next.openhab.org/docs/mainui/about.html#web-audio-sink)

In case the command Item tells the UI to navigate to a different page, I guess the same happens.

@OmegaQuest
Copy link

But it also does it with Edge

@florian-h05
Copy link
Contributor

I guess it is the same in all modern browsers.
And Edge is Chromium based, if it doesn’t work in Chrome, it likely also won’t work in Edge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request main ui Main UI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants