gytisgreitai / openhab-google-home

13 stars 1 forks source link

Will not link to google home app #3

Closed djmillsuk closed 5 years ago

djmillsuk commented 5 years ago

Firstly i want to thank you for starting this project asim so sick of the errors on the official myopenhab method when switching on a light.

I have been at this now for over 2 days, i have followed the guide exactly and everything works as expected (not cert errors, site says 'OK' when visiting) all good.

When i go to add the account from the google home app and press it, it says 'logging in' and then 'adding' and then nothing, its not added no errors.

I'm on openhab 2.4.

I have 1 item set up as follows Switch Light_GF_Office_Test "Test Light" (GF_Office, GF_Lights, Lights) {channel="mqtt:topic:6a326ec3:esp_32_Thing:PowerSwitch",google="action.devices.types.SWITCH"}

if theres anything you can do to help it would be greatly appreciated.

Thanks,

gytisgreitai commented 5 years ago

Well your item looks good. Can you post the contents of /var/log/app.log on the docker ? (just redact the IP and auth info for security purposes), e.g.: sudo docker cp <containerId>:/var/log/app.log app.log You can get the container id by doing docker ps.

I probably need to make this debugging easier

gytisgreitai commented 5 years ago

So I've pushed new version of docker image which has an endpoint /am-i-working with debug info.

This endpoint is protected by username (value of STANDALONE_CLIENT_ID) and password (value of STANDALONE_CLIENT_SECRET) which should output some debug info together with the contents of /var/log/app.log.

So if you could update to the lasted docker, try linking it with google home, and then go to https://yourdomain/am-i-working and paste the contents to http://pastebin.com and add a link here, it would be great. Just please redact the private info (like basic auth headers, and IP addresses)

djmillsuk commented 5 years ago

hey, thanks for your help, i stopped the docker container and started a new but the am-i-working url states 'Not Found' and the log states the same

<redacted>@<redacted>:~$ sudo docker cp <redacted>:/var/log/app.log app.log
<redacted>@<redacted>:~$ more app.log
OpenHAB Google Home Integration listening on 3000
route not found /am-i-working /am-i-working
route not found /favicon.ico /favicon.ico

by the way im using the standard first lets encrypt option and the secret and client id are from the openhabcloud connector which i think is correct

sudo docker run \ -v /home/<redacted>/certs:/etc/letsencrypt \ -e DOMAIN=<redacted> \ -e EMAIL=<redacted>@<redacted>.com \ -e STANDALONE=true \ -e STANDALONE_CLIENT_ID=<redacted> \ -e STANDALONE_CLIENT_SECRET=<redacted> \ -e OPENHAB_URL=http://<redacted>:8080 \ -p 80:80 -p 443:443 \ -d gytisgreitai/openhab-ga-unofficial-demo:latest

gytisgreitai commented 5 years ago

since we are using the latest tag you need to repull the docker by removing the image, eg:

sudo docker kill <pid>
sudo docker rm <pid>
sudo docker rmi gytisgreitai/openhab-ga-unofficial-demo
djmillsuk commented 5 years ago

yes you are correct my bad, thanks i found that just before you sent that message haha. sorry im new to docker :D.

here we go the problem becomes apparent so i need to use client id and secret from the google auth and NOT cloud connector for the docker container?

`

Openhab accessible:

Total items returned from openhab 53

Openhab google items:

[ { "id": "Lamp", "type": "action.devices.types.SWITCH", "traits": [ "action.devices.traits.OnOff" ], "name": { "defaultNames": [ "Main Lamp" ], "name": "Main Lamp", "nicknames": [ "Main Lamp" ] }, "willReportState": false, "customData": { "itemType": "Switch" }, "attributes": {} }, { "id": "Light_GF_Office_Test", "type": "action.devices.types.SWITCH", "traits": [ "action.devices.traits.OnOff" ], "name": { "defaultNames": [ "Test Light" ], "name": "Test Light", "nicknames": [ "Test Light" ] }, "willReportState": false, "customData": { "itemType": "Switch" }, "attributes": {} } ]

Log file:

OpenHAB Google Home Integration listening on 3000 clientId or clientSecret missmatched returning 403 { clientId: '', clientSecret: '' } .apps.googleusercontent.com `

djmillsuk commented 5 years ago

ok, so i did change it to the google client and secret and now the error is gone, but its still not linking and now no errors at all.

`

Openhab accessible:

Total items returned from openhab 53

Openhab google items:

[ { "id": "Lamp", "type": "action.devices.types.SWITCH", "traits": [ "action.devices.traits.OnOff" ], "name": { "defaultNames": [ "Main Lamp" ], "name": "Main Lamp", "nicknames": [ "Main Lamp" ] }, "willReportState": false, "customData": { "itemType": "Switch" }, "attributes": {} }, { "id": "Light_GF_Office_Test", "type": "action.devices.types.SWITCH", "traits": [ "action.devices.traits.OnOff" ], "name": { "defaultNames": [ "Test Light" ], "name": "Test Light", "nicknames": [ "Test Light" ] }, "willReportState": false, "customData": { "itemType": "Switch" }, "attributes": {} } ]

Log file:

OpenHAB Google Home Integration listening on 3000`

