kind3r / hass-addons

Integration of the offline TTLock sdk into Home Assistant
59 stars 21 forks source link

Importing an RFID card not physically present #9

Closed ProVeg-Simon closed 2 years ago

ProVeg-Simon commented 3 years ago

Hi, thanks for the great cloud-free implementation! We have around 100 RFID cards and a dozen locks distributed over 5 floors. Is it possible to import all the card IDs (our old lock system stored them in a database in hexadecimal format) into all the locks without swiping every card at every lock?

Cheers

Simon from ProVeg

kind3r commented 3 years ago

Hi Simon,

I will do some research cause I remember seeing some sort of restore functionality in the Android SDK. You should first test a card on a separate lock connected to the addon, get it's ID and check if it matches the ones in your database (in my tests it's the card's UUID and it's the same every time, also you can read it with any NFC enabled phone, so only issue is how it's stored in your DB).

The easiest way for me to implement this would be as a separate script in the SDK that you could customise and run on a separate machine. Implementing this functionality in the HASS addon would over complicate things (thinking about file format, what the columns represent, how the data is stored in each column etc.) and I don't believe this is something the everyday user would use. Tell me how you feel about this.

Another question would be how do you plan to connect from the HA instance to all the locks as BLE range is limited and the addon does not support the TTLock gateway (cause that is cloud based only anyway) and can only work with one ESP32 gateway at the moment. So in order to suggest a suitable solution I would like to know more about your use case, if possible.

Emanuel

ProVeg-Simon commented 3 years ago

Hi, thanks for the quick answer!

Yeah, a little command line tool would be great, then I can iterate through the card IDs and locks and run it for each key for each lock. Ideal.

At the moment, I'm using the Pi's internal BT to communicate with the locks, so I could run around the building with it on a battery pack to program all the locks, but in the long run, it would be great if I could just stick a separate ESP32 to the wall next to each lock if more than one gateway was supported. I have the cloud gateways, they contain a ESP8266 for WiFi, a Nordic something something for BT and ISP ports for both controllers, perhaps one day someone can port the gateway code to run on them. ;-)

kind3r commented 3 years ago

Hi Simon,

I have updated the SDK to include the code for adding already known card IDs and added an example to it.

Basically what you would need to do is:

But given the instability of the BLE communication (especially when using the PI) I would not recommend using this addon in a 'production' environment yet as it is unreliable. It is fine for setting up the locks using a portable PI like you are planning, but I would not use it for monitoring or remote management just yet. I am planning on trying to compensate for the communication issues at some point but it is really difficult as they are so random. My short term plan is to add an external antenna to my PI to see if it improves things as running from my laptop which is further away from the lock does not have such problems, making it harder to debug.

Now, about the gateway, I'm sure a stripped down version of the gateway would be possible to implement, but my initial goal for that project was to build something based on the existing noble websocket protocol. Of course, in the end, this could be adapted and the weight of the websocket protocol could be replaced by raw TCP to make things lighter so it's possible to run on the 8266.