-
-
Notifications
You must be signed in to change notification settings - Fork 243
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
[Main UI] Add support for webaudio #1422
Conversation
Job #459: Bundle Size — 10.78MB (+0.01%).Changed metrics (2/10)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding this feature.
I'm not particularly happy that it requires the maintenance of a permanent dedicated EventSource connection (something other UIs like HABPanel or Paper UI do/did anyway so it was less of a overhead) provided if it doesn't end up having adverse implications, like running out of the 6 max HTTP/1.1 connections per server - not per tab!
But I'm open to have it out of the interest of having this feature working again for those who need it.
Yes I also don't like the creation of an additional event source but there currently does not seem to be an easy way around it. Some infrastructure that allows for reusing / updating SSE subscription might help. Switching to websockets might also be an option (openhab/openhab-core#2891). It would also be nice if we can get HTTP/2 working with Jetty. 🙂 |
I'm all for switching to websockets as a mid/long-term goal since EventSource seems all but abandoned as a technology (too bad because they were a good fit for pushing events with little overhead), see the difficulties in passing authorization headers, we have to rely on a polyfill even when there's a native implementation. I tried to limit the number of SSE connections given this limitation, usually you would only have one for events (in settings pages) and one for item state updates. It means you can open 3 openHAB tabs at a maximum (never mind other UIs) before running into trouble. |
@wborn just had an idea. Those normally are focused only on appearance (hence the name of the Vue component: https://github.com/openhab/openhab-webui/blob/main/bundles/org.openhab.ui/web/src/components/theme-switcher.vue) and they're backed by local storage. We could expand these local options to more than appearance, including maybe a "Enable Web Audio sink support" option (which I'd like to remain disabled by default to save a precious SSE connection), so users could eventually enable it on select devices, that are perhaps dedicated to displaying the UI, and thus won't be at risk of running out of these 6 connections. Then I'd have no more objections to adding this feature because it would be something that despite its cost is something the user can control and opt-in to. |
Having an option to disable it is always useful, as you may not want to use webaudio on each and every device running an OH UI. |
Fixes openhab#743 Signed-off-by: Wouter Born <github@maindrain.net>
Signed-off-by: Wouter Born <github@maindrain.net>
Signed-off-by: Wouter Born <github@maindrain.net>
Signed-off-by: Wouter Born <github@maindrain.net>
Config option added. ✔️ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having an option to disable it is always useful, as you may not want to use webaudio on each and every device running an OH UI.
🔈 🙂
Yes, exactly!
And that way this has no impact on the number of working simultaneous openHAB tabs on a given browser (the main UI uses up to 2 SSE connections per tab, one /rest/events/states
and one /rest/events
in settings pages) in the default scenario, when the option is left alone.
Perfect, thanks, glad to have this feature back and running.
@wborn Would you mind providing a bit of description how to use the feature here as I am eager to try it out? I'd be happy to add this to the official documentation then. |
Hi @stefan-hoehn! This PR makes it possible to play any audio sent to the To enable webaudio in the UI first switch it on using the new config option: Then you can quickly test if it works by playing some static content that comes with openHAB in the
If you have a dog that gets triggered by barking you may opt for playing Note that most browsers block web pages from playing audio/video automatically nowadays. You first need to interact with the webpage before it will allow audio playback. But browsers allow for overriding this per website using some settings: These are some useful actions available to rules in which you can specify
You can also configure webaudio as sink when creating rules in the UI: If you really like webaudio, you can also make it the default sink in the "Audio" settings. Then you can omit the |
I will try it out as soon as it has become part of the first milestone. I am not brave enough to install the snapshot atm ;-) |
However, @wborn , it seems that streaming doesn't work. Did you try this out? Is it supposed to work? var audio = Java.type('org.openhab.core.model.script.actions.Audio'); |
I didn't test streaming but it seems to cause CORS errors. It also doesn't work for the same reason when using HABPanel. |
The Web Audio sink is now also supported by Main UI and Basic UI, see: * openhab/openhab-webui#1422 * openhab/openhab-webui#1426 Signed-off-by: Wouter Born <github@maindrain.net>
The Web Audio sink is now also supported by Main UI and Basic UI, see: * openhab/openhab-webui#1422 * openhab/openhab-webui#1426 Signed-off-by: Wouter Born <github@maindrain.net> Signed-off-by: Wouter Born <github@maindrain.net>
@wborn I was actually just thinking to document that functionality but it actually already starts that not even the about page is currently documented. Would that makes sense first and if, where would that page documenation go? e.g. here: https://www.openhab.org/docs/tutorial/first_steps.html ? I would start writing/documenting it but I have a few questions Can you help with these settings? I tried to research it in the forum or the docs or by looking into the could but could find a description that would make me understand it. btw, what URL is called the "homepage"? / or something else? Even though I tried to find out by looking into the code I am not sure about the behaviour. a) Simple navigation bar on home page b) Standard home page background color and regarding the other info I even don't find a good place where to dokument that because the whole settings part is kind of not documented in the way it is structured in the UI. Seems I am opening pandoras box here... :) What color is applied? It is not clear to me why this is on / off. I can see in the code that it chooses "default" or "standard" what what is the difference? (I don't see any) cc: @Confectrician |
I don't maintain the docs, so I think it is best for the @openhab/documentation-maintainers to answer where they'd like to see docs for main UI specific configuration. |
It means the navigation bar will look the same even whether you're at the top of the page or not - you won't have the alternate look with the date.
This is only for the light color scheme. The background color will be the same as the regular pages you can show from e.g. the sidebar, which is a kind of gray instead of white. |
@wborn I finally found the time to document it at openhab/openhab-docs#1892 |
My understanding is that to enable WebAudioSink for BasicUI on all devices, one has to go to This makes no sense. Either the option shall be enabled for all devices, or per device, but not for Main UI — per device, while for Basic UI — for all devices from one place. Moreover I would like to be able to set the per-device defaults on one place. That is configure once that webaudiosink in ON, and then from all places (browsers, devices) where I load the openHAB webpages, the webaudio will work. |
Fixes #743