#Discord as an assist chat
1 messages · Page 1 of 1 (latest)
not directly but maybe you could write a discord bot that takes the commands you type and sends them to a webhook which then processes them through the assist pipeline and pushes the output through the discord through the normal integration.
no idea how to go about this in practical terms but as a concept.... maybe it would work?
You can use Discord to send commands to Home Assistant by setting up a Discord bot that connects to your Home Assistant instance through its API or webhooks. Here’s a simple way to do it:
⸻
🔧 What You Need:
1. Home Assistant running (you already have this!)
2. A Discord bot
3. Some code (usually in Python) to connect them
⸻
🧠 Basic Steps:
1. Create a Discord Bot
• Go to Discord Developer Portal
• Create an application → Add a bot
• Copy the bot token
2. Invite the bot to your server
• Generate an OAuth2 URL with bot permissions
• Use the link to add the bot to your server
3. Write a Python script using discord.py and Home Assistant’s API
Example:
import discord
import requests
TOKEN = 'YOUR_DISCORD_BOT_TOKEN'
HASS_TOKEN = 'YOUR_HOME_ASSISTANT_LONG_LIVED_ACCESS_TOKEN'
HASS_URL = 'http://YOUR_HASS_IP:8123/api/services/light/turn_on'
client = discord.Client()
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content == '!lighton':
headers = {
'Authorization': f'Bearer {HASS_TOKEN}',
'Content-Type': 'application/json',
}
data = {"entity_id": "light.living_room"}
requests.post(HASS_URL, headers=headers, json=data)
await message.channel.send("💡 Light turned on!")
client.run(TOKEN)
4. Run the bot script and test it by typing !lighton in your Discord server
.
this is what Chatgpt suggested
what do you think?
sure maybe, i havent done it. but its AI code so if it doesnt work then dont be supprised. read up on the documention of all the stuff involved and see if you can put the pieces together
but what he suggesting is to have a python working 24/7 right?
yeah you would need whatever is running your bot to be running.
you could maybe write it in a container then run it on HA as an an addon. or even potentially write it as an integration
running it on home assistant on the rasbperry by is ok?
yeah a python script running a discord bot is not gunna take alot of resources
in this case i should be using pyscript integration?
its not exactly what I went initially but maybe? I have never used it.
could u explain more your idea please?
if you made the bot as a docker container you could run it as an addon on HAOS.
addons are just docker containers
true, whats the addon called? also how do you put the bot in the container?
I am saying if YOU make the bot as a container then YOU can MAKE an addon (and call it whatever you want)
as for making a container with python stuff running in it... that's beyond the scope for here.
it was just a passing suggestion of a possible solution. although a custom_integration might also run the way you need to also
or run it on another system
AH i need to make an addon from zero??
damn
it was just a possible suggestion
because the home assistant bot i already add it, as i use it for the itnegrations
i see, i see, i would this only if it doesnt take big skills to do