i8beef / HomeAutio.Mqtt.GoogleHome

MIT License
215 stars 29 forks source link

Raspberry Pi docker image failed to build #23

Closed diabl0w closed 5 years ago

diabl0w commented 5 years ago

https://hub.docker.com/r/i8beef/homeautio.mqtt.googlehome/builds/bqxcn5bnjcvoeltxupw4nwp/

i8beef commented 5 years ago

It no longer builds in Docker Hub, it builds on Docker Cloud. That was about the time I switched it over and isn't even the latest version up there (1.0.0.61). Unfortunately I don't really see a way to clear out the build history from Docker Hub without deleting and recreating the repository.

Rest assured, the builds are fine and up to date. Just look at the tags.

diabl0w commented 5 years ago

sorry for the newbie question then but how do I pull from the cloud instead of hub when issuing "docker run --restart=always --name homeautio.mqtt.googlehome"

i8beef commented 5 years ago

You don't. Docker Cloud is just providing build services. Its still distributed on Docker Hub. If you click on "tags" on Docker Hub you'll see the other versions, and "latest" and "latest-arm32" will always pull the latest of each of those platforms.

Those are just the "builds", not the released packages (which "tags" shows better).

diabl0w commented 5 years ago

in the link I posted, you can see the build error "91mstandard_init_linux.go:190: exec user process caused "exec format error""

I'm getting the same error running on pie so I would guess it's pulling from the same source

i8beef commented 5 years ago

Pi or Pi Zero? You can't run this on a Pi zero.

diabl0w commented 5 years ago

haha no, it's regular Pi

On Thu, Oct 18, 2018, 9:29 PM Michael Hallock notifications@github.com wrote:

Pi or Pi Zero? You can't run this on a Pi zero.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/i8beef/HomeAutio.Mqtt.GoogleHome/issues/23#issuecomment-431215890, or mute the thread https://github.com/notifications/unsubscribe-auth/APYcMqK1p0CKgwG6g_FTvOdmbPRt-vw_ks5umSsLgaJpZM4XvdI7 .

diabl0w commented 5 years ago

docker logs homeautio.mqtt.googlehome outputs: standard_init_linux.go:190: exec user process caused "exec format error"

running on rasoberry pi using the same docker command in the wiki. from my experience "exec format error" occurs when trying to run something like x86 binaries on arm32 pi

i8beef commented 5 years ago

And you're using the "latest-arm32" tag?

diabl0w commented 5 years ago

i am not sure how to tell that, I just run the docker command from the wiki except i modify the volume location

On Thu, Oct 18, 2018, 9:47 PM Michael Hallock notifications@github.com wrote:

And you're using the "latest-arm32" tag?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/i8beef/HomeAutio.Mqtt.GoogleHome/issues/23#issuecomment-431218672, or mute the thread https://github.com/notifications/unsubscribe-auth/APYcMv7RNjIqNu8ekYr3M2oHNXlqbmUDks5umS8qgaJpZM4XvdI7 .

i8beef commented 5 years ago

Ah, see the part on the end of that command: i8beef/homeautio.mqtt.googlehome:latest? Change that to i8beef/homeautio.mqtt.googlehome:latest-arm32

diabl0w commented 5 years ago

I just saw that right before you replied... downloading now. Thank you for bearing with me. I will update you in a few minutes

On Thu, Oct 18, 2018, 9:56 PM Michael Hallock notifications@github.com wrote:

Ah, see the part on the end of that command: i8beef/homeautio.mqtt.googlehome:latest? Change that to i8beef/homeautio.mqtt.googlehome:latest-arm32

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/i8beef/HomeAutio.Mqtt.GoogleHome/issues/23#issuecomment-431220094, or mute the thread https://github.com/notifications/unsubscribe-auth/APYcMpSYb7bUG77vM41dlluR5VsYwFm8ks5umTFGgaJpZM4XvdI7 .

