PlusPlus-ua / ha_tuya_ble

Home Assistant support for Tuya BLE devices
MIT License
161 stars 104 forks source link

Request for Gimdow A1 Max smart lock #46

Open mikekornikh opened 11 months ago

mikekornikh commented 11 months ago

Hi! I want to start by thanking you for the amazing work. I was also born in Ukraine, so I personally feel the terror you're going through. I'm hoping you can help integrate the Gimdow A1 Max smart lock here. I love this lock, and it's my really my only option for my rental apartment because it goes right over the included door lock. Here's a link to the product page https://www.gimdow.com/GIMDOW-A1.html

Product: A1 PRO MAX Device Information Product Name M515EGWT V2 Product Category cl

Any help would be greatly appreciated!

dmickeyus commented 11 months ago

Hi, I modified the code to make basic functions with lock, unlock and lock status for GIMDOW A1. My coding is quite dirty but it is working for me anyway. Hope it could provide some support for the development. BTW, many thanks everyone in supporting this project so that I could control my device without cloud.

tuya_ble.tar.gz

mikekornikh commented 11 months ago

Hi, I modified the code to make basic functions with lock, unlock and lock status for GIMDOW A1. My coding is quite dirty but it is working for me anyway. Hope it could provide some support for the development. BTW, many thanks everyone in supporting this project so that I could control my device without cloud.

tuya_ble.tar.gz

You're amazing! Thank you so much! This was the last thing missing from my home assistant setup. Sorry for the noob question, but how do I install the tuya_ble.tar.gz file into my HA?

dmickeyus commented 11 months ago

You may try to extract the tar file and paste the tuya_ble folder to custom_components. For windows, 7zip could help you to do so. Then restart HA should be good to go.

As it is not stable yet, to use this smart lock, bring the physical key when leaving the property ;)

mikekornikh commented 11 months ago

That's what I thought too. The problem was when I extracted the tar to move it to the folder, the file explorer app I have on HA only lets you upload files, not entire folders. And yeah, I never left without a key even before, the Tuya app isn't exactly trustworthy either 😂. I'll get the files over and give it a shot. Thanks again, I really appreciate your help

On Sat, Jul 22, 2023, 12:26 PM dmickeyus @.***> wrote:

You may try to extract the tar file and paste the tuya_ble folder to custom_components. For windows, 7zip could help you to do so. Then restart HA should be good to go.

As it is not stable yet, to use this smart lock, bring the physical key when leaving the property ;)

— Reply to this email directly, view it on GitHub https://github.com/PlusPlus-ua/ha_tuya_ble/issues/46#issuecomment-1646623774, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEJKKXGHGABLH5I6ZYN2FYDXRP5MNANCNFSM6AAAAAA2NW4634 . You are receiving this because you authored the thread.Message ID: @.***>

dmickeyus commented 11 months ago

If you choose not to give up, you may consider to try this one instead. It should be able to keep the connection more stable. But the coding is really bad, I don't know where to put the keepalive code properly. I hope someone could help me to solve this so that it may be able to merge into main branch in the future. tuya_ble.zip .

mikekornikh commented 11 months ago

No way I'm giving up lol. I'm really excited to try it! Thank you so much!

On Sat, Jul 22, 2023 at 3:20 PM dmickeyus @.***> wrote:

If you choose not to give up, you may consider to try this one instead. It should be able to keep the connection more stable. But the coding is really bad, I don't know where to put the keepalive code properly. I hope someone could help me to solve this so that it may be able to merge into main branch in the future. tuya_ble.zip https://github.com/PlusPlus-ua/ha_tuya_ble/files/12137109/tuya_ble.zip .

— Reply to this email directly, view it on GitHub https://github.com/PlusPlus-ua/ha_tuya_ble/issues/46#issuecomment-1646654393, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEJKKXHIWBB27FCNDJ7JHS3XRQRX7ANCNFSM6AAAAAA2NW4634 . You are receiving this because you authored the thread.Message ID: @.***>

mikekornikh commented 11 months ago

