LightMyRoom is a Discord bot that allows users to control Alexa-compatible smart lights through Discord reactions. It provides a simple, intuitive interface for changing light modes in your room directly from a Discord server.
- Control smart lights through Discord reactions
- Persistent menu for easy access to light controls
- Multiple light modes: red, blue, rave, normal, and off
- Displays current light mode and duration
- Logging of all light mode changes
- Python 3.7+
- Discord Bot Token
- Virtual Smart Home account
- Amazon Alexa
- Alexa-compatible smart lights
- Alexa routines set up for each light mode
- nextcord
- requests
-
Clone this repository:
git clone https://github.com/yourusername/lightmyroom-discord-bot.git cd lightmyroom-discord-bot
-
Install the required Python packages:
pip install nextcord requests
-
Set up your Virtual Smart Home account and create URL triggers for each light mode.
-
Create Alexa routines for each light mode, triggered by the Virtual Smart Home URL triggers.
-
Create a
config.json
file in the project root directory with the following structure:{ "red": "UUID_FOR_RED_MODE", "blue": "UUID_FOR_BLUE_MODE", "rave": "UUID_FOR_RAVE_MODE", "normal": "UUID_FOR_NORMAL_MODE", "off": "UUID_FOR_OFF_MODE" }
Replace
UUID_FOR_X_MODE
with the corresponding UUID from your Virtual Smart Home URL triggers. For example everything after 'trigger=' in the link provided by the site. -
Update the
BASE_URL
constant in thelightmyroom.py
file if necessary:BASE_URL = "https://www.virtualsmarthome.xyz/url_routine_trigger/activate.php?trigger="
-
(Optional) Replace the default light icon URL in the
create_lights_embed
function with your own icon:embed.set_author(name="LightMyRoom", icon_url="https://example.com/your_light_icon.png")
-
Start the bot:
python lightmyroom.py
-
In your Discord server, use the command
!lights
to bring up the light control menu. -
React to the menu message with the appropriate emoji to change the light mode:
- 🔴 : Red mode
- 🔵 : Blue mode
- 🎉 : Rave mode
- 💡 : Normal mode
- 🌙 : Off
-
The bot will update the menu message to show the current mode and how long it's been active.
-
Add a new UUID to your
config.json
file under thelight_modes
object. -
Update the
get_emoji_for_mode
andget_mode_from_emoji
functions inlightmyroom.py
to include an emoji for your new mode:def get_emoji_for_mode(mode): emoji_map = { "red": "🔴", "blue": "🔵", "rave": "🎉", "normal": "💡", "off": "🌙", "your_new_mode": "🆕" # Add your new mode here } return emoji_map.get(mode, "❓") def get_mode_from_emoji(emoji): emoji_map = { "🔴": "red", "🔵": "blue", "🎉": "rave", "💡": "normal", "🌙": "off", "🆕": "your_new_mode" # Add your new mode here } return emoji_map.get(emoji, None)
-
Create a new Alexa routine for your new mode, triggered by the corresponding Virtual Smart Home URL.
To change the command prefix from !
, update the command_prefix
parameter when initializing the Bot
:
bot = commands.Bot(command_prefix='YOUR_PREFIX_HERE', intents=intents)
The bot logs all light mode changes and any errors to a file named lightmyroom.log
in the same directory as the script. You can adjust the logging configuration in the logging.basicConfig()
call at the beginning of the script.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
This bot is not affiliated with Amazon Alexa or Virtual Smart Home. Use at your own risk.
If you encounter any problems or have any questions, please open an issue in this repository.
This README provides a comprehensive guide for setting up and using the LightMyRoom Discord bot. It includes all the necessary information about requirements, setup, usage, and customization.
Remember to update the versions to the latest stable releases when you create your repository.
Lastly, here's an example `config.json` file:
```json
{
"red": "UUID_FOR_RED_MODE",
"blue": "UUID_FOR_BLUE_MODE",
"rave": "UUID_FOR_RAVE_MODE",
"normal": "UUID_FOR_NORMAL_MODE",
"off": "UUID_FOR_OFF_MODE"
}
Replace YOUR_DISCORD_BOT_TOKEN_HERE
with your actual Discord bot token, and each UUID with the actual UUIDs from your Virtual Smart Home URL triggers.