- Clone this repository.
- If using Raspberry Pi, please download and use a pre-built binary from Releases page.
- cd Beatrice.Web
- Copy "appsettings.Beatrice.sample.json" to "appsettings.Beatrice.json".
- Copy "actions.sample.json" to "actions.json".
- Navigate to the Actions on Google
- Click "Actions Console"
- Click "Add/import project" to create new project.
- Input your project name and select country. (e.g. MyBeatriceApp and Japan)
- Note your project ID. You can see the project ID in
Settingspage or in console URL (e.g. https://console.actions.google.com/project/mybeatriceapp/ -> mybeatriceapp).
- Navigate to the Google Cloud Console API Manager
- Click "Credentials"
- Select your project.
- Click "Create Credentials"
- Click "API key"
- Copy API Key and paste to "SyncRequestApiKey" value in "appsettings.Beatrice.json"
- Open a terminal and run
ngrok http 5000 --host-header=localhost - In the output, note the assigned subdomain name on ngrok. (e.g. https://example.ngrok.io/ -> example)
- Configure Sign-in account
- Insert a username to Beatrice:Security:User.
- Create a password. The value must be a SHA256 hash digest of "UserName:Password" format.
- Linux/macOS:
echo -n UserName:Password | openssl sha256 - Windows:
((New-Object System.Security.Cryptography.SHA256Managed).ComputeHash([System.Text.Encoding]::UTF8.GetBytes("UserName:Password")) | %{ $_.ToString("x2") }) -join ""
- Linux/macOS:
- Insert the password to Beatrice:Security:Password.
- Configure OAuth Credentials
- Create
ClientIdand insert to Beatrice:Security:OAuth:ClientId. - Create
ClientSecretand insert to Beatrice:Security:OAuth:ClientSecret.ClientIdandClientSecretare any unguessable random string of your choice.
- In Beatrice:Security:OAuth:RedirectUrls, replace placeholder in
https://oauth-redirect.googleusercontent.com/r/<ProjectId>for your project's.
- Create
- Navigate to the Actions project.
- Click "Use Actions SDK"
- Update URLs in "actions.json" with where you hosted app location.
https://<AssignedSubDomain>.ngrok.io/Automation/->https://example.ngrok.io/Automation/https://server.home.example.com/Automation/- etc...
- To update the project settings, execute
gactionscommand with the "actions.json"- Download gactions CLI
- Execute
gactions update --project <Project ID> --action_package actions.jsonin a terminal.
- Click "OK"
- Click "ADD" under App information.
- Fill your app information. For example. App name, some description, contact info and more.
- Click "Account linking (optional)" and Click "ADD".
- Fill fields with your Beatrice OAuth configuration values.
- Grant type:
Authorization code - Client information
- Client ID: same as Beatrice:Security:OAuth:ClientId
- Client secret: same as Beatrice:Security:OAuth:ClientSecret
- Authorization URL:
https://<Hosted address>/connect/authorize - Token URL:
https://<Hosted address>/connect/token
- Grant type:
- Click "Save".
- Click "TEST DRAFT".
- cd
Beatrice.Web - Run
dotnet run- If using Raspberry Pi, Run
./Beatrice.Webinstead. - Recommend: At this time, You should check reachability to the app from the Internet. For example, you try to access the app via ngrok.io and sign in.
- If using Raspberry Pi, Run
- On a device with the Google Assistant logged into the same account used to create the project in Actions Console.
- Open Google Home or Assistant settings.
- Click "Home Control"
- Click the "+"
- Find your app project on the list.
- Sign in to the Beatrice.
- You can see the virtual devices on Beatrice in your smarthome device list.
Try saying "Turn on Outlet1" to Google Assistant(Home) or Simulator on Console. If there no problems, you can see a message "Hello! Konnichiwa!" in your terminal.
- Configure web server
- By default, the web server listens on port 5000. If you want to listen on another port, you can override the port setting.
- Set
http://*:1234toASPNETCORE_URLSenvironment variable.
- Set
- By default, the web server listens on port 5000. If you want to listen on another port, you can override the port setting.