-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
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
Temporary fix for the client_id generation (fixes #8315) #8336
Conversation
import random | ||
client_id = conf.get( | ||
CONF_CLIENT_ID, 'home-assistant-{}'.format(random.randrange(0, 1000))) | ||
#client_id = conf.get(CONF_CLIENT_ID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
block comment should start with '# '
# Remove the generation of the client_id after it's fixed in HBMQTT | ||
import random | ||
client_id = conf.get( | ||
CONF_CLIENT_ID, 'home-assistant-{}'.format(random.randrange(0, 1000))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we check to make sure the protocol is 3.1.1? I think with 3.1, zero length clientIds are supported by the pano-mqtt client. That being said, it just generates a random clientId for you, but who knows if someone depends on that.
Another option is to set the protocol to 3.1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we check to make sure the protocol is 3.1.1?
We could but I see no benefit. Isn't it highly unlikely that somebody depends on a random generated ID? My assumption was that if you depend on the client ID then it's configured already.
Another option is to set the protocol to 3.1.
As far as I remember is HBMQTT only supporting MQTT 3.1.1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes HBMQTT support only 3.1.1
@@ -315,6 +315,10 @@ def async_setup(hass, config): | |||
client_cert = conf.get(CONF_CLIENT_CERT) | |||
tls_insecure = conf.get(CONF_TLS_INSECURE) | |||
protocol = conf[CONF_PROTOCOL] | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blank line contains whitespace
I tweaked the fix to only apply if we are starting the built-in MQTT broker. |
this didnt fix the issue for me... had to add client_id: foo to get this working on 0.48.1 |
The intended "tweak" by @balloob made the fix only apply when you start the internal broker with an |
This applies what was the intended fix in home-assistant#8336. moves the fallback for setting client_id to the case when no mqtt config was provided at all. This should reflect the most common use case that fails. This commit should be reverted when hbmqtt is fixed to allow empty client_id again.
This applies what was the intended fix in home-assistant#8336. moves the fallback for setting client_id to the case when no mqtt config was provided at all. This should reflect the most common use case that fails. This commit is a workaround and should be reverted when hbmqtt is fixed to allow empty client_id again.
This applies what was the intended fix in #8336. moves the fallback for setting client_id to the case when no mqtt config was provided at all. This should reflect the most common use case that fails. This commit is a workaround and should be reverted when hbmqtt is fixed to allow empty client_id again.
home-assistant#8336) * Temporary fix for the client_id generation (fixes home-assistant#8315) * Fix comment * Move client id setting. * Lint
This applies what was the intended fix in home-assistant#8336. moves the fallback for setting client_id to the case when no mqtt config was provided at all. This should reflect the most common use case that fails. This commit is a workaround and should be reverted when hbmqtt is fixed to allow empty client_id again.
Description:
MQTT 3.1.1 delegates the generation of a client ID to the server. With
paho-mqtt-1.3.0
and the embedded MQTT server it only works ifclient_id
is provided.This temporary fix allows to run the embedded MQTT server without setting a
client_id
.Related issue (if applicable): fixes #8315
Example entry for
configuration.yaml
(if applicable):mqtt:
Checklist:
If the code does not interact with devices:
tox
run successfully. Your PR cannot be merged unless tests pass