Skip to content

A small containerized application that controls a LIFX light based on your Microsoft Teams presence and Discord voice channel activity. The light color changes to indicate your current status across these platforms, helping others know when you're in meetings, sharing your camera, or streaming.

License

Notifications You must be signed in to change notification settings

JoshKoiro/status-light

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Status Light Controller

A small containerized application that controls a LIFX light based on your Microsoft Teams presence and Discord voice channel activity. The light color changes to indicate your current status across these platforms, helping others know when you're in meetings, sharing your camera, or streaming.

Features

  • Controls LIFX light based on:
    • Microsoft Teams presence (Available, Busy, Do Not Disturb, Away)
    • Discord voice channel activity (Camera, Screen Share, Streaming)
  • Priority-based status handling (configurable through environment variables)
  • Web interface for configuration and monitoring
  • REST API endpoints for integration with other services
  • Docker support for easy deployment

Prerequisites

  • Node.js v16+ (for development)
  • Docker and Docker Compose (for deployment)
  • LIFX smart light
  • LIFX API key
  • Microsoft Graph API token
  • Discord bot token and application

Required API Keys & Tokens

  1. LIFX API Key:

  2. Microsoft Graph API:

    • Register application in Azure AD
    • Grant necessary permissions for presence API
    • Generate access token
  3. Discord Bot:

    • Create application at https://discord.com/developers/applications
    • Create bot and get token
    • Enable required intents (Presence, Server Members, Message Content)
    • Get your Discord user ID (Developer Mode -> Right click your name -> Copy ID)

Installation

Development Setup

  1. Clone the repository:

    git clone <repository-url>
    cd status-light
  2. Install dependencies:

    npm install
  3. Create .env file:

    # API Keys
    LIFX_API_KEY=your_lifx_api_key
    MS_GRAPH_API_KEY=your_microsoft_graph_token
    DISCORD_API_KEY=your_discord_bot_token
    DISCORD_USER_ID=your_discord_user_id
    
    # Service Settings
    SERVICE_PRIORITY=teams,discord
    POLLING_INTERVAL=5000
    
    # Teams Light Colors
    TEAMS_AVAILABLE=green
    TEAMS_BUSY=red
    TEAMS_DO_NOT_DISTURB=purple
    TEAMS_AWAY=yellow
    TEAMS_OFFLINE=off
    
    # Discord Light Colors
    DISCORD_STREAMING=blue
    DISCORD_CAMERA_ON=purple
  4. Start the development server:

    npm run dev

Docker Deployment

  1. Build and start using Docker Compose:

    docker-compose up -d
  2. View logs:

    docker-compose logs -f

Configuration

Environment Variables

  • SERVICE_PRIORITY: Comma-separated list of services in priority order (e.g., "teams,discord")
  • POLLING_INTERVAL: How often to check for status changes (in milliseconds)
  • Color settings:
    • Can be any color name supported by LIFX
    • Setting a status to "off" will turn the light off for that state

Discord Bot Setup

  1. Enable these privileged intents:

    • PRESENCE INTENT
    • SERVER MEMBERS INTENT
    • MESSAGE CONTENT INTENT
    • GUILD VOICE STATES
  2. Required bot permissions:

    • Read Messages/View Channels
    • View Server Insights
    • Send Messages
    • Read Message History
    • Connect to Voice Channels
    • View Voice Channel Status

Permission integer for easy setup: 274877975552

API Endpoints

  • /api/services - Get current status of all services
  • /api/health - Service health check
  • /api/logs - View recent logs
  • /api/config/keys - Update API keys

Web Interface

Access the web interface at http://localhost:3000 to:

  • View current status
  • Update API keys
  • Monitor logs
  • Check service health

Logging

  • Console shows essential startup and error logs
  • Detailed logs available via web interface or API
  • Log files stored in logs directory:
    • error.log: Error messages
    • detailed.log: Detailed debug information

Status Priority

The service uses the priority order defined in SERVICE_PRIORITY to determine which status to display when multiple services are active. For example, with SERVICE_PRIORITY=teams,discord:

  1. Teams status takes precedence if active
  2. Discord status is used if Teams is inactive
  3. Light turns off if no service is active

Common Issues

  1. Light not responding:

    • Verify LIFX API key
    • Check light is online in LIFX app
    • Confirm light name matches configuration
  2. Discord status not updating:

    • Verify bot is in server
    • Check bot permissions
    • Confirm correct user ID in configuration
  3. Teams status not updating:

    • Verify Graph API token
    • Check token permissions
    • Ensure token hasn't expired

About

A small containerized application that controls a LIFX light based on your Microsoft Teams presence and Discord voice channel activity. The light color changes to indicate your current status across these platforms, helping others know when you're in meetings, sharing your camera, or streaming.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published