gauravsacc / MMM-GoogleAssistant

Google Assistant module for magic mirror https://github.com/MichMich/MagicMirror
MIT License
118 stars 40 forks source link

GA works, GA in MM does not #52

Open maikinmoves opened 6 years ago

maikinmoves commented 6 years ago

I have been chasing my tail for about 6 hours trying to get this to work, and I am almost to the point of deleting everything and starting over.

When I run google assistant (GA) through googlesamples-assistant-hotword, it works, I can even leave that running in the background, open up magicmirror (MM) and add things to my calender and watch them populate on my calendar on MM 2 seconds later, But the GA icon never moves in MM and if I don't have the sample going in the background it doesn't work. So I know it is something in the assistant.py because see below, and I have no idea what to try or where to go next. Thank you for the help.

(env) pi@raspberrypi:~/MagicMirror/modules/MMM-GoogleAssistant/pi $ sudo python ./assistant.py
Traceback (most recent call last):
  File "./assistant.py", line 25, in <module>
    import google.oauth2.credentials
ImportError: No module named google.oauth2.credentials
(env) pi@raspberrypi:~/MagicMirror/modules/MMM-GoogleAssistant/pi $ sudo /home/pi/env/bin/python3 -u assistant.py
pubnub subscription completed
[FATAL:audio_input_stream.cc(47)] Input device could not be opened: default
Aborted
maikinmoves commented 6 years ago

Solved some of this, For the Audio, I went back into /home/pi/.asoundrc from the terminal and all looked good, I went back into that same file from the file manager and found some of the stock script back in it at the bottom, I deleted that and it then worked.

Credentials was i had the google project id and not the generated device id which you get after you run the sample setup.

and for the async issue, i went into /home/pi/MagicMirror/modules/MMM-GoogleAssistant/pi/assistant.py and searched for _async and did find replace with _pnasync

Now off a fresh restart of the raspberry I can go straight into MagicMirror and GA assistant works but the icon does not move when she is activated.

gauravsacc commented 6 years ago

@maikinmoves is your pubnub setup all good?

maikinmoves commented 6 years ago

Honestly, I have never heard of pubnub before starting this project. I did sign up for an account, I do have my demo keyset publish key and subscribe key in assistant.py , but now that you questioned that, I logged back into that page to see the keys on there and decided to click on "Functions" and am now realizing I don't know shit about this setup and am assuming it is more than just grabbing an API key for some of the other modules.
While I would love for you to come over here and just set it up for me, I know that this isn't what a forum is for so if you could just point me in the right directions of where to find the answers for setting up the PubNub would be greatly appreciated.

gauravsacc commented 6 years ago

@maikinmoves I'm not using the new 'Functions' feature from pubnub in this project. All you have to do in pubnub is to create a project (you can also use the demo one) and configure the keys in the assistant.py and config.js

mirrorsmart200 commented 5 years ago

logo isnt activated in magic mirror but works well when executed via terminal i am stuck please help.

mirrorsmart200 commented 5 years ago

@gauravsacc GA works well in terminal but no response in MM what could be the problem?

djcors commented 4 years ago

Same problem, MM dont run assistant.py?

maikinmoves commented 4 years ago

Djcors, i wish i could tell you a better answer, but i have accepted my work around. I just open two terminals any time i restart my MM use one to start python and start the assistant, use the other terminal to start the magic mirror and then it works. I am pretty sure there is someway to get raspberry to start it on its own separately but im too lazy to figure it out now that i have it atleast running.

djcors commented 4 years ago

@maikinmoves I tried this, works but is not great work XD on node_helper.js

publishSampleMessage: function(pubnub) {
    console.log("Since we're publishing on subscribe connectEvent, we're sure we'll receive the following publish.");
    var publishConfig = {
        channel : "magicmirror",
        message : "ON_CONVERSATION_TURN_STARTED"
    }
    pubnub.publish(publishConfig, function(status, response) {
        console.log(status, response);
    })
},
socketNotificationReceived: function(notification, payload) {
    if (notification === 'INIT') {
      console.log("now initializing assistant");
      const { spawn } = require('child_process');
      const py = spawn('/home/pi/env/bin/python', ['/home/pi/MagicMirror/modules/MMM-GoogleAssistant/pi/assistant.py'])
      this.initGoogleAssistant(payload);
    }
}
djcors commented 4 years ago

@maikinmoves on node_helper.js

status: function(statusEvent) {
        if (statusEvent.category === "PNConnectedCategory") {
          self.publishSampleMessage(self.pubnub);
        }
   },
djcors commented 4 years ago

@maikinmoves works like your run two terminal with MM and Assistant.py, but only one command, the problem with that is MM not get message from pubnub and not update UI interface

georgeion commented 3 years ago

I have been chasing my tail for about 6 hours trying to get this to work, and I am almost to the point of deleting everything and starting over.

When I run google assistant (GA) through googlesamples-assistant-hotword, it works, I can even leave that running in the background, open up magicmirror (MM) and add things to my calender and watch them populate on my calendar on MM 2 seconds later, But the GA icon never moves in MM and if I don't have the sample going in the background it doesn't work. So I know it is something in the assistant.py because see below, and I have no idea what to try or where to go next. Thank you for the help.

(env) pi@raspberrypi:~/MagicMirror/modules/MMM-GoogleAssistant/pi $ sudo python ./assistant.py
Traceback (most recent call last):
  File "./assistant.py", line 25, in <module>
    import google.oauth2.credentials
ImportError: No module named google.oauth2.credentials
(env) pi@raspberrypi:~/MagicMirror/modules/MMM-GoogleAssistant/pi $ sudo /home/pi/env/bin/python3 -u assistant.py
pubnub subscription completed
[FATAL:audio_input_stream.cc(47)] Input device could not be opened: default
Aborted

For my the googlesamples-assistant-hotword project id blah blah, is not working. it said googlesamples-assistant-hotword: command not found. I even tried to downgrade the library version. still not working. What version of RPi you were using?