This component pulls information about user's status, and the game he's currently playing from the Discord. It creates a sensor for every configured user with online status and game played status. Discord avatar is used as entity_picture.
You can use this component in combination with native Home Assistant Discord notify integration. It works well together, and you can use the same token for both components, and the bot will combine both functions. So 1 Discord bot to rule both.
First you have to create a Discord bot user and get it's token to be able to use this component.
To create a bot user and get a token:
- Go to https://discordapp.com/developers/applications/
- Create New Application
- Put in a Name of your liking and click create
- Click on Bot in the left panel and then Add Bot and Yes, do it!
- A green message "A wild bot has appeared!" should appear on the page
- Uncheck PUBLIC BOT
- Enable every Intent in the Privileged Gateway Intents section
- Click Save changes on the bottom of the page
- Under Token, click on Copy, this is your token, that you need to later paste into home assistant configuration flow, keep in mind that the bot first has to be invited to some server
You also need your own discord server (or some server where you have "manage server" permission), and you need to invite the bot to that server. To invite your bot to your server, use following steps:
- Go to General information tab on your Discord bot developer page
- Under Client ID, click Copy
- Go to following URL (replace [CLIENT_ID] with id from previous step) https://discordapp.com/api/oauth2/authorize?client_id=[CLIENT_ID]&scope=bot&permissions=0
- Select server to which you want to invite the bot and press Authorize
If this doesn't work for you, you can try to use this guide to invite your bot (select no permissions): https://discordpy.readthedocs.io/en/stable/discord.html#inviting-your-bot
Now just go to Home Assistant integrations/devices dashboard and add Discord Game integration:
- Paste your token
- Select image format (only works for user avatars)
- On the next step select users that you want to track
- If you want to use channel tracking which tracks which user last added a reaction, you can select channels, but this is optional and can be left blank.
- Now continue and device for each user will be created with all the tracked sensors
If you are using Safari or the iOS Home Assistant app, please set the image_format
to png
, because Safari doesn't support the webp
image format.
Thanks to @descention https://github.com/descention for an original component idea and component itself which I've rewritten for current Discord API and Home Assistant and integrated it with HACS.