Somewhere in the future…
Until then, you can think of tons of simple ways to restrict access with widgets available at the moment. For example, in one of my projects there are four buttons acting like a pin input. Here is little screen cast: https://www.dropbox.com/s/6i4tdus9wivg75l/IMG_2327.TRIM.MOV?dl=0
Just in case someone finds it useful, here are the code excerpts:
bool alarmAccess;
int alarmMode; // 1 -> ON 2 -> OFF
int alarmState; // 1 -> OPEN 2 -> CLOSED
bool toggle;
int accessCountDown;
String pin = String(11334);
String enteredPin = String();
BlynkTimer timer;
void timerEvent()
{
updateAccessCountDown();
updateAlarmState();
if (Blynk.connected()) {
toggleAlarmLED();
}
}
void toggleAlarmLED() {
toggle = !toggle;
Blynk.virtualWrite(V24, toggle ? 255 : 0);
}
void updateAccessCountDown() {
if (!alarmAccess) {
return;
}
if (accessCountDown > 0) {
accessCountDown--;
Blynk.virtualWrite(V25, String("ACCESS GRANTED (") + accessCountDown + ")");
}
else {
updateAlarmAccess(false, false);
}
}
void updateAlarmAccess(bool newAccess, bool force) {
if (!force && alarmAccess == newAccess) {
return;
}
alarmAccess = newAccess;
if (alarmAccess) {
Blynk.setProperty(V21, "color", BLYNK_BLUE);
Blynk.setProperty(V25, "color", BLYNK_BLUE);
Blynk.virtualWrite(V25, "ACCESS GRANTED (9)");
accessCountDown = 10;
}
else {
Blynk.setProperty(V21, "color", BLYNK_GREEN);
Blynk.setProperty(V25, "color", BLYNK_GREEN);
Blynk.virtualWrite(V25, " ");
}
updateStateLabel();
}
void updateStateLabel() {
if (alarmMode == 2) {
Blynk.setProperty(V22, "color", BLYNK_GREEN);
Blynk.virtualWrite(V22, "OFF");
}
else if (alarmState == 2) {
Blynk.setProperty(V22, "color", BLYNK_GREEN);
Blynk.virtualWrite(V22, "ON AND CLOSED");
}
else {
Blynk.setProperty(V22, "color", BLYNK_RED);
Blynk.virtualWrite(V22, "ON AND OPEN!");
}
}
void updateEnteredPin() {
if (pin == enteredPin) {
enteredPin = String();
updateAlarmAccess(true, false);
return;
}
else if (enteredPin.length() <= 6) {
String hiddenPin = enteredPin;
hiddenPin.replace("1", " * ");
hiddenPin.replace("2", " * ");
hiddenPin.replace("3", " * ");
hiddenPin.replace("4", " * ");
Blynk.virtualWrite(V25, hiddenPin);
}
else {
enteredPin = String();
Blynk.virtualWrite(V25, " ");
}
}
// MENU - ALARM ON/OFF
BLYNK_WRITE(V21) {
if (!alarmAccess) {
Blynk.virtualWrite(V21, alarmMode);
Blynk.virtualWrite(V25, "ACCESS DENIED");
return;
}
int newAlarmMode = param.asInt();
if (alarmMode == newAlarmMode) {
return;
}
alarmMode = newAlarmMode;
Blynk.virtualWrite(V100, alarmMode);
updateStateLabel();
}
BLYNK_WRITE(V11) {
if (!param.asInt()) {
return;
}
enteredPin = enteredPin + String(1);
updateEnteredPin();
}
BLYNK_WRITE(V12) {
if (!param.asInt()) {
return;
}
enteredPin = enteredPin + String(2);
updateEnteredPin();
}
BLYNK_WRITE(V13) {
if (!param.asInt()) {
return;
}
enteredPin = enteredPin + String(3);
updateEnteredPin();
}
BLYNK_WRITE(V14) {
if (!param.asInt()) {
return;
}
enteredPin = enteredPin + String(4);
updateEnteredPin();
}
BLYNK_CONNECTED() {
Blynk.syncVirtual(V100);
}
BLYNK_WRITE(V100)
{
alarmMode = param.asInt() ?: 1;
updateAlarmState();
updateAlarmAccess(false, true);
}
void setup() {
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
timer.setInterval(1000L, timerEvent);
}
void loop() {
Blynk.run();
timer.run();
}