My Vision of a Smart Building Operating System

I have a vision of a smart building operating system.

A whole building operating system, built on web technologies, which weaves together every sensor, actuator and human-computer interface in a building into a seamless user experience.

Smart Building OS User Interface

This vision builds on everything I’ve learnt from working on Webian, Firefox OS and Mozilla WebThings.

Rather than a single desktop or mobile computer, the OS is designed to operate over many different pieces of hardware spread throughout a building.

Hub, Terminals and Devices

Every terminal is a web client, every device has a URL and a hub acts as a central web server.

OS Architecture

Hub

The hub is a central computer for the building.

Hub

This central computer is inspired by the “ship computer” trope and similar ideas often portrayed in science fiction (e.g. the duotronic ship computer from Star Trek, Holly from Red Dwarf, HAL 9000 from 2001: A Space Odyssey, Eddy from The Hitchkiker’s Guide to the Galaxy, KITT from Knight Rider or The Great Machine from Forbidden Planet1).

It acts as a central hub for monitoring, controlling and automating a building. Think of it as a permanent electrical appliance, like a boiler or a fuse box, but for information rather than heat or electricity.

As a long term vision, imagine the hub hosting a semi-autonomous software agent with a conversational voice interface and an interactive 3D model of the building. As a starting point, a server for hosting 2D graphical web applications.

Hub Architecture

Fundamentally the hub is a web server which hosts web applications and stores user data. Each application is isolated inside its own sandboxed container which includes all of the dependencies the application needs and can be atomically updated. Both the host operating system and applications receive automatic over-the-air updates. A reverse proxy sits in front of all the applications and routes HTTP requests to the correct application.

Hub UI

The first of those applications, the “killer app” and default home page of the OS, provides a unified web interface for monitoring, controlling and automating all of the connected devices in the building. It does this by bridging a range of different smart home protocols and commercial building management systems to a single standardised Web of Things API using the Web Thing Protocol, which is then consumed by the web front end. Third party apps and services can also request access to this API.

Terminals

Terminal

“A computer terminal is an interface where the mind and body can connect with the universe and move bits of it about.” — Douglas Adams, Mostly Harmless

Terminals could be a smart display or smart TV (think tabs, pads and boards), or even a smart speaker or VR headset. These are devices which provide a human-computer interface through vision, audio or touch.

Terminals act as web user agents which enable users to interact with the web applications hosted on the hub, but also discover and use installable web applications from anywhere on the World Wide Web.

Terminal Architecture

On the front end is a shell for discovering and using web applications. On the back end are core services which provide the shell with access to hardware such as network adapters, displays, cameras, speakers and microphones.

Terminal UI

The shell communicates with the core services using the Web Thing Protocol. This also means that terminals can act as web things themselves, so that they can be remotely controlled over the network.

Devices

Devices

Devices are the sensors and actuators which interface with the physical world. That could be a motion sensor, door sensor, smoke alarm, smart socket or a light bulb for example.

Devices may natively be web things, or may be bridged to the Web of Things by the hub, from a range of different protocols like Zigbee, Z-Wave, HomeKit, Matter, BACnet and Modbus.

Either way every device has a URL on the Web of Things which acts as a globally unique identifier and resolves to a machine readable WoT Thing Description. The Thing Description describes the capabilities of the device in a machine readable format and provides URL endpoints with which to communicate with it.

Implementation

Interested? Come and join us in the WebThings open source community where Krellian are building the key components which will eventually make up “Krellian OS”, including WebThings Gateway and WebThings Shell.


  1. The name Krellian is actually inspired by the 1956 science-fiction film Forbidden Planet. Krellian meaning “of or belonging to the Krell”. The Krell were an ancient alien race who created “The Great Machine” on Altair IV, a vast underground machine controlled by thought and capable of monitoring and affecting change throughout the whole planet. The machine continued to function autonomously for thousands of years after the Krell themselves went extinct. It serves as both an inspiration and a warning. ↩︎

What is a Web App?

What is a web app? What is the difference between a web app and a web site? What is the difference between a web app and a non-web app?

In terms of User Experience there is a long continuum between “web site” and “web app” and the boundary between the two is not always clear. There are some characteristics that users perceive as being more “app like” and some as more “web like”.

