Skip to content

FlameInTheDark/lhcontrol

Repository files navigation

lhcontrol

⬇️ Get the latest Windows Installer

Application Screenshot

A simple application to control Valve Lighthouse (SteamVR) base stations v2.0 power state via Bluetooth LE.

Features

  • Scan for nearby Lighthouse base stations.
  • Display discovered stations and their current power state (On/Off/Unknown).
  • Toggle the power state of individual base stations.
  • Power On/Off all known base stations simultaneously.
  • Rename base stations (locally) for easier identification.
  • Persistent list of discovered stations across scans (within a single app session).

Technology Stack

Prerequisites

  • Bluetooth Adapter: You MUST have a working Bluetooth adapter compatible with your OS that supports Bluetooth Low Energy (BLE). Many built-in adapters work, but dedicated USB adapters can sometimes offer better performance/compatibility.
  • Go: Version 1.18 or higher.
  • Node.js & npm: Required by Wails for frontend dependencies.
  • Wails CLI: Install via go install github.com/wailsapp/wails/v2/cmd/wails@latest.
  • TinyGo: While the main build uses the standard Go compiler, the tinygo/bluetooth library is used. Ensure required system dependencies for BLE development are met (e.g., build-essential, libbluetooth-dev on Debian/Ubuntu).

Setup

  1. Clone the repository:
    git clone https://github.com/FlameInTheDark/lhcontrol
    cd lhcontrol
  2. Install frontend dependencies: Wails typically handles this automatically during the build, but you can run it manually if needed:
    cd frontend
    npm install
    cd ..

Running the Application

  • Development Mode: (Live reload)
    wails dev
  • Production Build:
    wails build
    This will create an executable in the build/bin directory. Alternatively, for Windows users, a pre-built installer (lhcontrol-amd64-installer.exe) may be available in the project's releases.

Usage

  1. Launch the application.
  2. Click Scan to discover nearby base stations.
  3. The application will attempt to connect to discovered stations to determine their power state.
  4. Use the Toggle Power button next to each station to turn it On or Off.
  5. Use the Power On All or Power Off All buttons to control all known stations simultaneously.

Troubleshooting

  • Scanning Issues: If scans fail after the first time, or interactions fail with errors like "characteristic not found", try removing the base station(s) from your operating system's Bluetooth device list and restarting your computer. Do not re-pair them in the OS settings; the application will find them via scanning.
  • Bluetooth Drivers: Ensure you have the latest drivers for your Bluetooth adapter.
  • Permissions: The application might require specific permissions to access Bluetooth hardware.

HTTP API (for External Integration)

This application also exposes a simple HTTP API on http://127.0.0.1:7575 for basic control and status monitoring from external scripts or applications.

Endpoints:

  • POST /allon

    • Description: Attempts to turn ON all known base stations.
    • Request Body: None
    • Response: 200 OK on success (or if command sent).
  • POST /alloff

    • Description: Attempts to turn OFF all known base stations.
    • Request Body: None
    • Response: 200 OK on success (or if command sent).
  • GET /status

    • Description: Returns the current list of known base stations and their states.
    • Request Body: None
    • Response: 200 OK with JSON body:
      [
        {
          "name": "LHB-STATION1_RENAMED",
          "originalName": "LHB-XXXXXXXX",
          "address": "XX:XX:XX:XX:XX:XX",
          "powerState": 1 
        },
        {
          "name": "LHB-YYYYYYYY",
          "originalName": "LHB-YYYYYYYY",
          "address": "YY:YY:YY:YY:YY:YY",
          "powerState": 0
        }
        // ... more stations
      ]
      (Power States: -1 = Unknown, 0 = Off, 1 = On)
  • POST /scan

    • Description: Triggers a background scan for base stations (approx. 5s scan + 7s state fetch). The list returned by /status will update once complete.
    • Request Body: None
    • Response: 202 Accepted (indicates the scan has started).

Example Usage (curl):

# Get current status
curl http://127.0.0.1:7575/status

# Turn all base stations ON
curl -X POST http://127.0.0.1:7575/allon

# Turn all base stations OFF
curl -X POST http://127.0.0.1:7575/alloff

About

A simple app to control SteamVR lighthouse basestations

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •