xtools-at / AssistantPi

Bring both Google Assistant and Alexa to your Raspberry Pi
MIT License
490 stars 50 forks source link

Custom actions possible? #20

Closed mmgill closed 7 years ago

mmgill commented 7 years ago

I really liked what you guys have done here but had one issue that I was hoping to get more info on.

Using the standard google sdk I was able to create custom actions based on keywords (action.py) . (Ex. - "OK Google, turn on TV"; action.py would fire a subprcoess irsend command; tv would turn on)

Is it possible to implement custom actions/GPIO using Google/Alexa in this program?

class IRRemote(object): def init(self, say, command): self.say = say self.command = command

def run(self, voice_command):
    if self.command == "power":
        self.say("TV Power")
        subprocess.call(["irsend", "SEND_ONCE", "samsung", "KEY_POWER"])
    elif self.command == "mute":
        self.say("Muting TV")
        subprocess.call(["irsend", "SEND_ONCE", "samsung", "KEY_MUTE"])
    elif self.command == "switch to tv":
        self.say("Input 1")
        subprocess.call(["irsend", "SEND_ONCE", "hdmi", "KEY_PROG1"])
    elif self.command == "switch to input":
        self.say("Input2")
        subprocess.call(["irsend", "SEND_ONCE", "hdmi", "KEY_PROG2"])
    elif self.command == "switch to nexus":
        self.say("Input 3")
        subprocess.call(["irsend", "SEND_ONCE", "hdmi", "KEY_PROG3"])
    else:
        logging.error("Error identifying power command.")
        self.say("Sorry I didn't identify that command")
xtools-at commented 7 years ago

Hi @mmgill AssistantPi is using it's own instance of Google Assistant Python SDK 0.2.1 (find the fork that's installed here), which is downoaded to /opt/AlexaPi/src/assistant-sdk-python. If the custom actions don't require a newer version of the SDK, you can try doing your changes there.

I haven't updated to 0.3.x yet as they've

When the SDK matures, I'll put together AssistantPi 2.0 ;)

mmgill commented 7 years ago

Thanks for the info. I did use the https://github.com/google/aiyprojects-raspbian repo to get GA running on the pi which has integrated custom voice commands using action.py. Might have to look for other options to handle my situation, rasp pi3.

Thanks!