Drakulix / googlehome

Google Home Integration for Home-Assistant
Apache License 2.0
29 stars 3 forks source link

ADB configuration #1

Closed Leatherface75 closed 4 years ago

Leatherface75 commented 5 years ago

Seems it doesn't accept adb configuration for me.

Invalid config for [googlehome]: [adb_host] is an invalid option for [googlehome]. Check: googlehome->googlehome->adb_host. (See /config/configuration.yaml, line 1073). Please check the docs at https://home-assistant.io/components/googlehome/

In configuration.yaml

  adb_host: 127.0.0.1
  adb_port: 5037
  adb_device: 192.168.0.80:5555

adb server bridge installed in hassio.

Drakulix commented 5 years ago

This should work, I am a little bit confused to why it does not. But you may ignore the adb_host and adb_port config in your case because those are the defaults.

Drakulix commented 5 years ago

Can you post your complete googlehome: config?

Leatherface75 commented 5 years ago

I am also confused because i can see those options in init.py file.

Already removed the configuration but it was something like this. The only difference is those 3 added adb lines and IP to real googlehome instead of my ghproxys.

googlehome:
  adb_host: 127.0.0.1
  adb_port: 5037
  adb_device: 192.168.0.80:5555
  devices:
  - host: 192.168.0.15
    track_alarms: true
    rssi_threshold: -65
  - host: 192.168.0.30
    track_alarms: true
    rssi_threshold: -65
  - host: 192.168.0.70
    track_alarms: true
    rssi_threshold: -65

Maybe works better after some coffee.

Leatherface75 commented 5 years ago

Seems it was same problem i had with google_calendar after an update to newer HA version. Had to remove configuration and restart HA then put exactly same thing back and voila no error anymore. But all devices is away so something is wrong anyway hmms.

Logfile says a lot of this

2019-09-06 12:02:23 ERROR (MainThread) [homeassistant.components.device_tracker] The see service is not supported for this entity device_tracker.mi_phone

Can't see anything about googlehome integration there and seems to start so nothing wrong there. Maybe that ADB server bridge for Hassio is not connecting as root?

Leatherface75 commented 5 years ago

Hmm seems to have downloaded home_graph file to config dir so that part seems to work atleast.

Drakulix commented 5 years ago

The root elevation should be done on the device via the shell commandos, that I am sending. That it is able to pull the home_graph file is proof of that.

Leatherface75 commented 5 years ago

Yeah seems to be something else hmms

Drakulix commented 5 years ago

Yeah seems to be something else hmms

Can you try the alarm/timer sensor and check if they display the correct values? I am not using the bluetooth-devicetracker on my device, so maybe that is just borked?

If that is the case, I can investigate and try to reproduce this in the next days.

Leatherface75 commented 5 years ago

I can try alarm/timer but if that works then device_tracker should work it's same token and works with that ghproxy and old official googlehome component.

Leatherface75 commented 5 years ago

No same problem there just says "Invalid date".

Leatherface75 commented 5 years ago

Tried to add this but seems it doesn't help either

print(self.device.shell(["input", "keyevent", "4"]))

Maybe this is wrong it doesn't do what this does on another linuxmachine

adb shell input keyevent 4

Also tried my update commands from my crontab on my other linuxmachine and seems to not change anything so the problem is maybe not the home_graph file.

Leatherface75 commented 5 years ago

Can it be same problem that i have with decodeProtoFile.js in that other solution? I had to change this in that file

var token = getObjByKey(val2['7'], '28')['28']; to var token = getObjByKey(val2['7'], '28');

Otherwise it could not decode the file and gave me this

/tmp/decodeProtoFile.js:24
var token = getObjByKey(val2['7'], '28')['28'];
^

TypeError: Cannot read property '28' of undefined
at /tmp/decodeProtoFile.js:24:57
at Array.forEach ()
at /tmp/decodeProtoFile.js:21:18
at Array.forEach ()
at Object. (/tmp/decodeProtoFile.js:19:6)
at Module._compile (internal/modules/cjs/loader.js:774:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:785:10)
at Module.load (internal/modules/cjs/loader.js:641:32)
at Function.Module._load (internal/modules/cjs/loader.js:556:12)
at Function.Module.runMain (internal/modules/cjs/loader.js:837:10)

I think it's same problem here. The problem is that home_graph file have lamps and other things with other values than 28 so it must have a check for that.

Leatherface75 commented 5 years ago

Tried this in decode.py but seems not working either

                            if isinstance(val2['7'], '28'):
                              token = _get_obj_by_key(val2['7'], '28')['28']
                              tokens[device] = token
Drakulix commented 5 years ago

Tried this in decode.py but seems not working either

                            if isinstance(val2['7'], '28'):
                              token = _get_obj_by_key(val2['7'], '28')['28']
                              tokens[device] = token

