Skip to main content

A Python project for interacting with the Vestaboard local API and post content from various integrations

Project description

Vestaboard Local API Wrapper and Integrations

Overview

This Python package provides an API wrapper for controlling a Vestaboard display using its local API. The package also includes integrations such as Twitter scraping (using Playwright) to post tweets directly to the Vestaboard. This project has evolved from a simple CLI script into a fully featured package that can be installed and used by third-party developers to extend the functionality of their Vestaboard displays.

Features

  • Message Display: Send text messages to the Vestaboard, supporting background colors and gradients.
  • Justification Options: Supports left, center, and right justification for text.
  • Gradient Background: Display a gradient background across the board with customizable colors.
  • Integrations: Integration with Twitter (via Playwright) to scrape and display tweets from specific users.
  • Environment-Based Configuration: The package uses a .env file for easy configuration of API keys and settings.

Requirements

  • Python 3.x
  • requests, python-dotenv, and playwright libraries; playwright is required for twitter/x.com scrapes
  • Access to a Vestaboard with a local API enablement token and API key
  • Chrome or another browser installed via Playwright for Twitter scraping

Installation

Step 1: Clone the Repository

git clone https://github.com/booyasatoshi/vestaboard

Step 2: Set up a Virtual Environment (optional but recommended)

python -m venv env
source env/bin/activate   # On Linux/macOS
env\Scripts\activate      # On Windows

Step 3: Install Dependencies

pip install -r requirements.txt

Step 4: Install Playwright Browsers

The Twitter scraping integration uses Playwright, which requires browser binaries to be installed.

playwright install

Step 5: Set Up the .env File

A sample .env file is provided in the package to configure your Vestaboard API settings. Copy the sample .env file to the correct location:

cp vestaboard/.env.sample vestaboard/.env

Edit the .env file with your own credentials:

VBOARD_ENABLEMENT_TOKEN=<Your Enablement Token>
VBOARD_API_TOKEN=<Your API Token>
VBOARD=<Your Vestaboard IP Address>

TWITTER_ENABLED=True
LAST_TWEETS=5
X_USERS=your_twitter_username
  • VBOARD_ENABLEMENT_TOKEN: Token for enabling the Vestaboard API.
  • VBOARD_API_TOKEN: API token for authenticating with the Vestaboard API.
  • VBOARD: The local IP address of your Vestaboard.
  • TWITTER_ENABLED: Set to True to enable Twitter scraping.
  • LAST_TWEETS: Number of recent tweets to display.
  • X_USERS: Comma-separated Twitter usernames to scrape tweets from.

Usage

Importing the Package

After installing the package, you can import it and use it to send messages to the Vestaboard:

import vestaboard
vestaboard.send_message("Hello, Vestaboard!", color="red", justify="center")

Sending a Message

  • send_message(message, color=None, justify='left', gradient=None)
    • message: The text message to be displayed.
    • color: (Optional) The background color for the message. Supported options are red, orange, yellow, green, blue, violet, white, and black.
    • justify: (Optional) Text justification. Can be left, center, or right. Default is left.
    • gradient: (Optional) A tuple of two colors to create a gradient (e.g., ("red", "blue")).

Scraping Tweets (Twitter Integration)

The Twitter scraping integration allows you to pull tweets from specific users and display them on the Vestaboard. This feature uses Playwright to automate the scraping process.

To use the Twitter scraping feature:

  1. Ensure that Playwright is installed and the .env file is correctly configured with Twitter scraping enabled.
  2. You can scrape and display the latest tweets by calling the scrape_tweet method from the twitter.py integration.

Example:

from vestaboard.connections.twitter import scrape_tweet

latest_tweet = scrape_tweet("your_twitter_username")
vestaboard.send_message(latest_tweet['text'], color="blue")

Using the .env File

The .env file is used to store API keys and configuration parameters securely. Make sure to configure it properly before running the package.

  • Vestaboard API Keys: Set VBOARD_ENABLEMENT_TOKEN, VBOARD_API_TOKEN, and VBOARD (the local IP address of the Vestaboard).
  • Twitter Scraping: Set TWITTER_ENABLED, LAST_TWEETS, and X_USERS to enable Twitter scraping.

Example Usage with Gradient

vestaboard.send_message("Gradient Message!", gradient=("red", "blue"), justify="center")

Debugging

To enable debugging for more verbose output, pass debug=True when initializing the vestaboard instance:

vb = vestaboard(debug=True)
vb.send_message("Debug Mode On")

Troubleshooting

Common Issues

Connection Issues

  • You will not be able to connect to the board on the local network and send messages until you obtain an enablement token.
  • The board will print out an API key every time you make a POST request using the enablement token given to you by Vestaboard:
curl -X POST -H "X-Vestaboard-Local-Api-Enablement-Token: YOUR_API_ENABLEMENT_TOKEN" http://vestaboard.local:7000/local-api/enablement

Error: Failed to Send Message

  • Ensure that the Vestaboard IP address is correctly set in your .env file.
  • Ensure the local API key and enablement token are valid.

Playwright Installation Issues

  • If Playwright does not install browser binaries, manually run:
    playwright install
    

Contributing

Feel free to contribute to this project by opening issues or submitting pull requests. All contributions are welcome!

License

This project is licensed under the GNU General Public License (GPL). The GPL ensures that the software remains free and open-source, allowing users to modify, distribute, and use it freely. However, any modifications or derivative works must also be licensed under the GPL and include the source code, ensuring that improvements to the software are shared with the community. This fosters collaboration and encourages transparency and innovation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vestapy-0.1.0.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vestapy-0.1.0-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file vestapy-0.1.0.tar.gz.

File metadata

  • Download URL: vestapy-0.1.0.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for vestapy-0.1.0.tar.gz
Algorithm Hash digest
SHA256 098635589177261303c2abc0101788d433fa6bbfda9a69f737e35652e2c365ee
MD5 5253c670a3f02b7432fb903245234459
BLAKE2b-256 c7fb8861a626ef8fe1da91c6f1acb1ff67497bfeb4b37226f6b1ee9f9ab39a32

See more details on using hashes here.

File details

Details for the file vestapy-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: vestapy-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for vestapy-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 80dd25e7349cac4f42a80c8daf08489479d3949d512d3186388bbf9244fd4f00
MD5 cf2ad1bbaa06710b69422ef172c6307d
BLAKE2b-256 b2416e28807201533d32c81b418744aaa1811ea1b9d385edd1b8ad36d4d08b2b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page