bdraco / yalexs-ble Goto Github PK
View Code? Open in Web Editor NEWBluetooth control of Yale and August locks
License: GNU General Public License v3.0
Bluetooth control of Yale and August locks
License: GNU General Public License v3.0
I was wondering if it would be possible to add support for the battery level of the August Smart Keypad. Usually when the batteries are low, when I open the August app I get a notification about the batteries going low. I don't really know if the app (phone) connects directly to the keypad or it is through the lock. I think it's probably the later.
Maybe the Lock is exposing the battery level somewhere.
thanks
Hi, I am trying to integrate your bluetooth integration into home assistant. Unfortunately the ESP32 bluetooth proxy was not detecting the lock (model Yale YDM-4115A with an Yale Access Bluetooth Module installed). My home assistant machine is in the rack on a VMWare ESxi host which is very hard to move close to door even for temporary testing due to router/VLAN/wiring setup.
So I thought I will try using this to see if I am able to connect to the lock directly from my laptop first. I have updated the sample file run.py with the serial, key and key slot no obtained from rooted android phone. But I am getting an error "TypeError: Passing coroutines is forbidden, use tasks explicitly."
Could you please help me where I am going wrong?
python --version
Python 3.11.1
python run.py
INFO:main:Expected local_name: M2000LR
c:\yale\run.py:41: FutureWarning: This method will be removed in a future version of Bleak. Use the detection_callback of the BleakScanner constructor instead.
scanner.register_detection_callback(push_lock.update_advertisement)
DEBUG:yalexs_ble.push:Waiting for advertisement callbacks for M2000LR
INFO:main:Started, waiting for lock to be discovered with local_name: M2000LR
DEBUG:yalexs_ble.push:M2000LR: Scheduling update to happen in 0.01 seconds
DEBUG:yalexs_ble.push:M2000LR: Update queued
DEBUG:yalexs_ble.push:M2000LR: Queued update starting
DEBUG:yalexs_ble.push:M2000LR: Starting update
DEBUG:yalexs_ble.push:M2000LR: Acquiring lock
DEBUG:yalexs_ble.push:M2000LR: Starting retry loop
DEBUG:yalexs_ble.push:M2000LR: Starting update (has_lock_info: False)
DEBUG:yalexs_ble.lock:M2000LR: Connecting to the lock
DEBUG:bleak_retry_connector:M2000LR - 98:1B:B5:01:9E:19: Connection attempt: 1
DEBUG:yalexs_ble.push:M2000LR: Scheduling update to happen in 0.01 seconds
DEBUG:yalexs_ble.push:M2000LR: Rescheduling update since one already in progress
DEBUG:yalexs_ble.push:M2000LR: Scheduling update to happen in 1.0 seconds
DEBUG:yalexs_ble.push:M2000LR: Rescheduling update since one already in progress
DEBUG:yalexs_ble.push:M2000LR: Scheduling update to happen in 1.0 seconds
DEBUG:yalexs_ble.push:M2000LR: Rescheduling update
DEBUG:yalexs_ble.push:M2000LR: Scheduling update to happen in 0.05 seconds
DEBUG:yalexs_ble.push:M2000LR: Existing update in 0.04999999998835847 seconds will happen sooner than now
DEBUG:yalexs_ble.push:M2000LR: Rescheduling update since one already in progress
DEBUG:yalexs_ble.push:M2000LR: Scheduling update to happen in 1.0 seconds
DEBUG:yalexs_ble.push:M2000LR: Rescheduling update since one already in progress
DEBUG:yalexs_ble.push:M2000LR: Scheduling update to happen in 1.0 seconds
DEBUG:yalexs_ble.push:M2000LR: Rescheduling update since one already in progress
DEBUG:yalexs_ble.push:M2000LR: Scheduling update to happen in 1.0 seconds
DEBUG:yalexs_ble.push:M2000LR: Rescheduling update since one already in progress
DEBUG:yalexs_ble.push:M2000LR: Scheduling update to happen in 1.0 seconds
DEBUG:yalexs_ble.push:M2000LR: Rescheduling update since one already in progress
DEBUG:yalexs_ble.push:M2000LR: Scheduling update to happen in 1.0 seconds
DEBUG:yalexs_ble.push:M2000LR: Rescheduling update since one already in progress
DEBUG:yalexs_ble.push:M2000LR: Scheduling update to happen in 1.0 seconds
DEBUG:yalexs_ble.push:M2000LR: Rescheduling update since one already in progress
DEBUG:yalexs_ble.push:M2000LR: Scheduling update to happen in 1.0 seconds
DEBUG:yalexs_ble.lock:M2000LR: Connected
DEBUG:yalexs_ble.session:M2000LR: Starting notify for <class 'yalexs_ble.secure_session.SecureSession'>
DEBUG:yalexs_ble.push:M2000LR: Rescheduling update since one already in progress
DEBUG:yalexs_ble.push:M2000LR: Scheduling update to happen in 1.0 seconds
DEBUG:yalexs_ble.session:M2000LR: Starting notify for <class 'yalexs_ble.session.Session'>
DEBUG:yalexs_ble.lock:M2000LR: Setting up the session
ERROR:yalexs_ble.push:M2000LR: Error updating
Traceback (most recent call last):
File "C:\Users\xyz\AppData\Local\Programs\Python\Python311\Lib\site-packages\yalexs_ble\push.py", line 713, in _queue_update
await self._update()
File "C:\Users\xyz\AppData\Local\Programs\Python\Python311\Lib\site-packages\yalexs_ble\push.py", line 77, in _async_wrap_operation_lock
return await func(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\xyz\AppData\Local\Programs\Python\Python311\Lib\site-packages\yalexs_ble\push.py", line 98, in _async_wrap_retry_bluetooth_connection_error
return await func(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\xyz\AppData\Local\Programs\Python\Python311\Lib\site-packages\yalexs_ble\push.py", line 492, in _update
lock = await self._ensure_connected()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\xyz\AppData\Local\Programs\Python\Python311\Lib\site-packages\yalexs_ble\push.py", line 378, in _ensure_connected
await self._client.connect()
File "C:\Users\xyz\AppData\Local\Programs\Python\Python311\Lib\site-packages\yalexs_ble\lock.py", line 158, in connect
await self._setup_session()
File "C:\Users\xyz\AppData\Local\Programs\Python\Python311\Lib\site-packages\yalexs_ble\lock.py", line 200, in _setup_session
response = await self.secure_session.execute(self._disconnected_event, cmd)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\xyz\AppData\Local\Programs\Python\Python311\Lib\site-packages\yalexs_ble\session.py", line 216, in execute
await asyncio.wait(
File "C:\Users\xyz\AppData\Local\Programs\Python\Python311\Lib\asyncio\tasks.py", line 415, in wait
raise TypeError("Passing coroutines is forbidden, use tasks explicitly.")
TypeError: Passing coroutines is forbidden, use tasks explicitly.
C:\Users\xyz\AppData\Local\Programs\Python\Python311\Lib\site-packages\yalexs_ble\push.py:744: RuntimeWarning: coroutine 'Event.wait' was never awaited
_LOGGER.exception("%s: Error updating", self.name)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
DEBUG:yalexs_ble.session:M2000LR: Encrypted command: d70c7417889f8356f0750a7455d41fa00f01
DEBUG:yalexs_ble.session:M2000LR: Writing command to bd4ac613-0b45-11e3-8ffd-0800200c9a66 (Handle: 22): Unknown: d70c7417889f8356f0750a7455d41fa00f01
DEBUG:yalexs_ble.session:M2000LR: Waiting for response
DEBUG:yalexs_ble.session:M2000LR: Receiving response via notify: 9d86d97cf384b53df9c6dd54a3dae2280f01 (waiting=True)
DEBUG:yalexs_ble.session:M2000LR: Decrypted response via notify: 02000000cd21c4998abea606a71f955f0f01
DEBUG:yalexs_ble.secure_session:M2000LR: Response security checksum: 1603608487, expected: 1603608487
DEBUG:yalexs_ble.session:M2000LR: Got response: 02000000cd21c4998abea606a71f955f0f01
DEBUG:yalexs_ble.push:M2000LR: Update queued
DEBUG:yalexs_ble.push:M2000LR: Queued update starting
DEBUG:yalexs_ble.push:M2000LR: Starting update
DEBUG:yalexs_ble.push:M2000LR: Acquiring lock
DEBUG:yalexs_ble.push:M2000LR: Starting retry loop
DEBUG:yalexs_ble.push:M2000LR: Starting update (has_lock_info: False)
DEBUG:yalexs_ble.lock:M2000LR: Probing the lock
DEBUG:yalexs_ble.lock:M2000LR: Executing status
ERROR:yalexs_ble.push:M2000LR: Error updating
Traceback (most recent call last):
File "C:\Users\xyz\AppData\Local\Programs\Python\Python311\Lib\site-packages\yalexs_ble\push.py", line 713, in _queue_update
await self._update()
File "C:\Users\xyz\AppData\Local\Programs\Python\Python311\Lib\site-packages\yalexs_ble\push.py", line 77, in _async_wrap_operation_lock
return await func(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\xyz\AppData\Local\Programs\Python\Python311\Lib\site-packages\yalexs_ble\push.py", line 98, in _async_wrap_retry_bluetooth_connection_error
return await func(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\xyz\AppData\Local\Programs\Python\Python311\Lib\site-packages\yalexs_ble\push.py", line 495, in _update
state = await lock.status()
^^^^^^^^^^^^^^^^^^^
File "C:\Users\xyz\AppData\Local\Programs\Python\Python311\Lib\site-packages\yalexs_ble\lock.py", line 298, in status
response = await self._execute_command(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\xyz\AppData\Local\Programs\Python\Python311\Lib\site-packages\yalexs_ble\lock.py", line 271, in _execute_command
response = await self.session.execute(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\xyz\AppData\Local\Programs\Python\Python311\Lib\site-packages\yalexs_ble\session.py", line 216, in execute
await asyncio.wait(
File "C:\Users\xyz\AppData\Local\Programs\Python\Python311\Lib\asyncio\tasks.py", line 415, in wait
raise TypeError("Passing coroutines is forbidden, use tasks explicitly.")
TypeError: Passing coroutines is forbidden, use tasks explicitly.
ERROR:asyncio:Task exception was never retrieved
future: <Task finished name='Task-25' coro=<Session._write() done, defined at C:\Users\xyz\AppData\Local\Programs\Python\Python311\Lib\site-packages\yalexs_ble\session.py:102> exception=AssertionError('Cipher not set')>
Traceback (most recent call last):
File "C:\Users\xyz\AppData\Local\Programs\Python\Python311\Lib\site-packages\yalexs_ble\session.py", line 105, in _write
return await self._locked_write(command)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\xyz\AppData\Local\Programs\Python\Python311\Lib\site-packages\yalexs_ble\session.py", line 139, in _locked_write
assert self.cipher_encrypt is not None, "Cipher not set" # nosec
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: Cipher not set
DEBUG:yalexs_ble.lock:M2000LR: Disconnected from lock callback
Traceback (most recent call last):
File "C:\Users\xyz\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 118, in run
Exception ignored in: <function BleakScannerWinRT.start.. at 0x0000019F1208BCE0>
Traceback (most recent call last):
File "C:\Users\xyz\AppData\Local\Programs\Python\Python311\Lib\site-packages\bleak\backends\winrt\scanner.py", line 245, in
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\xyz\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 653, in run_until_complete
lambda s, e: event_loop.call_soon_threadsafe(self._received_handler, s, e)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\xyz\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 806, in call_soon_threadsafe
return future.result()
^^^^^^^^^^^^^^^
self._check_closed()
File "c:\Data\ESP8266\yale\run.py", line 48, in run
File "C:\Users\xyz\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 519, in _check_closed
await asyncio.sleep(1000000)
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
File "C:\Users\xyz\AppData\Local\Programs\Python\Python311\Lib\asyncio\tasks.py", line 639, in sleep
return await future
^^^^^^^^^^^^
asyncio.exceptions.CancelledError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\Data\ESP8266\yale\run.py", line 57, in
asyncio.run(run())
File "C:\Users\xyz\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "C:\Users\xyz\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 123, in run
raise KeyboardInterrupt()
Is your feature request related to a problem? Please describe.
It would be great it it was possible to enable/disable and adjust the timeout for AutoLock
Describe the solution you'd like
Functions to disable_autlock()
, enable_autolock()
, set_autlock_timeout(seconds)
Additional context
Add any other context or screenshots about the feature request here.
It seems like this must be done using BLE, as it can not be done from the app unless you are within Bluetooth-range
https://www.yalehome.com/it/en/support/product-support/apps-integrations/yale-access-app/everyday-use/how-to-enable-auto-lock
2022-08-19 15:06:06.852 DEBUG (MainThread) [bleak_retry_connector] Front Door (M10CK0F) - /org/bluez/hci0/dev_78_9C_85_19_63_C6: Connecting (attempt: 1, last rssi: -76)
2022-08-19 15:06:06.863 DEBUG (MainThread) [bleak_retry_connector] Cached services found: <bleak.backends.service.BleakGATTServiceCollection object at 0xffffa1ee7040>
2022-08-19 15:06:06.863 DEBUG (MainThread) [bleak_retry_connector] Front Door (M10CK0F) - /org/bluez/hci0/dev_78_9C_85_19_63_C6: Connected (attempt: 1, last rssi: -76)
2022-08-19 15:06:06.875 DEBUG (MainThread) [bleak_retry_connector] Front Door (M10CK0F) - /org/bluez/hci0/dev_78_9C_85_19_63_C6: Connecting (attempt: 1, last rssi: -76)
2022-08-19 15:06:06.888 DEBUG (MainThread) [bleak_retry_connector] Cached services found: <bleak.backends.service.BleakGATTServiceCollection object at 0xffffa1ee7040>
2022-08-19 15:06:06.888 DEBUG (MainThread) [bleak_retry_connector] Front Door (M10CK0F) - /org/bluez/hci0/dev_78_9C_85_19_63_C6: Connected (attempt: 1, last rssi: -76)
2022-08-19 15:06:06.904 DEBUG (MainThread) [bleak_retry_connector] Front Door (M10CK0F) - /org/bluez/hci0/dev_78_9C_85_19_63_C6: Connecting (attempt: 1, last rssi: -76)
2022-08-19 15:06:06.918 DEBUG (MainThread) [bleak_retry_connector] Cached services found: <bleak.backends.service.BleakGATTServiceCollection object at 0xffffa1ee7040>
2022-08-19 15:06:06.919 DEBUG (MainThread) [bleak_retry_connector] Front Door (M10CK0F) - /org/bluez/hci0/dev_78_9C_85_19_63_C6: Connected (attempt: 1, last rssi: -76)
2022-08-19 15:06:06.926 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [281472934383424] [org.bluez.Error.InProgress] In Progress
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 199, in handle_call_service
await hass.services.async_call(
File "/usr/src/homeassistant/homeassistant/core.py", line 1717, in async_call
task.result()
File "/usr/src/homeassistant/homeassistant/core.py", line 1754, in _execute_service
await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 204, in handle_service
await service.entity_service_call(
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 676, in entity_service_call
future.result() # pop exception if have
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 931, in async_request_call
await coro
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 713, in _handle_entity_call
await result
File "/usr/src/homeassistant/homeassistant/components/yalexs_ble/lock.py", line 62, in async_lock
await self._device.lock()
File "/usr/local/lib/python3.10/site-packages/yalexs_ble/push.py", line 77, in _async_wrap_cancelable_operation
await self._operation_task
File "/usr/local/lib/python3.10/site-packages/yalexs_ble/push.py", line 90, in _async_wrap_operation_lock
return await func(self, *args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/yalexs_ble/push.py", line 111, in _async_wrap_retry_bluetooth_connection_error
return await func(self, *args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/yalexs_ble/push.py", line 304, in lock
async with lock:
File "/usr/local/lib/python3.10/site-packages/yalexs_ble/lock.py", line 63, in __aenter__
await self.connect()
File "/usr/local/lib/python3.10/site-packages/yalexs_ble/lock.py", line 107, in connect
response = await self.secure_session.execute(self._disconnected_event, cmd)
File "/usr/local/lib/python3.10/site-packages/yalexs_ble/session.py", line 190, in execute
return write_task.result()
File "/usr/local/lib/python3.10/site-packages/yalexs_ble/session.py", line 91, in _write
return await self._locked_write(command)
File "/usr/local/lib/python3.10/site-packages/yalexs_ble/session.py", line 141, in _locked_write
await self.client.write_gatt_char(self.write_characteristic, command, True)
File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/client.py", line 694, in write_gatt_char
assert_reply(reply)
File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/utils.py", line 22, in assert_reply
raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.bluez.Error.InProgress] In Progress
2022-12-03 18:17:57.385 ERROR (MainThread) [homeassistant] Error doing job: Task was destroyed but it is pending!: File "/usr/local/lib/python3.10/runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/local/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/usr/src/homeassistant/homeassistant/__main__.py", line 214, in <module>
sys.exit(main())
File "/usr/src/homeassistant/homeassistant/__main__.py", line 202, in main
exit_code = runner.run(runtime_conf)
File "/usr/src/homeassistant/homeassistant/runner.py", line 120, in run
return loop.run_until_complete(setup_and_run_hass(runtime_config))
File "/usr/local/lib/python3.10/asyncio/base_events.py", line 633, in run_until_complete
self.run_forever()
File "/usr/local/lib/python3.10/asyncio/base_events.py", line 600, in run_forever
self._run_once()
File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1888, in _run_once
handle._run()
File "/usr/local/lib/python3.10/asyncio/events.py", line 80, in _run
self._context.run(self._callback, *self._args)
File "/usr/local/lib/python3.10/site-packages/yalexs_ble/push.py", line 89, in _async_wrap_operation_lock
return await func(self, *args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/yalexs_ble/push.py", line 110, in _async_wrap_retry_bluetooth_connection_error
return await func(self, *args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/yalexs_ble/push.py", line 390, in _update
async with lock:
File "/usr/local/lib/python3.10/site-packages/yalexs_ble/lock.py", line 61, in __aenter__
await self.connect()
File "/usr/local/lib/python3.10/site-packages/yalexs_ble/lock.py", line 130, in connect
response = await self.secure_session.execute(self._disconnected_event, cmd)
File "/usr/local/lib/python3.10/site-packages/yalexs_ble/session.py", line 182, in execute
await asyncio.wait(
File "/usr/local/lib/python3.10/asyncio/tasks.py", line 382, in wait
fs = {ensure_future(f, loop=loop) for f in fs}
File "/usr/local/lib/python3.10/asyncio/tasks.py", line 382, in <setcomp>
fs = {ensure_future(f, loop=loop) for f in fs}
File "/usr/local/lib/python3.10/asyncio/tasks.py", line 615, in ensure_future
return _ensure_future(coro_or_future, loop=loop)
File "/usr/local/lib/python3.10/asyncio/tasks.py", line 636, in _ensure_future
return loop.create_task(coro_or_future)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.