It seems your proto file is encoded differently, which is very interesting. I would like to support that as well.

Could you run python3 ./decode.py home_graph.proto > decoded.proto, remove all sensible data (just replace the strings with something like ) and upload that file, so I could take a look at the structure of your file?

Drakulix commented 5 years ago

I can try alarm/timer but if that works then device_tracker should work it's same token and works with that ghproxy and old official googlehome component.

Yeah but the thing is, that I had to adjust the code making the requests to include the new token. Maybe I messed up that part specifically for the bluetooth api. But if the timer/alarm does not work as well, this does not seem to be the case.

I think the decoding is the culprit here. Otherwise the extension seems to work for you, because it is grabbing the file and trying to do requests (just failing because of a wrong token).

adb shell input keyevent 4

How does this help refreshing the file? 4 should be the back button, is this not quitting the app? What is your order of commands? Is it:

  1. kill
  2. input
  3. monkey
Leatherface75 commented 5 years ago

Well in my case it works because that refreshes my home_graph file on virtual machine.

  1. kill
  2. monkey
  3. input

Just killing the app after monkey doesn't work so it's not same behaviour.

Leatherface75 commented 5 years ago

It can't decode anything at all just shows {}

And this is both without changes and with my changes. And just to check if it was Hassio i checked on my linuxmachine there i have that javascript and crontab with proxy i got same thing there.

Leatherface75 commented 5 years ago

If if change this line

#print("Read:", d[id]) to print("Read:", d[str(id)]) It shows everything so no problem with decoding. Just removing # gave me error and had to add str.

Leatherface75 commented 5 years ago

Have you checked anything with that file?

Drakulix commented 5 years ago

Have you checked anything with that file?

Sorry, had a busy weekend.

So the file does decode correctly.

/tmp/decodeProtoFile.js:24
var token = getObjByKey(val2['7'], '28')['28'];
^

TypeError: Cannot read property '28' of undefined
at /tmp/decodeProtoFile.js:24:57
at Array.forEach ()
at /tmp/decodeProtoFile.js:21:18
at Array.forEach ()
at Object. (/tmp/decodeProtoFile.js:19:6)
at Module._compile (internal/modules/cjs/loader.js:774:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:785:10)
at Module.load (internal/modules/cjs/loader.js:641:32)
at Function.Module._load (internal/modules/cjs/loader.js:556:12)
at Function.Module.runMain (internal/modules/cjs/loader.js:837:10)

This problem arises, because you have a device with an entry '7' and '18', but not '28'. The js-file fails in that case. I had the same problem, reported it in the original issue and also fixed it in my fork.

My python script does also skip unsupported devices (Sonos speakers in my case). So this is not what's causing your issues. This part of the script works fine for your home-minis.

Leatherface75 commented 5 years ago

I fixed it myself too and that solution with your ghproxy and orginal googlehome integration works perfectly for me. Yeah as i said i checked with your commented print commands and it outputs data there so the problem seems to be with parsing data when you have a lot of other stuff too.

Drakulix commented 5 years ago

I fixed it myself too and that solution with your ghproxy and orginal googlehome integration works perfectly for me. Yeah as i said i checked with your commented print commands and it outputs data there so the problem seems to be with parsing data when you have a lot of other stuff too.

My file is not much shorter. You could add a print here to see, if tokens contains the correctly filtered data.

Leatherface75 commented 5 years ago

I can check later but for me the problems seems to be in decode.py. It shows everything with uncommented print i mention above in that file. But it doesn't filter anything out of what it shows. Without that print command again as normal nothing shows.

Leatherface75 commented 5 years ago

Have you been looking anything more on my home_graph file? And forgot to tell you i tested a print there you said and it's same it just shows {}

Drakulix commented 5 years ago

Have you been looking anything more on my home_graph file? And forgot to tell you i tested a print there you said and it's same it just shows {}

The problem is, that I cannot pipe your decoded and filtered file into my parser. But you should not upload your raw-proto file, because of sensitive data. If you print the 'proto' variable instead of the 'tokens' variable, I can see, what my parser produces. Can you wipe infos from that file and upload that result instead maybe?

Sorry that this is a little verbose.

Leatherface75 commented 5 years ago

I can see what i can do. I removed some things but rest was a few tokens i for googlehome that doesn't matter when it changed again a few hours later. When i tried with print there you said it doesn't show anything. I will try change variable and see.

Drakulix commented 4 years ago

This should finally be fixed by 8fd9b2a415a515db4b351e433db95344dabedd6b. (My proto file started to break for the same reasons, so I finally had the ability to debug this.)

Leatherface75 commented 4 years ago

Ok i'll try and see if it works better now.