WebThingsIO / gateway

WebThings Gateway
http://webthings.io/gateway
Mozilla Public License 2.0
2.61k stars 333 forks source link

Distribution for smart speakers & smart displays #2796

Open benfrancis opened 3 years ago

benfrancis commented 3 years ago

In the last WebThings monthly public meeting multiple people (myself included) expressed an interest in adding touch screen controller software to WebThings. There have also been many requests to add built-in support for voice input via microphones directly connected to the gateway (e.g. using the ReSpeaker hat on Raspberry Pi).

I have created a new controller repository (which replaces the things-controller repository) intended for work on a controller application which provides a web runtime to render the gateway's web interface on a screen and accept user input via touch and voice. This application is intended to be used either on a combined gateway/controller device, or on standalone controller devices which connect to a central gateway.

The default Raspberry Pi image of WebThings Gateway (built on Raspberry Pi OS Lite), is designed for headless (i.e. no display, touch panel, microphone or speaker) smart home hubs. Rather than try to augment the existing OS image into a distribution for smart speakers and smart displays (adding lots of dependencies that headless hubs don't need), my suggestion is to create a separate distribution specifically for those devices (e.g. based on the full desktop version of Raspberry Pi OS). It's quite common for Linux distributions to have separate desktop and headless versions (e.g. Raspbian & Raspbian Lite, Fedora Workstation & Fedora Server, Ubuntu Desktop & Ubuntu Server etc.) so this makes perfect sense to me.

The obvious challenge we have is who would maintain this distribution, as we're already lacking the resources needed to continue to maintain the existing cut down distribution for Raspberry Pi. Something which could make this easier is to pick a containerised OS like Ubuntu Core or Balena OS where another organisation maintains the core/host OS (via automatic updates) and we can focus on our maintaining WebThings Gateway & WebThings Controller applications inside their own container(s). We already have a docker image and (WIP) snap package of the gateway application.

flatsiedatsie commented 3 years ago

Wouldn't a full desktop OS create a much bigger attack surface? And as you said, wouldn't having two images create management overhead?

In my experience installing a minimal window manager and privacy-hardened Chromium browser on the headless image worked very well.

https://www.candlesmarthome.com/adding-a-touch-screen-to-the-candle-controller

I created an install script that sets all this up. It can be found here: www.candlesmarthome.com/tools/kiosk.txt

It has cool features, like showing an image / looping logo video during boot.

It did have a downside: what I created did not handle multiple browser tabs gracefully. There was no UI for switching tabs, and this was by design. I tried to just not have the gateway every open other tabs in order to make kiosk-users not have to window-manage. For example, I used browser flags to forbid opening external links. But this still allowed users to open a new tab for the internal logs page, which opens in a new tab.

Perhaps a pragmatic solution would be an addon that manages this window manager and browser installation. But that would require some serious sudo-ing during that installation process :-)

benfrancis commented 3 years ago

Wouldn't a full desktop OS create a much bigger attack surface?

Yes, and that was just an example. What I'd really like to do is to use a much more stripped-down OS with a kiosk runtime. For example, Krellian Kiosk provides a web runtime which runs on mir-kiosk on Ubuntu Core (and also happens to act as a web thing which can be remotely controlled).

And as you said, wouldn't having two images create management overhead?

Yes, but that is preferable to me than trying to transform a headless OS into a graphical one through add-ons which sudo apt install a bunch of dependencies.

One potential solution I have in mind is different pre-built images based on Ubuntu Core. One which bundles a gateway snap, one which bundles a controller snap, and perhaps one which bundles both (or the user could simply install the controller snap on the gateway image or vice-versa). This would be much cleaner than trying to manually apt install a bunch of dependencies, since all the required dependencies are bundled inside the snaps and the core snap and application snaps can be automatically and atomically updated.

The same approach could work with another container solution like docker containers.

In my experience installing a minimal window manager and privacy-hardened Chromium browser on the headless image worked very well.

Whilst that would fulfill the basic use case of displaying a web page on the screen, there are limitations to what can be achieved by just running the full desktop Chromium browser in kiosk mode because you're limited to the features provided by browser. The kiosk runtime I have in mind would be a bit more sophisticated than that, with a WebView API providing a lot more flexibility. (I have a lot of experience with this kind of thing from Webian and Firefox OS.)

