Aircoookie / Espalexa

Alexa voice control for ESP8266/ESP32 (including brightness and color!)
MIT License
529 stars 135 forks source link

New version 2.5, Device not found by Alexa #154

Open policchio opened 3 years ago

policchio commented 3 years ago

Hi, and thanks for the fantastic job. I am truly grateful. Using the previous version I had no problems with Alexa, but as soon as I upgraded to version 2.5 Alexa no longer sees the device. I've already tried turning Alexa off and on several times, deleting the old device and searching for it. I also tried to search with the Philips bridge, but nothing. The strange thing is that this update should have solved the problems that instead caused me again (even at the beginning I had to struggle to find the device, but once I did I had no more problems).

Aircoookie commented 3 years ago

Hi! I am very sorry that the newer version is causing trouble for you. What is your Echo model? Also please find out the IP of your ESP (either in your router or by serial output of one of the examples) and check what http://[esp-IP]/api/api/lights returns. That may help with troubleshooting. Thank you :)

policchio commented 3 years ago

I have 2 Echo:

I did these tests:

This is what I see in http://[esp-IP]/api/api/lights:

-with 2.5.0 version: {"1":{"state":{"on":false,"bri":254,"hue":0,"sat":0,"effect":"none","xy":[0.500000,0.500000],"ct":500,"alert":"none","colormode":"xy","mode":"homeautomation","reachable":true},"type":"Extended color light","name":"Luce1","modelid":"LCT015","manufacturername":"Philips","productname":"E4","uniqueid":"0291481f1c01","swversion":"espalexa-2.5.0"}}

-with 2.4.7 version: {"75624897": {"state": {"on": true, "bri": 254, "hue": 0, "sat": 0, "effect": "none", "xy": [0.500000, 0.500000], "ct": 500, "alert": "none", "colormode": "xy", "mode": "homeautomation", "reachable": true}, "type": "Extended color light", "name": "Luce1", "modelid": "LCT015", "manufacturername": "Philips", "productname": "E4", "uniqueid": "75624897", "swversion": "espalexa-2.4.7 "}}

Thanks again for the work done, I hope these problems will be solved.

konsumer commented 3 years ago

I'm not sure what Alexa version I have, but I tested using Alexa android app (using "find new devices" command), and I have same problem, I think.

curl http://192.168.86.35/api/api/lights

{"1":{"state":{"on":false,"bri":254,"hue":0,"sat":0,"effect":"none","xy":[0.500000,0.500000],"ct":500,"alert":"none","colormode":"xy","mode":"homeautomation","reachable":true},"type":"Extended color light","name":"arch 1","modelid":"LCT015","manufacturername":"Philips","productname":"E4","uniqueid":"cca8ae982e01","swversion":"espalexa-2.5.0"}}

I tried manually adding it (under "Devices", in alexa app) and it asks about bluetooth & a bridge. I answered yes to bluetooth, and it did search but did not discover it. I answered no to bluetooth, and it said I need a hub. I tried "V2 bridge" and it required an app install. "V1 bridge" tried to find it, but had no luck. I also tried setting device to "Other" instead of Phillips Hue, and it searched, but also no luck.

Here is the code I am using:

#define WIFI_NAME "<SECRET>"
#define WIFI_PASS "<SECRET>"
#define DEVICE_NAME "arch 1"

#include <ESP8266WiFi.h>
#include <Espalexa.h>
#include <printf.h>

Espalexa espalexa;

// this sets up printf
void _putchar(char character) {
  Serial.print(character);
}

// called when Alexa tries to change the color
void handleColorChange(uint8_t brightness, uint32_t rgb) {
  printf("Brightness: %d, Red: %d, Green: %d, Blue: %d\n", brightness, (rgb >> 16) & 0xFF, (rgb >>  8) & 0xFF, rgb & 0xFF);
}

boolean connectWifi(){
  boolean state = true;
  int i = 0;

  WiFi.mode(WIFI_STA);
  WiFi.begin(WIFI_NAME, WIFI_PASS);
  printf("\nConnecting to WiFi\n");

  // Wait for connection
  printf("Connecting");
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    printf(".");
    if (i > 40) {
      state = false;
      break;
    }
    i++;
  }
  printf("\n");

  if (state) {
    printf("Connected to %s (%s)", WIFI_NAME, WiFi.localIP().toString().c_str());
  } else {
    printf("Connection failed.\n");
  }

  return state;
}

