home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.56k stars 30.74k forks source link

Failed to initialize notification service discord #69782

Closed Tooa closed 2 years ago

Tooa commented 2 years ago

The problem

After upgrading from 2022.3.8 to 2022.4.1 the notify component reports issues in the log when using the discord integration:

homeassistant    | 2022-04-10 10:37:20 ERROR (MainThread) [homeassistant.components.notify] Failed to initialize notification service discord

The issue still occurs when removing the discord configuration from the YML file.

What version of Home Assistant Core has the issue?

2022.4.1

What was the last working version of Home Assistant Core?

2022.3.8

What type of installation are you running?

Home Assistant Container

Integration causing the issue

discord, notify

Link to integration documentation on our website

https://www.home-assistant.io/integrations/discord/

Diagnostics information

No response

Example YAML snippet

notify:
  - name: discord
    platform: discord
    token: !secret discord_bot_token

logger:
  default: warn
  logs:
    homeassistant.components.notify: debug

Anything in the logs that might be useful for us?

homeassistant    | 2022-04-10 11:00:31 WARNING (MainThread) [homeassistant.components.discord.config_flow] Configuration of the Discord integration in YAML is deprecated and will be removed in Home Assistant 2022.6; Your existing configuration has been imported into the UI automatically and can be safely removed from your configuration.yaml file
homeassistant    | 2022-04-10 11:00:37 INFO (MainThread) [homeassistant.components.notify] Setting up notify.discord
homeassistant    | 2022-04-10 11:00:37 ERROR (MainThread) [homeassistant.components.notify] Failed to initialize notification service discord
homeassistant    | 2022-04-10 11:00:37 INFO (MainThread) [homeassistant.components.notify] Setting up notify.discord
homeassistant    | 2022-04-10 11:00:38 INFO (MainThread) [homeassistant.components.notify] Setting up notify.mobile_app

Additional information

Other users experience this problem as well:

probot-home-assistant[bot] commented 2 years ago

discord documentation discord source (message by IssueLinks)

probot-home-assistant[bot] commented 2 years ago

Hey there @tkdrob, mind taking a look at this issue as it has been labeled with an integration (discord) you are listed as a code owner for? Thanks! (message by CodeOwnersMention)

malosaa commented 2 years ago

Just delete the discord entry in yaml. i'm using this addon aswell

tkdrob commented 2 years ago

Just delete the discord entry in yaml. i'm using this addon aswell

This is correct. Delete the yaml entry and the error will no longer appear on startup.

Tooa commented 2 years ago

Just delete the discord entry in yaml. i'm using this addon aswell

This is correct. Delete the yaml entry and the error will no longer appear on startup.

Thank you, looks like that resolved it. Are there any plans to make the token configuration available via the UI as well?

tkdrob commented 2 years ago

Just delete the discord entry in yaml. i'm using this addon aswell

This is correct. Delete the yaml entry and the error will no longer appear on startup.

Thank you, looks like that resolved it. Are there any plans to make the token configuration available via the UI as well?

Looks like this would require some action from Nabu Casa just like it is with Spotify. @balloob

rwarner commented 2 years ago

Just delete the discord entry in yaml. i'm using this addon aswell

This did not resolve it for me. Still have an issue as well as another from the original ticket: https://github.com/home-assistant/core/issues/68547

I have removed the discord entry in my configuration.yaml and also removed an re-integrated Discord through the front end and I still get this issue.

This has also been happening prior to 2022.4, at least since 2022.3.6

dereitz commented 2 years ago

I had never used the discord integration before and was going through the UI setup today -- therefore I don't have any entries in my configuration.yaml, nor did I ever before.

After going through the UI, I went to access "notify.discord" and realized it was missing, which led me to start debugging/troubleshooting. In my logs, I now see the same error message as in the original ticket as well:

Error handling message: Unable to find service notify.discord (unknown_error)

In order to fix this, should I remove my Discord configuration and instead use configuration.yaml?

malosaa commented 2 years ago

I don't have an issue with discord, i did deete the config in the yaml.

There could be 2 things, did you check your atomations and update them with the correct entity ? As it change when its imported..

Or if u still have that issue, delete discord and re-add it again, but i'm sure you did not update the automation.

tkdrob commented 2 years ago

Imported Discord configurations should display the same name as they did before. People can use multiple instances of Discord. Being the Notify platform is more limited than others, the service will be named the same as what you set up in the Discord dev portal if you're setting up in the UI.

stevietv commented 2 years ago

I am also having the same issue. Added the discord integration through the UI (never had it added through configuration.yaml). There is no service created under the discord integration and no notify.discord service available to call.

malosaa commented 2 years ago

thats really weird, as my device did change in my automations.

Well i added my bot again and it works normal, no errors. i can send notification with home assistant by calling the service.

Also you can add discord with node-red i have that aswell for sending realtime my home status what i need to a channel

stevietv commented 2 years ago

I turned debugging of the nextcord component up to debug and removed and r-added the discord integration

I get these entries:

today at 1:12:43 PM2022-04-12 13:12:43 INFO (MainThread) [nextcord.client] logging in using static token
today at 1:12:44 PM2022-04-12 13:12:44 DEBUG (MainThread) [nextcord.http] GET https://discord.com/api/v9/users/@me with None has returned 200
today at 1:12:44 PM2022-04-12 13:12:44 DEBUG (MainThread) [nextcord.http] GET https://discord.com/api/v9/users/@me has received {'id': 'XXXAPPIDXXX', 'username': 'Home Assistant', 'avatar': '91b6340ce52f6eaee0933caa4e616b4a', 'discriminator': '0689', 'public_flags': 0, 'flags': 0, 'bot': True, 'banner': None, 'banner_color': None, 'accent_color': None, 'bio': '', 'pronouns': '', 'locale': 'en-US', 'mfa_enabled': True, 'email': None, 'verified': True}
today at 1:12:44 PM2022-04-12 13:12:44 DEBUG (MainThread) [nextcord.http] GET https://discord.com/api/v9/oauth2/applications/@me with None has returned 200
today at 1:12:44 PM2022-04-12 13:12:44 DEBUG (MainThread) [nextcord.http] GET https://discord.com/api/v9/oauth2/applications/@me has received {'id': 'XXXAPPIDXXX', 'name': 'Home Assistant', 'icon': '91b6340ce52f6eaee0933caa4e616b4a', 'description': 'Home Assistant Notifications', 'summary': '', 'type': None, 'hook': True, 'bot_public': False, 'bot_require_code_grant': False, 'verify_key': 'XXXPUBLICKEYXXX', 'owner': {'id': '127801261159350272', 'username': 'XXXUSERNAMEXXX', 'avatar': '93aaaef2b406b62a2caff5080f0f3db9', 'discriminator': '4218', 'public_flags': 0, 'flags': 0}, 'flags': 532480, 'team': None}

(APPID, PUBLICKEY AND USERNAME REDACTED)

rwarner commented 2 years ago

It seems like there is an actual issue at hand beside the naming documentation. Should we open up a new ticket for this? Or can we re open this issue

tkdrob commented 2 years ago

Please have a look here. https://github.com/home-assistant/core/issues/68547

Also, the bot token is what is needed. That can be found under Build-A-Bot. @stevietv