Hi! I just wanted to thank you again and tell you your code isn't just working, it's been absolutely fantastic so far. It reacts to commands in a split second, much faster than anything in the Tuya ecosystem. I think you were just selling yourself short on purpose lol. One of the reasons I switched to home assistant is because I was getting very delayed and often missed commands using a ZigBee door sensor to trigger a lock routine in Tuya routines. Not only does your code make the lock react instantly to locking/unlocking commands and ZigBee sensor triggers, but there's even the option to see the current state, which is just a cherry on top, so I don't have to ever open the Tuya app. I was so happy to unplug that stupid little white Tuya Bluetooth gateway and hope it stays buried deep in my junk drawer. I can't tell you how much I appreciate this integration and the brilliant work you've done on it.

On Sat, Jul 22, 2023, 5:34 PM Michael Kornikh @.***> wrote:

No way I'm giving up lol. I'm really excited to try it! Thank you so much!

On Sat, Jul 22, 2023 at 3:20 PM dmickeyus @.***> wrote:

If you choose not to give up, you may consider to try this one instead. It should be able to keep the connection more stable. But the coding is really bad, I don't know where to put the keepalive code properly. I hope someone could help me to solve this so that it may be able to merge into main branch in the future. tuya_ble.zip https://github.com/PlusPlus-ua/ha_tuya_ble/files/12137109/tuya_ble.zip .

— Reply to this email directly, view it on GitHub https://github.com/PlusPlus-ua/ha_tuya_ble/issues/46#issuecomment-1646654393, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEJKKXHIWBB27FCNDJ7JHS3XRQRX7ANCNFSM6AAAAAA2NW4634 . You are receiving this because you authored the thread.Message ID: @.***>

leonardoleb commented 11 months ago

Hi, I modified the code to make basic functions with lock, unlock and lock status for GIMDOW A1. My coding is quite dirty but it is working for me anyway. Hope it could provide some support for the development. BTW, many thanks everyone in supporting this project so that I could control my device without cloud.

tuya_ble.tar.gz

Great work, dmickeyus!

It would be beneficial if you could post this code to a GitHub repository. In the future, we could merge this code to support a larger number of smart locks using the same add-on.

dmickeyus commented 11 months ago

ok, I'm willing to contribute, I will do it when I'm free.

chris24walsh commented 10 months ago

@dmickeyus Using your code seems to add the correct buttons and sensors to the A1 Pro Max device under the Tuya BLE integration, but they stay in the 'unavailable' state. The logs show various errors such as 'Device unexpectedly disconnected', 'Sending device info request failed' and 'device not found, not in range, or poor RSSI'. I get this for all devices (2 A1 locks as well as some other bluetooth Tuya devices, including a Gimdow P1 Keypad), even for the lock that is just 3 metres from my HA server bluetooth dongle. I think the devices only get added because of a lookup to Tuya Cloud, and they are not found by local discovery, is that right? I wonder if then if my bluetooth adapter is even supported by this integration - I don't have a Raspberry Pi, I'm using the Homeassistant Blue (Odroid N2+) with a TP-Link bluetooth dongle. Incidentally, it would be great to be able to integrate the P1 Keypad through this integration, so that it can be used for other purposes (e.g. alarm panel). Have you looked at that device? If I can provide some data I will try!

liouma commented 8 months ago

If you choose not to give up, you may consider to try this one instead. It should be able to keep the connection more stable. But the coding is really bad, I don't know where to put the keepalive code properly. I hope someone could help me to solve this so that it may be able to merge into main branch in the future. tuya_ble.zip .

Hello @dmickeyus Thanks a lot for this file, I just received my A1 lock and I'm going to test your file.

Since your last post, did you create a git repo or a new version of your code ? I see that there is a ha_tuya_ble integration available here but A1 is not supported: https://github.com/PlusPlus-ua/ha_tuya_ble I guess it is not related to your work...

dmickeyus commented 8 months ago

@dmickeyus Using your code seems to add the correct buttons and sensors to the A1 Pro Max device under the Tuya BLE integration, but they stay in the 'unavailable' state. The logs show various errors such as 'Device unexpectedly disconnected', 'Sending device info request failed' and 'device not found, not in range, or poor RSSI'. I get this for all devices (2 A1 locks as well as some other bluetooth Tuya devices, including a Gimdow P1 Keypad), even for the lock that is just 3 metres from my HA server bluetooth dongle. I think the devices only get added because of a lookup to Tuya Cloud, and they are not found by local discovery, is that right? I wonder if then if my bluetooth adapter is even supported by this integration - I don't have a Raspberry Pi, I'm using the Homeassistant Blue (Odroid N2+) with a TP-Link bluetooth dongle. Incidentally, it would be great to be able to integrate the P1 Keypad through this integration, so that it can be used for other purposes (e.g. alarm panel). Have you looked at that device? If I can provide some data I will try!