Perhaps a pragmatic solution would be an addon that manages this window manager and browser installation. But that would require some serious sudo-ing during that installation process :-)

This is what I would like to avoid :)

flatsiedatsie commented 3 years ago

I see. I was just thinking what would give the quickest result for the least amount of work/overhead. The 80/20 rule and all that. But I know this is your expertise.

you're limited to the features provided by browser

Could you elaborate what you'd be missing?

with a WebView API providing a lot more flexibility

So like an app that has a built-in browser view? Would that be Chromium or Firefox under the hood?

dizzwold commented 2 years ago

Hi Guys,

I'm going to give Candle a try first.

I have the official RPi 7" touchscreen and RPi 4b.

Can you clarify the correct connections from the RPi to the display?

RPi - 7" Display 5v - 5v Gnd - Gnd Which USB? - USB

Darren.

benfrancis commented 2 years ago

Hi @dizzwold,

I suggest the Raspberry Pi forum for questions about the the Raspberry Pi touchscreen and the Candle GitHub repo for questions about Candle.

dizzwold commented 2 years ago

Well I've given up on the Candle system for now as it seems to lack the support I need. Shame as it looks so good.

So I've tried the above approach of benfrancis with the new controller repo, but. I'm on a mac, and how much software have I just downloaded and installed to get even less further and confused. I thought the whole Webthings idea was so you didn't need a Turing Award. Lol. Well confused. How do you even import a github file into android studio, to then flash the RPi, is there no way to do this with Balena Etcher? I think I'm now going bold...

benfrancis commented 2 years ago

Hi @dizzwold,

The new controller repo is currently empty, so I assume you are talking about the old things-controller repo which was a prototype built on Android Things. That repo has been archived for a reason, because Google have discontinued support for Android Things. I don't recommend you try using it, and it was never possible to run both that controller software and the gateway software on the same Raspberry Pi because one is built on Android and the other is built on vanilla Linux (Raspbian).

I thought the whole Webthings idea was so you didn't need a Turing Award. Lol. Well confused.

I'm afraid you're trying to do something that just isn't supported by WebThings right now. WebThings Gateway is designed for headless IoT gateways, I'm sorry if you've been confused by a downstream distribution into thinking otherwise. This issue is about a possible future WebThings distribution for smart speakers and smart displays which doesn't exist yet.

I hope that clears some things up.

dizzwold commented 2 years ago

Hi Ben,  I'm grateful for your detailed reply, thank you.  Regarding the possible future of WebThings for smart speakers and smart dispays, I'm all for that.  I'm surprised this doesn't exist yet and that theres no request poll for it to be added. Regards,  Darren.

On Thursday, 4 November 2021, 11:01:11 GMT, Ben Francis ***@***.***> wrote:  

Hi @dizzwold,

The new controller repo is currently empty, so I assume you are talking about the old things-controller repo which was a prototype built on Android Things. That repo has been archived for a reason, because Google have discontinued support for Android Things. I don't recommend you try using it, and it was never possible to run both that controller software and the gateway software on the same Raspberry Pi because one is built on Android and the other is built on vanilla Linux (Raspbian).

I thought the whole Webthings idea was so you didn't need a Turing Award. Lol. Well confused.

I'm afraid you're trying to do something that just isn't supported by WebThings right now. WebThings Gateway is designed for headless IoT gateways, I'm sorry if you've been confused by a downstream distribution into thinking otherwise. This issue is about a possible future WebThings distribution for smart speakers and smart displays which doesn't exist yet.

I hope that clears some things up.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

benfrancis commented 2 years ago

@dizzwold Oh there's no shortage of requests! But Amazon has 10,000 people working on Amazon Echo products and we... don't.

flatsiedatsie commented 2 years ago

@dizzwold I've recently updated the Candle script that turns a normal Raspberry Pi Webthings Gateway into a device with a touch screen.

A step-by-step guide can be found here: https://www.candlesmarthome.com/adding-a-touch-screen-to-the-candle-controller