You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: examples/switch/switch.ino
+10-4Lines changed: 10 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,6 @@
24
24
25
25
#defineBTN_FLASH0
26
26
27
-
SinricProSwitch mySwitch(SWITCH_ID);
28
27
bool myPowerState = false;
29
28
unsignedlong lastBtnPress = 0;
30
29
@@ -57,8 +56,13 @@ void handleButtonPress() {
57
56
myPowerState = true;
58
57
}
59
58
digitalWrite(LED_BUILTIN, myPowerState?LOW:HIGH); // if myPowerState indicates device turned on: turn on led (builtin led uses inverted logic: LOW = LED ON / HIGH = LED OFF)
60
-
Serial.printf("Device %s turned %s (manually via flashbutton)\r\n", mySwitch.getDeviceId(), myPowerState?"on":"off");
59
+
60
+
// get Switch device back
61
+
SinricProSwitch& mySwitch = SinricPro[SWITCH_ID];
62
+
// send powerstate event
61
63
mySwitch.sendPowerStateEvent(myPowerState); // send the new powerState to SinricPro server
64
+
Serial.printf("Device %s turned %s (manually via flashbutton)\r\n", mySwitch.getDeviceId(), myPowerState?"on":"off");
65
+
62
66
lastBtnPress = actualMillis; // update last button press variable
Copy file name to clipboardExpand all lines: pio-examples/switch/src/switch.cpp
+10-4Lines changed: 10 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,6 @@
24
24
25
25
#defineBTN_FLASH0
26
26
27
-
SinricProSwitch mySwitch(SWITCH_ID);
28
27
bool myPowerState = false;
29
28
unsignedlong lastBtnPress = 0;
30
29
@@ -57,8 +56,13 @@ void handleButtonPress() {
57
56
myPowerState = true;
58
57
}
59
58
digitalWrite(LED_BUILTIN, myPowerState?LOW:HIGH); // if myPowerState indicates device turned on: turn on led (builtin led uses inverted logic: LOW = LED ON / HIGH = LED OFF)
60
-
Serial.printf("Device %s turned %s (manually via flashbutton)\r\n", mySwitch.getDeviceId(), myPowerState?"on":"off");
59
+
60
+
// get Switch device back
61
+
SinricProSwitch& mySwitch = SinricPro[SWITCH_ID];
62
+
// send powerstate event
61
63
mySwitch.sendPowerStateEvent(myPowerState); // send the new powerState to SinricPro server
64
+
Serial.printf("Device %s turned %s (manually via flashbutton)\r\n", mySwitch.getDeviceId(), myPowerState?"on":"off");
65
+
62
66
lastBtnPress = actualMillis; // update last button press variable
0 commit comments