gauravsacc / MMM-GoogleAssistant

Google Assistant module for magic mirror https://github.com/MichMich/MagicMirror

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Async request Exception - ¨Publish¨ object has no attribute ´async´

n1xan opened this issue · comments

Hi,

I have completed the setup of the module with audio and assistant test working correctly.

Once I run the assistant.py script I am getting an error which prevents the module from working:

pi@raspberrypi:~/MagicMirror/modules/MMM-GoogleAssistant/pi $ sudo /home/pi/env/bin/python3 -u assistant.py
pubnub subscription completed
Async request Exception. 'Publish' object has no attribute 'async'
Exception in subscribe loop: 'Publish' object has no attribute 'async'

After this error the hotword gets detected, but then another errors are logged and nothing happens:

Playing WAVE 'start.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
Traceback (most recent call last):
  File "assistant.py", line 137, in <module>
    main()
  File "assistant.py", line 134, in main
    init_googleAssistant()
  File "assistant.py", line 130, in init_googleAssistant
    process_event(event)
  File "assistant.py", line 100, in process_event
    pubnub.publish().channel("magicmirror").message("ON_CONVERSATION_TURN_STARTED").async(my_publish_callback)
AttributeError: 'Publish' object has no attribute 'async'

Is anyone getting this error, or got a working solution?

Thanks a lot!

yes i am getting the same error

(env) pi@MagicMirror:~/MagicMirror/modules/MMM-GoogleAssistant/pi $ python assistant.py
pubnub subscription completed
Traceback (most recent call last):
File "assistant.py", line 137, in
main()
File "assistant.py", line 134, in main
init_googleAssistant()
File "assistant.py", line 128, in init_googleAssistant
with Assistant(credentials,"magic-mirror-device-id") as assistant:
TypeError: init() takes 2 positional arguments but 3 were given
Async request Exception. 'Publish' object has no attribute 'async'
Exception in subscribe loop: 'Publish' object has no attribute 'async'

As the error is from the publish method, it could most probably be because async has been changed to pn_async

refer this:
https://www.pubnub.com/docs/python/changelog#v4-1-1

hey @mayankkumar15 yes the method name change is the problem. Do you want to raise a PR with this fix?

Copy that, getting the same error on here. start.wav will play, but no response from Google received

To anybody else receiving this error, do:

pip uninstall pubnub 
pip install==4.0.13 

pip uninstall pubnub
pip install pubnub==4.0.13

Tried that, and went into MagicMmirror, said "hey google" and without any animation got the response "something went wrong try again in a few moments". Exited MM, tried the google sample and recieved the audio 47 fault again. Restarted the Pi, then the google sample worked but nothing out of MM so i ran assistant.py and got an error about pn_async, so I edited the assistant.py and removed the 'pn_' from the four async strings and ran assitant.py again and recieved "hello from pubhub" tested google sample and that was working, test MM and still no response from GA.

I greatly appreciate you taking the time to help with this.

(env) pi@raspberrypi:~ $ pip install pubnub==4.0.13
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting pubnub==4.0.13
  Downloading https://www.piwheels.org/simple/pubnub/pubnub-4.0.13-py3-none-any.whl (68kB)
    100% |████████████████████████████████| 71kB 230kB/s 
Requirement already satisfied: requests>=2.4 in ./env/lib/python3.5/site-packages (from pubnub==4.0.13) (2.20.0)
Requirement already satisfied: pycryptodomex>=3.3 in ./env/lib/python3.5/site-packages (from pubnub==4.0.13) (3.7.0)
Requirement already satisfied: six>=1.10 in ./env/lib/python3.5/site-packages (from pubnub==4.0.13) (1.11.0)
Requirement already satisfied: idna<2.8,>=2.5 in ./env/lib/python3.5/site-packages (from requests>=2.4->pubnub==4.0.13) (2.7)
Requirement already satisfied: urllib3<1.25,>=1.21.1 in ./env/lib/python3.5/site-packages (from requests>=2.4->pubnub==4.0.13) (1.24.1)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in ./env/lib/python3.5/site-packages (from requests>=2.4->pubnub==4.0.13) (3.0.4)
Requirement already satisfied: certifi>=2017.4.17 in ./env/lib/python3.5/site-packages (from requests>=2.4->pubnub==4.0.13) (2018.10.15)
Installing collected packages: pubnub
Successfully installed pubnub-4.0.13

while True:
sensor_value = {'voltage':random.uniform(-5, 5)}
print(sensor_value)
envelope = pubnub.publish().channel('channel0').message(sensor_value).sync()
print("publish timetoken: %d" % envelope.result.timetoken)
time.sleep(5)

Am i suppose to add that code to assistant.py

I had trouble with async(), so I just used the sync() method instead.

If you want to publish msgs you can try the about code. The setup code isn't shown.

The renaming of the async() method to pn_async() worked for me.

Thanks a lot.