sinricpro / esp8266-esp32-sdk

Library for https://sinric.pro - simple way to connect your device to Alexa, Google Home, SmartThings and cloud
https://sinric.pro
Other
234 stars 124 forks source link

Device states after power up #319

Closed khorner116 closed 1 year ago

khorner116 commented 1 year ago

System recovery code I've written handles the loss of Wifi and/or Sinric fine and reconnects. I have a question about the operation of SinricPro.restoreDeviceStates(true).

When I issue that call, does it send messages for each device that are picked up by my OnPowerState routines? I need to know the status of a switch device on the server after I reboot.

thanks

kakopappa commented 1 year ago

Hello,

The server sends the last known state to each device id you have specified

https://github.com/sinricpro/esp8266-esp32-sdk/blob/master/examples/Switch/Switch/Switch.ino#L105

so OnPowerState will be called with the last known state for each device.

Alternative option is to store the values in the SPIFF / EEPROM and handle it

On Mon, 1 May 2023 at 5:10 AM khorner116 @.***> wrote:

System recovery code I've written handles the loss of Wifi and/or Sinric fine and reconnects. I have a question about the operation of SinricPro.restoreDeviceStates(true).

When I issue that call, does it send messages for each device that are picked up by my OnPowerState routines? I need to know the status of a switch device on the server after I reboot.

thanks

— Reply to this email directly, view it on GitHub https://github.com/sinricpro/esp8266-esp32-sdk/issues/319, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABZAZZSKTQCNPL6UJERL2ATXD3PORANCNFSM6AAAAAAXRGAYNE . You are receiving this because you are subscribed to this thread.Message ID: @.***>

khorner116 commented 1 year ago

There still seems to be an issue. If I turn the switch on or off from the Sinric App, I get a trigger of the onPowerState event as below..

13:13:30.445 -> Device 63616a9a333d12dd2ae2a684 turned on (via SinricPro) 13:13:34.937 -> Device 63616a9a333d12dd2ae2a684 turned off (via SinricPro)

But on startup after the SinricPro.restoreDeviceStates(true) statement is executed, there is no message as above. Is the another way to query the Server about the state of the Switch? I'm trying to use it to enable or disable functionality in the ESP32 program, and I don't want to have to log on to the app and reset the switch with every power on. I guess I could store the last change in a Prefs variable, but that seems unnecessary given the server has the info.

stale[bot] commented 1 year ago

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!

khorner116 commented 1 year ago

Aruna, You can close it out. I was never able to get the server info working, so I just implemented a set of "prefs" variables to store the last state and read that on reset. when the server side switch is opened or closed, I record the action and then alter the ESP32 processing accordingly. It works fine.

thanks

Ken Horner

On Sun, May 21, 2023 at 6:28 AM stale[bot] @.***> wrote:

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!

— Reply to this email directly, view it on GitHub https://github.com/sinricpro/esp8266-esp32-sdk/issues/319#issuecomment-1556142719, or unsubscribe https://github.com/notifications/unsubscribe-auth/AICQSLPUUVVPVNNOM3LFGDDXHHU5VANCNFSM6AAAAAAXRGAYNE . You are receiving this because you authored the thread.Message ID: @.***>