Custom Component: Discord status and game sensor

Looking for some examples as well. Its possible to add to lovelace with the Entity or Entities card, but it seems like it can only show one attribute for each user.

Yeah some examples would be great, I got it to show state on some discord users, but how to display games etc

Hello

+1 :grinning:

Hello all!
I have just released a new version that introduces separate sensors for every tracked information.
This version also introduces use of config flow and can be configured only from Home Assistant Integrations Dashboard.

1 Like

really nice, thank you for your effort

@lordBoos I was running the previous version (using yaml) to get user status and it worked great. I could see when friends were online.

#- platform: discord_game
#  token: OTk0MTxdxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxZ11meQBE
#  image_format: webp            # optional, available formats are: png, webp, jpeg, jpg
#  members:
#    - 71186xxxxxxxxxxx6295
#    - 5154xxxxxxxxxxxx4138
#    - 716xxxxxxxxxxx333390
#    - 2665xxxxxxxxxxx 9312

Moving to the new version, I disabled the yaml (restarted) and entered the bot token successfully via the UI but it it not showing any entities ?

Note: The bot was added to the channel with admin permissions

Any ideas on what I have done wrong?

Hello @Andrew123.
Have you selected the users in the second step of the configuration flow? Do you have any errors in the home assistant log?
I have not been able to reproduce your issue, it might be specific to your setup so any errors in the log should give us better understanding of the problem.

EDIT: I see, that your screenshot is of the Discord integration (the official HA one) and not the Discord game integration. You might have accidentally used that instead of Discord game integration. The official integration can only send messages to Discord channels and cannot track users.

1 Like

Thankyou ! I was using the wrong integration.

I feel rather silly for that mistake - but grateful you could help me.

Thakyou again for that.

i have a question: you can create channel entities. what are they good for? The voice channels have a “last user” attribute, which, like the status, is actually always “unknown”.
Is that correct?
Why can I also monitor text channels? is there a way to record “commands” or messages from the channel in an event?

That monitors who last added reaction to a message in a channel. We used it instead of polls (before discord added them) and had google home voice notification when somebody voted.

is there a way to read the messages which are send in a channel or is there only the option to read who added a reaction?

You cannot read the message. Who added the last reaction is in “last user” attribute.

oh what a pity, it would be cool to receive the messages as an “event” like with the snmp integration

It’s not really a fit for this integration, it’s purpose is mainly to read what games users are playing. But I’ll add it to todo-list for future release, but not necessarily the next one.

Good Day,
I am getting error occured when trying to add the Discord Game integration.

Logger: aiohttp.server
Source: /usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py:421
First occurred: 15:49:09 (5 occurrences)
Last logged: 16:00:32
Error handling request

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 452, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_app.py", line 543, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_middlewares.py", line 114, in impl
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 92, in security_filter_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 210, in forwarded_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 26, in request_context_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 85, in ban_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 242, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 32, in headers_middleware
    response = await handler(request)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/http.py", line 73, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/decorators.py", line 81, in with_admin
    return await func(self, request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 222, in post
    return await super().post(request, flow_id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 74, in wrapper
    return await method(view, request, data, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 122, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 368, in async_configure
    result = await self._async_configure(flow_id, user_input)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 415, in _async_configure
    result = await self._async_handle_step(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 518, in _async_handle_step
    result: _FlowResultT = await getattr(flow, method)(user_input)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/discord_game/config_flow.py", line 41, in async_step_user
    await validate_auth_and_fetch_data(user_input[CONF_ACCESS_TOKEN])
  File "/config/custom_components/discord_game/config_flow.py", line 95, in validate_auth_and_fetch_data
    _members = await guild.fetch_members().flatten()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/nextcord/iterators.py", line 114, in flatten
    return [element async for element in self]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/nextcord/iterators.py", line 118, in __anext__
    return await self.next()
           ^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/nextcord/iterators.py", line 753, in next
    await self.fill_members()
  File "/usr/local/lib/python3.12/site-packages/nextcord/iterators.py", line 772, in fill_members
    data = await self.state.http.get_members(self.guild.id, self.retrieve, after)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/nextcord/http.py", line 393, in request
    raise Forbidden(response, data)
nextcord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access

Please help