Skip to content

jinglemansweep/wideboy

Repository files navigation

WideBoy

mypy flake8 black codeql License

WideBoy Logo

WideBoy was designed to act as a unique home dashboard. It is a custom PyGame application designed to be displayed on HUB75 LED matrix panels, powered by a modern Raspberry Pi.

It displays basic information such as the current date and time, weather information and calendar events. An image carousel sprite is also included to showcase artwork or other images.

WideBoy has extensive Home Assistant support in that it is fully remotely controllable via the MQTT Discovery integration. Also, a comprehensive animated dynamic Entity grid sprite is provided, where each tile can be configured with it's own style, icon and visibility rules.

Wideangle Photo of WideBoy Display

Features

  • ⏰ Customisable dedicated clock widget
  • 📆 Basic calendar with events and reminders
  • ☀️ Weather summary and next hour forecast
  • 📷 Background image slideshow (great with ArtyFarty AI art generator)
  • 🏠 Animated dynamic Home Assistant entity grid
  • 📨 Announcements and notifications via MQTT
  • 📡 Remote control via MQTT and Home Assistant
  • 🔳 QR code display for easy linking from mobile devices
  • 🍓 Optimised for DietPi running on a Raspberry Pi 4

Screenshots

Default scene showing background artwork carousel sprite as well as dynamic Home Assistant entity tile grid sprite:

Default Scene

Default scene showing real-time incoming MQTT notification message:

Incoming Notification

Animated starfield scene:

Animated Starfied

Credits and debugging scene:

Animated Starfield

Home Assistant MQTT Device:

Home Assistant Device

Home Assistant Entity Tile Grid:

Home Assistant Entity Tile Grid

Usage

MQTT

By default, WideBoy subscribes and publishes to topics starting with wideboy/<device-id>. The device ID is automatically generated from the devices MAC address but can be overridden (see settings.toml).

If configured to use the same MQTT broker as Home Assistant, WideBoy will automatically advertise and configure itself using Home Assistant's MQTT Discovery mechanism.

Manual MQTT control is also possible, see below for example topic and message formats:

Power

# Turn on
mosquitto_pub -t "wideboy/example/master/set" -m '{"state": "ON"}'

# Turn off
mosquitto_pub -t "wideboy/example/master/set" -m '{"state": "OFF"}'

# Set display brightness to 50% (100% = 255)
mosquitto_pub -t "wideboy/example/master/set" -m '{"state": "ON", "brightness": 128}'

Scene Control

# Advance to next scene
mosquitto_pub -t "wideboy/example/scene_next/set" -m '{"state": "PRESS"}'

# Switch to 'default' scene
mosquitto_pub -t "wideboy/example/scene_select/set" -m "default"

# Switch to 'starfield' scene
mosquitto_pub -t "wideboy/example/scene_select/set" -m "starfield"

# Trigger custom scene actions
mosquitto_pub -t "wideboy/example/action_a/set" -m '{"state": "PRESS"}'
mosquitto_pub -t "wideboy/example/action_b/set" -m '{"state": "PRESS"}'

Notifications / Alerts

# Display 'Hello World' notification on display
mosquitto_pub -t "wideboy/example/message/set" -m "Hello World"

Debugging

# Save screenshot (to 'images/screenshots' directory)
mosquitto_pub -t "wideboy/example/screenshot/set" -m '{"state": "PRESS"}'

Sensors

# Current FPS
mosquitto_sub -t "wideboy/example/fps/state"

Entity Tile Grid

The provided Tile Grid sprite relies on Home Assistant's MQTT Statestream integration which publishes specific entity state changes over MQTT. Each grid tile subscribes to specific entity states and will redraw on change.

Enabling the Statestream integration requires manual changes to Home Assistant's YAML configuration files.

If you have a large number of entities, it is advisable to only publish changes for entities you want to display in the tile grid to avoid overloading the MQTT service. Entities can be whitelisted or blacklisted using the include and exclude directives.

The following snippet should be added to configuration.yaml or equivalent:

mqtt_statestream:
  base_topic: homeassistant/statestream
  publish_attributes: true
  publish_timestamps: false
  include:
    entity_globs:
      - sensor.speedtest_download_average
      ...

The statestream_topic_prefix option in the homeassistant section of settings.toml will need updating to match the base_topic specified above.

Each Entity tile must be created as a Python class which can then be added to Column groups and finally rendered as a full grid. See wideboy/scenes/default/tiles.py for some examples.

Components

Hardware

Software

Installation

Fetch dependencies submodules:

git submodule update --init --recursive

Build rpi-rgb-led-matrix Python bindings:

cd lib/rpi-rgb-led-matrix
make build-python

Configuration

Project configuration is provided using Dynaconf, meaning that configuration can be provided using one or more TOML files, but can also be overridden at runtime using environment variables. For more information, see config.py.

The provided settings.toml details all the available options, but they are all commented out. The preferred method of configuration is to override any settings by creating a settings.local.toml and/or a secrets.toml (for sensitive values). Both of these files, if they exist, will be used, but should not be stored in source control and are therefore ignored using .gitignore.

Development

Create a Python 3.x virtual environment, and install project dependencies:

python3 -m venv venv
. venv/bin/activate
pip install --upgrade pip poetry
poetry install

Running

To run the project:

. venv/bin/activate
python3 -m wideboy