i8beef commented 5 years ago

LOL no problem, Docker commands sometimes feel like voodoo.

diabl0w commented 5 years ago

yes, this is the first time I'm using docker. it's definitely a different environment than I'm used to. seems to be working now, just having issues connecting to the mqtt broker but I'll figure that out. thanks again

On Thu, Oct 18, 2018, 10:01 PM Michael Hallock notifications@github.com wrote:

LOL no problem, Docker commands sometimes feel like voodoo.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/i8beef/HomeAutio.Mqtt.GoogleHome/issues/23#issuecomment-431220830, or mute the thread https://github.com/notifications/unsubscribe-auth/APYcMjUO_6zw7TnpdNrgyMdRijl4VPcxks5umTJrgaJpZM4XvdI7 .

diabl0w commented 5 years ago

I am stuck at one last part... I am able to successfully login under the google assistant app, accept permissions for the scopes, and then it says "linking your [test] account", but then after that it says "couldn't update your setting, check the connection" and then under docker logs it says :

" Request starting HTTP/1.1 POST http://192.168.111.101:5000/google/home/smarthome application json;charset=UTF-8 80 [11:58:02 INF] Route matched with {action = "Post", controller = "GoogleHome"}. Executing action HomeAutio. qtt.GoogleHome.Controllers.GoogleHomeController.Post (HomeAutio.Mqtt.GoogleHome) [11:58:25 INF] Removing expired grants [11:59:02 ERR] Exception occurred while processing message. System.InvalidOperationException: IDX20803: Unable to obtain configuration from: 'https://MY-DYN-DNS.URL/g ogle/home/.well-known/openid-configuration'. ---> System.IO.IOException: IDX20804: Unable to retrieve docum nt from: ' https://MY-DYN-DNS.URL/google/home/.well-known/openid-configuration'. ---> System.OperationCance edException: The operation was canceled."

In my appsettings.Production.json I have:

""authority": "https://MY-DYN-DNS.URL/google/home", "publicOrigin": "https://MY-DYN-DNS.URL",

Replacing my-dyn-dns with my actual public url

On Thu, Oct 18, 2018, 10:23 PM Brian L b.lee2394@gmail.com wrote:

yes, this is the first time I'm using docker. it's definitely a different environment than I'm used to. seems to be working now, just having issues connecting to the mqtt broker but I'll figure that out. thanks again

On Thu, Oct 18, 2018, 10:01 PM Michael Hallock notifications@github.com wrote:

LOL no problem, Docker commands sometimes feel like voodoo.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/i8beef/HomeAutio.Mqtt.GoogleHome/issues/23#issuecomment-431220830, or mute the thread https://github.com/notifications/unsubscribe-auth/APYcMjUO_6zw7TnpdNrgyMdRijl4VPcxks5umTJrgaJpZM4XvdI7 .

i8beef commented 5 years ago

Those should be right. As part of the OAuth / OpenID implementation it should expose that URL. Can you actually hit that URL (https://MY-DYN-DNS.URL/google/home/.well-known/openid-configuration)?

diabl0w commented 5 years ago

Yes, it opens a webpage with json formated text. One thing about my configuration is that I can only access MY-DYN-DNS.URL from outside of my LAN. From inside, the url doesnt resolve properly and I never figured out what is exactly causing it. Is the call for "https://my-dyn-dns.url/google/home/.well-known/openid-configuration" coming from the raspberry pi or is it coming from google servers? if its coming from the servers then I don't know what the problem is. If its coming from the pi then maybe its because of not resolving within my LAN

i8beef commented 5 years ago

Its coming from the Pi, so yes, it needs to resolve. When Google makes a request to the API, it has to in turn make a request to the OAuth implementation to get this information.

Why does that URL not resolve? Does it get an IP address (i.e., resolve) but doesn't ROUTE? If so, that might be due to you needing whats called a "hairpin nat" rule.

diabl0w commented 5 years ago

Yes, you description is spot on. It resolves but doesnt Route. I have come across the hairpin nat as a possible issue, I also have what i think is double NAT. Due to certain circumstances, I have a complicated setup. Internet --> ISP combo modem/router --> OpenWRT router connected to ISP router as a client --> Raspberry Pi connected as client to OpenWRT. MY-DYN-DNS.URL points to ISP Router.

So what I think is happening is, coming from Raspberry Pi, makes a request to MY-DYN-DNS.URL which my OpenWRT router's DNS resolves to the public IP of the ISP Router and then ISP router has port 80 forwarded back to OpenWRT router and gets confused.

Do you think adding "192.168.111.1 MY-DYN-DNS.URL" to the raspberry pi host file is an appropriate workaround? Also, clarify that double NAT or hairpin NAT are the problem, should I even be making it up to that point of openid-configuration? Shouldn't it be failing earlier when even trying to login and accept permissions, or is that part coming from google server?

i8beef commented 5 years ago

You could try the host file. Not sure if that'll work or not... the proper fix is probably a hairpin NAT at (maybe) the OpenWRT router or (probably) the ISP router NAT though. Im no networking expert there... I THINK you'd want it at the router the external address POINTS at which would be the ISP one.

diabl0w commented 5 years ago

I agree, I think it would be the ISP router that needs hairpin. I am not sure if the ISP router supports that or not. I rather at this time do the dirtier/easier hosts file "hack" first to see if it works. Thanks for talking it through with me, and thanks for creating this project!

diabl0w commented 5 years ago

Good news, all up and running. Setting the values in the hosts files I think broke other things. Instead, I changed my Openwrt router's DNS server to serve out 192.168.111.1 when requesting MY-DYN-DNS.URL

In the rare chance that someone else has this issue and is running an unbound DNS server, I fixed it by adding: local-data: "MY-DYN-DNS.URL IN A local.ip.of.nginx.server"

Now I'm all set!

i8beef commented 5 years ago

Awesome! Let me know if you find yourself in need of additional documentation. Feedback will help me fill in any holes that you think should have been documented. This hairpin nat issue should probably be added as a common issue for instance.

diabl0w commented 5 years ago

for the googledevicesjson file, the default generated file puts something similar to the following for the first two lines of each device:

"google/home/switch": { "id": "google/home/switch",

if i change these values to anything else, even for only one device, none of my devices work. They will still show up and be added, but as soon as i try and control any device, i get some kind of error about tokens.

can these values be changed? in your wiki, you have the id changed to something different, but even if i leave the first "google/home/switch" and only change the id, it still breaks something. In effect, i can just leave them the way they are and its no big deal, until i want to add another device of the same type for example, another switch, because then i have to use the same id

i8beef commented 5 years ago

Yes they can (and should) be changed, but not after you've already imported them in Google Home, as these function as unique identifiers... so if you change it, Google will still look for the original device.

If you change these, you may need to relink your account in Google Home to get it to refresh it's list of devices, worst case.

I think there's a Google Home voice command like "sync my devices" or something like that which will also trigger a refresh without having to relink.

There's also an MQTT topic this project will listen for, "google/home/REQUEST_SYNC", that if everythings setup (Google Home Graph API key, etc.) will trigger the request from my side... but Im not sure I've documented that, and its really there for if someone just wanted a button in their home automation system that would trigger the same thing.

diabl0w commented 5 years ago

If changing the "id" of the device, should i be setting the part before the semi-colon to the same thing? i.e in my previous example, both are "google/home/switch". In your wiki example, you omit the first part so that's why I am unsure.

yes, I have tried "sync my devices" and also unlinking and relinking. I will try again this time starting fresh with a pruned docker image.

On Mon, Oct 29, 2018, 12:52 PM Michael Hallock notifications@github.com wrote:

Yes they can (and should) be changed, but not after you've already imported them in Google Home, as these function as unique identifiers... so if you change it, Google will still look for the original device.

If you change these, you may need to relink your account in Google Home to get it to refresh it's list of devices, worst case.

I think there's a Google Home voice command like "sync my devices" or something like that which will also trigger a refresh without having to relink.

There's also an MQTT topic this project will listen for, "google/home/REQUEST_SYNC", that if everythings setup (Google Home Graph API key, etc.) will trigger the request from my side... but Im not sure I've documented that, and its really there for if someone just wanted a button in their home automation system that would trigger the same thing.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/i8beef/HomeAutio.Mqtt.GoogleHome/issues/23#issuecomment-433987051, or mute the thread https://github.com/notifications/unsubscribe-auth/APYcMkviePc-XNkgZ_4OcrH5xjSuhqamks5upzIygaJpZM4XvdI7 .

i8beef commented 5 years ago

Ah, yeah, they have to match... this is an artifact of my laziness here. The googleDevices.json file is just a serialized version of the actual storage in the app cause it was easy, and I could load directly into a readonly collection. The internal storage is organized as a dictionary like this because its quicker to lookup the device config by key, thus the dictionary structure.

I think I actually intended to fix that at one point and just never did.

Yeah, I mean worse comes to worst, you just get the JSON file setup correctly, unlink, and then relink. When you unlink a service in Google Home it wipes everything, so when you relink its like setting it up fresh in terms of device sync.

diabl0w commented 5 years ago

Its working great now, pruned everything. I cant thank you enough. Im sorry for all these questions, I am trying to figure things out without having to ask you. But so far, every problem I've faced you've been able to help me solve without much trouble. That being said, here is an issue im running into now:

I have my TV set up to receive on/off trait as well as mode trait. The on/off trait works fine. The mode trait doesnt seem to even be recognized by google. When I ask it to set the channel, it just gives me some google search based on my keywords (ive tried multiple different ways of asking like "set TV's channel to.." "change TV's channel mode to..." etc.). There is nothing in the logs at all, google does not even attempt to query/execute my device. I've tried setting it up multiple ways, including not having any traits besides mode trait, and also trying to change the device type to scene, but nothing works. I also have a airpurifier that has an attributes field that i have to fill out but that doesn't seem to work either. Here is the devices.json for the TV portion that I am using:

"bedroom/tv": { "id": "bedroom/tv", "type": "action.devices.types.SWITCH", "willReportState": false, "roomHint": "Bedroom", "name": { "defaultNames": [], "name": "TV", "nicknames": [] }, "deviceInfo": { "manufacturer": "Brian", "model": "multi", "hwVersion": "1.0", "swVersion": "1.0" }, "traits": [ { "trait": "action.devices.traits.Modes", "attributes": { "availableModes" : [ { "name": "channel", "name_values": [ { "name_synonym": [ "station" ], "lang": "en" } ], "settings": [ { "setting_name": "ESPN", "setting_values": [ { "setting_synonym": [ "espn", "espn sports" ], "lang": "en" } ] }, { "setting_name": "NBCSN", "setting_values": [ { "setting_synonym": [ "NBC Sports", "nbc sports" ], "lang": "en" } ] }, { "setting_name": "FSFL", "setting_values": [ { "setting_synonym": [ "Fox Sports Florida", "fox sports florida" ], "lang": "en" } ] }, { "setting_name": "Party", "setting_values": [ { "setting_synonym": [ "party", "i.d", "investigation discovery" ], "lang": "en" } ] } ], "ordered": false } ] }, "commands": { "action.devices.commands.SetModes": { "updateModeSettings.channel": "bedroom/tv/channel/set" } }, "state": { "currentModeSettings.channel": { "topic": "bedroom/tv/channel", "googleType": "string", "valueMap": [ { "mqtt": "ESPN", "type": "value", "google": "ESPN" }, { "mqtt": "NBCSN", "type": "value", "google": "NBCSN" }, { "mqtt": "FSFL", "type": "value", "google": "FSFL" }, { "mqtt": "ID", "type": "value", "google": "Party" } ] } } }, { "trait": "action.devices.traits.OnOff", "commands": { "action.devices.commands.OnOff": { "on": "bedroom/tv/power/set" } }, "state": { "on": { "topic": "bedroom/tv/power", "googleType": "bool", "valueMap": [ { "mqtt": "1", "type": "value", "google": true }, { "mqtt": "0", "type": "value", "google": false } ] } } } ] },

diabl0w commented 5 years ago

Edit: im sorry its hard to read, i cant figure out how to keep apporpriate spacing in "< c o d e >"

i8beef commented 5 years ago

That's because Google hasn't unlocked arbitrary modes yet.

https://developers.google.com/actions/smarthome/traits/modes https://developers.google.com/actions/reference/smarthome/traits/modes

You can use "import source" and the specific values they allow you to use for that. The terminology is "set X input source to Y" where Y is one of the specific input sources they support.

We've been waiting for them to open that up for almost a year I think.

diabl0w commented 5 years ago

@i8beef wow thanks your a savior, I did not know that at all. Does this project support the fanspeed trait? because I am also having trouble with that. It's smiliar to mode and toggle trait but a little different. When I try to use "set my air purifier speed to high", it says my air purifier "doesn't support that functionality" ... on/off works fine. I've tried setting the "commands section to use both "fanSpeed.speeds" because your documentation says something about flattening the json, and also tried leaving it as "fanSpeed" as per the google documentation. Here is the code:

"bedroom/airpurifier": { "id": "bedroom/airpurifier", "type": "action.devices.types.AIRPURIFIER", "willReportState": false, "roomHint": "Bedroom", "name": { "defaultNames": [], "name": "Air Purifier", "nicknames": [] }, "deviceInfo": { "manufacturer": "Winix", "model": "Climate", "hwVersion": "1.0", "swVersion": "1.0" }, "traits": [ { "trait": "action.devices.traits.OnOff", "commands": { "action.devices.commands.OnOff": { "on": "bedroom/airpurifier/power/set" } }, "state": { "on": { "topic": "bedroom/airpurifier/power", "googleType": "bool", "valueMap": [ { "mqtt": 1, "type": "value", "google": true }, { "mqtt": 0, "type": "value", "google": false } ] } } }, { "trait": "action.devices.traits.FanSpeed", "attributes": { "availableFanSpeeds" : { "speeds": [ { "speed_name": "Low", "speed_values": [ { "speed_synonym": ["low", "slow"], "lang": "en" } ] }, { "speed_name": "High", "speed_values": [ { "speed_synonym": ["high"], "lang": "en" } ] } ], "ordered": true } }, "commands": { "action.devices.commands.SetFanSpeed": { "fanSpeed.speeds": "bedroom/airpurifier/fanspeed/set" } }, "state": { "currentFanSpeedSetting": { "topic": "bedroom/airpurifier/fanspeed", "googleType": "string", "valueMap": [ { "mqtt": 1, "type": "value", "google": "Low" }, { "mqtt": 5, "type": "value", "google": "High" } ] } } } ] },

i8beef commented 5 years ago

Ah, no does't seem so. I added the trait attribute for it, but I didn't realize they took a "mode" / "toggle" / "completely different than everything else" approach to the fan speed stuff. It'll need a release for that. Put in a new ticket for it, and I'll see if I can get it done for ya this weekend.

diabl0w commented 5 years ago

awesome, thank you so much for your help

i8beef commented 5 years ago

Your JSON is really close BTW, good job. I think the commands section should be this though.

        "commands":{  
            "action.devices.commands.SetFanSpeed":{  
               "fanSpeed":"bedroom/airpurifier/fanspeed/set"
            }
         },