The presence of web browser-like user interface elements like a URL bar and navigation controls are likely to make a user feel like they’re using a web site rather than an app for example, whereas content which appears to run independently of the browser feels more like an app. Apps are generally assumed to have at least limited functionality without an Internet connection and tend to have the concept of residing in a self-contained way on the local device after being “installed”, rather than being navigated to somewhere on the Internet.

From a technical point of view there is in fact usually very little difference between a web site and a web app. Different platforms currently deal with the concept of “web apps” in all sorts of different, incompatible ways, but very often the main difference between a web site and web app is simply the presence of an “app manifest”. The app manifest is a file containing a collection of metadata which is used when “installing” the app to create an icon on a homescreen or launcher.

At the moment pretty much every platform has its own proprietary app manifest format, but the W3C has the beginnings of a proposed specification for a standard “Manifest for web applications” which is starting to get traction with multiple browser vendors.

Web Manifest – Describing an App

Below is an example of a web app manifest following the proposed standard format.

http://example.com/myapp/manifest.json:

{
  "name": "My App",
  "icons": [{
    "src": "/myapp/icon.png",
    "sizes": "64x64",
    "type": "image/png"
  }],
  "start_url": "/myapp/index.html"
}

The manifest file is referenced inside the HTML of a web page using a link relation. This is cool because with this approach a web app doesn’t have to be distributed through a centrally controlled app store, it can be discovered and installed from any web page.

http://example.com/myapp/index.html:

<!DOCTYPE html>
<html>
  <head>
    <title>My App - Welcome</title>
    <link rel="manifest" href="manifest.json">
    <meta name="application-name" content="My App">
    <link rel="icon" sizes="64x64" href="icon.png">
...

As you can see from the example, these basic pieces of metadata which describe things like a name, an icon and a start URL are not that interesting in themselves because these things can already be expressed in HTML in a web standard way. But there are some other other proposed properties which could be much more interesting.

Display Modes – Breaking out of the Browser

We said above that one thing that makes a web app feel more app like is when it runs outside of the browser, without common browser UI elements like the URL bar and navigation controls. The proposed “display” property of the manifest allows authors of web content which is designed to function without the need for these UI elements to express that they want their content to run outside of the browser.

http://example.com/myapp/manifest.json:

{
  "name": "My App",
  "icons": [{
    "src": "/myapp/icon.png",
    "sizes": "64x64",
    "type": "image/png"
  }],
  "start_url": "/myapp/index.html"
  "scope": "/myapp"
  "display": "standalone"
}

The proposed display modes are “fullscreen”, “standalone”, “minimal-ui” and “browser”. The “browser” display mode opens the content in the user agent’s conventional method (e.g. a browser tab), but all of the other display modes open the content separate from the browser, with varying levels of browser UI.

There’s also a proposed “orientation” property which allows the content author to specify the default orientation (i.e. portrait/landscape) of their content.

App Scope – A Slice of the Web

In order for a web app to be treated separately from the rest of the web, we need to be able to define which parts of the web are part of the app, and which are not. The proposed “scope” property of the manifest defines the URL scope to which the manifest applies.

By default the scope of a web app is anything from the same origin as its manifest, but a single origin can also be sliced up into multiple apps or into app and non-app content.

Below is an example of a web app manifest with a defined scope.

http://example.com/myapp/manifest.json:

{
  "name": "My App",
  "icons": [{
    "src": "/myapp/icon.png",
    "sizes": "64x64",
    "type": "image/png"
  }],
  "start_url": "/myapp/index.html"
  "scope": "/myapp"
}

From the user’s point of view they can browse around the web, seamlessly navigating between web apps and web sites until they come across something they want to keep on their device and use often. They can then slice off that part of the web by “bookmarking” or “installing” it on their device to create an icon on their homescreen or launcher. From that point on, that slice of the web will be treated separately from the browser in its own “app”.

Without a defined scope, a web app is just a web page opened in a browser window which can then be navigated to any URL. If that window doesn’t have any browser-like navigation controls or a URL bar then the user can get stranded at a dead on the web with no way to go back, or worse still can be fooled into thinking that a web page they thought was part of a web app they trust is actually from another, malicious, origin.

