Domoticz to Google Assistant integration

Alexa, Google Home and Siri

Moderator: leecollings

Post Reply
Pawcio
Posts: 9
Joined: Thursday 18 October 2018 23:02
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Domoticz to Google Assistant integration

Post by Pawcio »

Domoticz to Google Assistan integration

Based on the home assistant implementation:
https://github.com/home-assistant/home- ... _assistant
and https://github.com/actions-on-google/smart-home-nodejs

Required:
- Public IP
- python >= 3.5
- reverse proxy for establishing secure connection (aog itself provides currently only unsecure one - http only)

Aog delivers:
- the oauth authorization and smarthome endpoint for the google assistant
- OnOff, Brightness, Scene and OpenClose traits, rest to be done...
Please feel free to modify it, extend and improve


Before first launch, config.py must be modified properly:
PORT_NUMBER = 3030 -> port number for the aog server

SMARTHOMEPROVIDERGOOGLECLIENTID = 'AxqqWpwYj4' - Client ID issued by your Actions to Google, check actions on google configuration
SMARTHOMEPROVIDEGOOGLECLIENTSECRET = '11MH3uWlMVrqa7FAbKLBoNUMCyLC22' - Client secret
SMARTHOMEPROVIDERAPIKEY = 'zOzaSyBu5Y8W7EiHvO1eyPmOAtZRxM9GaLP_uLA' -> https://github.com/actions-on-google/sm ... quest-sync

DOMOTICZ_URL='http://[DOMOTICZ_IP]:[PORT]'
U_NAME_DOMOTICZ = 'domoticz user name'
U_PASSWD_DOMOTICZ = 'domoticz user password'

#oauth credentials -> required for app linking
U_NAME = 'username'
U_PASSWD = 'password'

