【问题标题】:Custom device action won't run on raspberry pi with embedded assistant自定义设备操作不会在带有嵌入式助手的树莓派上运行
【发布时间】:2018-05-05 01:58:02
【问题描述】:

我有一个在树莓派上运行的谷歌家庭助理,我正在尝试为它进行自定义设备操作。

我想要做的动作是:“嘿,谷歌分析这个对象”,它只是拍下我拿着的任何东西的照片。由于某种原因,我不能使用“拍照”,因为它只会回复“对不起,我还不能拍照!”

我无法让它工作,我不知道为什么。闪烁灯示例有效,但此命令更简单,甚至没有参数。我已经更新了操作并获得了成功(您的 XXXX 项目助手的应用程序已成功更新为您的操作)。但每当我说“嘿,谷歌分析这个对象”时,它只会发出“对不起!我不明白”的声音。

我在这里做错了什么?

动作文件中的 JSON:

    {
    "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"
                    ]
                }
            ]
        }
    ]
}

python程序中的事件代码

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')

【问题讨论】:

    标签: json google-assistant-sdk


    【解决方案1】:

    呃,找到了。您必须更新您的操作,然后为您的操作推送测试。我忘记推送测试了。

    【讨论】:

      猜你喜欢
      • 2018-11-21
      • 2022-07-08
      • 1970-01-01
      • 2016-09-10
      • 1970-01-01
      • 2019-05-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多