void setup() {
  Serial.begin(115200);
  boolean connected = connectWifi();

  if (connected){
    espalexa.addDevice(DEVICE_NAME, handleColorChange);
    espalexa.begin();
  } else {
    printf("Try restarting the ESP8266.\n");
  }
}

void loop() {
  espalexa.loop();
  delay(1);
}

printf comes from here if you want to run the example.

Jorgen-VikingGod commented 3 years ago

Badly the new version did not discover for me too :( Maybe take a look at master branch of: https://github.com/vintlabs/fauxmoESP this is working for me on first try and really stable.

here response of http://192.168.188.65/api/api/lights with Espalexa:

{
  "1":{
    "state":{
      "on":false,
      "bri":254,
      "hue":0,
      "sat":0,
      "effect":"none",
      "xy":[
        0.500000,
        0.500000
      ],
      "ct":500,
      "alert":"none",
      "colormode":"xy",
      "mode":"homeautomation",
      "reachable":true
    },
    "type":"Extended color light",
    "name":"power",
    "modelid":"LCT015",
    "manufacturername":"Philips",
    "productname":"E4",
    "uniqueid":"6f28aff1f801",
    "swversion":"espalexa-2.5.0"
  },
  "2":{
    "state":{
      "on":false,
      "bri":254,
      "hue":0,
      "sat":0,
      "effect":"none",
      "xy":[
        0.500000,
        0.500000
      ],
      "ct":500,
      "alert":"none",
      "colormode":"xy",
      "mode":"homeautomation",
      "reachable":true
    },
    "type":"Extended color light",
    "name":"time",
    "modelid":"LCT015",
    "manufacturername":"Philips",
    "productname":"E4",
    "uniqueid":"6f28aff1f802",
    "swversion":"espalexa-2.5.0"
  },
  "3":{
    "state":{
      "on":false,
      "bri":254,
      "hue":0,
      "sat":0,
      "effect":"none",
      "xy":[
        0.500000,
        0.500000
      ],
      "ct":500,
      "alert":"none",
      "colormode":"xy",
      "mode":"homeautomation",
      "reachable":true
    },
    "type":"Extended color light",
    "name":"brightness",
    "modelid":"LCT015",
    "manufacturername":"Philips",
    "productname":"E4",
    "uniqueid":"6f28aff1f803",
    "swversion":"espalexa-2.5.0"
  }
}

here response of http://192.168.188.65/api/api/lights with fauxmoESP:

{
  "1":{
    "type":"Extended color light",
    "name":"power",
    "uniqueid":"7e5ac3bd6d25",
    "modelid":"LCT007",
    "state":{
      "on":false,
      "bri":0,
      "xy":[
        0,
        0
      ],
      "reachable":true
    },
    "capabilities":{
      "certified":false,
      "streaming":{
        "renderer":true,
        "proxy":false
      }
    },
    "swversion":"5.105.0.21169"
  },
  "2":{
    "type":"Extended color light",
    "name":"time",
    "uniqueid":"8a03e306e586",
    "modelid":"LCT007",
    "state":{
      "on":false,
      "bri":0,
      "xy":[
        0,
        0
      ],
      "reachable":true
    },
    "capabilities":{
      "certified":false,
      "streaming":{
        "renderer":true,
        "proxy":false
      }
    },
    "swversion":"5.105.0.21169"
  },
  "3":{
    "type":"Extended color light",
    "name":"brightness",
    "uniqueid":"fe689e67bcd0",
    "modelid":"LCT007",
    "state":{
      "on":false,
      "bri":0,
      "xy":[
        0,
        0
      ],
      "reachable":true
    },
    "capabilities":{
      "certified":false,
      "streaming":{
        "renderer":true,
        "proxy":false
      }
    },
    "swversion":"5.105.0.21169"
  }
}
mrhill commented 3 years ago

I upgraded to v2.5 and with Echo Dot Gen3, discovery did work again, but grouping devices does not.

I have 5 ESP8266 with 2 Espalexa devices each, I can see and control all 10 devices individually in Alexa. But if I add all devices into a group, it always remembers only 2 of them. Even if I put any 2 devices into the group, it remembers 2 different ones. That makes me believe that something with the uniqueid is still off.

Jorgen-VikingGod commented 3 years ago

Maybe the discovery issue is on ESP32 only?...