Giter Site home page Giter Site logo

sinricpro / esp8266-esp32-sdk Goto Github PK

View Code? Open in Web Editor NEW
218.0 17.0 121.0 6.02 MB

Library for https://sinric.pro - simple way to connect your device to Alexa, Google Home, SmartThings and cloud

Home Page: https://sinric.pro

C++ 98.64% C 1.36%
esp8266 esp32 iot google-home alexa-skill platformio arduino

esp8266-esp32-sdk's Introduction

SinricPro (ESP8266 / ESP32 / RP2040)

arduino-library-badge PlatformIO Registry

Platform ESP8266 Platform ESP32 Raspberry Pi RP2040

Framework

GitHub release (latest by date)

Build

Build

Discord

Installation

VS Code & PlatformIO:

  1. Install VS Code
  2. Install PlatformIO
  3. Create a new Project
  4. Use the Library Manager to add the library to your project or add sinricpro/SinricPro manually to your lib_deps in platformio.ini.

sinricpro library manager

ArduinoIDE

  1. Open Library Manager (Tools / Manage Libraries)
  2. Search for SinricPro and click Install
  3. Repeat step 2 for all dependent libraries!
  4. Open example in ArduinoIDE (File / Examples / SinricPro / ...)

ArduinoIDE Library Manager


Dependencies

  • ArduinoJson by Benoit Blanchon (minimum Version 7.0.3)
  • WebSockets by Markus Sattler (minimum Version 2.4.0)

Full user documentation

Please see here for full user documentation


Examples

See examples on GitHub


Usage

Include SinricPro-Library (SinricPro.h) and SinricPro-Device-Libraries (eg. SinricProSwitch.h)

#include <SinricPro.h>
#include <SinricProSwitch.h>

Define your credentials from SinricPro-Portal (portal.sinric.pro)

#define APP_KEY    "YOUR-APP-KEY"    // Should look like "de0bxxxx-1x3x-4x3x-ax2x-5dabxxxxxxxx"
#define APP_SECRET "YOUR-APP-SECRET" // Should look like "5f36xxxx-x3x7-4x3x-xexe-e86724a9xxxx-4c4axxxx-3x3x-x5xe-x9x3-333d65xxxxxx"
#define SWITCH_ID  "YOUR-DEVICE-ID"  // Should look like "5dc1564130xxxxxxxxxxxxxx"

Define callback routine(s)

bool onPowerState(const String &deviceId, bool &state) {
  Serial.printf("device %s turned %s\r\n", deviceId.c_str(), state?"on":"off");
  return true; // indicate that callback handled correctly
}

In setup()

  // create and add a switch to SinricPro
  SinricProSwitch& mySwitch = SinricPro[SWITCH_ID];
  // set callback function
  mySwitch.onPowerState(onPowerState);
  // startup SinricPro
  SinricPro.begin(APP_KEY, APP_SECRET);

In loop()

  SinricPro.handle();

How to add a device?

Syntax is

  DeviceType& myDevice = SinricPro[DEVICE_ID];

Example

  SinricProSwitch& mySwitch = SinricPro["YOUR-SWITCH-ID-HERE"];

How to retrieve a device for sending an event?

Syntax is

  DeviceType& myDevice = SinricPro[DEVICE_ID];

Example

  SinricProDoorbell& myDoorbell = SinricPro["YOUR-DOORBELL-ID-HERE"];
  myDoorbell.sendDoorbellEvent();

How to send a push notification?

SinricProSwitch& mySwitch = SinricPro[SWITCH_ID];
mySwitch.sendPushNotification("Hello SinricPro!");

Devices

  • Switch
  • Dimmable Switch
  • Light
  • TV
  • Speaker
  • Thermostat
  • Fan (US and non US version)
  • Lock
  • Doorbell
  • Temperaturesensor
  • Motionsensor
  • Contactsensor
  • Windows Air Conditioner
  • Interior Blinds
  • Garage Door
  • Custom devices

Join the community!

Join us on our Official Discord Server!

esp8266-esp32-sdk's People

Contributors

fngstudios avatar italo-coelho avatar jpa-welten avatar kakopappa avatar sivar2311 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

esp8266-esp32-sdk's Issues

Alexa status update

I would like the following help: I ​​am mounting with the ESP-12 a module with light. I felt the need to put the button on / off manually, but could not get the command to update the light state (on or off) in the Alexa application.
NOTE: I have assembled other modules like Plugs and I was able to do it, but I didn't find a command that would update when it comes to light.

void ManualCommand () {
unsigned long TempoNow = millis ();

if (digitalRead (PinKey_1) == LOW && TimeNow - TimeButton> 1000) {// This prevents button replication
if (device_state.powerState) {// Invert the current value
device_state.powerState = false;
} else {
device_state.powerState = true;
}

// Here I turn on the light
onPowerState (LIGHT_ID, device_state.powerState);

// The following command does not update the Alexa application.
setupSinricPro ();

TimeButton = TimeNow; // update last button press variable

}
}

Thanks to anyone who can help.

sinricPro doorbell

