2 # SinricPro (ESP8266 / ESP32 SDK)
6 ### VS Code & PlatformIO:
7 1. Install [VS Code](https://code.visualstudio.com/)
8 2. Install [PlatformIO](https://platformio.org/platformio-ide)
9 3. Install **SinricPro** library by using [Library Manager](https://docs.platformio.org/en/latest/librarymanager/)
10 4. Use included [platformio.ini](examples/platformio/platformio.ini) file from examples to ensure that all dependent libraries will installed automaticly.
12 
15 1. Open Library Manager (*Tools / Manage Libraries*)
16 2. Search for *SinricPro* and click *Install*
17 3. Repeat step 2 for all [dependent libraries](#dependencies)!
18 4. Open example in ArduinoIDE (*File / Examples / SinricPro / ...*)
20 
25 [ArduinoJson](https://github.com/bblanchon/ArduinoJson) by Benoit Blanchon (minimum Version 6.12.0)
26 [WebSockets](https://github.com/Links2004/arduinoWebSockets) by Markus Sattler (minimum Version 2.2.0)
30 ## Full user documentation
31 Please see here for [full user documentation](https://sinricpro.github.io/esp8266-esp32-sdk)
36 See [examples](https://github.com/sinricpro/esp8266-esp32-sdk/tree/master/examples) on GitHub
41 ### Include SinricPro-Library (SinricPro.h) and SinricPro-Device-Libraries (eg. SinricProSwitch.h)
43 #include <SinricPro.h>
44 #include <SinricProSwitch.h>
47 ### Define your credentials from SinricPro-Portal (portal.sinric.pro)
49 #define APP_KEY "YOUR-APP-KEY" // Should look like "de0bxxxx-1x3x-4x3x-ax2x-5dabxxxxxxxx"
50 #define APP_SECRET "YOUR-APP-SECRET" // Should look like "5f36xxxx-x3x7-4x3x-xexe-e86724a9xxxx-4c4axxxx-3x3x-x5xe-x9x3-333d65xxxxxx"
51 #define SWITCH_ID "YOUR-DEVICE-ID" // Should look like "5dc1564130xxxxxxxxxxxxxx"
54 ### Define callback routine(s)
56 bool onPowerState(const String &deviceId, bool &state) {
57 Serial.printf("device %s turned %s\r\n", deviceId.c_str(), state?"on":"off");
58 return true; // indicate that callback handled correctly
64 // create and add a switch to SinricPro
65 SinricProSwitch& mySwitch = SinricPro[SWITCH_ID];
66 // set callback function
67 mySwitch.onPowerState(onPowerState);
69 SinricPro.begin(APP_KEY, APP_SECRET);
79 ## How to add a device?
82 DeviceType& myDevice = SinricPro[DEVICE_ID];
86 SinricProSwitch& mySwitch = SinricPro["YOUR-SWITCH-ID-HERE"];
88 *Example 2 (alternatively)*
90 SinricProSwitch& mySwitch = SinricPro.add<SinricProSwitch>("YOUR-SWITCH-ID-HERE");
94 ## How to retrieve a device for sending an event?
97 DeviceType& myDevice = SinricPro[DEVICE_ID];
101 SinricProDoorbell& myDoorbell = SinricPro["YOUR-DOORBELL-ID-HERE"];
102 myDoorbell.sendDoorbellEvent();
105 *Example 2 (alternatively)*
107 SinricPro["YOUR-DOORBELL-ID-HERE"].as<SinricProDoorbell>().sendDoorbellEvent();
120 * Fan (US and non US version)
126 * Windows Air Conditioner