0
votes

I have a google home assistant running on a raspberry pi and I'm trying to make custom device actions for it.

The action I want to do is: "Hey Google analyze this object", and it just takes a picture of whatever I am holding. I can't for some reason use "take a picture" because it just responds with "Sorry I can't take photos yet!"

I can not get this to work and I have no idea why. The blink a light example works, but this command simpler and doesn't even have parameters. I've updated the actions and get an ok (Your app for the Assistant for project XXXX was successfully updated with your actions). But whenever I say "hey google analyze this object", it just chrips "Sorry! I don't understand".

What am I doing wrong here?

JSON in actions file:

    {
    "manifest": {
        "displayName": "Office Controller",
        "invocationName": "Office Controller",
        "category": "PRODUCTIVITY"
    },
    "actions": [
            {
            "name": "com.acme.actions.analyze_object",
            "availability": {
                "deviceClasses": [
                    {
                        "assistantSdkDevice": {}
                    }
                ]
            },
            "intent": {
                "name": "com.acme.intents.analyze_object",
                "trigger": {
                    "queryPatterns": [
                        "analyze this object"
                    ]
                }
            },
            "fulfillment": {
                "staticFulfillment": {
                    "templatedResponse": {
                        "items": [
                            {
                                "simpleResponse": {
                                    "textToSpeech": "Ok. Analyzing."
                                }
                            },
                            {
                                "deviceExecution": {
                                    "command": "com.acme.commands.analyze_object"
                                }
                            }
                        ]
                    }
                }
            }
        },
        {
            "name": "com.acme.actions.blink_light",
            "availability": {
                "deviceClasses": [
                    {
                        "assistantSdkDevice": {}
                    }
                ]
            },
            "intent": {
                "name": "com.acme.intents.blink_light",
                "parameters": [
                    {
                        "name": "number",
                        "type": "SchemaOrg_Number"
                    },
                    {
                        "name": "light_target",
                        "type": "LightType"
                    }
                ],
                "trigger": {
                    "queryPatterns": [
                        "blink the $LightType:light_target $SchemaOrg_Number:number times"
                    ]
                }
            },
            "fulfillment": {
                "staticFulfillment": {
                    "templatedResponse": {
                        "items": [
                            {
                                "simpleResponse": {
                                    "textToSpeech": "Blinking the $light_target.raw $number times"
                                }
                            },
                            {
                                "deviceExecution": {
                                    "command": "com.acme.commands.blink_light",
                                    "params": {
                                        "lightKey": "$light_target",
                                        "number": "$number"
                                    }
                                }
                            }
                        ]
                    }
                }
            }
        }
    ],
    "types": [
        {
            "name": "$LightType",
            "entities": [
                {
                    "key": "LIGHT",
                    "synonyms": [
                        "LED",
                        "light",
                        "bulb",
                        "light bulb"
                    ]
                }
            ]
        }
    ]
}

Event Code in python program

if event.type == EventType.ON_DEVICE_ACTION:
        for command, params in process_device_actions(event, device_id):
            print('Do command', command, 'with params', str(params))

            if command == "com.acme.commands.blink_light":
                number = int( params['number'] )
                for i in range(int(number)):
                    print('Device is blinking.')
                    GPIO.output(25, 1)
                    time.sleep(1)
                    GPIO.output(25, 0)
                    time.sleep(1)

            elif command == "com.acme.commands.analyze_object":
                camera = picamera.PiCamera()
                camera.capture('photo.jpg')
                print('Took a photo')
1

1 Answers

0
votes

Ugh found it. You have to update your actions and then push a test for your actions. I forgot to push the test.