Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Topic homekey_mqtt/status? #81

Open
segdy opened this issue Jul 6, 2024 · 6 comments
Open

Topic homekey_mqtt/status? #81

segdy opened this issue Jul 6, 2024 · 6 comments
Labels
dev Fixed or added in dev branch

Comments

@segdy
Copy link

segdy commented Jul 6, 2024

I just got my hardware and it works super well. YAY!

However, HomeAssistant shows the lock as unavailable:

image

I did check "Enable HASS MQTT Discovery". I think the issue is the availablity_topic in the auto disccovery which is always set to topic "homekey_mqtt/status":

image

But this topic doesn't exist and I didn't define it anywhere. Is this a bug? It should be in homekey/homekey/status

EDIT: Indeed. I removed "availability_topic via MQTT Explorer and the lock shows up now in HA. So I think this is a bug. Appreciate a fix :)

@segdy
Copy link
Author

segdy commented Jul 8, 2024

Removing availability_topic doesn't actually work because the topic will be overwritten.
As another temporary fix, I just created retained topic homekey_mqtt/status with value online. This works, but fix in code would be highly appreciated!

@rednblkx
Copy link
Owner

rednblkx commented Jul 8, 2024

Hi there!

"homekey_mqtt/status" is an internal topic defined on connection, used for LWT and also as the availability_topic for HASS as that is required.

If this topic is not present, you might have connectivity issues which prevents the esp from telling the broker it's "alive" or more specifically setting status to online.

In normal conditions this works without issues, suggest to check the mqtt settings on the esp, try changing the client id, perhaps there might be a conflict for some reason.

@segdy
Copy link
Author

segdy commented Jul 8, 2024

I'm confused. The topic should be configured somewhere, just as the other ones are configured:

image

There is nowhere anything to configure the availability topic (or availability function in the first place).

Instead of "homekey_mqtt/status" it should be "homekey/homekey/availability" (or similar). And HomeKey-ESP32 (HomeSpan) is supposed to write this ... but doesn't.

@rednblkx
Copy link
Owner

rednblkx commented Jul 8, 2024

I haven't included it as an option since it doesn't add any benefit to being configurable as it really was only meant to be used by HASS and it is also made to be "unique" as it uses the mqtt client id for the first part.

@segdy
Copy link
Author

segdy commented Jul 8, 2024

Yes, I see what's going on now. "$clientID/status" topic is being generated automatically and used as availability topic. Most often, users have fine grained access control (incl myself), so access to topic "homekey_mqtt/" was not allowed b y mosquitto ACL. I can make it work by changing Client ID to "homekey". So, there are many workarounds (three now described in this thread).

While not something critical, I'd still think it would be a good idea to make this configurable. Because:

since it doesn't add any benefit to being configurable as it really was only meant to be used by HASS

with the same argument you wouldn't need anything configurable. The benefit of letting users change all the MQTT topics is exactly identical to letting them change the availability topic. (see my story above as an example).

The behavior that a device automatically generates an availability topic under "$clientID" I have not experienced with any other device so far. I don't think it's common or best practice. Just as an example, OpenGarage uses an automatically generated client ID derived from MAC address (OG_B02E82 in my example). Yet, the availability topic shows up as "/garage/OUT/STATUS" and not "OG_B02E82/STATUS".

@rednblkx
Copy link
Owner

Just to be clear, the project is not yet in final shape, main page and versioning I think says as much.
I’m not saying things like this will stay as they are, just providing some reasoning to why it is how it is now, i did not thought it was worth the extra lines at the time so I did not include it.
Note that it is mentioned in the wiki that it uses <MQTT_CLIENTID>/status as the topic for LWT though I agree I should’ve mentioned it is also used in availability_topic.

On a side note, this is exactly why I enabled the Issues and Discussions tab, so I know what things need to be worked on as I try to make the project as good as it can be.

Thank you for letting me know, it will be handled.

@rednblkx rednblkx added the dev Fixed or added in dev branch label Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dev Fixed or added in dev branch
Projects
None yet
Development

No branches or pull requests

2 participants