Smart home system diagram, from sensor to phone, in Python
This invented smart home system, from the devices in each room to the apps on a phone, is for anyone who explains a connected-device product. open-diagram draws it from a 35-line Python script.
Updated
A smart home, from sensor to phone. Drawn by open-diagram 0.6.2 from examples/smart_home.py: 0 layout problems. Source
The picture as text
A smart home, from sensor to phone
States shown: Live, Being built, In trial, Retiring. Solid lines: data flows today. Dotted lines: connection to build.
Blocks, left to right:
- Devices (In every room): Thermostat; Door lock; Lights; Motion sensors
- Home hub (Talks to every device): Device pairing; Local rules; Works offline (being built)
- Cloud: Device registry; Usage history; Firmware updates (being built). Owner: Platform team
- Apps: Phone app; Voice assistants (in trial); Web dashboard (retiring). Owner: Apps team
Lines:
- Devices -> Home hub
- Home hub -> Cloud
- Cloud -> Apps
- Apps -> Home hub, labeled "At home, the phone talks to the hub directly"
- Cloud -> Devices (connection to build), labeled "New firmware sent to devices at night"
Note: Example. An invented product. Every part and status is made up.Which way does the data go?
Left to right, from the devices to the home hub, the cloud and the apps. Two lines take shortcuts in lanes. Along the top, the phone talks to the hub directly when it is at home. Along the bottom, a dotted line marks a firmware path still to build. Working offline and firmware updates are being built.
Which building blocks draw it?
"""An invented smart home system, from the sensors in each room to the apps on a phone.
Run: python3 examples/smart_home.py"""
import os
from open_diagram import Diagram, Note, Panel, Tile, Tiles
HERE = os.path.dirname(os.path.abspath(__file__))
def build() -> Diagram:
d = Diagram("A smart home, from sensor to phone", tag="EXAMPLE",
note=Note("Example", "An invented product.", "Every part and status is made up."))
(devices,), (hub,), (cloud,), (apps,) = d.columns([
[Panel("Devices", Tiles(["Thermostat", "Door lock", "Lights", "Motion sensors"], cols=2), sub="In every room")],
[Panel("Home hub", Tiles(["Device pairing", "Local rules", Tile("Works offline", status="building")], cols=1),
sub="Talks to every device")],
[Panel("Cloud", Tiles(["Device registry", "Usage history", Tile("Firmware updates", status="building")],
cols=1), footer="Owner: Platform team")],
[Panel("Apps", Tiles(["Phone app", Tile("Voice assistants", status="trial"),
Tile("Web dashboard", status="retiring")], cols=1), tone="neutral",
footer="Owner: Apps team")],
], gap=80, valign="center")
d.link(devices, hub)
d.link(hub, cloud)
d.link(cloud, apps)
top = min(p.y for p in d.placed) - 56
bottom = max(p.bottom for p in d.placed) + 44
d.link(apps, hub, start="top", end="top", via_y=top, label="At home, the phone talks to the hub directly")
d.link(cloud, devices, start="bottom", end="bottom", via_y=bottom, kind="planned",
label="New firmware sent to devices at night")
return d
if __name__ == "__main__":
build().save(os.path.join(HERE, "..", "docs", "images", "smart_home"))d.columns()places one panel per column, 80 px apart, centred against the tallest.Tiles([...], cols=2)puts the four devices in a two-by-two grid. The other panels use one column.sub="In every room"adds a line under a panel title.- Both shortcut lines use
via_y. The script reads the panels' positions fromd.placedand sets one lane above them and one below. kind="planned"makes the firmware line dotted, in its lane.
How do I show that a part has shipped?
Change its status in the script, or keep statuses in a separate file and draw with --statuses. When the two tiles being built ship:
{"Firmware updates": "live", "Works offline": "live"}open-diagram draw smart_home.py --statuses states.jsonBoth tiles take the plain look, and "Being built" drops out of the key. A status file changes panels and tiles only, so the firmware line stays dotted until the script changes it.
How do I make my own?
Copy examples/smart_home.py and put in your own devices, services and apps. Install open-diagram with pip install open-diagram, then run open-diagram check smart_home.py and open-diagram draw smart_home.py.
When is this kind of diagram useful?
When a product has parts in the home and parts online, and a reader needs to know which path the data takes. The lanes show the exceptions without crossing the main flow.