Closed nader54 closed 2 years ago
It’s likely your device IDs are not set up correctly in the sketch. Can you share the code without secrets?
On Tue, 11 Jan 2022 at 6:34 AM nader54 @.***> wrote:
[image: Screen Shot 2022-01-10 at 3 31 38 PM] https://user-images.githubusercontent.com/3778135/148855172-c3175a88-3458-40ad-a8d0-a0ef1357243c.png
— Reply to this email directly, view it on GitHub https://github.com/sinricpro/help-docs/issues/14#issuecomment-1009457529, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABZAZZUE6VUWJH5GYG3UTMLUVNUHNANCNFSM5LU4X7RA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
You are receiving this because you are subscribed to this thread.Message ID: @.***>
@nader54 here's the fixed code.
You have to add multiple devices, if you add a single device, only single device is online
// Uncomment the following line to enable serial debug output
//#define ENABLE_DEBUG
#ifdef ENABLE_DEBUG
#define DEBUG_ESP_PORT Serial
#define NODEBUG_WEBSOCKETS
#define NDEBUG
#endif
#include <Arduino.h>
#ifdef ESP8266
#include <ESP8266WiFi.h>
#endif
#ifdef ESP32
#include <WiFi.h>
#endif
#include "SinricPro.h"
#include "SinricProGarageDoor.h"
#define WIFI_SSID ""
#define WIFI_PASS ""
#define APP_KEY ""
#define APP_SECRET ""
#define GARAGEDOOR_ID1 "" // Toyota Garage
#define GARAGEDOOR_ID2 "" // BMW Garage
#define GARAGEDOOR_ID3 "" // Lamborghini Garage
#define BAUD_RATE 9600 // Change baudrate to your need
bool onDoorState(const String& deviceId, bool &doorState) {
Serial.printf("Garagedoor is %s now.\r\n", doorState?"closed":"open");
return true;
}
void setupWiFi() {
Serial.printf("\r\n[Wifi]: Connecting");
WiFi.begin(WIFI_SSID, WIFI_PASS);
while (WiFi.status() != WL_CONNECTED) {
Serial.printf(".");
delay(250);
}
IPAddress localIP = WiFi.localIP();
Serial.printf("connected!\r\n[WiFi]: IP-Address is %d.%d.%d.%d\r\n", localIP[0], localIP[1], localIP[2], localIP[3]);
}
void setupSinricPro() {
SinricProGarageDoor &myGarageDoor1 = SinricPro[GARAGEDOOR_ID1];
myGarageDoor1.onDoorState(onDoorState);
SinricProGarageDoor &myGarageDoor2 = SinricPro[GARAGEDOOR_ID2];
myGarageDoor2.onDoorState(onDoorState);
SinricProGarageDoor &myGarageDoor3 = SinricPro[GARAGEDOOR_ID3];
myGarageDoor3.onDoorState(onDoorState);
// setup SinricPro
SinricPro.onConnected([](){ Serial.printf("Connected to SinricPro\r\n"); });
SinricPro.onDisconnected([](){ Serial.printf("Disconnected from SinricPro\r\n"); });
SinricPro.begin(APP_KEY, APP_SECRET);
}
void setup() {
Serial.begin(BAUD_RATE); Serial.printf("\r\n\r\n");
setupWiFi();
setupSinricPro();
}
void loop() {
SinricPro.handle();
}
Thanks so much! Have a great day!
Get Outlook for iOShttps://aka.ms/o0ukef
From: Aruna Tennakoon @.> Sent: Tuesday, January 11, 2022 3:57:58 AM To: sinricpro/esp8266-esp32-sdk @.> Cc: nader54 @.>; Author @.> Subject: Re: [sinricpro/esp8266-esp32-sdk] Sinricpro dashboard showing only one out of three devices is online. I have deleted and created three device ten times, still only one is online. (Issue #241)
// Uncomment the following line to enable serial debug output //#define ENABLE_DEBUG
#define DEBUG_ESP_PORT Serial
#define NODEBUG_WEBSOCKETS
#define NDEBUG
#include <ESP8266WiFi.h>
#include <WiFi.h>
bool onDoorState(const String& deviceId, bool &doorState) { Serial.printf("Garagedoor is %s now.\r\n", doorState?"closed":"open"); return true; }
void setupWiFi() { Serial.printf("\r\n[Wifi]: Connecting"); WiFi.begin(WIFI_SSID, WIFI_PASS);
while (WiFi.status() != WL_CONNECTED) { Serial.printf("."); delay(250); } IPAddress localIP = WiFi.localIP(); Serial.printf("connected!\r\n[WiFi]: IP-Address is %d.%d.%d.%d\r\n", localIP[0], localIP[1], localIP[2], localIP[3]); }
void setupSinricPro() { SinricProGarageDoor &myGarageDoor1 = SinricPro[GARAGEDOOR_ID1]; myGarageDoor1.onDoorState(onDoorState);
SinricProGarageDoor &myGarageDoor2 = SinricPro[GARAGEDOOR_ID2]; myGarageDoor2.onDoorState(onDoorState);
SinricProGarageDoor &myGarageDoor3 = SinricPro[GARAGEDOOR_ID3]; myGarageDoor3.onDoorState(onDoorState);
// setup SinricPro SinricPro.onConnected([](){ Serial.printf("Connected to SinricPro\r\n"); }); SinricPro.onDisconnected([](){ Serial.printf("Disconnected from SinricPro\r\n"); }); SinricPro.begin(APP_KEY, APP_SECRET); }
void setup() { Serial.begin(BAUD_RATE); Serial.printf("\r\n\r\n"); setupWiFi(); setupSinricPro(); }
void loop() { SinricPro.handle(); }
— Reply to this email directly, view it on GitHubhttps://github.com/sinricpro/esp8266-esp32-sdk/issues/241#issuecomment-1009893863, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AA42MV4RLD63C7DFNDCUXS3UVQLMNANCNFSM5LWDT27Q. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you authored the thread.Message ID: @.***>
Hi Aruna,
All my three garage doors are online, but only one is working (Toyota Garage), when I click the open or close button on the other garage doors, the dashboard shows(Waiting) sign.[Graphical user interface, application Description automatically generated] Could you please help me?
Thanks, Nader Arvanaghi
From: Aruna Tennakoon @.> Date: Tuesday, January 11, 2022 at 3:57 AM To: sinricpro/esp8266-esp32-sdk @.> Cc: nader54 @.>, Author @.> Subject: Re: [sinricpro/esp8266-esp32-sdk] Sinricpro dashboard showing only one out of three devices is online. I have deleted and created three device ten times, still only one is online. (Issue #241)
// Uncomment the following line to enable serial debug output
//#define ENABLE_DEBUG
#define DEBUG_ESP_PORT Serial
#define NODEBUG_WEBSOCKETS
#define NDEBUG
#include <ESP8266WiFi.h>
#include <WiFi.h>
bool onDoorState(const String& deviceId, bool &doorState) {
Serial.printf("Garagedoor is %s now.\r\n", doorState?"closed":"open");
return true;
}
void setupWiFi() {
Serial.printf("\r\n[Wifi]: Connecting");
WiFi.begin(WIFI_SSID, WIFI_PASS);
while (WiFi.status() != WL_CONNECTED) {
Serial.printf(".");
delay(250);
}
IPAddress localIP = WiFi.localIP();
Serial.printf("connected!\r\n[WiFi]: IP-Address is %d.%d.%d.%d\r\n", localIP[0], localIP[1], localIP[2], localIP[3]);
}
void setupSinricPro() {
SinricProGarageDoor &myGarageDoor1 = SinricPro[GARAGEDOOR_ID1];
myGarageDoor1.onDoorState(onDoorState);
SinricProGarageDoor &myGarageDoor2 = SinricPro[GARAGEDOOR_ID2];
myGarageDoor2.onDoorState(onDoorState);
SinricProGarageDoor &myGarageDoor3 = SinricPro[GARAGEDOOR_ID3];
myGarageDoor3.onDoorState(onDoorState);
// setup SinricPro
SinricPro.onConnected([](){ Serial.printf("Connected to SinricPro\r\n"); });
SinricPro.onDisconnected([](){ Serial.printf("Disconnected from SinricPro\r\n"); });
SinricPro.begin(APP_KEY, APP_SECRET);
}
void setup() {
Serial.begin(BAUD_RATE); Serial.printf("\r\n\r\n");
setupWiFi();
setupSinricPro();
}
void loop() {
SinricPro.handle();
}
— Reply to this email directly, view it on GitHubhttps://github.com/sinricpro/esp8266-esp32-sdk/issues/241#issuecomment-1009893863, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AA42MV4RLD63C7DFNDCUXS3UVQLMNANCNFSM5LWDT27Q. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you authored the thread.Message ID: @.***>
Hi @nader54!
It sounds like your devices are assigned to different AppKey / AppSecret pair. If you're running mulitple devices on the same ESP module all devices must be assigned to the same AppKey / AppSecret. Please check in devices tab (dashboard) that all your devices (which are running on the same ESP module) assigned to the correct AppKey.
Only use different AppKey / AppSecret pairs if your (logical) devices are running on different ESP modules (physical devices).
Hi,
I have one AppKey , one AppSecret, and three device id, one for each garage. I rebuilt everything fresh, and now every button I press, it opens the same garage door. Even with alexa is doing the same thing. Please see my code.
Best regards, Nader Arvanaghi
From: Boris Jäger @.> Date: Tuesday, January 11, 2022 at 8:35 PM To: sinricpro/esp8266-esp32-sdk @.> Cc: nader54 @.>, Mention @.> Subject: Re: [sinricpro/esp8266-esp32-sdk] Only one out of three devices is online (Issue #241)
Hi @nader54https://github.com/nader54!
It sounds like your devices are assigned to different AppKey / AppSecret pair. If you're running mulitple devices on the same ESP module all devices must assigned and use the same AppKey / AppSecret. Please check in devices tab (dashboard) that all your devices (which are running on the same ESP module) assigned to the correct AppKey.
Only use different AppKey / AppSecret pairs if your (logical) devices are running on different ESP modules (physical devices).
— Reply to this email directly, view it on GitHubhttps://github.com/sinricpro/esp8266-esp32-sdk/issues/241#issuecomment-1010626221, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AA42MV2RRILN7JI532PJF6TUVUAINANCNFSM5LWDT27Q. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you were mentioned.Message ID: @.***>
Please see my code.
Your current sketch is missing. The latest code i can see is the one Aruna posted. I suggest not to reply via email. Instead post directly on git issues
You have two options
onDoorState1
, onDoorState2
, onDoorState3
) and assign them to the different devices.
Short example how this works:bool onDoorState1(const String& deviceId, bool& state) {
// do whatever when door 1 state changes
return true;
}
bool onDoorState2(const String& deviceId, bool& state) {
// do whatever when door 2 state changes
return true;
}
bool onDoorState3(const String& deviceId, bool& state) {
// do whatever when door 3 state changes
return true;
}
void setupSinricPro() {
...
SinricProGarageDoor &myGarageDoor1 = SinricPro[GARAGEDOOR_ID1];
myGarageDoor1.onDoorState(onDoorState1);
SinricProGarageDoor &myGarageDoor2 = SinricPro[GARAGEDOOR_ID2];
myGarageDoor2.onDoorState(onDoorState2);
SinricProGarageDoor &myGarageDoor3 = SinricPro[GARAGEDOOR_ID3];
myGarageDoor3.onDoorState(onDoorState3);
...
}
Option 2: Implement one onDoorState function that checks the used deviceId.
bool onDoorState(const String& deviceId, bool& state) {
if (deviceId == GARAGEDOOR_ID1 {
// do whatever when door 1 state changes
return true;
}
if (deviceId == GARAGEDOOR_ID2 {
// do whatever when door 1 state changes
return true;
}
if (deviceId == GARAGEDOOR_ID3 {
// do whatever when door 1 state changes
return true;
}
return false; // none of the deviceId's matched -> error!
}
void setupSinricPro() { ... SinricProGarageDoor &myGarageDoor1 = SinricPro[GARAGEDOOR_ID1]; myGarageDoor1.onDoorState(onDoorState);
SinricProGarageDoor &myGarageDoor2 = SinricPro[GARAGEDOOR_ID2]; myGarageDoor2.onDoorState(onDoorState);
SinricProGarageDoor &myGarageDoor3 = SinricPro[GARAGEDOOR_ID3]; myGarageDoor3.onDoorState(onDoorState); ... }
Updatet: fixed copy & paste bug in option2
Sorry, i had a copy & paste bug in option 2. I updated my previous post.
Hi. Your option one did not work, and option two is giving me an error. Arduino: 1.8.13 (Mac OS X), Board: "NodeMCU 0.9 (ESP-12 Module), 80 MHz, Flash, Disabled (new aborts on oom), Disabled, All SSL ciphers (most compatible), 32KB cache + 32KB IRAM (balanced), Use pgm_read macros for IRAM/PROGMEM, 4MB (FS:2MB OTA:~1019KB), v2 Lower Memory, Disabled, None, Only Sketch, 115200"
Alexa_Garage_New_Code:68:6: error: ambiguating new declaration of 'void onDoorState(const String&, bool&)'
68 | void onDoorState(const String& deviceId, bool& state) {
| ^~~
Both options are giving me an error.
Alexa_Garage_New_Code:68:6: error: ambiguating new declaration of 'void onDoorState(const String&, bool&)' 68 | void onDoorState(const String& deviceId, bool& state) {
Have a closer look at the numbers behind the functions! There are 3 different functions in option 1:
bool onDoorState1(... bool onDoorState2(... bool onDoorState3(...
You cannot have 3 functions with the same name like bool onDoorState(... bool onDoorState(... bool onDoorState(... This is what the compiler complains about.
// Uncomment the following line to enable serial debug output
//#define ENABLE_DEBUG
#ifdef ENABLE_DEBUG
#define DEBUG_ESP_PORT Serial
#define NODEBUG_WEBSOCKETS
#define NDEBUG
#endif
#include <Arduino.h>
#ifdef ESP8266
#include <ESP8266WiFi.h>
#endif
#ifdef ESP32
#include <WiFi.h>
#endif
#include "SinricPro.h"
#include "SinricProGarageDoor.h"
#define WIFI_SSID ""
#define WIFI_PASS ""
#define APP_KEY ""
#define APP_SECRET ""
#define GARAGEDOOR_ID1 "" // Toyota Garage
#define GARAGEDOOR_ID2 "" // BMW Garage
#define GARAGEDOOR_ID3 "" // Lamborghini Garage
#define BAUD_RATE 9600 // Change baudrate to your need
bool onDoorState1(const String& deviceId, bool& state) {
// do whatever when door 1 state changes
return true;
}
bool onDoorState2(const String& deviceId, bool& state) {
// do whatever when door 2 state changes
return true;
}
bool onDoorState3(const String& deviceId, bool& state) {
// do whatever when door 3 state changes
return true;
}
void setupWiFi() {
Serial.print("[WiFi]: Connecting");
WiFi.begin(WIFI_SSID, WIFI_PASS);
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(250);
}
Serial.println("connected!");
Serial.printf("[WiFi]: IP-Address is %s\r\n", WiFi.localIP().toString().c_str());
}
void setupSinricPro() {
SinricProGarageDoor& myGarageDoor1 = SinricPro[GARAGEDOOR_ID1];
myGarageDoor1.onDoorState(onDoorState1);
SinricProGarageDoor &myGarageDoor2 = SinricPro[GARAGEDOOR_ID2];
myGarageDoor2.onDoorState(onDoorState2);
SinricProGarageDoor &myGarageDoor3 = SinricPro[GARAGEDOOR_ID3];
myGarageDoor3.onDoorState(onDoorState3);
// setup SinricPro
SinricPro.onConnected([](){ Serial.printf("Connected to SinricPro\r\n"); });
SinricPro.onDisconnected([](){ Serial.printf("Disconnected from SinricPro\r\n"); });
SinricPro.begin(APP_KEY, APP_SECRET);
}
void setup() {
Serial.begin(BAUD_RATE);
Serial.println();
setupWiFi();
setupSinricPro();
}
void loop() {
SinricPro.handle();
}
I tested your code this morning and I got these error messages <img width="1382" alt="Screen Shot 2022-01-12 at 1 15 03 PM" src="https://user-images.githubusercontent.com/3778135/149222675-6333b806-6747-469a-8fc5
-015e3faed8ec.png"> .
The return type of the callback functions must be bool
not void
- sorry for this confusion.
Here is the correct sketch:
// Uncomment the following line to enable serial debug output
//#define ENABLE_DEBUG
#ifdef ENABLE_DEBUG
#define DEBUG_ESP_PORT Serial
#define NODEBUG_WEBSOCKETS
#define NDEBUG
#endif
#include <Arduino.h>
#ifdef ESP8266
#include <ESP8266WiFi.h>
#endif
#ifdef ESP32
#include <WiFi.h>
#endif
#include "SinricPro.h"
#include "SinricProGarageDoor.h"
#define WIFI_SSID ""
#define WIFI_PASS ""
#define APP_KEY ""
#define APP_SECRET ""
#define GARAGEDOOR_ID1 "" // Toyota Garage
#define GARAGEDOOR_ID2 "" // BMW Garage
#define GARAGEDOOR_ID3 "" // Lamborghini Garage
#define BAUD_RATE 9600 // Change baudrate to your need
bool onDoorState1(const String& deviceId, bool& state) {
// do whatever when door 1 state changes
return true;
}
bool onDoorState2(const String& deviceId, bool& state) {
// do whatever when door 2 state changes
return true;
}
bool onDoorState3(const String& deviceId, bool& state) {
// do whatever when door 3 state changes
return true;
}
void setupWiFi() {
Serial.print("[WiFi]: Connecting");
WiFi.begin(WIFI_SSID, WIFI_PASS);
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(250);
}
Serial.println("connected!");
Serial.printf("[WiFi]: IP-Address is %s\r\n", WiFi.localIP().toString().c_str());
}
void setupSinricPro() {
SinricProGarageDoor& myGarageDoor1 = SinricPro[GARAGEDOOR_ID1];
myGarageDoor1.onDoorState(onDoorState1);
SinricProGarageDoor &myGarageDoor2 = SinricPro[GARAGEDOOR_ID2];
myGarageDoor2.onDoorState(onDoorState2);
SinricProGarageDoor &myGarageDoor3 = SinricPro[GARAGEDOOR_ID3];
myGarageDoor3.onDoorState(onDoorState3);
// setup SinricPro
SinricPro.onConnected([](){ Serial.printf("Connected to SinricPro\r\n"); });
SinricPro.onDisconnected([](){ Serial.printf("Disconnected from SinricPro\r\n"); });
SinricPro.begin(APP_KEY, APP_SECRET);
}
void setup() {
Serial.begin(BAUD_RATE);
Serial.println();
setupWiFi();
setupSinricPro();
}
void loop() {
SinricPro.handle();
}
Please not that this sketch has no function.
it only work for myGarageDoor2, when I press other buttons nothing happens and i get this on my Serial monitor: load 0x4010f000, len 3460, room 16 tail 4 chksum 0xcc load 0x3fff20b8, len 40, room 4 tail 4 chksum 0xc9 csum 0xc9 v000653d0 ~ld
WiFi: IP-Address is 10.0.1.6 Connected to SinricPro
This is the code I am using.
#include <WiFi.h>
bool onDoorState1(const String& deviceId, bool &doorState) { Serial.printf("Garagedoor is %s now.\r\n", doorState?"closed":"open");
if(GARAGEDOOR_ID1== "61de6f4eb484c17bc567d323" ){ // Lamborghini Garage Serial.print("Lamborghini Garage is open"); Serial.println(GARAGEDOOR_ID1); digitalWrite(D1,HIGH); delay(1000); digitalWrite(D1,LOW); return true; }
} bool onDoorState2(const String& deviceId, bool &doorState) { Serial.printf("Garagedoor is %s now.\r\n", doorState?"closed":"open");
if (GARAGEDOOR_ID2 == "61de7189b484c17bc567d364"){ // BMW Garage Serial.print("BMW Garage is open"); Serial.println(GARAGEDOOR_ID2); digitalWrite(D7,HIGH); delay(1000); digitalWrite(D7,LOW); return true; }
} bool onDoorState3(const String& deviceId, bool &doorState) { Serial.printf("Garagedoor is %s now.\r\n", doorState?"closed":"open");
if (GARAGEDOOR_ID3 == "61de71c37c2a5a7bcddbbc57"){ // Toyota Garage
Serial.print("Toyota Garage is open");
Serial.println(GARAGEDOOR_ID3);
digitalWrite(D2,HIGH);
delay(1000);
digitalWrite(D2,LOW);
return true;
}
}
void setupWiFi() { Serial.printf("\r\n[Wifi]: Connecting"); WiFi.begin(WIFI_SSID, WIFI_PASS);
while (WiFi.status() != WL_CONNECTED) { Serial.printf("."); delay(250); } IPAddress localIP = WiFi.localIP(); Serial.printf("connected!\r\n[WiFi]: IP-Address is %d.%d.%d.%d\r\n", localIP[0], localIP[1], localIP[2], localIP[3]); }
void setupSinricPro() { SinricProGarageDoor &myGarageDoor1 = SinricPro[GARAGEDOOR_ID1]; myGarageDoor1.onDoorState(onDoorState1);
SinricProGarageDoor &myGarageDoor2 = SinricPro[GARAGEDOOR_ID2]; myGarageDoor2.onDoorState(onDoorState2);
SinricProGarageDoor &myGarageDoor3 = SinricPro[GARAGEDOOR_ID3]; myGarageDoor3.onDoorState(onDoorState3);
SinricPro.onConnected([](){ Serial.printf("Connected to SinricPro\r\n"); }); SinricPro.onDisconnected([](){ Serial.printf("Disconnected from SinricPro\r\n"); }); SinricPro.begin(APP_KEY, APP_SECRET); }
void setup() { Serial.begin(BAUD_RATE); Serial.printf("\r\n\r\n"); pinMode(D1,OUTPUT); pinMode(D7,OUTPUT); pinMode(D2,OUTPUT);
setupWiFi(); setupSinricPro(); }
void loop() { SinricPro.handle(); }
I figuer it out!!! Thank you so much for your help!!! Have great day!
Sinricpro dashboard showing only one out of three devices is online. I have deleted and created three device ten times, still only one is online Screen Shot 2022-01-10 at 3.31.38 PM.png