gytisgreitai commented 5 years ago

Ok, so the devices response look good. Have you tried linking in google home app? it's strange that you don't have anything in the logs? Can you paste docker logs ? docker logs <containerId>

How are you runing the command? E.g. if my command would be :

sudo docker run \
      -v /home/djmillsuk/certs:/etc/letsencrypt \
      -e DOMAIN=example1.org \
      -e EMAIL=youremail-for-letsencrypt@example.org \
      -e STANDALONE=true \
      -e STANDALONE_CLIENT_ID=djmillsuk  \
      -e STANDALONE_CLIENT_SECRET=djmillsuk123 \
      -e OPENHAB_URL=http://localhost:8080 \
      -p 80:80 -p 443:443 \
      -d gytisgreitai/openhab-ga-unofficial-demo:latest

Then auth configuration on google Account Linking would look like this:

Screenshot 2019-11-02 at 14 50 34
djmillsuk commented 5 years ago

yes i have tried it, that is exactly how mine looks (with the exception of differing values for id and secret of course), ill try a smaller id, im using a google generated one and its very long.

UPDATE, didnt make any difference, it just does nothing when i try to add it to google home, just goes back to the accounts page, not added, no errors. Damn i really want this to work!

gytisgreitai commented 5 years ago

Try relinking your google home app couple of times, and post the output of docker <containerId> logs it's strange that the log is empty

djmillsuk commented 5 years ago

ok, i tried a few more times, i also reset my google home app just in case but nothing,

the log is still empty.

here is the docker log...

no certs found, creating temporary ones
Generating RSA private key, 4096 bit long modulus (2 primes)
........++++
......................................................................................................................................................................++++
e is 65537 (0x010001)
Generating RSA private key, 4096 bit long modulus (2 primes)
...........................................................................................++++
............................................................................................................................................................................................................................................................................................++++
e is 65537 (0x010001)
req: Skipping unknown attribute "EMAIL"
Signature ok
subject=C = PT, ST = World, L = World, O = <redacted>, OU = Fiercely lda, CN = <redacted>
Getting Private key
Setting up watches.
Watches established.
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator webroot, Installer None
Cert not yet due for renewal
Keeping the existing certificate
Setting up watches.
Watches established.
gytisgreitai commented 5 years ago

Well it looks like the endpoints are not being hit at all. Can you check if it's accessible externally? e.g. with https://www.uptrends.com/tools/uptime try entering https://your-domain/standalone-auth/token and https://your-domain/ first should fail with 403 while the later should succeed

Also the contents of /var/log/nginx/access.log and /var/log/nginx/error.log migh help

djmillsuk commented 5 years ago

ok, the token url did get 403 and the base url did get OK so thats all good. both of those nginx files are completely empty.

djmillsuk commented 5 years ago

is the /standalone-auth/authorize url supposed to say 'Not Found'?

gytisgreitai commented 5 years ago

hm I have no idea, something is off with the config on google project I guess because it does not seem to be hitting any endpoints at all. Is it all ok in the setup, e.g. something like this?

image

Have you invoked ./gactions test --action_package action.json --project project-id ?

And the logging is a mess in the docker, I should fix that.

djmillsuk commented 5 years ago

where do i put that command sorry? ./gactions test --action_package action.json --project project-id

heres my setup

ss1 ss2 ss3

djmillsuk commented 5 years ago

oh here we go...

./gactions test --action_package action.json --project openhab-<redacted>
Pushing the app for the Assistant for testing...
Your app for the Assistant for project openhab-<redacted> is now ready for testing on Actions on Google enabled devices or the Actions Web Simulator at https://console.actions.google.com/project/openhab-<redacted>/simulator/

its still not working however.

djmillsuk commented 5 years ago

okayyyy, well, i dont know what happened but its now just linked after 3 days of screwing around, did you do something?

gytisgreitai commented 5 years ago

Did you follow the steps in Deploy your actions project ? This is where gactions command comes from. Cause if not, and you only executed the gactions command now, it would explain why it started working.

djmillsuk commented 5 years ago

i did but i guess i must have screwed it up, i cant apologise enough, please close this. i appreciate all your time and help.

gytisgreitai commented 5 years ago

no problem, you pointed out where this should be improved :)

gytisgreitai commented 5 years ago

btw, did you experience issues with official binding (like sorry unable to reach or something went wrong?) if so, it would be interesting to hear if these are gone if you are using this implementation.

djmillsuk commented 5 years ago

Yes that's correct. That's why I tried this. It fixed the issue. So thank you. I am so grateful!