Closed Naesstrom closed 5 years ago
What does the service data look like? Was this working before? I am using discord notifications just fine.
I have the same error, was working just fine before. Also on 0.88.1 Example of notification action in automation:
- service: notify.hass_discord
data_template:
target: !secret discord_hass_id
message: "Automated Snapshot {{ now().strftime('%Y-%m-%d') }}"
I am also having this issue with an identical error log, and also running Hass.io - it worked fine prior to 0.88.
Have made zero changes on the Discord side or my config side, it simply broke on 0.88.
heck your fast! My automation looks like this
- service: notify.discord
data:
message: Brevlådan öppnades
target: 123456789
In 0.88 the home assistant docker image was updated to use Python 3.7. In Python 3.7 async
is a reserved keyword. So even though the discord notify platform wasn't changed, the change in environment surfaced this problem.
It'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...
Also not working for me anymore. Was fine prior to 0.88
It's fixed in the discord.py package, so updating the dependency should solve it? Rapptz/discord.py@1863a1c
Edit: Sorry, mistake on my part, the fix doesn't seem to be in a release, only in a dev branch...
Thanks :+1: Personally I went with a manual change for now, searched for /usr/local/lib/python3.7/site-packages/discord/compat.py and changed _createtask = asyncio.async into _createtask = getattr(asyncio, 'async')
I will do that too!
hmm, I don't have a python3.7 folder at /usr/local/lib/
only a perl5/site_perl
but then nothing more beneath that?
Are you running Hass.io inside a Docker container? In that case the /usr/local/lib is inside a Docker volume. Go inside the container and change it. More hackey route would be to do a full disc search for discord.py and you should be able to find where the /usr/local/lib/...../compat.py file is. Searching for compat.py will give a lot of results, you would have to find a path which includes 'discord'.
I guess it is, running the normal hass.io image on a rpi3b+
Did a full search but didn't even find a compat.py connected to discord?
Try running it with sudo and see if you get more directories. None of those are discord/compat.py
This got me my file. sudo find /var/lib/docker/ -name compat.py | grep discord/compat.py
I run hass.io in a docker container on Ubuntu
I just get File not found
doing that Isa but I can wait until a patched update!
Im running Hass in a docker container on Unraid. If I manually change the .py wouldnt it revert back to original every time the container is restarted?
So just went to set up discord last night and ran into this exact issue. Looking into it seems this has been fixed on one of the branches of the library does the owner just need to push that branch to pippy?
How would one go about fixing this in a docker container until that happens?
The pypi branch of discord.py hasn't been updated in over a year. The only updated branch now is rewrite which will be released onto pypi soon™️. If you want to use 3.7 with discord.py you can either use the rewrite branch (which is better in basically every way) or just fix the issue yourself.
The pypi branch of discord.py hasn't been updated in over a year. The only updated branch now is rewrite which will be released onto pypi soon™️. If you want to use 3.7 with discord.py you can either use the rewrite branch (which is better in basically every way) or just fix the issue yourself.
Could I bother you to tell me what exactly to change? Im running docker also.
What's rewrite? Check out discord.py's rewrite branch, that's the code. The revisions introduce many breaking changes, which you should read about here: https://discordpy.readthedocs.io/en/rewrite/migrating.html
The command to install rewrite (and overwrite the existing version installed) is
pip(3.5+) install -U git+https://github.com/Rapptz/discord.py.git@rewrite#egg=discord.py
or pip(3.5+) install -U git+https://github.com/Rapptz/discord.py.git@rewrite#egg=discord.py[voice]
for voice support. For more info, see the discord.py support server.
@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.py
If 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:
sudo nano /var/lib/docker/aufs/mnt/<SomeRandomIDNumber>/usr/local/lib/python3.7/site-packages/discord/compat.py
On line 35 you will see
create_task = asyncio.async
change that to to
create_task = getattr(asyncio, 'async')
@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.py
If 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:
sudo nano /var/lib/docker/aufs/mnt/<SomeRandomIDNumber>/usr/local/lib/python3.7/site-packages/discord/compat.py
On line 35 you will see
create_task = asyncio.async
change that to tocreate_task = getattr(asyncio, 'async')
Unraid is what im running. Dont you mean in the HA container itself or right on unraid?
@Naesstrom I have the same issue on the same hardware and have not been able to locate the compat.py file to manually update.
@Naesstrom I have the same issue on the same hardware and have not been able to locate the compat.py file to manually update.
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
- platform: rest
name: discord_webhook
method: POST
message_param_name: content
title_param_name: username
data:
username: Home Assistant
resource: "https://discordapp.com/api/webhooks/551783857968513035/your webhook url
Automation example:
- service: notify.discord_webhook
data:
message: 'your message here'
@Naesstrom My MAN! (or preferred pronoun) Perfect workaround. Many thanks.
Im still trying to get this file edited in the docker container but seems to be no way to use a text editor to do so.
my location is /usr/local/lib/python3.7/site-packages/discord/compat.py
@mkono87 Great! 🥇 But for some reason I get the notification but an error in my log 😮
Log Details (ERROR) Fri Mar 08 2019 11:00:57 GMT+0100 (Central European Standard Time) Error sending message. Response 204: NO CONTENT: NoneType: None
@filikun It's annoying, but can be ignored. 204 is one kind of success message but unfortunately it only listens for 200.
@filikun just a heads up with the webhook method you can only send text.
Changing the line a discribed above is quite simple to change and will bring the original component back.
@Wutname1 thanks for the easy fix. It worked for my docker container on pi3b+
@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.py
If 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:
sudo nano /var/lib/docker/aufs/mnt/<SomeRandomIDNumber>/usr/local/lib/python3.7/site-packages/discord/compat.py
On line 35 you will see
create_task = asyncio.async
change that to tocreate_task = getattr(asyncio, 'async')
Hi everyone. This fixes the problem. Is it possible to make this change in the repository ?
Thanks !
@mTrax- Unfortunately it's not that easy, since this is a dependency and the package creator has not released this update.
The fix has been pushed to the repo, but no changes will be pushed to PyPi until later this month, when rewrite (a new version with a load of breaking changes) is released officially.
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 :)
@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.py
If 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:
sudo nano /var/lib/docker/aufs/mnt/<SomeRandomIDNumber>/usr/local/lib/python3.7/site-packages/discord/compat.py
On line 35 you will see
create_task = asyncio.async
change that to tocreate_task = getattr(asyncio, 'async')
Fixed the Discord error... Seems to break the FitBit component... https://github.com/home-assistant/home-assistant/tree/dev/homeassistant/components/fitbit
Error while setting up platform fitbit
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py", line 128, in _async_setup_platform
SLOW_SETUP_MAX_WAIT, loop=hass.loop)
File "/usr/local/lib/python3.7/asyncio/tasks.py", line 416, in wait_for
return fut.result()
File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/local/lib/python3.7/site-packages/homeassistant/components/sensor/fitbit.py", line 250, in setup_platform
authd_client.client.refresh_token()
File "/usr/local/lib/python3.7/site-packages/fitbit/api.py", line 157, in refresh_token
auth=HTTPBasicAuth(self.client_id, self.client_secret)
File "/usr/local/lib/python3.7/site-packages/requests_oauthlib/oauth2_session.py", line 374, in refresh_token
self.token = self._client.parse_request_body_response(r.text, scope=self.scope)
File "/usr/local/lib/python3.7/site-packages/oauthlib/oauth2/rfc6749/clients/base.py", line 415, in parse_request_body_response
self.token = parse_token_response(body, scope=scope)
File "/usr/local/lib/python3.7/site-packages/oauthlib/oauth2/rfc6749/parameters.py", line 425, in parse_token_response
validate_token_parameters(params)
File "/usr/local/lib/python3.7/site-packages/oauthlib/oauth2/rfc6749/parameters.py", line 432, in validate_token_parameters
raise_from_error(params.get('error'), params)
File "/usr/local/lib/python3.7/site-packages/oauthlib/oauth2/rfc6749/errors.py", line 405, in raise_from_error
raise cls(**kwargs)
oauthlib.oauth2.rfc6749.errors.InvalidGrantError: (invalid_grant)
I've set my bot up and I am getting these errors:
Traceback (most recent call last):
File "/usr/src/app/homeassistant/components/automation/__init__.py", line 381, in action
await script_obj.async_run(variables, context)
File "/usr/src/app/homeassistant/helpers/script.py", line 131, in async_run
await self._handle_action(action, variables, context)
File "/usr/src/app/homeassistant/helpers/script.py", line 210, in _handle_action
action, variables, context)
File "/usr/src/app/homeassistant/helpers/script.py", line 299, in _async_call_service
context=context
File "/usr/src/app/homeassistant/helpers/service.py", line 88, in async_call_from_config
domain, service_name, service_data, blocking=blocking, context=context)
File "/usr/src/app/homeassistant/core.py", line 1138, in async_call
self._execute_service(handler, service_call))
File "/usr/src/app/homeassistant/core.py", line 1160, in _execute_service
await handler.func(service_call)
File "/usr/src/app/homeassistant/components/notify/__init__.py", line 117, in async_notify_message
await notify_service.async_send_message(**kwargs)
File "/usr/src/app/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
any idea og what could be causing this and how to fix?
@AlexKalopsia did you change the lines in the .py as above? Did you make an automation that results in that? Just posting an error long doesnt show anything
@mkono87 sorry, I should have been clearer.
I do have an automation that results in that, yes (it's literally "send message if light turns on"). I have not tried changing those lines as I was wondering if this will come as an official fix. But I guess I will try changing those and see if it works
@AlexKalopsia Yeah worked for me but it just sucks that it has to be time every time you pull a new updated container. The problem is on the discord side I believe and a dependency has to be updated. Nothing HA can do.
@mkono87 I understand! Well if there is one thing that right now I'm having a problem with, is actually finding discord/compat.py
. I am running HA inside a docker running on my Syno, but I can't find those files at all uhm
my location is /usr/local/lib/python3.7/site-packages/discord/compat.py
yes, finally found it! That fixed the problem, thank you, hopefully this gets fixed
It looks like the new version of the library has been pushed to pipy now. Any chance someone can take a look at what needs to be updated to get this working with that version?
Im sure soon it will be done. I have had it disabled for quite a bit and now just using pushover
@mkono87 I set up the webhook to send messages succesfully. My next step would be to send an image from my camera. I guess i need message_param_name: file for this. but i tried: data: file: xxxx in an automation but that doesnt seem to work.
Are you willing to share the same info for a file as you did for content above? It was very clear to me in that way.
thanks in advance.
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):Traceback (if applicable):
Additional information: