kakopappa / arduino-esp8266-alexa-wemo-switch

Amazon Alexa + WeMos switch made with Arduino D1 Mini
https://sinric.pro
MIT License
281 stars 249 forks source link

having issues with keeping wemos d1 connected #45

Open rramesh68 opened 3 years ago

rramesh68 commented 3 years ago

I am not a software programmer by profession and I am just a DIY enthusiast so plese go easy on me as I put down my peculiar problem.

When I first configured my first 4 devices on Sinric and got it to work with my echo dot, I was thrilled. The convenience of lying in bed and ordering alexa to turn lights and fans off and on was unmatched like never before. That was using an NodeMCU. Then I discovered the Wemos D1 board and I decided to try that and made my second alexa controlled switch (8 relays) and improved the design by putting it into a more professional looking box etc.

Rather than running extra lenghts of wire from various rooms to one common Alexa controlled switch board, i decided to replicate my 8 relays switch boxes in most rooms till I had a total of four boxes. All of them were connected to the same network using the same SSID and PWD.

There was this occasional issue with some of the boards not responding once in 4-5 days and it took recycling the power to reset the board. This is when I came across a piece of code on the net which introduced the HEARTBEATS as thus and I thought that improved the performance a bit. So now my loop included this code snippet as below:-

webSocket.loop();

if(isConnected) { uint64_t now = millis();

  // Send heartbeat in order to avoid disconnections during ISP resetting IPs over night. Thanks @MacSass
  if((now - heartbeatTimestamp) > HEARTBEAT_INTERVAL) {
      heartbeatTimestamp = now;
      webSocket.sendTXT("H");          
  }

Then from elsewhere I came across another code which suggested making a function called setupWifi() and calling it in the loop. This led to introducing the lines below in the loop function.

if (WiFi.status() != WL_CONNECTED) { Serial.print("Attempting to connect to SSID: "); Serial.println(ssid);
setupWifi(); }

All in all I though I had the issues with Wemos D1 sleeping solved. But in fact it seems to have worsened. Looking at the code, I don't think there is anything there to really make it worse. But that may be my lack of experience talking.

So now I have the Alexa app and I also have the SINRIC app on my phone. When I notice the devices are not getting switched ON/OFF, I notice the device state does not change on the SINRIC app either. However Alexa seems to have no problems acknowledging to my requests with the usual "Okay".

The next thing I did while these problems were around was to try and set up IFTTT to send a text to my phone when the device state changed. That made it significantly worse.

The strange thing is the same unresponsive switches start automatically after a while. Now I am not sure if the 5 minute HEARTBEAT interval has anything to do with that.

So I am not sure if there is a limitation in connecting so may Wemos D1 modules all to the same network. Unlikely but I will still ask.

Does the webhook, IFTTT messaging and sinric have any known compatibility issues that I am not aware of?

Please help. Thank you in advance.

kakopappa commented 3 years ago

Have you tried the our pro version yet? Pro SDK handles the heart-beat internally and it works well. You can use the Sinric Pro app to notify you when a device goes offline. Please give it a try.

https://Sinric.pro

On Tue, 1 Sep 2020 at 7:50 PM rramesh68 notifications@github.com wrote:

I am not a software programmer by profession and I am just a DIY enthusiast so plese go easy on me as I put down my peculiar problem.

When I first configured my first 4 devices on Sinric and got it to work with my echo dot, I was thrilled. The convenience of lying in bed and ordering alexa to turn lights and fans off and on was unmatched like never before. That was using an NodeMCU. Then I discovered the Wemos D1 board and I decided to try that and made my second alexa controlled switch (8 relays) and improved the design by putting it into a more professional looking box etc.

Rather than running extra lenghts of wire from various rooms to one common Alexa controlled switch board, i decided to replicate my 8 relays switch boxes in most rooms till I had a total of four boxes. All of them were connected to the same network using the same SSID and PWD.

There was this occasional issue with some of the boards not responding once in 4-5 days and it took recycling the power to reset the board. This is when I came across a piece of code on the net which introduced the HEARTBEATS as thus and I thought that improved the performance a bit. So now my loop included this code snippet as below:-

webSocket.loop();

if(isConnected) { uint64_t now = millis();

// Send heartbeat in order to avoid disconnections during ISP resetting IPs over night. Thanks @MacSass if((now - heartbeatTimestamp) > HEARTBEAT_INTERVAL) { heartbeatTimestamp = now; webSocket.sendTXT("H"); }

Then from elsewhere I came across another code which suggested making a function called setupWifi() and calling it in the loop. This led to introducing the lines below in the loop function.

if (WiFi.status() != WL_CONNECTED) { Serial.print("Attempting to connect to SSID: "); Serial.println(ssid); setupWifi(); }

All in all I though I had the issues with Wemos D1 sleeping solved. But in fact it seems to have worsened. Looking at the code, I don't think there is anything there to really make it worse. But that may be my lack of experience talking.

So now I have the Alexa app and I also have the SINRIC app on my phone. When I notice the devices are not getting switched ON/OFF, I notice the device state does not change on the SINRIC app either. However Alexa seems to have no problems acknowledging to my requests with the usual "Okay".

The next thing I did while these problems were around was to try and set up IFTTT to send a text to my phone when the device state changed. That made it significantly worse.

The strange thing is the same unresponsive switches start automatically after a while. Now I am not sure if the 5 minute HEARTBEAT interval has anything to do with that.

So I am not sure if there is a limitation in connecting so may Wemos D1 modules all to the same network. Unlikely but I will still ask.

Does the webhook, IFTTT messaging and sinric have any known compatibility issues that I am not aware of?

Please help. Thank you in advance.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/kakopappa/arduino-esp8266-alexa-wemo-switch/issues/45, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABZAZZUSETXNDIOCOLFPOODSDTUZZANCNFSM4QRVXT7A .

rramesh68 commented 2 years ago

hello again,

I recently upgraded my switches when Sinric stopped working. it is not registered under this email id and so you may not find it. However, I have a question. While the upgraded app is good and does away with the need for IFTTT (for my use at least) and it worked all fine.

QUESTION 1 However today for some reason when I say "Alexa switch on tv room light", the light gets on almost immediately but the blue light on Alexa's rim keeps going in circles and after a while says "Sorry TV room light is not responding". same is true for every other device.

(a) I have already tried disabling and re-enabling the device in Alea app (b) I have tried deleting the device and re- discovering it in Alexa app

Either which, way I get the same response.

A code snippet is as below:-

bool onPowerState1(const String &deviceId, bool &state) { Serial.printf("Side Light turned %s\r\n", state?"on":"off"); myPowerState1 = state; digitalWrite(device_1, myPowerState1?LOW:HIGH); return true; }

QUESTION 2 One other thing i noticed on the devices connected / controlled by wemos is that when it connects up to the internet as per this code below:-

// setup function for WiFi connection void setupWiFi() { Serial.printf("\r\n[Wifi]: Connecting"); WiFi.begin(WIFI_SSID, WIFI_PASS);

while (WiFi.status() != WL_CONNECTED) { Serial.printf("."); delay(250); }

Serial.printf("connected!\r\n[WiFi]: IP-Address is %s\r\n", WiFi.localIP().toString().c_str()); }

It is supposed to type .........connected IP address etc etc.

now the problem i have is that on the nodemcu board this works fine. However, on two other switches where I use wemos boards, i get only ........................?C .The rest of the message does not follow. what could be the reason for this?

Please advise what could be wrong.

Regards, Ramesh


From: Aruna Tennakoon @.> Sent: Tuesday, September 1, 2020 12:57 PM To: kakopappa/arduino-esp8266-alexa-wemo-switch @.> Cc: rramesh68 @.>; Author @.> Subject: Re: [kakopappa/arduino-esp8266-alexa-wemo-switch] having issues with keeping wemos d1 connected (#45)

Have you tried the our pro version yet? Pro SDK handles the heart-beat internally and it works well. You can use the Sinric Pro app to notify you when a device goes offline. Please give it a try.

https://Sinric.pro

On Tue, 1 Sep 2020 at 7:50 PM rramesh68 @.***> wrote:

I am not a software programmer by profession and I am just a DIY enthusiast so plese go easy on me as I put down my peculiar problem.

When I first configured my first 4 devices on Sinric and got it to work with my echo dot, I was thrilled. The convenience of lying in bed and ordering alexa to turn lights and fans off and on was unmatched like never before. That was using an NodeMCU. Then I discovered the Wemos D1 board and I decided to try that and made my second alexa controlled switch (8 relays) and improved the design by putting it into a more professional looking box etc.

Rather than running extra lenghts of wire from various rooms to one common Alexa controlled switch board, i decided to replicate my 8 relays switch boxes in most rooms till I had a total of four boxes. All of them were connected to the same network using the same SSID and PWD.

There was this occasional issue with some of the boards not responding once in 4-5 days and it took recycling the power to reset the board. This is when I came across a piece of code on the net which introduced the HEARTBEATS as thus and I thought that improved the performance a bit. So now my loop included this code snippet as below:-

webSocket.loop();

if(isConnected) { uint64_t now = millis();

// Send heartbeat in order to avoid disconnections during ISP resetting IPs over night. Thanks @MacSass if((now - heartbeatTimestamp) > HEARTBEAT_INTERVAL) { heartbeatTimestamp = now; webSocket.sendTXT("H"); }

Then from elsewhere I came across another code which suggested making a function called setupWifi() and calling it in the loop. This led to introducing the lines below in the loop function.

if (WiFi.status() != WL_CONNECTED) { Serial.print("Attempting to connect to SSID: "); Serial.println(ssid); setupWifi(); }

All in all I though I had the issues with Wemos D1 sleeping solved. But in fact it seems to have worsened. Looking at the code, I don't think there is anything there to really make it worse. But that may be my lack of experience talking.

So now I have the Alexa app and I also have the SINRIC app on my phone. When I notice the devices are not getting switched ON/OFF, I notice the device state does not change on the SINRIC app either. However Alexa seems to have no problems acknowledging to my requests with the usual "Okay".

The next thing I did while these problems were around was to try and set up IFTTT to send a text to my phone when the device state changed. That made it significantly worse.

The strange thing is the same unresponsive switches start automatically after a while. Now I am not sure if the 5 minute HEARTBEAT interval has anything to do with that.

So I am not sure if there is a limitation in connecting so may Wemos D1 modules all to the same network. Unlikely but I will still ask.

Does the webhook, IFTTT messaging and sinric have any known compatibility issues that I am not aware of?

Please help. Thank you in advance.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/kakopappa/arduino-esp8266-alexa-wemo-switch/issues/45, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABZAZZUSETXNDIOCOLFPOODSDTUZZANCNFSM4QRVXT7A .

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/kakopappa/arduino-esp8266-alexa-wemo-switch/issues/45#issuecomment-684832766, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AM4HSADXR6YZG5RL2VTCODLSDTVU7ANCNFSM4QRVXT7A.

MacSass commented 2 years ago

Hmmm, not sure it´s a good idea to pull up an old thread for a new issue ... you might get way better feedback opening a new thread.

But: I can state that just since today I´m also getting Alexa feedback saying "the device did not respond" although it does work will. I´m suspecting there is some slowdown from sinric.pro in the Alexa response that causes this. Alexa requires a response in a given time - and it looks like this response is coming too slow currently.

Not sure what is causing this - but I would suspect it will get fixed soon on sinric.pro backend ...

Regards - MacSass