EDIT: I’m using this modified version of pytedee on my HA and I don’t see bridge added to list of locks … so I think that it’s fine.
EDIT2: I think that U used wrong API - https://api.tedee.com/api/v1.15/my/device
With “devices” API you have 2 x ID’s - and here you would receive 2 locks - lock and bridge
Try using “lock” as per my example above
I see, you have used my/lock. I missed that. Then your suggestion is correct.
I will update the github code, once I am ready with restoration of my host pc.
I have pushed small PR which add using lock properties in get_devices method. I can still see some mistakes in current implementation:
the get_state method should update lock is_connected and is_charging properties
in open method you assume it will take only 5 seconds but this can take longer depends of user configuration
in open/lock/unlock commands you set the state the end state just after calling endpoint but this doesnt must be true. at the end the operation may failure or the lock may jam. it would be better to use in progress state like (4 - unlocking, 5 -locking, 8 - pulling)
i do not know how the home assistant works but is there any logic to refresh the devices state periodically?
@Konrad-Tedee, I appreciate your help and thank you very much.
First, the update intervall is 30s as default. A user can change it.
The reason I set the state in form of optimistic is because I haven’t had the right enumeration of state. I saw a difference to what you sent me by email. But with the right information the python module can be corrected. The best would be that the module can receive notifications, then the state is always right and not assumed and must not be requested. In your documentation i saw that the requests for state should not be more than 1 per 10s. So how long must we wait until the lock is in position or failed, to make a request for it’s state? But waiting to long makes a bad user experience as everybody knows with touch devices when they do not react.
Further, homeassistant lock integration knows only Locked and Unlocked. There are no states in between. We can send the real state only as additional argument to homeassistant to show it somewhere, i.e. in a custom button card.
For the time of pull spring I can add a parameter, so the user can change it in homeassistant configuration.
Then, I will need some time to check your pull request.
I have pushed the version of pytedee to 0.0.2, because I added a request to duration of pullspring and updated the custom component. The custom component stays compatible to 0.0.1, but to see some additional state attributes, pytedee needs to be updated.
Additional state attributes:
A custom Button-Card with battery icon and different state strings as Locked, Locking, Unlocked, Unlocking, Pulling…
A single tap toggles between lock and unlock, a double tap is to open pullspring (only works when lock is unlocked).
The example code for it:
Thanks, looks nice.
I don’t see reson to keep compability with previous versions … as it’s not yet published to https://pypi.org/ … so no need to complicate code.
Here too. Lock locked not at 21:30 from the automation.
If I start HA:
2020-12-17 21:39:35 ERROR (MainThread) [homeassistant.components.lock] Error while setting up tedee platform for lock
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 199, in _async_setup_platform
await asyncio.shield(task)
File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/tedee_lock/lock.py", line 38, in setup_platform
tedee = TedeeClient(config[CONF_USERNAME], config[CONF_PASSWORD])
File "/usr/local/lib/python3.8/site-packages/pytedee/TedeeClient.py", line 42, in __init__
self.get_devices()
File "/usr/local/lib/python3.8/site-packages/pytedee/TedeeClient.py", line 73, in get_devices
result = r.json()["result"]
KeyError: 'result'
Edit: Also logged off in the iPhone tedee app.
Edit2: Cloud API is back online
Yes, it was the same here. In the afternoon I was not able to connect with the bridge in HA, also not by Tedee app, but the lock was connected to the app.
I am worried about this can happen always, that servers are down. I would like that we don’t need an external server.
Tedee support: Please think of this. Give the users the chance to decide how they use the lock, security served by you, or in own responsibility by the user.
If you had token (which is valid if I remember correctly for 3 hrs) … then it was mostly working for you, until token expired.
Portal that generate token was down, so any new requests couldn’t be completed
Yesterday our cloud provider Microsoft Azure had an issue. After 30 minutes we it was solved but we still analyzing it.
Even if cloud in unavailable user still can connect to devices using mobile app over Bluetooth, the switch is done automatically by the app. The cloud services can go down like google few days ago. The question is how many of you decided to build own SMTP server? The could give us and you match more versus local solutions.
@Konrad-Tedee Thanks for the Feedback. Not big deal for the short outage.
About SMTP:
The setup of a local SMTP is not needed to deliver E-Mails. You could use the existing one from your personal E-Mail provider like Gmail, Web.de, etc. They all provide SMTP services which I use in several local services.