black and red wireless computer mouse
How to Turn a PC Mouse into a TV Remote, Smart Window Controller, and Indoor Climate Manager

In the age of IoT (Internet of Things), it’s possible to repurpose everyday devices into powerful home automation tools. One of the most underestimated peripherals in this context is the PC mouse—both classic and gaming variants. With the right modifications and integrations, a mouse can be transformed into a universal smart controller for:

  • TV and media center control
  • Fenestration management (automated windows and doors)
  • Smart lighting
  • Air conditioner control

This article outlines how to technically modify and integrate a PC mouse into a multi-functional smart home remote.


🛠 What You’ll Need

Hardware:

  • Wired/wireless USB PC mouse (preferably gaming with extra buttons)
  • Raspberry Pi (Zero, 3B+, or 4)
  • USB OTG adapter (for USB mice)
  • IR LED + IR receiver module
  • 2-channel or 4-channel relay module
  • Servo motors or linear actuators (for window/door actuation)
  • Smart light bulbs or relay-controlled lighting
  • Wi-Fi enabled smart plug (optional for AC)
  • Power supply (5V 3A for Pi, 12V for actuators)

Software:

  • Python 3 (on Raspberry Pi)
  • evdev library for mouse event capture
  • LIRC for IR control
  • RPi.GPIO or gpiozero for relay control
  • Home Assistant (optional for integration)
  • MQTT (optional for wireless home automation)

🧠 Step 1: Connect and Read Mouse Events

Using Python and the evdev library, the Raspberry Pi can read raw inputs from the mouse.

pip3 install evdev
from evdev import InputDevice, categorize, ecodes

mouse = InputDevice('/dev/input/eventX')  # Replace X with your mouse event number

for event in mouse.read_loop():
    if event.type == ecodes.EV_KEY:
        print(categorize(event))

Map specific mouse buttons or gestures (like left-click, scroll up, side button) to smart actions.


📺 Step 2: Turn Mouse into TV Remote

Use the LIRC library to emit IR signals via an IR LED connected to your Pi.

  1. Install LIRC:
sudo apt-get install lirc
  1. Configure /etc/lirc/lirc_options.conf and /boot/config.txt for GPIO IR out.
  2. Record your TV remote with irrecord, name it e.g. tv_remote.conf.
  3. Emit signal via button press:
import os

def tv_power_toggle():
    os.system("irsend SEND_ONCE tv_remote KEY_POWER")

Map this to a button like scroll-click or side button.


🪟 Step 3: Fenestration Management (Windows and Doors)

Attach servo motors or linear actuators to windows or sliding doors. Connect these to a relay module or motor driver board.

GPIO Trigger Example:

import RPi.GPIO as GPIO
import time

RELAY_PIN = 17
GPIO.setmode(GPIO.BCM)
GPIO.setup(RELAY_PIN, GPIO.OUT)

def open_window():
    GPIO.output(RELAY_PIN, GPIO.HIGH)
    time.sleep(2)  # Duration to fully open
    GPIO.output(RELAY_PIN, GPIO.LOW)

def close_window():
    GPIO.output(RELAY_PIN, GPIO.HIGH)
    time.sleep(2)
    GPIO.output(RELAY_PIN, GPIO.LOW)

Assign “open” to left scroll and “close” to right scroll, for example.


💡 Step 4: Indoor Light Control

For smart bulbs (e.g., Philips Hue, Tuya), integrate using APIs or Home Assistant via MQTT.

For relay-controlled lights:

LIGHT_PIN = 22
GPIO.setup(LIGHT_PIN, GPIO.OUT)

def toggle_light():
    GPIO.output(LIGHT_PIN, not GPIO.input(LIGHT_PIN))

Map this function to the right mouse button or a gaming macro key.


❄️ Step 5: Air Conditioner Management

IR-Controlled AC

Use LIRC again, as in the TV remote, but with AC-specific IR codes (commonly used by LG, Daikin, etc.).

def ac_toggle():
    os.system("irsend SEND_ONCE ac_remote KEY_POWER")

Smart Plug AC Integration

Control via MQTT or API if plugged into a smart plug.


🧬 Optional: Full Smart Home Integration via MQTT

Install Mosquitto MQTT broker on your Pi and have it relay commands to other smart devices:

sudo apt install mosquitto mosquitto-clients

Python MQTT Example:

import paho.mqtt.client as mqtt

client = mqtt.Client()
client.connect("localhost", 1883, 60)
client.publish("home/lights/livingroom", "toggle")

Use this method for more scalable automation and remote control.


🧠 Button Mapping Strategy

Mouse InputFunction
Left-clickOpen windows
Right-clickClose windows
Scroll clickToggle TV power
Side Button 1Toggle AC
Side Button 2Toggle indoor lights
Scroll upIncrease AC temp / brightness
Scroll downDecrease AC temp / brightness

For gaming mice, use the extra macro buttons for complex scene triggers like “Sleep Mode” or “Leave Home”.


🧩 Future Extensions

  • Integrate voice assistant triggers via mouse buttons
  • Add gesture recognition using mouse movement
  • Expand to control smart blinds and garage doors
  • Mobile app to mirror mouse control remotely

🏁 Conclusion

With just a PC mouse and a Raspberry Pi, you can build a cost-effective, highly customizable universal smart home controller. Whether you want to replace your TV remote, automate your windows, or manage your home’s climate—all it takes is a little creativity, some GPIO magic, and a few lines of Python.