jbergler / hass-ttlock

Home Assistant integration for TTLock locks
55 stars 12 forks source link

add a notification that goes away when the webhook receives data #15

Closed jbergler closed 1 year ago

jbergler commented 1 year ago

fixes #14

cordvision commented 1 year ago

Where is that notification supposed to show up? I installed the latest version... Restarted HA, but I didn't get a notification anywhere. I still don’t know what the webhook url is.

jbergler commented 1 year ago

it uses the persistent_notification framework, so should show up bottom left in the menu above your user profile.

If that's not there can you download and share the diagnostic info for ttlock from the integrations page?

cordvision commented 1 year ago

Sorry for that, I just found it myself. I was looking for a notification in the logs and on the device page. I’m fairly new to HA. It might be obvious to longer-term home assistant users but not to a newbie like me. Adding something like ”shows up in notifications tab on left hand side in the HA toolbar" to the installation instructions would probably help out a lot.

cordvision commented 1 year ago

One more thing.... The webhook URL starts with my local ip address... Isn’t it supposed to be my outward facing domain (the one I use to remote access HA when I’m not connected to my local wifi)?

jbergler commented 1 year ago

All good, glad you figured it out and good call out with adding info to the docs.

It's a bit hard to reliably figure out the external url, I tried to copy the logic from another component that looked somewhat robust, but clearly not.

The important part is the path (the /api/webhoook/.... part), so you can change the hostname and protocol accordingly to your external values.

cordvision commented 1 year ago

IMG_20230415_134549

I did add the webhook url as you can see in the screenshot. I changed the local ip address to my outward facing domain name that I use to remote access HA. The notification still appears everytime I reload the integration. While we are at it: I noticed that the power level (battery of lock) is reported in the diagnostic file. However, I have no entity available in the integration that shows the power level.

jbergler commented 1 year ago

The webhook notification will keep showing up until you successfully receive some data via the web-hook. If it's not working I'd suggest trying a site like https://httpstatus.io/ to confirm if the url is externally reachable

cordvision commented 1 year ago

I finally figured out what the issue was.... I'm using the "Cloudflared" add on to access home assistant remotely (tunnel). I added my external url to In Settings -> System -> Network -> Home Assistant URL. After that, the webhook URL changed from http://192.168.1.1:8123/api/webho...... to https://myexternalurl.com:8123/api/webho.... I then removed the port number from the webhook so it had this format: https://myexternalurl.com/api/webho.... This was the missing piece, and it works now (history displays the unlock events).

One issue remains: I still only have 1 entity (Lock/Unlock), but not a power entity (battery level). However, when downloading the logs, I can see that the battery level is listed ("electricQuantity": 75,). Not sure why there is no battery entity in the integration available.

Thanks for all your work! I'm super happy that I can finally use the lock in automations :)

jbergler commented 1 year ago

Glad to hear you got the webhook sorted out.

I'm working (slowly) on a refactor to support adding entities for the other attributes of the lock without hitting the rate limits of the API. Hope I'll have something working in the next week or two (it's been hard finding time amongst everything else going on at the moment)