Objective and Design Philosophy

The goal of the Smart TV is to allow control of a TV and a Roku home entertainment system through the Home Assistant and thus through the Smart Mobile Device. This allows the resident to have control over their day-to-day entertainment.

Core Components

The system is built around the following hardware and software elements:

  • Pi Pico W (bridge): Connects to both the Hub and the Roku to enable the Roku integration on Home Assistant to function.
  • Roku Express: A streaming media player that offers many free channels and handles streaming services. It can be controlled through HTTP commands from a device on the same network.

Implementation Strategy:

This implementation uses a Raspberry Pi Pico W to bridge communication between Home Assistant and a Roku Express located on separate networks. Home Assistant already has a Roku integration that communicates to Roku devices using HTTP. For security reasons, the Hub and thus Home Assistant are located on a local private network, the Roku Express is not able to use HTTP to communicate with devices on separate networks.
The Pico connects to Wi-Fi and runs a local server on port 8060 , mimicking the Roku Express’s API endpoint so Home Assistant can send commands to it. Upon receiving a request, the Pico rewrites the destination IP to the Roku’s IP address and forwards the data to the actual Roku, then relays the response back to Home Assistant. The data forwarding is done in cycles and garbage collection \cite{pythonGc} is initiated after a complete request is forwarded to avoid memory errors. This allows Home Assistant to interact with the Roku as if it were on the same network, bypassing network segmentation restrictions. The setup includes connection diagnostics, error handling, and non-blocking sockets for efficient data forwarding.

Engineering Challenges and Solutions

  • Before we figured out how to get the system to automatically disconnect, we would have to wait a while after each activation or get an address in use error.
  • We had issues with sending longer requests, and discovered that it was either sending incomplete requests or ran out of memory. We fixed this by cycling through the request and forwarding it in chunks.
  • We had memory issues after running the code for a period of time. This was resolved by adding garbage collection after sockets closed.

Performance:

The Pico proxy works to bridge communication between the Home Assistant and the Roku. There are slight delays, although it is unclear how much of it is due to the Pico and how much is built into the pre-existing system. Human participants were able to use the Home Assistant dashboard, the SMD UI, and the SALE-R to control the TV and watch various media.