Closed elnino1947 closed 1 year ago
Hi,
Is this issue limited to Google Home only? Does portal / Sinric Pro app shows the correct value when the state change?
On Wed, 28 Dec 2022 at 1:13 PM elnino1947 @.***> wrote:
I am unable to see any change in my google home app based on the feedback. Ideally i want my Smart door lock which is accessible both manually and by the app to be updated according the latest state sent by MY ESP
`/*
- Example for smart lock with feedback
- The lock must give a feedback signal on pin defined in LOCK_STATE_PIN
- Alternative: Use a contact sensor, indicating the current lock state
- HIGH on LOCK_STATE_PIN means lock is locked
- LOW on LOCK_STATE_PIN means lock is unlocked
- If you encounter any issues:
- check the readme.md at https://github.com/sinricpro/esp8266-esp32-sdk/blob/master/README.md
- ensure all dependent libraries are installed
- open serial monitor and check whats happening
- check full user documentation at https://sinricpro.github.io/esp8266-esp32-sdk
- visit https://github.com/sinricpro/esp8266-esp32-sdk/issues and check for existing issues or open a new one */
// 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
ifdef ESP8266
include
endif
ifdef ESP32
include
endif
include "SinricPro.h"
include "SinricProLock.h"
define WIFI_SSID "XXXXXX"
define WIFI_PASS "XXXXX"
define APP_KEY "XXXXX" // Should look like
"de0bxxxx-1x3x-4x3x-ax2x-5dabxxxxxxxx"
define APP_SECRET "XXXXX" // Should look like
"5f36xxxx-x3x7-4x3x-xexe-e86724a9xxxx-4c4axxxx-3x3x-x5xe-x9x3-333d65xxxxxx"
define LOCK_ID "XXXXX" // Should look like "5dc1564130xxxxxxxxxxxxxx"
define BAUD_RATE 9600 // Change baudrate to your need
define LOCK_PIN LED_BUILTIN // PIN where the lock is connected to: HIGH =
locked, LOW = unlocked
define LOCK_STATE_PIN 17 // PIN where the lock feedback is connected to
(HIGH:locked, LOW:unlocked)
bool lastLockState;
bool onLockState(String deviceId, bool &lockState) { Serial.printf("Device %s is %s\r\n", deviceId.c_str(), lockState?"locked":"unlocked"); digitalWrite(LOCK_PIN, lockState); return true; }
void checkLockState() { bool currentLockState = digitalRead(LOCK_STATE_PIN); // get current lock state Serial.println(currentLockState); if (currentLockState == lastLockState) return; // do nothing if state didn't changed Serial.printf("Lock has been %s manually\r\n", currentLockState?"locked":"unlocked"); // print current lock state to serial lastLockState = currentLockState; // update last known lock state SinricProLock &myLock = SinricPro[LOCK_ID]; // get the LockDevice myLock.sendLockStateEvent(currentLockState); // update LockState on Server }
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() { 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");
pinMode(LOCK_PIN, OUTPUT); pinMode(LOCK_STATE_PIN, INPUT_PULLUP);
setupWiFi(); setupSinricPro(); }
void loop() { SinricPro.handle(); checkLockState(); }`
— Reply to this email directly, view it on GitHub https://github.com/sinricpro/esp8266-esp32-sdk/issues/304, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABZAZZS433HS4PNLMAHMECLWPPLABANCNFSM6AAAAAATK7MQDQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>
Hi, sorry, it was my mistake,( i was not patient enough to wait for the output to change during testing). and in my scenario, the lock engages within a second of unlocking through the app(this is not handled well) . I added a delay to send the lock's status, which solved my other issue.
This issue has gone quiet. Spooky quiet. We currently close issues after 14 days of inactivity. It’s been at least 7 days since the last update here. If we missed this issue or if you want to keep it open, please reply here. As a friendly reminder, the best way to fix this or any other problem is to provide a detailed error description including a serial log. Thanks for being a part of the SinricPro community!
Hey again! It’s been 14 days since anything happened on this issue, so our friendly robot (that’s me!) is going to close it. Please keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m HUMAN_EMOTION_SORRY
. Please feel free to comment on this issue or create a new one if you need anything else. As a friendly reminder, the best way to fix this or any other problem is to provide a detailed error description including a serial log. Thanks again for being a part of the SinricPro community!
I am unable to see any change in my google home app based on the feedback. Ideally i want my Smart door lock which is accessible both manually and by the app to be updated according the latest state sent by MY ESP
`/*
// Uncomment the following line to enable serial debug output
define ENABLE_DEBUG
ifdef ENABLE_DEBUG
endif
include
ifdef ESP8266
endif
ifdef ESP32
endif
include "SinricPro.h"
include "SinricProLock.h"
define WIFI_SSID "XXXXXX"
define WIFI_PASS "XXXXX"
define APP_KEY "XXXXX" // Should look like "de0bxxxx-1x3x-4x3x-ax2x-5dabxxxxxxxx"
define APP_SECRET "XXXXX" // Should look like "5f36xxxx-x3x7-4x3x-xexe-e86724a9xxxx-4c4axxxx-3x3x-x5xe-x9x3-333d65xxxxxx"
define LOCK_ID "XXXXX" // Should look like "5dc1564130xxxxxxxxxxxxxx"
define BAUD_RATE 9600 // Change baudrate to your need
define LOCK_PIN LED_BUILTIN // PIN where the lock is connected to: HIGH = locked, LOW = unlocked
define LOCK_STATE_PIN 17 // PIN where the lock feedback is connected to (HIGH:locked, LOW:unlocked)
bool lastLockState;
bool onLockState(String deviceId, bool &lockState) { Serial.printf("Device %s is %s\r\n", deviceId.c_str(), lockState?"locked":"unlocked"); digitalWrite(LOCK_PIN, lockState);
return true; }
void checkLockState() { bool currentLockState = digitalRead(LOCK_STATE_PIN); // get current lock state Serial.println(currentLockState); if (currentLockState == lastLockState) return; // do nothing if state didn't changed Serial.printf("Lock has been %s manually\r\n", currentLockState?"locked":"unlocked"); // print current lock state to serial lastLockState = currentLockState; // update last known lock state SinricProLock &myLock = SinricPro[LOCK_ID]; // get the LockDevice myLock.sendLockStateEvent(currentLockState); // update LockState on Server }
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() { 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");
pinMode(LOCK_PIN, OUTPUT); pinMode(LOCK_STATE_PIN, INPUT_PULLUP);
setupWiFi(); setupSinricPro(); }
void loop() { SinricPro.handle(); checkLockState(); }`