在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):openhab/openhab-google-assistant开源软件地址(OpenSource Url):https://github.com/openhab/openhab-google-assistant开源编程语言(OpenSource Language):JavaScript 100.0%开源软件介绍(OpenSource Introduction):openHAB Google AssistantopenHAB Google Assistant is based on Google Cloud Function powered by Firebase and realized by Node.js. This serverless application connects the Google Assistant platform with the users openHAB instance through the openHAB Cloud service and lets the user control IoT devices through the Google Assistant. The openHAB Smart Home app lets you connect, query, and control devices through openHAB Cloud infrastructure. openHAB Cloud is the Smart Home IoT cloud engine in this setup and provides both the main openHAB business logic for the web services and proxying, as well as the web portal used to administrate the granted application in the frontend. It handles authentication, and ultimately handles requests from the Google Assistant. openHAB Cloud is also the access point and backend for the Node.js based openHAB Google Cloud function app that acts as mediator and adapter code. This Adapter will receive commands from the Google Assistant and has listeners for POST requests for receiving SYNC, QUERY or EXEC smart home device control messages towards the openHAB Cloud. The path for requests to this adapter is Google Home Graph: The Google related parts of any Smart Home action rely on Google Home Graph, a database that stores and provides contextual data about the home and its devices. For example, Home Graph can store the concept of a living room that contains multiple types of devices (a light, television, and speaker) from different manufacturers. This information is passed to the Google Assistant in order to execute user requests based on the appropriate context. General InstructionsRequirements
Google Cloud Functions
curl -O https://dl.google.com/gactions/updates/bin/linux/amd64/gactions/gactions
chmod +x gactions
Deploy the
Keep the address somewhere, you'll need it (something like Create OAuth CredentialsYou'll need to create OAuth credentials to enable API access. Since this is only used between your Google Cloud function and your openHAB cloud server, you can choose them on your own. See The Client ID and Secret - OAuth for details.
Setup your Database
use openhab
db.oauth2clients.insert({ clientId: "<CLIENT-ID>", clientSecret: "<CLIENT SECRET>"})
db.oauth2scopes.insert({ name: "any"})
db.oauth2scopes.insert( { name : "google-assistant", description: "Access to openHAB Cloud specific API for Actions on Google Assistant", } ) Actions on GoogleActions on Google is Google's platform for developers to extend Google Assistant. Here you need to develop your actions to engage users on Google Home, Pixel, and other surfaces where the Google Assistant is available.
Deploy your actionWhen you ask your assistant to “Turn on the light”, it will use the auth bearer Token and call the specified endpoint. To specify which endpoint the Google Assistant should call, you need to create an action.json similar to the one below, with your endpoint URL.
{
"actions": [{
"name": "actions.devices",
"deviceControl": {
},
"fulfillment": {
"conversationName": "automation"
}
}],
"conversations": {
"automation" :
{
"name": "automation",
"url": "https://YOUR-FULFILLMENT-URL-GIVEN-FROM-DEPLOYMENT"
}
}
} If you want to deploy your action in a foreign language, add locale parameter to the top of the action.js like : {
"locale": "fr",
"actions": [{
"name": "actions.devices",
"deviceControl": {
[...]
gactions update --action_package action.json --project <PROJECT ID> Google Assistant will call the service endpoint:
gactions test --action_package action.json --project <PROJECT ID> Note: Anytime you make changes to the settings to your Action on the Actions By Google interface, you'll need to repeat this step. Testing & Usage on Google App
If you're lucky this works! You'll need to configure your items (below) and then sync again. If it didn't work, try the workaround below. To resync changes in the metadata or other openHAB configuration, tell Google Home to WorkaroundsScope issuesIf you're getting error messages about an unknown scope, first check you've updated the MongoDB correctly in the Setup your Database step. If you still have issues, you can try this:
Using a different Google accountIn some cases, you may wish to have your Follow the same process above to setup the function and action, using your [email protected] account. By default, when you go to add OpenHAB to the Google Home app using your [email protected] account, your To fix:
Return back to the Google Home app and try to add the OpenHAB service again. You should now be able to see Item Configuration, Example Voice Commands & Service LinkageFor details on how to configure your items and which voice commands you can use, please see the USAGE documentation. In addition, you can also find information there on how to set up service linking with https://myopenhab.org within the Google Home App. Logging & DebuggingTo check your deployed openHAB Google Cloud function app logs and debugging use the following command: gcloud beta functions logs read openhabGoogleAssistant Limitations & Known Issues
References
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论