Last active
September 15, 2021 16:19
-
-
Save kakopappa/ec3a1c664e116a8423ce0a6b33ed7a7d to your computer and use it in GitHub Desktop.
drape and curtain
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//#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 "SinricProBlinds.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 DRAPE_ID "" // Should look like "5dc1564130xxxxxxxxxxxxxx" | |
#define CURTAIN_ID "" // Should look like "5dc1564130xxxxxxxxxxxxxx" | |
#define BAUD_RATE 9600 // Change baudrate to your need | |
int drapeBlindsPosition = 0; | |
int curtainBlindsPosition = 0; | |
bool onDrapePowerState(const String &deviceId, bool &state) { | |
Serial.printf("Drape %s power turned %s \r\n", deviceId.c_str(), state?"on":"off"); | |
digitalWrite(22, HIGH); | |
return true; // request handled properly | |
} | |
bool onDrapeRangeValue(const String &deviceId, int &position) { | |
Serial.printf("Device %s set position to %d\r\n", deviceId.c_str(), position); | |
return true; // request handled properly | |
} | |
bool onDrapeAdjustRangeValue(const String &deviceId, int &positionDelta) { | |
drapeBlindsPosition += positionDelta; | |
Serial.printf("Device %s position changed about %i to %d\r\n", deviceId.c_str(), positionDelta, drapeBlindsPosition); | |
positionDelta = drapeBlindsPosition; // calculate and return absolute position | |
return true; // request handled properly | |
} | |
bool onCurtainPowerState(const String &deviceId, bool &state) { | |
Serial.printf("Curtain %s power turned %s \r\n", deviceId.c_str(), state?"on":"off"); | |
return true; // request handled properly | |
} | |
bool onCurtainRangeValue(const String &deviceId, int &position) { | |
Serial.printf("Device %s set position to %d\r\n", deviceId.c_str(), position); | |
return true; // request handled properly | |
} | |
bool onCurtainAdjustRangeValue(const String &deviceId, int &positionDelta) { | |
curtainBlindsPosition += positionDelta; | |
Serial.printf("Device %s position changed about %i to %d\r\n", deviceId.c_str(), positionDelta, curtainBlindsPosition); | |
positionDelta = curtainBlindsPosition; // calculate and return absolute position | |
return true; // request handled properly | |
} | |
// 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]); | |
} | |
void setupSinricPro() { | |
// get a new Blinds device from SinricPro | |
SinricProBlinds &myDrape = SinricPro[DRAPE_ID]; | |
myDrape.onPowerState(onDrapePowerState); | |
myDrape.onRangeValue(onDrapeRangeValue); | |
myDrape.onAdjustRangeValue(onDrapeAdjustRangeValue); | |
SinricProBlinds &myCurtain = SinricPro[CURTAIN_ID]; | |
myCurtain.onPowerState(onCurtainPowerState); | |
myCurtain.onRangeValue(onCurtainRangeValue); | |
myCurtain.onAdjustRangeValue(onCurtainAdjustRangeValue); | |
// 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(22, OUTPUT); | |
setupWiFi(); | |
setupSinricPro(); | |
} | |
void loop() { | |
SinricPro.handle(); | |
} |
The function of our automatic curtain is
① Open ② Stop ③ Close
3 actions and
③ Setting of operation time (open / stop)
④ Timer setting (wake up at 7:00, etc.)
It's different from the blinds, can you give me a special treatment?
- Open / Stop / Close - I can update the app to add a new screen for Curtain and show Open / Stop / Close buttons
- Open / Stop / Close commands must respond within 8 seconds back to Alexa. This is the Alexa rule, not ours. You should send the response back immediately and process the operation in the background.
- Timer setting (wake up at 7:00, etc.). Schedules will be available in the future version of the app. You can always use Alexa app as well for this
Hello!
I am sorry for late reply.
And thank you for telling me these situation.
By the way,
Could you tell me the situation of v2.13x?
has already been released?
Edit Name, WiFi within 14 days (26/June) (Current Sprint) (v2.13.x)
Okay, Thankyouforyourinformation.
Hello!
Please help me about schedule feature.
I'd like to try the schedule feature, but I can't find it.
The version of the app is v2.13.2, can I use it?
I'm using it on Android.
It’s in the top menu. Check the above picture
…On Tue, 14 Sep 2021 at 2:26 PM nakamuramitsuhiro ***@***.***> wrote:
***@***.**** commented on this gist.
------------------------------
Hello!
Please help me about schedule feature.
I'd like to try the schedule feature, but I can't find it.
The version of the app is v2.13.2, can I use it?
I'm using it on Android.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<https://gist.github.com/ec3a1c664e116a8423ce0a6b33ed7a7d#gistcomment-3892252>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABZAZZX2N4ZY6HQRBUH5TS3UB32IVANCNFSM45EMAN6A>
.
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>.
Thank you for your help.
I could found out it.
What’s the device type of: DRAPESs21?
…On Wed, 15 Sep 2021 at 7:54 AM nakamuramitsuhiro ***@***.***> wrote:
***@***.**** commented on this gist.
------------------------------
[image: Screenshot_20210915_092216_pro sinric]
<https://user-images.githubusercontent.com/26788550/133352400-3fcd5ae8-b4e8-49ce-a8ff-92e9e9f6c24e.jpg>
Good morning!
About schedule,
It seems have a bug at the action input box.
Although I set action with PC, App doesn't reflect action.
Do you still know this occur?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<https://gist.github.com/ec3a1c664e116a8423ce0a6b33ed7a7d#gistcomment-3893378>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABZAZZVYMEPQUTGOPRK3VKDUB7VF7ANCNFSM45EMAN6A>
.
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>.
device type is blind
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you . I understand.