core: Discord notifications not working
Home Assistant release with the issue:
0.88.1
Last working Home Assistant release (if known): Not sure actually
Operating environment (Hass.io/Docker/Windows/etc.):
Hass.io Component/platform:
https://www.home-assistant.io/components/notify.discord/
Description of problem: Sending notifications with the discord platform gives errors in the log and nothing is sent.
Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):
- name: Discord
platform: discord
token: !secret discord_token
Traceback (if applicable):
Sat Feb 23 2019 21:56:20 GMT+0100 (centraleuropeisk normaltid)
Error handling message: {'type': 'call_service', 'domain': 'notify', 'service': 'discord', 'service_data': {'message': "The sun is {% if is_state('sun.sun', 'above_horizon') %}up{% else %}down{% endif %}!"}, 'id': 14}
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/homeassistant/components/websocket_api/decorators.py", line 17, in _handle_async_response
await func(hass, connection, msg)
File "/usr/local/lib/python3.7/site-packages/homeassistant/components/websocket_api/commands.py", line 147, in handle_call_service
connection.context(msg))
File "/usr/local/lib/python3.7/site-packages/homeassistant/core.py", line 1133, in async_call
self._execute_service(handler, service_call))
File "/usr/local/lib/python3.7/site-packages/homeassistant/core.py", line 1155, in _execute_service
await handler.func(service_call)
File "/usr/local/lib/python3.7/site-packages/homeassistant/components/notify/__init__.py", line 117, in async_notify_message
await notify_service.async_send_message(**kwargs)
File "/usr/local/lib/python3.7/site-packages/homeassistant/components/notify/discord.py", line 43, in async_send_message
import discord
File "/usr/local/lib/python3.7/site-packages/discord/__init__.py", line 20, in <module>
from .client import Client, AppInfo, ChannelPermissions
File "/usr/local/lib/python3.7/site-packages/discord/client.py", line 38, in <module>
from .state import ConnectionState
File "/usr/local/lib/python3.7/site-packages/discord/state.py", line 36, in <module>
from . import utils, compat
File "/usr/local/lib/python3.7/site-packages/discord/compat.py", line 32
create_task = asyncio.async
^
SyntaxError: invalid syntax
Additional information:
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 1
- Comments: 45 (10 by maintainers)
In 0.88 the home assistant docker image was updated to use Python 3.7. In Python 3.7
asyncis a reserved keyword. So even though the discord notify platform wasn’t changed, the change in environment surfaced this problem.Hi everyone. Is there a hope that discord/compat.py file will be fix for HassIo users who can’t modify it with sudo?
I already use discord_webhook but we cannot add pic on our message. It useful when you want to use it with your security camera for example.
Thanks Long life to the community 😃
@filikun It’s annoying, but can be ignored. 204 is one kind of success message but unfortunately it only listens for 200.
I just started using webhooks on discord to get the same result and not have to worry about dependencies. I first created the webhook on discord in server settings to get the url then setup in home assistant. My config looks like
Automation example:
@mkono87 On the box that’s running docker run this command to find the file you need to edit:
sudo find /var/lib/docker/ -name compat.py | grep discord/compat.pyIf you find multiples you need to cleanup unused images (You can google a command for that)Edit the file you found with the above command example your path WILL be different:
On line 35 you will see
create_task = asyncio.asyncchange that to tocreate_task = getattr(asyncio, 'async')This got me my file.
sudo find /var/lib/docker/ -name compat.py | grep discord/compat.pyI run hass.io in a docker container on UbuntuIt’s fixed in the discord.py package, so updating the dependency should solve it? https://github.com/Rapptz/discord.py/commit/1863a1c6636f53592519320a173ec9573c090c0b
Edit: Sorry, mistake on my part, the fix doesn’t seem to be in a release, only in a dev branch…