if required nicknames, room hint and ack for selected devices can be added:
DEVICE_CONFIG = {
'135' : { - domoticz's idx of the device
'nicknames' : ['Kitchen Blind One'], - list of the nicknames
'room' : 'Kitchen' , - room hint
'ack' : True}, - ack for command execution


starting aog server:
python3 aog


1. Change your Account linking setting in Actions on Google console https://console.actions.google.com/, look for the Advanced Options in the bottom left of the sidebar.
Change Linking type to OAuth and Authorization Code.
In the Client information section:
Set Client ID - SMARTHOMEPROVIDERGOOGLECLIENTID
Set Client Secret - SMARTHOMEPROVIDEGOOGLECLIENTSECRET
Change Authorization URL to https://[YOUR REVERSE PROXY URL]/oauth (replace with your actual URL).
Change Token URL to https://[YOUR REVERSE PROXY URL]/token (replace with your actual URL).
In the Configure your client section:
Do NOT check Google to transmit clientID and secret via HTTP basic auth header.
Click ‘Save’ at the top right corner, then click ‘Test’ to generate a new draft version of the Test App.



https://[YOUR REVERSE PROXY URL]/sync - force devices sync
Attachments
aog.7z
Aog server
(10.51 KiB) Downloaded 411 times
reydecopas
Posts: 1
Joined: Wednesday 06 March 2019 20:33
Target OS: Linux
Domoticz version:
Contact:

Re: Domoticz to Google Assistan integration

Post by reydecopas »

Hi!!!!

I have been looking around about GassistPI and IFTTT but I wanted something like HomeAssistant directly to Google Assistant...

Thanks a lot!!!
EddyG
Posts: 1042
Joined: Monday 02 November 2015 5:54
Target OS: -
Domoticz version:

Re: Domoticz to Google Assistan integration

Post by EddyG »

Please clarify / explain where those file should be placed. Should it be in the root of domoticz?
I already have an https reversed proxy on my synology pointing to my raspberry where domoticz runs.
Pawcio
Posts: 9
Joined: Thursday 18 October 2018 23:02
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Domoticz to Google Assistan integration

Post by Pawcio »

Hi,
Actualy it is a standalone implementation. It means that you can put this AOG module wherever you want, even on another machine.
EddyG
Posts: 1042
Joined: Monday 02 November 2015 5:54
Target OS: -
Domoticz version:

Re: Domoticz to Google Assistan integration

Post by EddyG »

Oke, Tnx.
EddyG
Posts: 1042
Joined: Monday 02 November 2015 5:54
Target OS: -
Domoticz version:

Re: Domoticz to Google Assistan integration

Post by EddyG »

Am I missing something?
python3 aog does not work -> can't open file 'aog'
python3 server.py does not work -> no error message.
Pawcio
Posts: 9
Joined: Thursday 18 October 2018 23:02
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Domoticz to Google Assistan integration

Post by Pawcio »

Did you try in one level up?
You cannot be inside aog folder.
EddyG
Posts: 1042
Joined: Monday 02 November 2015 5:54
Target OS: -
Domoticz version:

Re: Domoticz to Google Assistan integration

Post by EddyG »

Sorry, :oops: That worked.
ressof
Posts: 60
Joined: Thursday 20 April 2017 7:20
Target OS: Linux
Domoticz version: Latest
Contact:

Re: Domoticz to Google Assistan integration

Post by ressof »

Pawcio wrote: Wednesday 06 March 2019 12:12 Domoticz to Google Assistan integration
Hi

Is it possible to explain a bit more how to configure Google Actions for this to work? I am a complete newbie at Actions on Google.
User avatar
DewGew
Posts: 579
Joined: Thursday 21 April 2016 12:01
Target OS: Raspberry Pi / ODroid
Domoticz version: V4.10618
Location: Sweden
Contact:

Re: Domoticz to Google Assistan integration

Post by DewGew »

Im trying this but after I have linked my account it say its an error try agin.
In terminal for aog I get

Code: Select all

"POST / HTTP/1.1" 404 -
Whats wrong?
Raspberry Pi 3 | domoticz | Aeon Labs Z-Stick GEN5 | RFlink gateway
NanoPi NEO-air | REGO6XX interface | Machinon theme | Homebridge | Domoticz Google Assistant | ideAlarm
User avatar
DewGew
Posts: 579
Joined: Thursday 21 April 2016 12:01
Target OS: Raspberry Pi / ODroid
Domoticz version: V4.10618
Location: Sweden
Contact:

Re: Domoticz to Google Assistan integration

Post by DewGew »

ressof wrote: Friday 22 March 2019 10:16
Pawcio wrote: Wednesday 06 March 2019 12:12 Domoticz to Google Assistan integration
Hi

Is it possible to explain a bit more how to configure Google Actions for this to work? I am a complete newbie at Actions on Google.
Setup Instructions
Use the Actions on Google Console to add a new project with a name of your choosing and click - Create Project.

Click Home Control, then click Smart Home.
On the left navigation menu under SETUP, click on Invocation.
Add your App's name. Click Save.
Click Save.
Add Credentials

Navigate to the Google Cloud Console API Manager for your project id.
Click 'Create credentials'
Click 'OAuth client ID'
Choose 'other'
Add name e.g. 'SMARTHOMEPROVIDERGOOGLECLIENTID'
Copy the client ID shown and insert it in SMARTHOMEPROVIDERGOOGLECLIENTID in config.py
Copy the client secret shown and insert it in SMARTHOMEPROVIDEGOOGLECLIENTSECRETin config.py
Add Request Sync

The Request Sync feature allows a cloud integration to send a request to the Home Graph to send a new SYNC request.

Navigate to the Google Cloud Console API Manager for your project id.
Enable the HomeGraph API. This will be used to request a new sync and to report the state back to the HomeGraph.
Click Credentials
Click 'Create credentials'
Click 'API key'
Copy the API key shown and insert it in SMARTHOMEPROVIDERAPIKEY in config.py.
Navigate back to the Actions on Google Console.

On the left navigation menu under BUILD, click on Actions. Click on Add Your First Action and choose your app's language(s). Enter the URL for fulfillment, e.g. https://[YOUR REVERSE PROXY URL]/smarthome, click Done.
On the left navigation menu under ADVANCED OPTIONS, click on Account Linking.
Select No, I only want to allow account creation on my website. Click Next.
For Linking Type, select OAuth.
For Grant Type, select 'Authorization Code' for Grant Type.
Under Client Information, enter the client ID and secret from earlier.
Change Authorization URL to https://[YOUR REVERSE PROXY URL]/oauth (replace with your actual URL).
Change Token URL to https://[YOUR REVERSE PROXY URL]/token (replace with your actual URL). In the Configure your client section:
Do NOT check Google to transmit clientID and secret via HTTP basic auth header.
Click ‘Save’ at the top right corner, then click ‘Test’ to generate a new draft version of the Test App.
Raspberry Pi 3 | domoticz | Aeon Labs Z-Stick GEN5 | RFlink gateway
NanoPi NEO-air | REGO6XX interface | Machinon theme | Homebridge | Domoticz Google Assistant | ideAlarm
ressof
Posts: 60
Joined: Thursday 20 April 2017 7:20
Target OS: Linux
Domoticz version: Latest
Contact:

Re: Domoticz to Google Assistan integration

Post by ressof »

Thank you for your detailed explanation.

I can now link my test application on Google Home app but it cant find any devices or sensors.
In the aog log I see this

Code: Select all

No user data
127.0.0.1 - - [01/Apr/2019 14:05:50] "GET /oauth?response_type=code&client_id=[MASKED]&redirect_uri=https://oauth-redirect.googleusercontent.com/r/domoticz-[MASKED] HTTP/1.0" 307 -
127.0.0.1 - - [01/Apr/2019 14:05:50] "GET /login?client_id=[MASKED]&redirect_uri=https%3A%2F%2Foauth-redirect.googleusercontent.com%2Fr%2Fdomoticz-[MASKED] HTTP/1.0" 200 -
127.0.0.1 - - [01/Apr/2019 14:06:18] "POST /login HTTP/1.0" 301 -
Do you know what the problem is?
User avatar
DewGew
Posts: 579
Joined: Thursday 21 April 2016 12:01
Target OS: Raspberry Pi / ODroid
Domoticz version: V4.10618
Location: Sweden
Contact:

Re: Domoticz to Google Assistan integration

Post by DewGew »

ressof wrote: Monday 01 April 2019 14:09 Thank you for your detailed explanation.

I can now link my test application on Google Home app but it cant find any devices or sensors.
In the aog log I see this

Code: Select all

No user data
127.0.0.1 - - [01/Apr/2019 14:05:50] "GET /oauth?response_type=code&client_id=[MASKED]&redirect_uri=https://oauth-redirect.googleusercontent.com/r/domoticz-[MASKED] HTTP/1.0" 307 -
127.0.0.1 - - [01/Apr/2019 14:05:50] "GET /login?client_id=[MASKED]&redirect_uri=https%3A%2F%2Foauth-redirect.googleusercontent.com%2Fr%2Fdomoticz-[MASKED] HTTP/1.0" 200 -
127.0.0.1 - - [01/Apr/2019 14:06:18] "POST /login HTTP/1.0" 301 -
Do you know what the problem is?
Redirect URL is wrong. Check you URL settings in Action on Google and in your reverse proxy settings.
Raspberry Pi 3 | domoticz | Aeon Labs Z-Stick GEN5 | RFlink gateway
NanoPi NEO-air | REGO6XX interface | Machinon theme | Homebridge | Domoticz Google Assistant | ideAlarm
ressof
Posts: 60
Joined: Thursday 20 April 2017 7:20
Target OS: Linux
Domoticz version: Latest
Contact:

Re: Domoticz to Google Assistan integration

Post by ressof »

Is the redirect url, "https://[YOUR REVERSE PROXY URL]/smarthome", the url to domoticz or to aog
"https://[YOUR REVERSE PROXY URL]/oauth" is to aog?
"https://[YOUR REVERSE PROXY URL]/token" is to aog?
User avatar
DewGew
Posts: 579
Joined: Thursday 21 April 2016 12:01
Target OS: Raspberry Pi / ODroid
Domoticz version: V4.10618
Location: Sweden
Contact:

Re: Domoticz to Google Assistan integration

Post by DewGew »

ressof wrote: Thursday 04 April 2019 13:10 Is the redirect url, "https://[YOUR REVERSE PROXY URL]/smarthome", the url to domoticz or to aog
"https://[YOUR REVERSE PROXY URL]/oauth" is to aog?
"https://[YOUR REVERSE PROXY URL]/token" is to aog?
Yes. Can be the settings in your reverse proxy also
Raspberry Pi 3 | domoticz | Aeon Labs Z-Stick GEN5 | RFlink gateway
NanoPi NEO-air | REGO6XX interface | Machinon theme | Homebridge | Domoticz Google Assistant | ideAlarm
User avatar
DewGew
Posts: 579
Joined: Thursday 21 April 2016 12:01
Target OS: Raspberry Pi / ODroid
Domoticz version: V4.10618
Location: Sweden
Contact:

Re: Domoticz to Google Assistan integration

Post by DewGew »

I cant make ’ack = True’ to work. Any ideas?
Raspberry Pi 3 | domoticz | Aeon Labs Z-Stick GEN5 | RFlink gateway
NanoPi NEO-air | REGO6XX interface | Machinon theme | Homebridge | Domoticz Google Assistant | ideAlarm
ressof
Posts: 60
Joined: Thursday 20 April 2017 7:20
Target OS: Linux
Domoticz version: Latest
Contact:

Re: Domoticz to Google Assistan integration

Post by ressof »

Now I get this in my log

Code: Select all

127.0.0.1 - - [08/Apr/2019 14:13:45] "POST /login HTTP/1.0" 301 -
127.0.0.1 - - [08/Apr/2019 14:13:47] "POST /token HTTP/1.0" 200 -
when I link the action on my google home app.

I get a message that the link is succesful in the google home app but after a few seconds it says
"An error occurred, please try again"

Why is this?
User avatar
DewGew
Posts: 579
Joined: Thursday 21 April 2016 12:01
Target OS: Raspberry Pi / ODroid
Domoticz version: V4.10618
Location: Sweden
Contact:

Re: Domoticz to Google Assistan integration

Post by DewGew »

ressof wrote: Monday 08 April 2019 14:22 Now I get this in my log

Code: Select all

127.0.0.1 - - [08/Apr/2019 14:13:45] "POST /login HTTP/1.0" 301 -
127.0.0.1 - - [08/Apr/2019 14:13:47] "POST /token HTTP/1.0" 200 -
when I link the action on my google home app.

I get a message that the link is succesful in the google home app but after a few seconds it says
"An error occurred, please try again"

Why is this?
Did you do this:
Navigate back to the Actions on Google Console.

On the left navigation menu under BUILD, click on Actions. Click on Add Your First Action and choose your app's language(s). Enter the URL for fulfillment, e.g. https://[YOUR REVERSE PROXY URL]/smarthome, click Done.
Raspberry Pi 3 | domoticz | Aeon Labs Z-Stick GEN5 | RFlink gateway
NanoPi NEO-air | REGO6XX interface | Machinon theme | Homebridge | Domoticz Google Assistant | ideAlarm
pvm
Posts: 550
Joined: Tuesday 17 June 2014 22:14
Target OS: NAS (Synology & others)
Domoticz version: 4.10538
Location: NL
Contact:

Re: Domoticz to Google Assistan integration

Post by pvm »

Would it be possible to run this using the mydomoticz service? (I might be asking something stupid here, reason for asking is not having complexity in safely opening system to the dangerous 'outside' world)
Synology NAS, slave PI3, ZWave (Fibaro), Xiaomi zigbee devices, BTLE plant sensor, DzVents, Dashticz on tablet, Logitech Media Server
User avatar
DewGew
Posts: 579
Joined: Thursday 21 April 2016 12:01
Target OS: Raspberry Pi / ODroid
Domoticz version: V4.10618
Location: Sweden
Contact:

Re: Domoticz to Google Assistan integration

Post by DewGew »

pvm wrote: Tuesday 09 April 2019 1:31 Would it be possible to run this using the mydomoticz service? (I might be asking something stupid here, reason for asking is not having complexity in safely opening system to the dangerous 'outside' world)
Its possible if the developer for mydomoticz service wants that. Its more like Controlicz then.
This python code creates your own google assistant service. With this you only open a port to aog server not to domoticz. and I use a reverse proxy on my synology.
internet <--> router <--> synology <--> reverse proxy <--> aog server <--> domoticz
Raspberry Pi 3 | domoticz | Aeon Labs Z-Stick GEN5 | RFlink gateway
NanoPi NEO-air | REGO6XX interface | Machinon theme | Homebridge | Domoticz Google Assistant | ideAlarm
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest