Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unable to register device using echo #1

Open
DavidHamburg opened this issue Jan 1, 2021 · 14 comments
Open

unable to register device using echo #1

DavidHamburg opened this issue Jan 1, 2021 · 14 comments

Comments

@DavidHamburg
Copy link

Hi,

I try to connect these example app running on a raspberry pi 3b+ with an echo v4. I can see some M-Search requests and calls in the HueDeviceController, but the echo always tells me that no device has been discovered. Also the alexa app (ios) is not able to find the example app. Do you have any idea?

 D |2021-01-01 13:08:34 1609502914027967| SsdpController:'M-SEARCH *' Received
 D |2021-01-01 13:08:34 1609502914032943| SsdpController:'M-SEARCH *' Received
 D |2021-01-01 13:08:34 1609502914033414| SsdpController:'M-SEARCH *' Received
 D |2021-01-01 13:08:34 1609502914033865| SsdpController:'M-SEARCH *' Received
 D |2021-01-01 13:08:34 1609502914034296| SsdpController:'M-SEARCH *' Received
 D |2021-01-01 13:08:34 1609502914034724| SsdpController:'M-SEARCH *' Received
 D |2021-01-01 13:08:34 1609502914041353| HueDeviceController:Request for description
 D |2021-01-01 13:08:34 1609502914069043| HueDeviceController:POST on /api with empty user, generated 'OatppSsdpHueDefaultUserfa37JncCHryDsbzay'
 D |2021-01-01 13:08:34 1609502914069130| HueDeviceController:Devicetype: Echo
 D |2021-01-01 13:08:34 1609502914095009| HueDeviceController:GET on /api/{username}/lights
 D |2021-01-01 13:08:34 1609502914137050| HueDeviceController:GET on /api/OatppSsdpHueDefaultUserpPIhMFSv8kP07U20o/lights/1
 D |2021-01-01 13:08:34 1609502914163191| HueDeviceController:POST on /api with empty user, generated 'OatppSsdpHueDefaultUsery4cBWDxS22JjzhMai'
 D |2021-01-01 13:08:34 1609502914163276| HueDeviceController:Devicetype: Echo
 D |2021-01-01 13:08:34 1609502914171557| HueDeviceController:GET on /api/{username}/lights
@lganzzzo
Copy link
Member

lganzzzo commented Jan 1, 2021

Hey @bamkrs , can you please assist with this issue.

@bamkrs
Copy link
Member

bamkrs commented Jan 1, 2021

Hey @DavidHamburg please be Patient. I'll fire up the example on my machine again with newest Oat++ and report back shortly.

But as a first try, have you set your IP-Address correclty?

desc->ipPort = "192.168.100.100:80"; // your real IP and Port your HTTP-Controller is running on

Have you checked your device list in your Alexa app? I've noticed that some times the app tells you "nothing" but the device was silently registered anyhow.

@DavidHamburg
Copy link
Author

Thank you for your quick response!

But as a first try, have you set your IP-Address correclty?

desc->ipPort = "192.168.100.100:80"; // your real IP and Port your HTTP-Controller is running on

yes, I have changed the IP address and double checked it in the swagger ui. The echo device also seems to call the proper routes from the HueDeviceController. What looks kinda strange is the second call of /api/{username}/lights in the log output.

Have you checked your device list in your Alexa app? I've noticed that some times the app tells you "nothing" but the device was silently registered anyhow.

No, unfortunately not.

@bamkrs
Copy link
Member

bamkrs commented Jan 1, 2021

Hey @DavidHamburg I'll need a bit longer. I've updated my macOS to Big Sur and am unable to receive multicast messages anymore. I'll have to look into this before I can can start working on the actual problem. Sorry for that, I'll try my best tomorrow.

@DavidHamburg
Copy link
Author

Sure, there is no rush!

@bamkrs
Copy link
Member

bamkrs commented Jan 2, 2021

Hey @DavidHamburg I'm working on the issue and can confirm your problem. It seems that in some unknown update to Alexa there were some silent changes to the discovery process (it seems to be unhappy about some parts of the response).

@DavidHamburg
Copy link
Author

Thank you for the hint. It seems that the unique id format has been changed in the last weeks (see bwssytems/ha-bridge#1272). I have updated the uniqueid in

dto->uniqueid = oatpp::String("BE570A70CAFE") + "-" + oatpp::String(hueDevice.id + 1); // BEST OAT CAFE!
and now alexa is able to find my device.

Many thanks for your fast support!

@bamkrs
Copy link
Member

bamkrs commented Jan 2, 2021

Hey @DavidHamburg awesome that you have created an PR! Are you sure that is the issue? I was already looking at the fauxmoESP and other sources and have seen this change. I Implemented it locally but I still have no luck finding new devices.

@DavidHamburg
Copy link
Author

DavidHamburg commented Jan 2, 2021

Are you sure that is the issue? I was already looking at the fauxmoESP and other sources and have seen this change. I Implemented it locally but I still have no luck finding new devices.

Quite sure, I was able to find the devices with alexa several times after removing the "-". Maybe your string is too short? You must have an 0001 at the end of the device id. I have updated the pull request, can you try it again with my changes?

Also ensure the port is 80, all others did not work for me.

@bamkrs
Copy link
Member

bamkrs commented Jan 2, 2021

Hey @DavidHamburg yes I found the new id scheme and now it works for me, too.
In my experiments I implemented a few other functions and fixed some more bugs. Is it ok if I close your PR and push all my fixes including the new naming? However, I can understand if you want your PR merged, at least you found the bug 👍

@DavidHamburg
Copy link
Author

In my experiments I implemented a few other functions and fixed some more bugs. Is it ok if I close your PR and push all my fixes including the new naming?

Sure, you can close my PR.

@bamkrs
Copy link
Member

bamkrs commented Jan 2, 2021

Hey @DavidHamburg
I closed your PR and at least mentioned you in my commit. Thanks again for finding the issue!
In the newest version of the example, Alexa now shows the correct symbol in the app (a lightbulb) and you can set the brightness and color temperature, too.
Setting a custom color works too, but Alexa will show you an error and does not confirm nor show which color you have set. Still need to figure out why.

@DavidHamburg
Copy link
Author

Thank you for the fixes. I have removed the device again from the alexa app and tried to re-register. With the latest commit alexa is not able to find the device again. Maybe the uniqueid (b97febe6d19c7d6e00000000) is too long?

@bamkrs
Copy link
Member

bamkrs commented Jan 3, 2021

Thats odd. I double checked that it works on my Echo (Gen2). Maybe the Gen4 has other constraints.
At least we know BE570A70CAFEx worked for your Gen4. So maybe they limited it to 16 characters?
Could you test the following scheme with your Gen4?

oatpp::Object<HueDeviceDto> Database::deserializeToDto(const HueDevice& hueDevice){
  auto dto = HueDeviceDto::createShared();
  size_t namehash = std::hash<std::string>{}(hueDevice.name->std_str());
  char idstr[16] = {0};
  snprintf(idstr, 16, "%08zx%04d", namehash & 0xffffffff, hueDevice.id);
  dto->uniqueid = idstr;
  dto->name = hueDevice.name;
  dto->state->bri = hueDevice.bri;
  dto->state->on = hueDevice.on;
  dto->state->ct = hueDevice.ct;
  dto->state->hue = hueDevice.hue;
  dto->state->sat = hueDevice.sat;
  dto->state->colormode = hueDevice.mode;
  return dto;
}

This would reduce the length to 12 characters like BE570A70CAFE was without the numbering.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants