LordBoos / discord_game

Home Assistant custom component to get online and game status of Discord users
MIT License
56 stars 7 forks source link

Configuration not getting validated #50

Closed AndreiGr closed 11 months ago

AndreiGr commented 11 months ago

Hi there,

I installed the component from HACS, restarted the HA and then added the config part.

Now, I am trying to check my config and restart, but it's just stuck at checking the configuration, any ideas why this could be?

My config snippet:


- platform: discord_game
   token: <token>
   members:
      - 287694783730810880
LordBoos commented 11 months ago

Hi, do you have sensor: there and token filled?

sensor:
  - platform: discord_game
    token: someSecretToken1234
    members:
      - 287694783730810880
AndreiGr commented 11 months ago

Yes, the is the actual token I just wrote it like that for privacy reasons. The sensor config area looks like this image

AndreiGr commented 11 months ago

Small update I just put the component config back into the .yaml to take the screenshot above, and now the config got validated without any issues. No clue why it didn't want to validate it last night.

LordBoos commented 11 months ago

And which version are you using? If you are on the pre-release version (any 5.x.x), then you might also need to add channels.

sensor:
  - platform: discord_game
    token: someSecretToken1234
    members:
      - 287694783730810880
    channels:
      - someChannelUID

If you don't need channels feature, you can change your version to the release one, they are the same only pre-release has channels feature.

AndreiGr commented 11 months ago

I'm using the stable version (4.2.6, I think). I managed to add the config and no complaints from HA.

But, the bot is offline in my server, and the status of my user in HA is unknown. Any clue what I did wrong?

LordBoos commented 11 months ago

Try restarting HA (completely, not just reloading config). And if it is still offline, there might be some error in HA log.

AndreiGr commented 11 months ago

I'm always fully restarting, never actually used the config reload, haha. Indeed there is an error in the logs:


This error originated from a custom integration.

Logger: homeassistant
Source: custom_components/discord_game/sensor.py:60
Integration: discord_game (documentation)
First occurred: 12:12:05 PM (1 occurrences)
Last logged: 12:12:05 PM

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/config/custom_components/discord_game/sensor.py", line 60, in start_server
    await bot.start(token)
  File "/usr/local/lib/python3.11/site-packages/nextcord/client.py", line 673, in start
    await self.connect(reconnect=reconnect)
  File "/usr/local/lib/python3.11/site-packages/nextcord/client.py", line 614, in connect
    raise PrivilegedIntentsRequired(exc.shard_id) from None
nextcord.errors.PrivilegedIntentsRequired: Shard ID None is requesting privileged intents that have not been explicitly enabled in the developer portal. It is recommended to go to https://discord.com/developers/applications/ and explicitly enable the privileged intents within your application's page. If this is not possible, then consider disabling the privileged intents instead.
LordBoos commented 11 months ago

Yea you have to enable privileged intents in the discord developer portal for the bot. image

AndreiGr commented 11 months ago

I had only the first two checked, because in the guide there's no mention about the message content intent.

LordBoos commented 11 months ago

I updated the guide. There was a change in the NextCord library, which this integration uses, few months ago that made the last one also required.

AndreiGr commented 11 months ago

There's no way to also get more details about the user, like if they're on mute/deafen, right?

LordBoos commented 11 months ago

It is and it is already implemented, look at entity attributes in HA. It only works if the user is currently in a voice channel on your server though.

voice_channel: 👫Private
voice_server_deafened: false
voice_server_muted: false
voice_self_deafened: true
voice_self_muted: true
voice_streaming: false
voice_broadcasting_video: false
voice_afk: false
AndreiGr commented 11 months ago

Oh ok, didn't see the long list of entity attributes. I was honestly hoping it would see my mute/deafen status when I'm in other servers as well, but it kind of makes sense it's not really possible, haha.