@chris24walsh Sorry for my late reply, From my understanding, using their accessories eg Keypad needs synchronization with Tuya Cloud to perform the flows. Some people like me would prefer local control and not to use Cloud service in order to save their system resources ;-). Luckily, ha_tuya_ble could control Tuya devices locally. So that we can use it to control the Gimdow smartlock.

https://developer.tuya.com/en/docs/iot/title?id=K9nmje3twsy7n

Refer to their sdk, I could not find a way to control the accessories locally. Sorry.

dmickeyus commented 8 months ago

hi @liouma I am still using that old code, I didn't clone a new branch for it yet. Anyway, feel free to try it, it has been running in my HA for months and it does the job for me at least.

chris24walsh commented 8 months ago

@dmickeyus thanks for your reply. I meant about trying to listen to the keypad/read it's endpoints, not integrate it with the lock. However, I looked up the listed endpoints on Tuya IoT developer console and there doesn't appear to be much documented there at all.

Regarding your code, I was able to get the locks integrated to HA eventually, it just took setting up an ESPHome Bluetooth proxy closer (presumably too much local 2.4GHz interference), removing the existing HA devices and waiting until they repaired (usually after restarting HA or reloading the integration). In the end, though, I found this integration less reliable than another cloud integration someone wrote for the Gimdow locks which actually works pretty flawlessly, just that it is not a local solution. The main reason I stopped using the local bluetooth integration is that I found it was crashing my HA instance :( Have you experienced this, or anyone else here? Would still love to rely on a local solution for the locks, ideally, but can't unless can fix these issues. Happy to provide testing/feedback.

mikekornikh commented 8 months ago

I've had a 100% success rate using this for the last 5 months. It's never messed up even one time. Works super fast, way faster and more consistently than using some garbage Tuya hub. Local control for the win! I could also add now that after these 5 months (and 2 or 3 before that using just the Tuya cloud stuff) my battery level finally changed from high to normal. This is incredibly energy efficient, especially compared to other similar locks out there. (Switchbot lock usually lasts only a few months from what I heard) This device should absolutely be in the Tuya Ble integration by default for all users.

On Wed, Nov 8, 2023, 2:51 PM dmickeyus @.***> wrote:

hi @liouma https://github.com/liouma I am still using that old code, I didn't clone a new branch for it yet. Anyway, feel free to try it, it has been running in my HA for months and it does the job for me at least.

— Reply to this email directly, view it on GitHub https://github.com/PlusPlus-ua/ha_tuya_ble/issues/46#issuecomment-1802550417, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEJKKXD5M3XCLZ56VOJ74NLYDPPDHAVCNFSM6AAAAAA2NW4636VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMBSGU2TANBRG4 . You are receiving this because you authored the thread.Message ID: @.***>

dmickeyus commented 8 months ago

@dmickeyus thanks for your reply. I meant about trying to listen to the keypad/read it's endpoints, not integrate it with the lock. However, I looked up the listed endpoints on Tuya IoT developer console and there doesn't appear to be much documented there at all.

Regarding your code, I was able to get the locks integrated to HA eventually, it just took setting up an ESPHome Bluetooth proxy closer (presumably too much local 2.4GHz interference), removing the existing HA devices and waiting until they repaired (usually after restarting HA or reloading the integration). In the end, though, I found this integration less reliable than another cloud integration someone wrote for the Gimdow locks which actually works pretty flawlessly, just that it is not a local solution. The main reason I stopped using the local bluetooth integration is that I found it was crashing my HA instance :( Have you experienced this, or anyone else here? Would still love to rely on a local solution for the locks, ideally, but can't unless can fix these issues. Happy to provide testing/feedback.

hi @chris24walsh

I also faced crashing to HA when the hardware not paired properly, with the error similar to this #27 . Once paring is failed, HA have to be restarted to retry paring from ground or otherwise the HA will be crashed. I didn't figure out the reason for it but it works after several retries from repairing :-(. Two months later, it seems run even smoother after I migrated the HA from pi4 to x86 VM and also remove the cloud app from my mobile.

I guess you are using the smart lock with accessories, right? In this case, I believe the device has to run in cloud environment unless someone could find a way to integrate those accessories locally.

ReNeGaDe124 commented 7 months ago

@dmickeyus thanks for your reply. I meant about trying to listen to the keypad/read it's endpoints, not integrate it with the lock. However, I looked up the listed endpoints on Tuya IoT developer console and there doesn't appear to be much documented there at all.

Regarding your code, I was able to get the locks integrated to HA eventually, it just took setting up an ESPHome Bluetooth proxy closer (presumably too much local 2.4GHz interference), removing the existing HA devices and waiting until they repaired (usually after restarting HA or reloading the integration). In the end, though, I found this integration less reliable than another cloud integration someone wrote for the Gimdow locks which actually works pretty flawlessly, just that it is not a local solution. The main reason I stopped using the local bluetooth integration is that I found it was crashing my HA instance :( Have you experienced this, or anyone else here? Would still love to rely on a local solution for the locks, ideally, but can't unless can fix these issues. Happy to provide testing/feedback.

Hello, can you please tell me how you got that cloud integration working? Did you have something to modify to make it work?

I put the files in custom_components, I added the lines in configuration.yaml (for the client id and api key is used client id and client secret, is that correct?) but after HA restart I get the following error in logs:

Logger: homeassistant.components.lock Source: helpers/entity_platform.py:573 Integration: Lock (documentation, issues) First occurred: 19:26:18 (1 occurrences) Last logged: 19:26:18

gimdow: Error on device update! Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 573, in _async_add_entity await entity.async_device_update(warning=False) File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 959, in async_device_update await hass.async_add_executor_job(self.update) File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/gimdow/lock.py", line 125, in update self._lock.update() File "/config/custom_components/gimdow/gimdow.py", line 49, in update if query_list.get("logs"): ^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'get'

Thank you! Regards

chris24walsh commented 7 months ago

@ReNeGaDe124 Sounds like you have done essentially what I did; but did you define the "device_id" correctly in your configuration.yaml entry? The error message looks like the lookup to the Tuya API endpoint doesn't find anything under: query_result = self._openapi.get( f"/v1.0/devices/{self._device_id}/logs?end_time={end_time}&start_time={start_time}&type=7")

ReNeGaDe124 commented 7 months ago

@ReNeGaDe124 Sounds like you have done essentially what I did; but did you define the "device_id" correctly in your configuration.yaml entry? The error message looks like the lookup to the Tuya API endpoint doesn't find anything under: query_result = self._openapi.get( f"/v1.0/devices/{self._device_id}/logs?end_time={end_time}&start_time={start_time}&type=7")

Do I have to get the device id from Iot Tuya? I thought I had to give it a name. I put the device id as gimdow_lock. What did you put?

chris24walsh commented 7 months ago

@dmickeyus thanks for the tips, however I found that even when both my locks were paired and working fine, eventually one would stop responding. In addition (perhaps because of continuous pairing attempts from HA) HA would crash very frequently, almost like a memory leak. I had to remove the integration to fix this :( I'll try and get it working again sometime soon when I can afford the downtime from the cloud integration, which works perfectly so I depend quite heavily on it :) Agree with @mikekornikh though about these Gimdow locks, they are really amazing. I have one for years already, well before the Switchbot one came out, and they work very well with the batteries lasting a long time for the effort they put in.

ReNeGaDe124 commented 7 months ago

@chris24walsh I got the correct device id and now it is working perfectly. Thank you for the help!

chris24walsh commented 7 months ago

@chris24walsh I got the correct device id and now it is working perfectly. Thank you for the help!

Bingo, great to hear! Have you also tried and encountered issues with the above BLE integration? It is still the aim to get local working smoothly for me of course, but I have almost never had issues after more than a year of using the cloud integration (only self-inflicted issues when the Tuya BLE gateway was disconnected accidentally or placed too far away). @dmickeyus I will try again sometime by removing the Tuya app as you mentioned, only I still use it for 1 or 2 devices still that don't have good local solutions e.g. Tuya wifi vacuum.

chris24walsh commented 7 months ago

@chris24walsh I got the correct device id and now it is working perfectly. Thank you for the help!

Bingo, great to hear! Have you also tried and encountered issues with the above BLE integration? It is still the aim to get local working smoothly for me of course, but I have almost never had issues after more than a year of using the cloud integration (only self-inflicted issues when the Tuya BLE gateway was disconnected accidentally or placed too far away). @dmickeyus I will try again sometime by removing the Tuya app as you mentioned, only I still use it for 1 or 2 devices still that don't have good local solutions e.g. Tuya wifi vacuum.

P.S. @dmickeyus you definitely should fork this repo and open a PR to include your additions for the Gimdow lock, if not I will do it, lol!! But seriously, please do so we can all contribute patches etc.

ReNeGaDe124 commented 7 months ago

@chris24walsh I got the correct device id and now it is working perfectly. Thank you for the help!

Bingo, great to hear! Have you also tried and encountered issues with the above BLE integration? It is still the aim to get local working smoothly for me of course, but I have almost never had issues after more than a year of using the cloud integration (only self-inflicted issues when the Tuya BLE gateway was disconnected accidentally or placed too far away). @dmickeyus I will try again sometime by removing the Tuya app as you mentioned, only I still use it for 1 or 2 devices still that don't have good local solutions e.g. Tuya wifi vacuum.

I didn’t try the bluetooth integration because I want to use it with accessories (keypad and button).

Also I am afraid to unpair it from Smart Life because I have read on their Facebook page that I won’t be able to pair it again, only with Gimdow app and I don’t think that can be integrated in Home Assistant. There are some people who posted that they can’t pair their lock anymore. 😢

https://m.facebook.com/story.php?story_fbid=pfbid02BUMWj7ZZgsiufTo1raSZVdKjmnJfetcVVQeZKjdQApwg172Q7VP7CwAj6N4jEPzRl&id=102194888771247&mibextid=WC7FNe

Until now I was using the Google SDK to use the lock in Home Assistant (send voice command to unlock + PIN) but for the past couple of days it has stopped working. I think maybe because they are removing support. So I started looking for an alternative and I’m glad I found the integration you mentioned. 😊

chris24walsh commented 7 months ago

@ReNeGaDe124 I was able to re-pair my locks to Tuya Smart (essentially the same as Smart Life) app after removing them, during some testing. But I have encountered that I am now unable to pair the keypad I have, or the keyfob button, back with the locks - not sure if that was particularly what you were referring to. It used to work, and I can't say when exactly it stopped working, because I practically didn't use them anyway. It sucks now though, because I actually would like to use them again, particularly the keypad. It's a nice piece of hardware, and would be a great alarm panel if I could get the events in HA, so if I could at least pair it with my lock I could infer to disarm whenever the lock is unlocked.

I also was using the Alexa integration to lock/unlock from HA, so glad to now have an integration that works directly with cloud api, since the Alexa way was soo slow and buggy. Reliable use of the direct BLE integration would be 11/10 though, especially if there was some way to read events of the keypad/keyfob.

suba83 commented 7 months ago

Hello everyone! Who can describe how to integrate custom_components created by @dmickeyus (step by step)? I created a folder with custom_components, placed files there. After the reboot, a new Tuya integration appeared. In the first dialog box, I entered the Access ID and Take It Access Secret, Account, Password from Take It Platform. As a result, I got a lock with buttons, but they are not all active. There are errors in the logs: This error originated from a custom integration.

Logger: custom_components.Gimdow.tuya_ble.tuya_ble Source: custom_components/Gimdow/tuya_ble/tuya_ble.py:863 Integration: Gimdow First occurred: 22:08:59 (7 occurrences) Last logged: 22:15:36

DC:23:4E:D1:E5:2A: timeout receiving response, RSSI: -21 DC:23:4E:D1:E5:2A: timeout receiving response, RSSI: -30 DC:23:4E:D1:E5:2A: timeout receiving response, RSSI: -22

This error originated from a custom integration.

Logger: custom_components.Gimdow.tuya_ble.tuya_ble Source: custom_components/Gimdow/tuya_ble/tuya_ble.py:627 Integration: Gimdow First occurred: 22:08:59 (7 occurrences) Last logged: 22:15:36

DC:23:4E:D1:E5:2A: Sending device info request failed

This error originated from a custom integration.

Logger: homeassistant Source: custom_components/Gimdow/tuya_ble/tuya_ble.py:1309 Integration: Gimdow First occurred: 22:08:59 (8 occurrences) Last logged: 22:15:59

Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/config/custom_components/Gimdow/tuya_ble/tuya_ble.py", line 139, in set_value await self._owner._update_from_user(self._id) File "/config/custom_components/Gimdow/tuya_ble/tuya_ble.py", line 205, in _update_from_user await self._owner._send_datapoints([dp_id]) File "/config/custom_components/Gimdow/tuya_ble/tuya_ble.py", line 1309, in _send_datapoints raise TuyaBLEDeviceError(0) custom_components.Gimdow.tuya_ble.exceptions.TuyaBLEDeviceError: BLE deice returned error code 0 This error originated from a custom integration.

Logger: homeassistant Source: custom_components/Gimdow/tuya_ble/tuya_ble.py:1309 Integration: Gimdow First occurred: 22:08:59 (8 occurrences) Last logged: 22:15:59

Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/config/custom_components/Gimdow/tuya_ble/tuya_ble.py", line 139, in set_value await self._owner._update_from_user(self._id) File "/config/custom_components/Gimdow/tuya_ble/tuya_ble.py", line 205, in _update_from_user await self._owner._send_datapoints([dp_id]) File "/config/custom_components/Gimdow/tuya_ble/tuya_ble.py", line 1309, in _send_datapoints raise TuyaBLEDeviceError(0) custom_components.Gimdow.tuya_ble.exceptions.TuyaBLEDeviceError: BLE deice returned error code 0

2023-11-25_22-32-07

liouma commented 3 months ago

Hello, as you know there was many evolutions in tuya and problems were reported with tuya_ble. New versions of the code were written by different persons to patch it.

@dmickeyus : can your please share your updated code ? Thank you again so much !

dmickeyus commented 3 months ago

Hello, I am ok to share my currently functional version but I cannot guarantee it works to you guys. Since tuya changed its sdk api version, old api won't work in the near future. I am done to rely on the cloud to retrieve the secret keys. I believe I should be the key owner, not the cloud. That means, my code removed the cloud login to retreive the device info. Instead, one needs to get the them manually and put it into the file. This version reads the local file and control everything locally. Once discovered your BLE smart lock that matches your file MAC address and keys, it will add to your inventory automatically. I also replaced using button entities with lock entity to control and update status.

As usual, unpack the file to custom_components and create the secret file /config/tuya_local_ble/devices.json with the following format: { "XX:XX:XX:XX:XX:XX": { "address": "XX:XX:XX:XX:XX:XX", "uuid": "your_uuid_key", "local_key": "your_secret_key'", "device_id": "Your_device_id", "category": "jtmspro", "product_id": "rlyxv7pe", "device_name": "A1 PRO MAX", "product_model": "AT1", "product_name": "Smart lock" } }

If you are lucky enough, your could find these information from the old home assistant bakcup in /config/.storage/core.config_entries. If not, find them via your tuya account. They are waiting for you.

tuya_local_ble.zip

liouma commented 3 months ago

Thanks a lot once again @dmickeyus !!

Do you know the python script tinytuya ? It can retrieve all the tuya info instead of the tuya dev cloud. I find it really usefull.

I installed your script, restarted, then my gimdow lock was discovered immediately and installed. At first, the AI PRO MAX lock appeared correctly but with no entity. Then a second device was discovered and a configure button appeard on the first device.

When I clicked on "configure" on any of those devices I got:

Erreur
Le flux de configuration n'a pas pu être chargé: 500 Internal Server Error Server got itself in trouble

and in my logs: /config/custom_components/tuya_local_ble/text.py:134: SyntaxWarning: invalid escape sequence '\d' pattern="^((\d{1,2}|100)(\/\d{1,2})?)(;((\d{1,2}|100)(\/\d{1,2})?))+$",

Later 4 entities appeared on the first lock and it started to work fine :)

When I click on "configure" I still get the same error. But it work fine.

dmickeyus commented 3 months ago

Hi @liouma ,

I didn't try tinytuya yet but I suggest the lock should bundle with a CD driver with this script included.

Per your question, it seems to be charset and python version issue, could you try add 'r' to declare as rawstring. ie pattern=r"^((\d{1,2}|100)(\/\d{1,2})?)(;(........

Or, the lock does not use text.py, I guess delete this file could also eliminate the error.

The patch also featured a jam detection timer, I set to 12 seconds as default. You may test and change the value per your needs. Read the lock.py and you will find it out.

liouma commented 3 months ago

About the CD driver I completely agree with you :D

Adding the 'r' fixed the error. Thank you :)

What happens for you when you click on "configure"? Here, I get the following message: The configuration stream could not be loaded: 500 Internal Server Error Server got itself in trouble

I don't know if it's really a problem. Thank you for the info regarding the jam detection timer. I'll test different values if necessary.

dmickeyus commented 3 months ago

The config button was used on original code for changing cloud account info. It is no use now. Thanks for checking this out. I should remove it next time, maybe.

liouma commented 3 months ago

Thanks a lot It's working really fine!!!

I guess you are too busy for that, but that would be great if someone could publish and maintain a new tuya_local_ble integration based on your work, don't you think so??

dmickeyus commented 3 months ago

I agreed, I will be happy if someone could properly branch it out and help to keep maintaining it. I believe more ppl will find this useful if the setup steps are documented.

mikekornikh commented 3 months ago

I've been using it your software with the Gimdow lock over a year now flawlessly. (not counting the breaking changes HA made) I I appreciate it so much and absolutely think this needs to be fully part of the repo

On Sun, Apr 7, 2024 at 8:37 AM dmickeyus @.***> wrote:

I agreed, I will be happy if someone could properly branch it out and help to keep maintaining it. I believe more ppl will find this useful if the setup steps are documented.

— Reply to this email directly, view it on GitHub https://github.com/PlusPlus-ua/ha_tuya_ble/issues/46#issuecomment-2041456886, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEJKKXHSGA4KUOKX37D2UHDY4E4ZPAVCNFSM6AAAAAA2NW4636VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANBRGQ2TMOBYGY . You are receiving this because you were mentioned.Message ID: @.***>

TomekKazim commented 3 months ago

Hello Can you describe in more detail how to install the lock? Everything seems clear, but nothing is detected in my case. After these changes, there are so many errors in Tuya and it works slowly that I would move it from the cloud to Home Assistant, but the lock is the most important and it does not work in other add-ons. I have it set to truenas and it is an esp32. proxy. Need to disconnect your lock from the cloud? to detect

liouma commented 2 months ago

You need to remove your previous tuya_ble integration. Then you unzip the folder into folder config/custom_components/tuya_local_ble Create a file /config/tuya_local_ble/devices.json with the info posted previously in this thread. Replace all the info with your account info. You can use tinytuya to get it. Replace XX:XX... with the mac address. Restart HA. A new device will be discovered, configure it. At first there won't be any entity, but be patient and it will appear.

efranulic commented 2 months ago

Hello liouma, I have all parameters for devices.json except address... Can you explain in more detail the way to obtain the MAC address please?

liouma commented 2 months ago

The MAC address should be the easiest to obtain :) This is the hardware address of your bluetooth car, so any device like your phone connected to the smart lock should have it. But it doesn't mean it's displayed. Check on your tuya app if it appear in a field like about your device. Or try to pair your phone and see if you can get it.

I used tiny tuya to get it with all other tuya params. If you have a machine with python installed you can find a tutorial online to get evertything about your tuya device incl MAC, otherwise it's a bit overkill...

@all: How did yoiu all got your bluetooth mac addr ??

efranulic commented 2 months ago

Yes! You're right, it's on the tuya app

Thank you!

El vie, 26 de abr de 2024, 05:17, Reunion974 @.***> escribió:

The MAC address should be the easiest to obtain :) This is the hardware address of your bluetooth car, so any device like your phone connected to the smart lock should have it. But it doesn't mean it's displayed. Check on your tuya app if it appear in a field like about your device. Or try to pair your phone and see if you can get it. How did the others managed to get it ??