Hi,
Help please. I having trouble getting the doorbell example working using the arduino example on a nodemcu using the flash button as per the doorbell example given. I've enabled the alex sinricPro skill and created the device on sinricPro. Alexa finds the doorbell all ok and gives me the settings for it etc.
All of that looks good and when I run the code I get the following on the serial port: (x's below to hide detail)
oOo
connected to BTHub6-xxxxx
IP address: 192.168.1.xxx
[SinricPro:add()]: Adding device with id "5de3974a553d0dxxxxxxxxxx".
[SinricPro:Websocket]: Connecting to WebSocket Server (ws.sinric.pro)
[SinricPro:Websocket]: headers:
appkey:f5dd293a-8ad0-42ec-865e-88xxxxxxxxxx
deviceids:5de3974a553d0dxxxxxxxxxx
restoredevicestates:false
platform:ESP8266
version:2.2.6
[SinricPro:sendMessage()]: pushing message into sendQueue
send doorbell event (<<< this is my text to confirm flash button press works)
[SinricPro:sendMessage()]: pushing message into sendQueue
send doorbell event (<<< and again)
oOo
But, no door bell sound from alexa when the nodemcu button pressed. On the SinricPro 'dashboard' it shows my doorbell device but says "0 Online" "1 Offline" and "power is off".

If I click on the doorbell symbol on the dashboard I do get the correct door bell sound/notification, but won't work using the nodemcu button.

I'm probably doing or not doing something stupid but don't know what that is! Your comments please.
Regards, Steve

fan

hi !
I set level 1, 2 or 3 then monitor Serial only print :
Fan turned on
Fan speed changed to 0
Fan speed changed to 0
Fan speed changed to 0.
Can you help me?

sinricpro temperature

hello, I can't read the temperature in the sinric pro dashboard of my sinricpro device, I have used this code. the device is online.this is the code://#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 "SinricProThermostat.h"

#define WIFI_SSID "w"
#define WIFI_PASS "a"
#define APP_KEY "b" // Should look like "de0bxxxx-1x3x-4x3x-ax2x-5dabxxxxxxxx"
#define APP_SECRET "4" // Should look like "5f36xxxx-x3x7-4x3x-xexe-e86724a9xxxx-4c4axxxx-3x3x-x5xe-x9x3-333d65xxxxxx"
#define THERMOSTAT_ID "" // Should look like "5dc1564130xxxxxxxxxxxxxx"
#define BAUD_RATE 9600 // Change baudrate to your need

define DHTTYPE DHT11

#include <DHT.h>
#define THERMOSTAT_PIN 17
float globalTemperature;
bool globalPowerState;

bool onPowerState(const String &deviceId, bool &state) {
Serial.printf("Thermostat %s turned %s\r\n", deviceId.c_str(), state?"on":"off");
globalPowerState = state;
return true; // request handled properly
}

bool onTargetTemperature(const String &deviceId, float &temperature) {
Serial.printf("Thermostat %s set temperature to %f\r\n", deviceId.c_str(), temperature);
globalTemperature = temperature;
return true;
}

bool onAdjustTargetTemperature(const String & deviceId, float &temperatureDelta) {
globalTemperature += temperatureDelta; // calculate absolut temperature
Serial.printf("Thermostat %s changed temperature about %f to %f", deviceId.c_str(), temperatureDelta, globalTemperature);
temperatureDelta = globalTemperature; // return absolut temperature
return true;
}

bool onThermostatMode(const String &deviceId, String &mode) {
Serial.printf("Thermostat %s set to mode %s\r\n", deviceId.c_str(), mode.c_str());
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() {
SinricProThermostat &myThermostat = SinricPro[THERMOSTAT_ID];
myThermostat.onPowerState(onPowerState);
myThermostat.onTargetTemperature(onTargetTemperature);
myThermostat.onAdjustTargetTemperature(onAdjustTargetTemperature);
myThermostat.onThermostatMode(onThermostatMode);

// 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");
pinMode(THERMOSTAT_PIN, INPUT);
setupWiFi();
setupSinricPro();
}

void loop() {
SinricPro.handle();

}

Alexa skill in Italy

Hello, after done all the steps to configure my device I figured out your Alexa skill isn't available yet in Italy. Do you know when it will be?

which pins are used

Hello everyone from Italy, questions: which pins are used? example, DimSwitch pin used? where can I change the pin layout.
Thanks and sorry my english/google

Repeat an announcement from Alexa

What do I need to repeat a "Alexa" announcement; while the state of the contact sensor is "open?"

I have code that can be used for the interval in minutes. Is it possible to do with this Skill set?

I am afraid one "Alexa" says, "Garage door is open" will not be enough.

William

Smart Door Lock

hello, I am using Sinric Pro to use it for Smart Door Lock.
I am using NodeMCU, Micro Servo 9G motor to make it Smart Lock.
But i am having trouble rotating the servo motor using the Smart Lock code.
Can anyone help me solve this issue.

''

// 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 "SinricProLock.h"

#define WIFI_SSID "Mitali"
#define WIFI_PASS "mitalibakliwal"
#define APP_KEY "ad6378e2-fee5-4e15-ad09-e3fe3a7647ee" // Should look like "de0bxxxx-1x3x-4x3x-ax2x-5dabxxxxxxxx"
#define APP_SECRET "93210423-960b-4462-ae98-9fb614239ba5-519c2868-7307-45c6-8e9e-b844bf47a42e" // Should look like "5f36xxxx-x3x7-4x3x-xexe-e86724a9xxxx-4c4axxxx-3x3x-x5xe-x9x3-333d65xxxxxx"
#define LOCK_ID "5e5cc22286622d498dd52345" // Should look like "5dc1564130xxxxxxxxxxxxxx"
#define BAUD_RATE 9600 // Change baudrate to your need

bool onLockState(String deviceId, bool &lockState) {
Serial.printf("Device %s is %s\r\n", deviceId.c_str(), lockState?"locked":"unlocked");
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() {
SinricProLock &myLock = SinricPro[LOCK_ID];
myLock.onLockState(onLockState);

// 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();
}
''

Doesn't Compile

Hi, I tried to change from Sinric to SinricPro, but when I tried the switch example the Arduino Ide wouldn't verify the code. It seems like an error from the WebSocketsClient but I made sure to download and include all libraries needed from Github. My goal is to use sinrinc on the ESP8622, can someone help me? This is the error.

Arduino: 1.8.11 (Windows 7), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, Flash, Disabled, All SSL ciphers (most compatible), 4M (no SPIFFS), v2 Lower Memory, Disabled, None, Only Sketch, 9600"

In file included from C:\Users\Phil\Documents\Arduino\libraries\esp8266-esp32-sdk-master\src/SinricPro.h:13:0,

             from C:\Users\Phil\AppData\Local\Temp\arduino_modified_sketch_35775\Switch.ino:34:

C:\Users\Phil\Documents\Arduino\libraries\esp8266-esp32-sdk-master\src/SinricProWebsocket.h: In member function 'void websocketListener::begin(String, String, String, SinricProQueue_t*)':

C:\Users\Phil\Documents\Arduino\libraries\esp8266-esp32-sdk-master\src/SinricProWebsocket.h:100:13: error: 'class WebSocketsClient' has no member named 'enableHeartbeat'

webSocket.enableHeartbeat(WEBSOCKET_PING_INTERVAL, WEBSOCKET_PING_TIMEOUT, WEBSOCKET_RETRY_COUNT);

         ^

Multiple libraries were found for "WebSocketsClient.h"
Used: C:\Users\Phil\Documents\Arduino\libraries\WebSockets
Not used: C:\Users\Phil\Documents\Arduino\libraries\arduinoWebSockets-master
exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

A push button? Relay?

Hi

I have had a door opener for my garage door for years using Fauxmo. As you have rightly said, this way is flawed and in recent weeks trying to fix it, I have discovered Sinric and think it is a great solution.
I have an ESP32 connected to a relay that operates a remote (to the garage) push switch. I only need it to press it, not to check the state or open/close. Just turn on very briefly to tell the lifter unit to open the door.
I have used the Switch sketch and it does the job but, I presume as expected, it turns on and stays on or turns off and stays off. So I can get it to operate like this but it's not quite the right way and will constantly (electronically) hold the push button down rather than just pressing and letting go.
I have tried putting in a delay and then telling it to turn off, but it is having no effect.
Is there a sketch that is better suited to this idea? Or should I persevere with adapting Switch?
I am usually okay at adapting other's code but not writing my own from scratch.

I am obviously missing something but I added the delay and what I thought might turn it off here:
I presumed digitalwrite turns on/off the LED and the pin? I also tried switching HIGH and LOW around to no avail.

void handleButtonPress() {
unsigned long actualMillis = millis(); // get actual millis() and keep it in variable actualMillis
if (digitalRead(BUTTON_PIN) == LOW && actualMillis - lastBtnPress > 1000) { // is button pressed (inverted logic! button pressed = LOW) and debounced?
if (myPowerState) { // flip myPowerState: if it was true, set it to false, vice versa
myPowerState = false;
} else {
myPowerState = true;
}
digitalWrite(LED_PIN, myPowerState?LOW:HIGH); // if myPowerState indicates device turned on: turn on led (builtin led uses inverted logic: LOW = LED ON / HIGH = LED OFF)
delayMicroseconds(5000);
digitalWrite(LED_PIN, myPowerState?HIGH:LOW);

// get Switch device back
SinricProSwitch& mySwitch = SinricPro[SWITCH_ID];
// send powerstate event
mySwitch.sendPowerStateEvent(myPowerState); // send the new powerState to SinricPro server
Serial.printf("Device %s turned %s (manually via flashbutton)\r\n", mySwitch.getDeviceId(), myPowerState?"on":"off");

lastBtnPress = actualMillis;  // update last button press variable

}
}

Alexa Routines

I would like to create a routine on Alexa where one Sinric device could trigger another. When configuring the routine (when this happens -> Smart Home) Sinric devices do not appear in the smart home group. They only appear in the second step (Add action). Do you have a solution?
Thanks

Device not supported in Alexa's Routine

Hi, I tried to do a routine using the event of a Sinricpro contact sensor and doorbell but in both case Alexa tell me: "ERROR, device not supported".
Do you know why? maybe in Italy this function is not implemented yet? (I didn't tried with original doorbells or contact sensor from other brands.)

Multiple Input and Output

Hi, with the switch example I was able to add a physical toggle switch and activate a device with it. Would it be possible to add more switch and devices on the same ESP8266 (4 Switch and 4 Device)? How could I modify my code to achieve that? Thanks.

`
// 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 "SinricProSwitch.h"

#define WIFI_SSID ""
#define WIFI_PASS ""
#define APP_KEY "" // Should look like "de0bxxxx-1x3x-4x3x-ax2x-5dabxxxxxxxx"
#define APP_SECRET "" // Should look like "5f36xxxx-x3x7-4x3x-xexe-e86724a9xxxx-4c4axxxx-3x3x-x5xe-x9x3-333d65xxxxxx"
#define SWITCH_ID "" // Should look like "5dc1564130xxxxxxxxxxxxxx"
#define BAUD_RATE 9600 // Change baudrate to your need

bool myPowerState = false;
int device_1 = 5;
int pass_1 = 0;
int storedvalue_1 = 0;
int switch_1 = 13;

bool onPowerState(const String &deviceId, bool &state) {
Serial.printf("Device %s turned %s (via SinricPro) \r\n", deviceId.c_str(), state?"on":"off");
myPowerState = state;
digitalWrite(device_1, myPowerState?HIGH:LOW);
return true; // request handled properly
}

void handleButtonPress() {
if(pass_1 == 0)
{
storedvalue_1 = digitalRead(switch_1);
pass_1 = 1;
}
if(storedvalue_1 != digitalRead(switch_1))
{
if (myPowerState) { // flip myPowerState: if it was true, set it to false, vice versa
myPowerState = false;
} else {
myPowerState = true;
}
digitalWrite(device_1, myPowerState?LOW:HIGH); // if myPowerState indicates device turned on: turn on led (builtin led uses inverted logic: LOW = LED ON / HIGH = LED OFF)
SinricProSwitch& mySwitch = SinricPro[SWITCH_ID];
mySwitch.sendPowerStateEvent(myPowerState); // send the new powerState to SinricPro server
Serial.printf("Device %s turned %s (manually via flashbutton)\r\n", mySwitch.getDeviceId(), myPowerState?"on":"off");
digitalWrite(device_1, myPowerState?HIGH:LOW);
delay(1000);
storedvalue_1 = digitalRead(switch_1);
pass_1 = 0;
}
}
// 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);
}
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]);
}

// setup function for SinricPro
void setupSinricPro() {
// add device to SinricPro
SinricProSwitch& mySwitch = SinricPro[SWITCH_ID];

// set callback function to device
mySwitch.onPowerState(onPowerState);

// 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);
}

// main setup function
void setup() {
pinMode(device_1, OUTPUT); // define LED GPIO as output
digitalWrite(device_1, LOW); // turn off LED on bootup
pinMode(switch_1, INPUT);

Serial.begin(BAUD_RATE); Serial.printf("\r\n\r\n");
setupWiFi();
setupSinricPro();
}

void loop() {
handleButtonPress();
SinricPro.handle();
}`

WemosD1 Mini doesn`t enter in local WIFI-Network

Hey guys, dont ask me why, I am a newbie in SinricPro, but it seems like my WemosD1 mini isnt able to enter in my local WIFI-area. Compiling and uploading a sketch on it works well, after it appears the buildin LED and blinks in tact (about 5Hz). If I now open the serial monitor I get this report(again and again): What does is mean??

Exception (28):
epc1=0x4021483e epc2=0x00000000 epc3=0x00000000 excvaddr=0x000000c0 depc=0x00000000

stack>>>

ctx: cont
sp: 3ffffb90 end: 3fffffc0 offset: 01a0
3ffffd30: 3ffffe30 000000c0 3ffffd90 40212e35
3ffffd40: 00000000 4023bf17 3ffed69c 00000022
3ffffd50: 3ffe8304 00000022 3ffffe30 40216e1a
3ffffd60: 3ffefd17 3ffe8874 00000009 3ffedde0
3ffffd70: 3ffe8de0 3ffe8de0 3ffefa07 3ffe8898
3ffffd80: 00000000 3ffe8897 3ffffe30 4021724b
3ffffd90: 00000000 ffffffff 00000000 00000000
3ffffda0: 3ffee5d0 00000022 00302073 00000001
3ffffdb0: 00000000 0000304f 4023f927 3ffede88
3ffffdc0: 3ffedec0 4023ff90 3ffedd94 00000000
3ffffdd0: 00fed750 4023f89c 3ffed69c 00000012
3ffffde0: 4023d918 4023d8ec 00000000 00000012
3ffffdf0: 3fffff60 3fffff30 0000000c 3ffe8304
3ffffe00: 4023de68 00000009 00000001 4023ff90
3ffffe10: 4023d895 3ffed818 00000002 3ffeef00
3ffffe20: 3ffeedd0 3ffe8304 00000040 402147ed
3ffffe30: 3fffff02 3ffe8514 0000001d ffff0208
3ffffe40: 3ffffee0 0000003f 3ffe885d 00000001
3ffffe50: 3ffef60c 40205378 3ffe885d 3ffe885d
3ffffe60: 40205555 40205531 3ffe8867 4020555b
3ffffe70: 33584e47 44353236 6f430043 63656e6e
3ffffe80: 676e6974 feefef00 feefeffe 4020ade8
3ffffe90: 3ffffee1 00000000 3358002e 4020cf01
3ffffea0: 3ffffee1 00000008 3ffeedd0 40214830
3ffffeb0: 3fffff60 3fffff30 00000008 00000001
3ffffec0: 3ffeedd0 00000008 3ffffee0 4020aaa8
3ffffed0: 80e33400 3fe4d205 00000008 4020ad98
3ffffee0: 6e6e6f63 65746365 0a0d2164 4669575b
3ffffef0: 203a5d69 412d5049 65726464 69207373
3fffff00: 44352073 4e375154 465a5648 40100a00
3fffff10: 4020cf99 feefeffe feefeffe feefeffe
3fffff20: 3fffff60 3fffff30 00000008 4020d2ab
3fffff30: 401052a9 0009bad0 000000c0 000000a8
3fffff40: 00000001 0000009d 3ffeed90 00000001
3fffff50: 3ffe8874 3fffff80 3fffff30 3fffff60
3fffff60: 9d01a8c0 00ffffff fe01a8c0 3ffeef00
3fffff70: 3fffdad0 3ffeed90 3ffeedd0 40201b5c
3fffff80: 40210a28 9d01a8c0 00000000 3ffeef00
3fffff90: 3fffdad0 00000000 3ffeedd0 40204821
3fffffa0: feefeffe feefeffe 3ffeeec0 4020bff0
3fffffb0: feefeffe feefeffe 3ffe8530 40100ce9
<<<stack<<<
⸮⸮⸮�!⸮@ȅ⸮

To understand what I did, I post the sketch below

`#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>

#include <SinricPro.h>
#include <SinricProSwitch.h>
#define WIFI_SSID "GNX1000DQ"
#define WIFI_PASS "TD7DTZ7NKLZF"
#define APP_KEY "a521bac6-c522-4aad-9f5a-3e8dd446bgg6"
#define APP_SECRET "35oc0c2f-4b22-4085-b7dc-8d5afd9dce9d-b4de63d6-d56c-41dd-b54x-2858105ed8bd"
#define BAUD_RATE 9600
#define SWITCH_ID "5e4da6097a70145df3855555"
#define LED_PIN 20

bool myPowerState = false;

bool onPowerState(const String &deviceId, bool &state) {
Serial.printf("device %s turned %s\r\n", deviceId.c_str(), state ? "on" : "off");
myPowerState = state;
digitalWrite(LED_PIN, myPowerState?LOW:HIGH);
return true;
}
void setupWiFi() {
Serial.printf("\r\nWifi: Connecting");
WiFi.begin(WIFI_SSID, WIFI_PASS);

while (WiFi.status() != WL_CONNECTED) {
Serial.printf(".");
delay(250);
}
IPAddress localIP = WiFi.localIP();
Serial.printf("connected!\r\nWiFi: IP-Address is %s\r\n", localIP[0], localIP[1], localIP[2], localIP[3]);
}
void setupSinricPro() {
SinricProSwitch& mySwitch = SinricPro[SWITCH_ID];
mySwitch.onPowerState(onPowerState);
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() {
pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, HIGH);
Serial.begin(BAUD_RATE); Serial.printf("\r\n\r\n");
setupWiFi();
setupSinricPro();
}
void loop() {
SinricPro.handle();
}`

It would be verry nice if someone could help me on finding the error
Thanks in the meantime

Wrong parameter declaration for adjustable level/power functions in Examples

In example DimSwitch the function declared as:
bool onAdjustPowerLevel(const String &deviceId, int levelDelta)
should be:
bool onAdjustPowerLevel(const String &deviceId, int &levelDelta)

asking Alexa to change power level is giving an error, with the new declaration everything is fine.

I suppose al examples that use adjustable levels must be checked.

Door bell

Door bell code. I pressed the button but Alexa didn't ding dong.
Device returned an error. : Device returned an error while processing the request!

SinricP Doorbell - websockets problem??

Hi,
I'm still trying hard to get the doorbell working. I'm using all the latest libraries (note: vs 2.2.6 was same) and the original code etc, using platformio on a nodemcu. Sometimes when I compile it works absolutely fine, press the button and alexa does what she should. Other times and most often it fails to start properly - please see terminal output below (debug on). I dont think its my router because everything I've got on original sinric is still working 100%. It looks to me (non expert eye) that its some kind of websockets timeout issue. That's the only explanation I've got, but why does it work sometimes and not others...

I would really appreciate your help please. Terminal output as follows:
SDK:2.2.2-dev(38a443e)/Core:2.6.3=20603000/lwIP:STABLE-2_1_2_RELEASE/glue:1.2-16-ge23a07e/BearSSL:89454af

state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 6
cnt

connected with BTHub6-xxxxx, channel 11
dhcp client start...
....ip:192.168.x.xxx,mask:255.255.255.0,gw:192.168.x.xxx
connected!
WiFi: IP-Address is 192.168.x.xxx
[SinricPro:add()]: Adding device with id "5de3974a5xxxxxxxxxxxxxxxx".
[SinricPro:Websocket]: Connecting to WebSocket Server (ws.sinric.pro)
[SinricPro:Websocket]: headers:
appkey:f5dd293a-8ad0-xxxx-xxxx-xxxxxxxxxxxx
deviceids:5de3974a553xxxxxxxxxxxxx
restoredevicestates:false
platform:ESP8266
version:2.2.7
[WS-Client] connect ws...
[WS-Client] connected to ws.sinric.pro:80.
[WS-Client][sendHeader] sending header...
[WS-Client][sendHeader] handshake GET / HTTP/1.1
Host: ws.sinric.pro:80
Connection: Upgrade
Upgrade: websocket
Sec-WebSocket-Version: 13
Sec-WebSocket-Key: woG190jRBoTZcY4NwXar6Q==
Sec-WebSocket-Protocol: arduino
appkey:f5dd293a-8ad0-xxxx-xxxx-xxxxxxxxxxxx
deviceids:5de3974axxxxxxxxxxxxxxxx
restoredevicestates:false
platform:ESP8266
version:2.2.7
User-Agent: arduino-WebSocket-Client

[write] n: 367 t: 7126
[WS-Client][sendHeader] sending header... Done (33927us).
[WS-Client][handleHeader] RX: HTTP/1.1 101 Switching Protocols
[WS-Client][handleHeader] RX: Server: nginx
[WS-Client][handleHeader] RX: Date: Tue, 17 Dec 2019 20:56:39 GMT
[WS-Client][handleHeader] RX: Connection: upgrade
[WS-Client][handleHeader] RX: Upgrade: websocket
[WS-Client][handleHeader] RX: Sec-WebSocket-Accept: bCCnndFQKswdSP7/ex9TKFqCDYk=
[WS-Client][handleHeader] RX: Sec-WebSocket-Protocol: arduino
[WS-Client][handleHeader] Header read fin.
[WS-Client][handleHeader] Client settings:
[WS-Client][handleHeader] - cURL: /
[WS-Client][handleHeader] - cKey: woG190jRBoTZcY4NwXar6Q==
[WS-Client][handleHeader] Server header:
[WS-Client][handleHeader] - cCode: 101
[WS-Client][handleHeader] - cIsUpgrade: 1
[WS-Client][handleHeader] - cIsWebsocket: 1
[WS-Client][handleHeader] - cAccept: bCCnndFQKswdSP7/ex9TKFqCDYk=
[WS-Client][handleHeader] - cProtocol: arduino
[WS-Client][handleHeader] - cExtensions:
[WS-Client][handleHeader] - cVersion: 0
[WS-Client][handleHeader] - cSessionId:
[WS-Client][handleHeader] Websocket connection init done.
[WS][0][headerDone] Header Handling Done.
[SinricPro:Websocket]: connected
[WS][0][handleWebsocketWaitFor] size: 2 cWsRXsize: 0
[readCb] n: 2 t: 7313
[WS][0][handleWebsocketWaitFor][readCb] size: 2 ok: 1
[WS][0][handleWebsocket] ------- read massage frame -------
[WS][0][handleWebsocket] fin: 1 rsv1: 0 rsv2: 0 rsv3 0 opCode: 1
[WS][0][handleWebsocket] mask: 0 payloadLen: 24
[readCb] n: 24 t: 7335
[WS][0][handleWebsocket] text: {"timestamp":1576616199}
[SinricPro:Websocket]: receiving data
[SinricPro.handleReceiveQueue()]: 1 message(s) in receiveQueue
[SinricPro.handleReceiveQueue()]: Signature is valid. Processing message...
[SinricPro:extractTimestamp(): Got Timestamp 1576616199
[HBtimeout] pong TIMEOUT! lp=-290499 millis=10001 pi=10001 count=1
[WS-Client] sending HB ping
[WS][0][sendFrame] ------- send message frame -------
[WS][0][sendFrame] fin: 1 opCode: 9 mask: 1 length: 0 headerToPayload: 0
[write] n: 6 t: 10009
[WS][0][sendFrame] sending Frame Done (3042us).
bcn_timout,ap_probe_send_start
pm open,type:2 0
ap_probe_send over, rest wifi status to disassoc
state: 5 -> 0 (1)
rm 0
pm close 7
[WS-Client] connection lost.
[WS-Client] client disconnected.
[SinricPro:Websocket]: disconnected
[WS-Client] connect ws...
[WS-Client] connection to ws.sinric.pro:80 Failed
[WS-Client] client disconnected.
[WS-Client] connect ws...
[WS-Client] connection to ws.sinric.pro:80 Failed
................etc etc continuously..............

Your comments/advice please.
Regards, Steve

Memory issue

ESP is showing error sometimes and restarting automatically. device is not running stable. Exception decoder showing the below.

  • This was reported by Adi

Decoding stack results
0x40092630: invoke_abort at /Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/esp32/panic.c line 155
0x40092861: abort at /Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/esp32/panic.c line 170
0x401f2353: __cxxabiv1::__terminate(void ()()) at /builds/idf/crosstool-NG/.build/src/gcc-5.2.0/libstdc++-v3/libsupc++/eh_terminate.cc line 47
0x401f239a: std::terminate() at /builds/idf/crosstool-NG/.build/src/gcc-5.2.0/libstdc++-v3/libsupc++/eh_terminate.cc line 57
0x401dfdd3: __cxxabiv1::__cxa_throw(void
, std::type_info*, void ()(void)) at /builds/idf/crosstool-NG/.build/src/gcc-5.2.0/libstdc++-v3/libsupc++/eh_throw.cc line 87
0x401dfffa: operator new(unsigned int) at /builds/idf/crosstool-NG/.build/src/gcc-5.2.0/libstdc++-v3/libsupc++/new_op.cc line 54
0x401dffb1: operator new[](unsigned int) at /builds/idf/crosstool-NG/.build/src/gcc-5.2.0/libstdc++-v3/libsupc++/new_opv.cc line 32
0x400e888f: WiFiUDP::parsePacket() at C:\Users\adi\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.2\libraries\WiFi\src\WiFiUdp.cpp line 210
0x400e9275: NTPClient::forceUpdate() at C:\Users\adi\Documents\Arduino\libraries\NTPClient-master\NTPClient.cpp line 99
0x400e932c: NTPClient::update() at C:\Users\adi\Documents\Arduino\libraries\NTPClient-master\NTPClient.cpp line 129
0x400dcc4b: SinricProClass::handle() at C:\Users\adi\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.2\libraries\SinricPro/SinricProNTP.h line 19

The below line is causing issue from WiFiUDP.cpp. The free heap memory is 36128. not sure if this is problem with memory overflow.
int slen = sizeof(si_other) , len;
char * buf = new char[1460];
if(!buf){

Adding a second dimswitch

Hi,
I am trying to add multiple dimswitches in one sketch like this:
SinricProDimSwitch &myDimSwitch = SinricPro[DIMSWITCH_ID];
SinricProDimSwitch &myDimSwitch2 = SinricPro[DIMSWITCH_ID2];

// set callback function to device
myDimSwitch.onPowerState(onPowerState);
myDimSwitch.onPowerLevel(onPowerLevel);
myDimSwitch.onAdjustPowerLevel(onAdjustPowerLevel);

myDimSwitch2.onPowerState(onPowerState);
myDimSwitch2.onPowerLevel(onPowerLevel);
myDimSwitch2.onAdjustPowerLevel(onAdjustPowerLevel);

I can switch them on and off with no problem but when using the dimfunction of dimswitch2 the deviceId of switch 1 is returned.

Thanks, Ed.

Google home

Hi,
when google home will be integrated?
thanks so mutch,
Andrea

IFTTT

Any thoughts about creating a link over to IFTTT so we can get our Sinric / Alexa events out to other services like sending text messages? e.g., I could use a Sinric device as a trigger for an IFTTT chain when onstate =true... or something. Similar to what Adafruit IO has done?

ESP8266P Monitor if door is open or closed

I am trying to monitor state of door; whether open or closed. I do not understand the command to for Alexa to accomplish this task.

Only response I get from Alexa is "...not responding." I am using the unmodified "ContactSensor.ino" example; except for "defines." I am using a Reed sensor type of switch and can see it open and close in the Serial Monitor:.

WiFi: IP-Address is 172.16.0.2
Contactsensor is open now
Contactsensor is closed now
Contactsensor is open now
Contactsensor is closed now
Contactsensor is open now

Alexa does discover the device. Your code I am using:

``/*

// 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 "SinricProContactsensor.h"

#define WIFI_SSID "Removed"
#define WIFI_PASS "Removed"
#define APP_KEY "Removed" // Should look like "de0bxxxx-1x3x-4x3x-ax2x-5dabxxxxxxxx"
#define APP_SECRET "Removed" // Should look like "5f36xxxx-x3x7-4x3x-xexe-e86724a9xxxx-4c4axxxx-3x3x-x5xe-x9x3-333d65xxxxxx"
#define CONTACT_ID "Removed" // Should look like "5dc1564130xxxxxxxxxxxxxx"
#define BAUD_RATE 9600 // Change baudrate to your need
#define CONTACT_PIN 2 // PIN where contactsensor is connected to
// LOW = contact is open
// HIGH = contact is closed

volatile int state = false;
volatile int flag = false;
const char* door_state = "closed";

bool myPowerState = true; // assume device is turned on
bool lastContactState = false;
bool actualContactState;
unsigned long lastChange = 0;

/**

  • @brief Checks contactsensor connected to CONTACT_PIN
  • If contactsensor state has changed, send event to SinricPro Server
  • state from digitalRead():
  •  HIGH = contactsensor is closed
    
  •  LOW  = contactsensor is open
    

*/

void handleContactsensor() {
if (!myPowerState) return; // if device switched off...do nothing

unsigned long actualMillis = millis();
if (actualMillis - lastChange < 250) return; // debounce contact state transitions (same as debouncing a pushbutton)

bool actualContactState = digitalRead(CONTACT_PIN); // read actual state of contactsensor

if (actualContactState != lastContactState) { // if state has changed
Serial.printf("Contactsensor is %s now\r\n", actualContactState?"open":"closed");
lastContactState = actualContactState; // update last known state
lastChange = actualMillis; // update debounce time
SinricProContactsensor &myContact = SinricPro[CONTACT_ID]; // get contact sensor device
myContact.sendContactEvent(actualContactState); // send event with actual state
}
}

/**

  • @brief Callback for setPowerState request
  • @param deviceId String containing deviceId (useful if this callback used by multiple devices)
  • @param[in] state bool true=turn on device / false=turn off device
  • @param[out] state bool true=device turned on / false=device turned off
  • @return true request handled properly
  • @return false request can't be handled because some kind of error happened
    */
    bool onPowerState(const String &deviceId, bool &state) {
    Serial.printf("Device %s turned %s (via SinricPro) \r\n", deviceId.c_str(), state?"on":"off");
    myPowerState = state;
    return true; // request handled properly
    }

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

while (WiFi.status() != WL_CONNECTED) {
Serial.printf(".");
delay(250);
}
IPAddress localIP = WiFi.localIP();
Serial.printf("connected!\r\nWiFi: IP-Address is %d.%d.%d.%d\r\n", localIP[0], localIP[1], localIP[2], localIP[3]);
}

// setup function for SinricPro
void setupSinricPro() {
// add device to SinricPro
SinricProContactsensor& myContact = SinricPro[CONTACT_ID];

// set callback function to device
myContact.onPowerState(onPowerState);

// 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);
}

// main setup function
void setup() {
Serial.begin(BAUD_RATE); Serial.printf("\r\n\r\n");

pinMode(CONTACT_PIN, INPUT);

setupWiFi();
setupSinricPro();
}

void loop() {
handleContactsensor();
SinricPro.handle();
}

Tried the Garage door example; same result.

Thank you for developing this skill set, examples, and documentation.

Will status monitoring be added?

William

sinricPro - re #17 and #15 (closed)

Hi,
Me again... I'm still battling with the same WS disconnect issue for the past 2weeks. Have spent hours on google researching potential solutions to the troublesome bcn_timout issue. Please see debug extract below. I have tried NOSLEEP, with and without setting mode STA (recommended on a few posts). Have tried ArduinoIDE, PIO using latest SDK and previous versions just in case. Have loaded both onto a clean PC and tried from scratch with virgin Pro examples. Have tried using iphone as an AP. Have tried multiple nodemcu's (including new one out of the packet) and a miniD1. I wont bore you with the full list of stuff I've tried... Still I cant stop the problem on an esp8266 (both doorbell and the switch examples do the same timout). By the way the legacy sinric stuff I have still compiles/works absolutely fine, I wish I could do the same with sinricPro. It beats me!

BUT, in desperation I bought an esp32 V4 and guess what, it works 100% (on doorbell and switch) with no WS disconnects etc. I'm using all the same code/environment except of course whatever changes the #define ESP32 creates relative to ESP8266.

The only conclusion I can come to is that there is something about the sinricPro libraries that does not like ESP8266.

//extract of debug output - see #17 for the full output//
[WS][0][sendFrame] sending Frame Done (3042us).
bcn_timout,ap_probe_send_start
pm open,type:2 0
ap_probe_send over, rest wifi status to disassoc
state: 5 -> 0 (1)
rm 0
pm close 7
[WS-Client] connection lost
// end//

I'm no C++ expert and have resisted messing with any library files. But could there be a marginal timeout issue causing this(?). Probably not, but I'm clutching at straws here... If you think that might be possible point me in the right direction please and I'll spend time on it.

Eitherway your views would be very welcome please.

Having said all that, let me say the doorbell and switch code is really impressive on ESP32 and simple to use. I've even managed to change the switch example to deal with multiple deviceIDs.

Regards, Steve

Heartbeat not needed?

Things seem to be going fine with my tests of "Pro" and Alexa. I note though that the examples given have dropped the heartbeat code issue that I encountered in the original Sinric implementation. I'm assuming you've taken that into account in your new Pro libraries and are handling it internally. Am I correct?

Ken

Wrong Callback name in SinricProDevice.h and documentation

Hi.

The callback onTargetTemperature in SinricProDevice.h and in the documentation at this link are wrong.

Correct in SinricProDevice.h :

void onTargetTemperatue(TargetTemperatureCallback cb) { targetTemperatureCallback = cb; }

with:

void onTargetTemperature(TargetTemperatureCallback cb) { targetTemperatureCallback = cb; }

and in documentation:

bool onTargetTemperatue(const String &deviceId, float &temperature)

in

bool onTargetTemperatue(const String &deviceId, float &temperature)

Regards

Sinric Pro respond some seconds late

Sometimes i notice Sinric Pro respond to my requests some seconds late (maybe 20 - 30 seconds) and if I've sent more requests in that period of time then the server process those requests all together.
Moreover sometimes Sinric Pro do not respond at all (and it happen too often).
I don't think this problem can be caused by low wifi signal of my esp8266 because I'm very close to my router and because the requests are processed all together I can exclude a sketch issue also... Have you ever noticed this behavior before?

RestoredeviceState Question

Hello Guys,

I've recently started to port my old projects from sinric to sinric pro and I must say the service works much better and it is much more stable and easier to implement.
Back to my question regarding the function restoreDeviceStates.

I've been programming an esp8266 to control my AC unit via IR and the funtion to restore the state works well to restore the ON/OFF state but what about the mode and Setpoint settings ?

Is it possible to enable automatic update temperature and Mode of the thermostat after a restart?
It would be great to have the option to set which settings we would like to restore automatically on restart and not just ON/OFF State. Off course I could also just save my settings in the persistence memory. Anyway just a question for you guys. You are doing a great job !

Reading a digital input

I want monitor a digital signal over an input from my nodemcu. Therefore I tried the GarageDoor.ino and the ContactSensor.ino but in both cases I did not get any answer in Serial Monitor or rather on Alexa App and Sinric Dashboard overview. Serial Monitor tells me only strange strings like:
⸮⸮⸮⸮⸮�!⸮D⸮⸮⸮ ⸮?�)⸮⸮⸮⸮⸮@h
I only needed the current state from a relay. Would also work to read the input over an interrupt (CHANGE), so every time the state changes, SinricPro synchronize it (or what´s the usefullest way)?
sinric pro

error compiling for esp8266.

Hi,
I'm trying to get the doorbell example working on the esp8266 but it errors out in the compile (for the ESP32, it compiles and runs fine). I used the dependency lib versions you listed. Greatful for any help as to where I'm going wrong.

Error below.

Arduino: 1.8.10 (Windows 10), Board: "LOLIN(WEMOS) D1 mini Pro, 80 MHz, Flash, Legacy (new can return nullptr), All SSL ciphers (most compatible), 16MB (FS:14MB OTA:~1019KB), v2 Lower Memory, Disabled, None, Only Sketch, 921600"

In file included from C:\Users\User\Documents\Arduino\libraries\arduinoWebSockets-master\src\libb64\cencode.c:9:0:

C:\Users\User\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.1\cores\esp8266/core_esp8266_features.h:88:1: error: unknown type name 'uint32_t'

inline uint32_t esp_get_cycle_count() attribute((always_inline));

^

In file included from C:\Users\User\Documents\Arduino\libraries\arduinoWebSockets-master\src\libb64\cdecode.c:9:0:

C:\Users\User\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.1\cores\esp8266/core_esp8266_features.h:88:1: error: unknown type name 'uint32_t'

inline uint32_t esp_get_cycle_count() attribute((always_inline));

^

C:\Users\User\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.1\cores\esp8266/core_esp8266_features.h:89:1: error: unknown type name 'uint32_t'

inline uint32_t esp_get_cycle_count() {

^

C:\Users\User\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.1\cores\esp8266/core_esp8266_features.h:89:1: error: unknown type name 'uint32_t'

inline uint32_t esp_get_cycle_count() {

^

C:\Users\User\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.1\cores\esp8266/core_esp8266_features.h: In function 'esp_get_cycle_count':

C:\Users\User\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.1\cores\esp8266/core_esp8266_features.h: In function 'esp_get_cycle_count':

C:\Users\User\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.1\cores\esp8266/core_esp8266_features.h:90:3: error: unknown type name 'uint32_t'

uint32_t ccount;

^

C:\Users\User\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.1\cores\esp8266/core_esp8266_features.h:90:3: error: unknown type name 'uint32_t'

uint32_t ccount;

^

C:\Users\User\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.1\cores\esp8266/core_esp8266_features.h: At top level:

C:\Users\User\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.1\cores\esp8266/core_esp8266_features.h: At top level:

C:\Users\User\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.1\cores\esp8266/core_esp8266_features.h:112:24: error: unknown type name 'uint32_t'

void precache(void *f, uint32_t bytes);

                    ^

C:\Users\User\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.1\cores\esp8266/core_esp8266_features.h:112:24: error: unknown type name 'uint32_t'

void precache(void *f, uint32_t bytes);

                    ^

exit status 1
Error compiling for board LOLIN(WEMOS) D1 mini Pro.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Pinout WEMOS D1 mini

Programming the WEMOS D1 mini I found out that Sinric Pro´s pinout distinguishes from the "normal one"
USUALLY SINRIC PRO
WemosPinD0 = 4 =16
WemosPinD1 = 20 =5
WemosPinD2 = 19 =4
WemosPinD3 = 18 did not find out (tried every number up to 40)
WemosPinD4 = 17 =2
WemosPinD5 = 5 =14
WemosPinD6 = 6 =12
WemosPinD7 = 7 =13
WemosPinD8 = 16 =15
pinout

It isnt a problem, its only a comment, but what`s the number from WemosPinD3?

TV adjust volume callback

Hello. Thank you for this amazing service! I've created a TV device and am handling the callbacks, but I've noticed that the "adjust volume" callback always gets a volumeDelta of 0.
The "set volume" callback gets the correct volume, but "adjust volume" seems to get nothing for JsonObject request_value.

How to use Esp8266 as a Decoder with Speaker type Device ?

Basically, How to use the Speaker Device type.
I would also like to know all the Voice commands available with Alexa.

So what my Idea is that, I use the Following Parts with your Library and Alexa to make a Small Smart Speaker:

  1. TPA3118 Amplifier Module
  2. Two 2.5" Full Range Speakers
  3. NodeMCU (as an Audio Receiver and Decoder) + DAC if needed
  4. and other parts such as DC Power Supply (12V 2A), Female DC Jack, Switch, wires, etc..

Alexa deactivate motion sensor does not work

Motion sensor obeys to "Alexa activate motion sensor" command, however it does not respond to "Alexa deactivate motion sensor". Thanks for your reply.

Juan - via support email

Two, Contact sensors one ESP8266

My application of the "contactsensor,ino" sketch will be for Garage with two doors. Tried to utilize the concept for multiple devices in the switch example; however, I am struck on a redeclaration: "redeclaration of 'SinricProContactsensor& myContact". Any suggestions?

Is this the way to go about adding a second device for the same ESP8266?

William
Two_devices_ContactSensor_NTP.zip

Update problem when send more request in the same time for different data

Hi.

I think so that will be a problem with your last update that data update with different delay for the same request.

I have centralized the request in a loop routine:

  if ( updateState )
  {
      SinricProThermostat& mySensor = SinricPro[SENSOR_ID];
      mySensor.sendTemperatureEvent(temperature, humidity); 
      mySensor.sendTargetTemperatureEvent(humidity);
      mySensor.sendPowerStateEvent(relState);
      if ( isAutoMode )
      {
        mySensor.sendThermostatModeEvent("AUTO"); 
      }
      else
      {
        if (relState == HIGH)
        {
          mySensor.sendThermostatModeEvent("HEAT");       
        }
        else
        {
          mySensor.sendThermostatModeEvent("COOL"); 
        }         
      }
      updateState = false;    
  }

In this situation some features update in different time.

Humidity

Is it not possible to see in the Alexa app or ask for the current humidity value?
I have set both temperature and humidity but I can see and ask only for current temperature.

Many thanks

SinricPro TV Example

Hi sinric developers!
I want de tell you thank you for your job, it's a magic.
I'am a sinric user and i want to switch to the pro version, so is it possible to use "TV/AC examples" to send IR codes using ESP, and how can i modify the sketch to send IR code to each commande if it is possible.
Thank's

trying to read garage door state

I need to read a switch (actually hall effect sensor) to determine if the the garage door is open or closed. I didn't see a way to do this using the garage door interface. I tried adding a switchContact device and it seems to work but I do not know how to get Alexa to tell me the state of the switch. When I check the Alexa app it just shows the switch power state which I think is seperate from the actual switch reading.
garageForUpload.txt

Can not get it to flash please help!

I need a good code for a LOCK i do not see one there so i am just trying to flash a switch one for now.
but getting errors.

             from C:\Users\admin\AppData\Local\Temp\arduino_modified_sketch_633916\Switch.ino:34:

C:\Users\admin\Documents\Arduino\libraries\esp8266-esp32-sdk-master\src/SinricProWebsocket.h: In member function 'void websocketListener::begin(String, String, String, SinricProQueue_t*)':

C:\Users\admin\Documents\Arduino\libraries\esp8266-esp32-sdk-master\src/SinricProWebsocket.h:100:13: error: 'class WebSocketsClient' has no member named 'enableHeartbeat'

webSocket.enableHeartbeat(WEBSOCKET_PING_INTERVAL, WEBSOCKET_PING_TIMEOUT, WEBSOCKET_RETRY_COUNT);

         ^

Multiple libraries were found for "ESP8266WiFi.h"
Used: C:\Users\admin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.0\libraries\ESP8266WiFi
Multiple libraries were found for "SinricPro.h"
Used: C:\Users\admin\Documents\Arduino\libraries\esp8266-esp32-sdk-master
Multiple libraries were found for "ArduinoJson.h"
Used: C:\Users\admin\Documents\Arduino\libraries\ArduinoJson
Not used: C:\Users\admin\Documents\Arduino\libraries\ArduinoJson-6.x
Not used: C:\Users\admin\Documents\Arduino\libraries\CoogleIOT
Not used: C:\Users\admin\Documents\Arduino\libraries\arduino_408104
Multiple libraries were found for "WebSocketsClient.h"
Used: C:\Users\admin\Documents\Arduino\libraries\WebSockets
Not used: C:\Users\admin\Documents\Arduino\libraries\arduinoWebSockets-2.1.0
Multiple libraries were found for "Hash.h"
Used: C:\Users\admin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.0\libraries\Hash
Using library ESP8266WiFi at version 1.0 in folder: C:\Users\admin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.0\libraries\ESP8266WiFi
Using library esp8266-esp32-sdk-master at version 2.2.7 in folder: C:\Users\admin\Documents\Arduino\libraries\esp8266-esp32-sdk-master
Using library ArduinoJson at version 6.13.0 in folder: C:\Users\admin\Documents\Arduino\libraries\ArduinoJson
Using library WebSockets at version 2.1.1 in folder: C:\Users\admin\Documents\Arduino\libraries\WebSockets
Using library Hash at version 1.0 in folder: C:\Users\admin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.0\libraries\Hash
exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).

ESP8266-12E with Blind sketch

Greetings everyone,
first of all thank you for this awesome project. Personally I find it simple enough yet pwerful.
Secondly: Please excuse my ignorance, because I'm totally new and trying to learn. So please expect that I might ask stupid question..
The issue:
I'm trying to apply the Blind example for an ESP8266-12E (AKA Node MCU) but I just can't find the definition of the stepper motor pins (or at least where the stepper should be connected to). Would you be so kind and explain to me how and where should I define the pins and out them into use?
Thank you very much

2 in 1

Hi everyone...
Sorry to bother, but I'm very interested in your project and trying to learn as much as possible.
My question: Would be hard to combine two sketches together?
For instance: I'm using SinricPro on an ESP8266-12E and made a smart light in my room, and I'd love to also connect a sensor (such as DHT11) to the same board. Would that be possible?
Thanks for your patience

Not really an issue but maybe a feature request?

I have a Wemos D1 running a light switch that is running perfectly at the moment unless I lose wifi connection or there's an issue with the Sinric service (this happened today).
The wifi link I've got around by periodically checking for connection and reconnecting if it's dropped out (we have a problem with our router sometimes and it kicks the wifi connections off).
However I seemed to have an issue today where the Alexa routine to switch on the light wouldn't work and when I went to log in to sinric.pro it seemed that the service was unavailable which explained why I couldn't control the light via Alexa.
After a while I checked and the Sinric services were back up ok but I still had no control until I had rebooted the Wemos that runs the switch.

Is there a simple routine that could periodically check for connection to the Sinric service and do a forced reconnect if there's a problem at all?

Would definitely make it a little easier if I can't get to the power supply to reset the board.

PIN High/Low On/Off Controls Reversed

This is probably a very simple fix for the pros out there, but I can't seem to understand what's happening. Was able to find some great code that basically meets my needs. Thanks to the OP on that one. However, what I can't figure out is why the controls are reversed. I have to switch the relay to 'off' on the control device to activate the relay and vice versa.

Have tried re-configuring a couple of ways, but basically the output never matches the Sinric.pro dashboard / Alexa device state. I've checked my relay NC/NO/GND wiring. All is good there. Any other ideas?

typedef struct {
  int pin;
  bool state;
} config_t;
std::map<String, config_t> deviceConfig = {
// SinricPro deviceId        ,  PIN, state (on/high=true, off/low = false) 
  {"5e3468**************", {D1, false}},
  {"5e3469**************", {D2, false}},
  {"5e35d5**************", {D3, false}},
  {"5e35d5**************", {D4, false}}
};

bool onPowerState(String deviceId, bool &state) {
  config_t config = deviceConfig[deviceId]; // get config for corresponding deviceId
  Serial.printf("DeviceId: %s, PIN: %d, state: %s\r\n", deviceId.c_str(), config.pin, state?"on":"off");
  digitalWrite(config.pin, state);
  deviceConfig[deviceId].state = state;
  return true;
}

// 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());
}

void setupSinricPro() {
  for (auto& config : deviceConfig) {
    const char* deviceId = config.first.c_str();
    SinricProSwitch &mySwitch = SinricPro[deviceId];
    mySwitch.onPowerState(onPowerState);
    pinMode(config.second.pin, OUTPUT);
  }

  SinricPro.begin(APP_KEY, APP_SECRET);
  SinricPro.restoreDeviceStates(true);
}

void setup() {
  Serial.begin(BAUD_RATE);
  setupWiFi();
  setupSinricPro();
 }

void loop() {
  SinricPro.handle();
}

Thermostat not returning current temperature

The Thermostat Code does not have a return current temperature function so the Alexa app displays it as -1. How do i go about updating the current temperature on the server?. Thanks!

How to finish Blinds program

I have a stepper motor and I am using the accelstepper library to control it, how can I add the instructions to your blinds example?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.