maximkulkin / esp-homekit-demo

Demo of Apple HomeKit accessory server library
MIT License
805 stars 233 forks source link

Lock - Siri cannot issue the lock command #321

Closed wasp100 closed 4 years ago

wasp100 commented 4 years ago

Hi @maximkulkin I'm using the Lock example, and noticed that when I ask Siri to lock the door, the response is "Sorry, I wasn't able to lock your Lock. For more details, check the Home app."

I can however unlock the lock through Siri with no problem!

I just can't seem to get Siri to lock the lock, and I cannot see anything in the code that would fix this.

renandw commented 4 years ago

How is your code? In the lock example in the esp-homekit-demo, you unlock and after 5 seconds it locks again. Does Siri unlock it?

wasp100 commented 4 years ago

I’ve tested this with the original lock example code. When you ask Siri to unlock the lock, the response is “ok, lock is unlocked”. However when you ask Siri to lock the lock, the response is “sorry I’m unable to lock your lock...” I’ve modified the code to allow for a separate lock and unlock, but the issue still exists.

wasp100 commented 4 years ago

Hi @maximkulkin

Can you please assist me in getting this to work? Could the issue lie in the ESPHomeKit code?

My coding seems fine and it works if i toggle the switch in HomeKit. It also works when I ask Siri to unlock. However, if I ask Siri to lock, I get a "sorry I'm unable to lock your lock" response.

Thanks!

maximkulkin commented 4 years ago

Ok, I have debugged this down to the following problem: when you update LOCK_TARGET_STATE characteristic (of type uint8_t), Home app properly sends numeric value. However, when you ask Siri to lock or unlock a lock, Siri sends a boolean value. While it's kind of nonsense, however I originally coded support for allowing booleans instead of integers, thus the error of invalid value format was not raised, but the value wasn't handled properly and always defaulted to zero.

I have pushed fix to properly convert booleans to integers if needed. In my tests Siri now properly locks and unlocks a lock.

wasp100 commented 4 years ago

Thank you so much @maximkulkin Silly question: what’s the easiest way to update esp-HomeKit?

maximkulkin commented 4 years ago

Just do

git pull --rebase origin master
git submodule update --init --recursive

since I have updated all versions in esp-homekit-demo repository.

Alternatively, go to components/common/homekit and do git pull --rebase origin master

wasp100 commented 4 years ago

@maximkulkin Thank you so much. Just tested it and it works like a charm! Much appreciated.