I used tiny tuya to get it with all other tuya params. If you have a machine with python installed you can find a tutorial online to get evertything about your tuya device incl MAC, otherwise it's a bit overkill...

— Reply to this email directly, view it on GitHub https://github.com/PlusPlus-ua/ha_tuya_ble/issues/46#issuecomment-2078982781, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOXISSRMHGPRG6VZBHDJ6NLY7ILUDAVCNFSM6AAAAAA2NW4636VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANZYHE4DENZYGE . You are receiving this because you commented.Message ID: @.***>

smirnowegor commented 2 months ago

Need to disconnect your lock from the cloud? to detect

Hi to all! Still fighting with the lock... it don't show up as a new device. Some maybe foolish questions: Should it be disconnected from Tuya app? Should there be any writing int configuration file? Where should be created /config/tuya_local_ble/devices.json?

TomekKazim commented 2 months ago

Check the paths to the folder and devices.json carefully because they should be different. You don't have to remove it from Tuya, but when you add it again, the local key changes

idanmid15 commented 2 months ago

After walking through the explanations above and implementing the local json file - has anyone encountered the following: It recognizes the device but all sensors are grayed out and unavailable. image

From the logs it seems like the device isn't recognized Getting this stacktrace - Traceback (most recent call last): File "/config/custom_components/tuya_local_ble/tuya_ble/tuya_ble.py", line 139, in set_value await self._owner._update_from_user(self._id) File "/config/custom_components/tuya_local_ble/tuya_ble/tuya_ble.py", line 205, in _update_from_user await self._owner._send_datapoints([dp_id]) File "/config/custom_components/tuya_local_ble/tuya_ble/tuya_ble.py", line 1309, in _send_datapoints raise TuyaBLEDeviceError(0) custom_components.tuya_local_ble.tuya_ble.exceptions.TuyaBLEDeviceError: BLE deice returned error code

