Google Custom Device Action Giving Error on Raspberry Pi Google Assistant

Internet of Things IoT Frameworks 2 years ago

0 1 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating
_x000D_ _x000D_ I'm creating a google assistant on my Raspberry Pi 3 and I'm trying to create a custom device action to eventually open my garage door. All it does is play with an LED at this point in time. Here is my actions.json file: { "manifest": { "displayName": "Garage door", "invocationName": "Garage door", "category": "PRODUCTIVITY" }, "actions": [ { "name": "me.custom.actions.GarageDoor", "availability": { "deviceClasses": [ { "assistantSdkDevice": {} } ] }, "intent": { "name": "me.custom.intents.GarageDoor", "trigger": { "queryPatterns": [ "open the garage door", "close the garage door" ] } }, "fulfillment": { "staticFulfillment": { "templatedResponse": { "items": [ { "simpleResponse": { "textToSpeech": "Okay" } }, { "deviceExecution": { "command": "me.custom.commands.GarageDoor" } } ] } } } } ], "types": [] } But when I run the command I get this error: INFO:root:Transcript of user request: "open the garage door". INFO:root:Playing assistant response. WARNING:root:Error during command execution Traceback (most recent call last): File "/home/pi/assistant-sdk-python/google-assistant-sdk/googlesamples/assistant/grpc/device_helpers.py", line 94, in dispatch_command self.handlers[command](**params) TypeError: gdoor() argument after ** must be a mapping, not NoneType Here's my handler: @device_handler.command('me.custom.commands.GarageDoor') def gdoor(*args): print(args) global g_open if g_open: GPIO.output(18, 0) g_open = 0 else: GPIO.output(18, 1) g_open = 1 I was playing around with the *args to see if it fixed anything - it didn't. I've changed my package names to custom just for privacy. I'm quite confused here. Any help appreciated! Thanks!

Posted on 16 Aug 2022, this text provides information on IoT Frameworks related to Internet of Things. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (1)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago
_x000D_ Looking at the sample code, it seems like the function signature is a bit different, as it directly adds the arguments. @device_handler.command('com.example.commands.BlinkLight') def blink(speed, number): logging.info('Blinking device %s times.' % number) delay = 1 if speed == "SLOWLY": delay = 2 elif speed == "QUICKLY": delay = 0.5 for i in range(int(number)): logging.info('Device is blinking.') time.sleep(delay) Looking at the action package, it doesn't seem like you're providing any actions to go along with the command fulfillment. As shown in the sample: { "deviceExecution": { "command": "com.example.commands.BlinkLight", "params": { "speed": "$speed", "number": "$number" } } } Without any params, it may not map any functions at all.

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.

Important Internet of Things Links