The web browser is like a catch-all app for browsing all of the parts of the web which the user hasn’t sliced off to use as a standalone app. Once a web app is registered with the user agent as managing a defined slice of the web, the user can seamlessly link into and out of installed web apps and the rest of the web as they please.

Service Workers – Going Offline

We said above that another characteristic users often associate with “apps” is their ability to work offline, in the absence of a connection to the Internet. This is historically something the web has done pretty badly at. AppCache was a proposed standard intended for this purpose, but there are many common problems and limitations of that technology which make it difficult or impractical to use in many cases.

A new, much more versatile, proposed standard is called Service Workers. Service Workers allow a script to be registered as managing a slice of the web, even whilst offline, by intercepting HTTP requests to URLs within a specified scope. A Service Worker can keep an offline cache of web resources and decide when to use the offline version and when to fetch a new version over the Internet.

The programmable nature of Service Workers make them an extremely versatile tool in adding app-like capabilities to web content and getting rid of the notion that using the web requires a persistent connection to the Internet. Service Workers have lots of support from multiple browser vendors and you can expect to see them coming to life soon.

The proposed “service_worker” property of the manifest allows a content author to define a Service Worker which should be registered with a specified URL scope when a web app is installed or bookmarked on a device. That means that in the process of installing a web app, an offline cache of web resources can be populated and other installation steps can take place.

Below is our example web app manifest with a Service Worker defined.

http://example.com/myapp/manifest.json:

{
  "name": "My App",
  "icons": [{
    "src": "/myapp/icon.png",
    "sizes": "64x64",
    "type": "image/png"
  }],
  "start_url": "/myapp/index.html"
  "scope": "/myapp"
  "service_worker": {
    "src": "app.js",
    "scope": "/myapp"
  }
}

Packages – The Good, the Bad and the Ugly

There’s a whole category of apps which many people refer to as “web apps” but which are delivered as a package of resources to be downloaded and installed locally on a device, separate from the web. Although these resources may use web technologies like HTML, CSS and Javascript, if those resources are not associated with real URLs on the web, then in my view they are by definition not part of a web app.

The reason this approach is commonly taken is that it allows operating system developers and content authors to side-step some of the current shortcomings of the web platform. Packaging all of the resources of an app into a single file which can be downloaded and installed on a device is the simplest way to solve the offline problem. It also has the convenience that the contents of that package can easily be reviewed and cryptographically signed by a trusted party in order to safely give the app privileged access to system functions which would currently be unsafe to expose to the web.

Unfortunately the packaged app approach misses out on many of the biggest benefits of the web, like its universal and inter-linked nature. You can’t hyperlink into a packaged app, and providing an updated version of the app requires a completely different mechanism to that of web content.

We have seen above how Service Workers hold some promise in finally solving the offline problem, but packages as a concept may still have some value on the web. The proposed “Packaging on the Web” specification is exploring ways to take advantage of some of the benefits of packages, whilst retaining all the benefits of URLs and the web.

This specification does not explore a new security model for exposing more privileged APIs to the web however, which in my view is the single biggest unsolved problem we now have left on the web as a platform.

Conclusions

In conclusion, a look at some of the latest emerging web standards tells us that the answer to the question “what is a web app?” is that a web app is simply a slice of the web which can be used separately from the browser.

With that in mind, web authors should design their content to work just as well inside and outside the browser and just as well offline as online.

Packaged apps are not web apps and are always a platform-specific solution. They should only be considered as a last resort for apps which need access to privileged functionality that can’t yet be safely exposed to the web. New web technologies will help negate the need for packages for offline functionality, but packages as a concept may still have a role on the web. A security model suitable for exposing more privileged functionality to the web is one of the last remaining unsolved challenges for the web as a platform.

The web is the biggest ecosystem of content that exists, far bigger than any proprietary walled garden of curated content. Lots of cool stuff is possible using web technologies to build experiences which users would consider “app like”, but creating a great user experience on the web doesn’t require replicating all of the other trappings of proprietary apps. The web has lots of unique benefits over other app platforms and is unrivalled in its scale, ubiquity, openness and diversity.

It’s important that as we invent cool new web technologies we remember to agree on standards for them which work cross-platform, so that we don’t miss out on these unique benefits.

The web as a platform is here to stay!