I'm also getting many Timeouts for the Mac address not found - not sure if related since I remember getting these timeouts very often a while back when this used to work

TomekKazim commented 2 months ago

Today I have the same problem and I had it 2 weeks ago. Recently I removed the lock from Tuya and added it again, changed the key in devices.json and it worked. edit: After a few restarts and clicking ESP - it worked. maybe it has something to do with HA because it takes a long time to start and works slowly

dmickeyus commented 2 months ago

After walking through the explanations above and implementing the local json file - has anyone encountered the following: It recognizes the device but all sensors are grayed out and unavailable. image

From the logs it seems like the device isn't recognized Getting this stacktrace - Traceback (most recent call last): File "/config/custom_components/tuya_local_ble/tuya_ble/tuya_ble.py", line 139, in set_value await self._owner._update_from_user(self._id) File "/config/custom_components/tuya_local_ble/tuya_ble/tuya_ble.py", line 205, in _update_from_user await self._owner._send_datapoints([dp_id]) File "/config/custom_components/tuya_local_ble/tuya_ble/tuya_ble.py", line 1309, in _send_datapoints raise TuyaBLEDeviceError(0) custom_components.tuya_local_ble.tuya_ble.exceptions.TuyaBLEDeviceError: BLE deice returned error code

I'm also getting many Timeouts for the Mac address not found - not sure if related since I remember getting these timeouts very often a while back when this used to work

I faced similar case a year ago. It was because of the BLE connection. I was using rpi4 internal bluetooth device, the connection intermittently broken. Later I also tried USB Bluetooth adapter, but not really improved.

I am currently using esp32 ble_proxy to handle and quite stable with HA. I suggest you could also try stop your android app access the Lock via mobile coz the device wont allow multiple connections locally.

Good luck.

dmickeyus commented 2 months ago

For anyone interested, I upgraded HA 202405 and found the plugin sometimes not loaded normally. The integration page showed it is loaded but the status shown Not available. I made some updates and hope it could do some help.

tuya_local_ble.zip

comandor1967 commented 1 month ago

I have done all the above operations, nothing works. You can publish a ready-made integration so as not to waste time.

dmickeyus commented 1 month ago

@comandor1967 , u're right, this plug is literally not working. Dont waste time on it.

liouma commented 1 month ago

I have done all the above operations, nothing works. You can publish a ready-made integration so as not to waste time.

@comandor1967 : dmickeyus is kind enough to share his code with us but already explained that he does not have time to do more. Why don't you publish a new github with his code ?

smirnowegor commented 1 month ago

It seems that i got connection to the lock, but only Signal is appeared

Снимок экрана 2024-05-10 132124