Re: Domoticz to Google Assistant integration
Posted: Tuesday 07 January 2020 22:36
Thanks man!
That was quick.
1.4.10 is working fine.
That was quick.
1.4.10 is working fine.
Open source Home Automation System
https://forum.domoticz.com/
I did enable the HomeGraph API: I followed your wiki, encountered the error and found a reference to the HomeGraph API. Removed everything and started all over. I didn't see other API keys, so I assume just enabling this should be ok.DewGew wrote: ↑Tuesday 17 December 2019 10:10Maybe you missed to enable the Homegraph APIrvanderven wrote: ↑Monday 16 December 2019 19:34 Does anyone have a complete uptodate description of the creation of the Google Action credentials and API keys?
To me it looks like things on the Google site have changed since the description is created.
Eg. When enabling HomeGraph for my project I could't create an API key via the credentials, only by going back to https://console.cloud.google.com/apis/c ... roject=<My project>
When clicking Test and entering a phrase I received the message that it was not possible to use this in the webbrowser.
After entering all details in config.yaml I started dzga service and after login with the /settings url I was able to login.
Clicking on the Sync devices resulted in the message: "Homegraph API key not valid!"
The dzga.log mentions error 404
2019-12-16 19:10:00 - ERROR - {
"error": {
"code": 404,
"message": "Requested entity was not found.",
"status": "NOT_FOUND"
}
I tried all kinds of things, but I am completely stuck.
I have setup my own domain and installed a reverse proxy on my synology encrypted with Letsencrypt.
I can reach the dzga installation from outside and am able to login.
Edit: I updated wiki
lzwfkv wrote: ↑Sunday 12 January 2020 12:53 Hello DewGew, i think i have found a bug in the update switch (OnOff trait devices) status, in that whenever the status of a switch/light/etc. is changed either through google assistant voice command or in Domoticz itself, the updated status is not passed correctly to Google Assistant by DZGA.
In particular, upon investigation i think i have identified the issue in the fact that DZGA does not synch the devices status with Domoticz and keep storing the initial status of the switches that it got from Domoticz upon the latest Sync, therefore DZGA send stale status to Google Assistant after a query from the latter.
The simplest and quickest way, though probably a dirty one, that i have found to fix the issue is to force an update of the Queried device from Domoticz to DZGA whenever a query for device's attributes is submitted to DZGA (Smarthome) by adding the following code line (in bold) in smarthome.py:
def smarthome_query(self, payload, token):
"""Handle action.devices.QUERY request.
https://developers.google.com/actions/s ... vicesquery
"""
devices = {}
for device in payload.get('devices', []):
devid = device['id']
_GoogleEntity(aogDevs.get(devid, None)).async_update()
state = aogDevs.get(devid, None)
if not state:
# If we can't find a state, the device is offline
devices[devid] = {'online': False}
continue
e = _GoogleEntity(state)
devices[devid] = e.query_serialize()
return {'devices': devices}
After some tests the above change seems to work and to fix both the cases described above where i have been able to observe the issue raising.
Thank you for reporting this. I had similar issue also before on some devices. I look into thisfrankdep wrote: ↑Sunday 12 January 2020 17:41 Related to the above. I had some issues because GA had a wrong status. I tried to open my garage but GA was telling me that it was already open
This issue is not improving with the Report_state feature. So I'm triggering a manual "http://localhost:port/sync" on an important device change or time change event in Domoticz. Had to bypass the userinfo and useragent check in syncDevices and forceDevicesSync routines in smarthome.py.
The status is updating instantly in GA.
I think it is an interesting feature to trigger updates from Domoticz.
There is no touch control for selectors in google home app. Only by voice. Just say "Turn on Normaal on Verwarming".
Dzga fetches language from domoticz. Turn on debug log. There you can see if your dzga get the settings from domoticz correct.EddyG wrote: ↑Monday 13 January 2020 17:16 I tried that but did not work. I suppose that the problem lies in the language.
If I try it in English, Google does not understand. If I try in Dutch then Google sums up all kind of Firms with Verwarming.
I keep on trying with other names for the Domoticz device.
Problem seems to be report_state:
Code: Select all
400 Client Error: Bad Request for url: https://homegraph.googleapis.com/v1/dev ... tification
Code: Select all
<voicecontrol>
report_state = False
</voicecontrol>
I guess you already figured this outddtpv wrote: ↑Saturday 25 January 2020 8:42 Hi all!
Though kill, I can’t understand what’s going wrong.
Copy - paste everything correctly. But Google Home is still a error
client_id xxxxxxxx.apps.googlecontent.com invalid
https://6522467d.ngrok.io/smarthome - not supported
https://6522467d.ngrok.io/oauth - response_type must equal "code"
http://6522467d.ngrok.io/token - Page not found!: '/token'
localhost:3030 has no errors in logfile
Code: Select all
bash <(curl -s https://raw.githubusercontent.com/DewGew/dzga-installer/master/install.sh)
Code: Select all
!-----------------------------------!
Domoticz-Google-Assistant already installed.
Check for update...
Geraakt:1 http://archive.raspberrypi.org/debian buster InRelease
Geraakt:2 http://raspbian.raspberrypi.org/raspbian buster InRelease
Pakketlijsten worden ingelezen... Klaar
Pakketlijsten worden ingelezen... Klaar
Boom van vereisten wordt opgebouwd
De statusinformatie wordt gelezen... Klaar
libffi-dev is reeds de nieuwste versie (3.2.1-9).
libssl-dev is reeds de nieuwste versie (1.1.1d-0+deb10u2).
python3 is reeds de nieuwste versie (3.7.3-1).
python3-dev is reeds de nieuwste versie (3.7.3-1).
python3-venv is reeds de nieuwste versie (3.7.3-1).
python3-pip is reeds de nieuwste versie (18.1-5+rpt1).
De volgende pakketten zijn automatisch geïnstalleerd en zijn niet langer nodig:
bluealsa distro-info-data docutils-common fonts-piboto gir1.2-atk-1.0 gir1.2-freedesktop gir1.2-gdkpixbuf-2.0 gir1.2-gmenu-3.0
gir1.2-gtk-3.0 gir1.2-pango-1.0 gnome-themes-standard gtk2-engines-clearlookspix gtk2-engines-pixflat libbluetooth3
libgnome-menu-3-0 libimagequant0 librtimulib-dev librtimulib-utils librtimulib7 lxde-common lxplug-bluetooth lxplug-cputemp
lxplug-ejecter lxplug-network lxplug-ptbatt lxplug-volume lxsession-logout pi-greeter pishutdown pixflat-icons python-apt-common
python-olefile python-pil python-rtimulib python-sense-hat rpd-plym-splash rpd-wallpaper sgml-base xml-core xsel
Gebruik 'sudo apt autoremove' om ze te verwijderen.
0 opgewaardeerd, 0 nieuw geïnstalleerd, 0 te verwijderen en 26 niet opgewaardeerd.
Check github for update...
HEAD is now at 46f3a90 [skip travis]
Already up to date.
/dev/fd/63: regel 78: Domoticz-Google-Assistant/env/bin/activate: Bestand of map bestaat niet
Installing python packages...
Defaulting to user installation because normal site-packages is not writeable
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: certifi>=2019.9.11 in ./.local/lib/python3.7/site-packages (from -r Domoticz-Google-Assistant/requirements/pip-requirements.txt (line 1)) (2019.11.28)
Requirement already satisfied: chardet>=3.0.4 in ./.local/lib/python3.7/site-packages (from -r Domoticz-Google-Assistant/requirements/pip-requirements.txt (line 2)) (3.0.4)
Requirement already satisfied: future>=0.18.2 in ./.local/lib/python3.7/site-packages (from -r Domoticz-Google-Assistant/requirements/pip-requirements.txt (line 3)) (0.18.2)
Requirement already satisfied: idna>=2.8 in ./.local/lib/python3.7/site-packages (from -r Domoticz-Google-Assistant/requirements/pip-requirements.txt (line 4)) (2.8)
Requirement already satisfied: PyYAML>=5.1.2 in ./.local/lib/python3.7/site-packages (from -r Domoticz-Google-Assistant/requirements/pip-requirements.txt (line 5)) (5.2)
Requirement already satisfied: requests>=2.22.0 in ./.local/lib/python3.7/site-packages (from -r Domoticz-Google-Assistant/requirements/pip-requirements.txt (line 6)) (2.22.0)
Requirement already satisfied: urllib3>=1.25.7 in ./.local/lib/python3.7/site-packages (from -r Domoticz-Google-Assistant/requirements/pip-requirements.txt (line 7)) (1.25.8)
Requirement already satisfied: GitPython>=3.0.5 in ./.local/lib/python3.7/site-packages (from -r Domoticz-Google-Assistant/requirements/pip-requirements.txt (line 8)) (3.0.5)
Requirement already satisfied: google-auth>=1.8.1 in ./.local/lib/python3.7/site-packages (from -r Domoticz-Google-Assistant/requirements/pip-requirements.txt (line 9)) (1.11.0)
Requirement already satisfied: gitdb2>=2.0.0 in ./.local/lib/python3.7/site-packages (from GitPython>=3.0.5->-r Domoticz-Google-Assistant/requirements/pip-requirements.txt (line 8)) (2.0.6)
Requirement already satisfied: setuptools>=40.3.0 in /usr/lib/python3/dist-packages (from google-auth>=1.8.1->-r Domoticz-Google-Assistant/requirements/pip-requirements.txt (line 9)) (40.8.0)
Requirement already satisfied: rsa<4.1,>=3.1.4 in ./.local/lib/python3.7/site-packages (from google-auth>=1.8.1->-r Domoticz-Google-Assistant/requirements/pip-requirements.txt (line 9)) (4.0)
Requirement already satisfied: cachetools<5.0,>=2.0.0 in ./.local/lib/python3.7/site-packages (from google-auth>=1.8.1->-r Domoticz-Google-Assistant/requirements/pip-requirements.txt (line 9)) (4.0.0)
Requirement already satisfied: six>=1.9.0 in /usr/lib/python3/dist-packages (from google-auth>=1.8.1->-r Domoticz-Google-Assistant/requirements/pip-requirements.txt (line 9)) (1.12.0)
Requirement already satisfied: pyasn1-modules>=0.2.1 in ./.local/lib/python3.7/site-packages (from google-auth>=1.8.1->-r Domoticz-Google-Assistant/requirements/pip-requirements.txt (line 9)) (0.2.8)
Requirement already satisfied: smmap2>=2.0.0 in ./.local/lib/python3.7/site-packages (from gitdb2>=2.0.0->GitPython>=3.0.5->-r Domoticz-Google-Assistant/requirements/pip-requirements.txt (line 8)) (2.0.5)
Requirement already satisfied: pyasn1>=0.1.3 in ./.local/lib/python3.7/site-packages (from rsa<4.1,>=3.1.4->google-auth>=1.8.1->-r Domoticz-Google-Assistant/requirements/pip-requirements.txt (line 9)) (0.4.8)
Login to Domoticz Google Assistant Server UI at: http://ip.address:3030/settings
Default username is admin and default password is admin
or
Goto Domoticz-Google-Assistant folder and Edit config.yaml and then
restart dzga.server e.g 'sudo systemctl restart dzga'
Code: Select all
sudo systemctl status dzga
● dzga.service - Domoticz-Google-Assistant Service
Loaded: loaded (/etc/systemd/system/dzga.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2020-01-29 22:21:43 CET; 38s ago
Process: 9234 ExecStart=/home/pi/Domoticz-Google-Assistant/env/bin/python3 /home/pi/Domoticz-Google-Assistant/ (code=exited, status=
Main PID: 9234 (code=exited, status=203/EXEC)
jan 29 22:21:43 raspberrypi systemd[1]: dzga.service: Service RestartSec=100ms expired, scheduling restart.
jan 29 22:21:43 raspberrypi systemd[1]: dzga.service: Scheduled restart job, restart counter is at 5.
jan 29 22:21:43 raspberrypi systemd[1]: Stopped Domoticz-Google-Assistant Service.
jan 29 22:21:43 raspberrypi systemd[1]: dzga.service: Start request repeated too quickly.
jan 29 22:21:43 raspberrypi systemd[1]: dzga.service: Failed with result 'exit-code'.
jan 29 22:21:43 raspberrypi systemd[1]: Failed to start Domoticz-Google-Assistant Service.
I changed the bash script and now I revert it. Back up your config.yaml and smart-home-key.json then delete Domoticz-Google-Assistant folder.
Its not depending on the sdk library. Its python 3.7 in buster that might be an issue.pvklink wrote: ↑Thursday 30 January 2020 13:06 Does this Google assistant integration works on raspbian buster on a rpi 4?
If you used The google sdk library for your integration, this not supported anymore on buster and rpi 4.
Only the sdk service version is supported, and lacks lots off options that the old sdk-lib had...