From 0b60400d62a99c855a052a8f9e29dd01cdf3754e Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Tue, 4 Jul 2017 13:23:37 +0200 Subject: [PATCH 1/4] Temporary fix for the client_id generation (fixes #8315) --- homeassistant/components/mqtt/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/mqtt/__init__.py b/homeassistant/components/mqtt/__init__.py index 6be47581a5084..32584d2fedb29 100644 --- a/homeassistant/components/mqtt/__init__.py +++ b/homeassistant/components/mqtt/__init__.py @@ -296,7 +296,11 @@ def async_setup(hass, config): if conf is None: conf = CONFIG_SCHEMA({DOMAIN: {}})[DOMAIN] - client_id = conf.get(CONF_CLIENT_ID) + # 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))) + #client_id = conf.get(CONF_CLIENT_ID) keepalive = conf.get(CONF_KEEPALIVE) # Only setup if embedded config passed in or no broker specified From f2fee656013bb0dae13af25bcd7d426f0d4193d7 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Tue, 4 Jul 2017 13:35:50 +0200 Subject: [PATCH 2/4] Fix comment --- homeassistant/components/mqtt/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/mqtt/__init__.py b/homeassistant/components/mqtt/__init__.py index 32584d2fedb29..a3db7121a0d8d 100644 --- a/homeassistant/components/mqtt/__init__.py +++ b/homeassistant/components/mqtt/__init__.py @@ -300,7 +300,7 @@ def async_setup(hass, config): import random client_id = conf.get( CONF_CLIENT_ID, 'home-assistant-{}'.format(random.randrange(0, 1000))) - #client_id = conf.get(CONF_CLIENT_ID) + # client_id = conf.get(CONF_CLIENT_ID) keepalive = conf.get(CONF_KEEPALIVE) # Only setup if embedded config passed in or no broker specified From e7ca07fefae3de7b2b53063f05e96ef271c53d3b Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Tue, 4 Jul 2017 21:13:26 -0700 Subject: [PATCH 3/4] Move client id setting. --- homeassistant/components/mqtt/__init__.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/mqtt/__init__.py b/homeassistant/components/mqtt/__init__.py index a3db7121a0d8d..a10a4f4060600 100644 --- a/homeassistant/components/mqtt/__init__.py +++ b/homeassistant/components/mqtt/__init__.py @@ -296,11 +296,7 @@ def async_setup(hass, config): if conf is None: conf = CONFIG_SCHEMA({DOMAIN: {}})[DOMAIN] - # 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))) - # client_id = conf.get(CONF_CLIENT_ID) + client_id = conf.get(CONF_CLIENT_ID) keepalive = conf.get(CONF_KEEPALIVE) # Only setup if embedded config passed in or no broker specified @@ -319,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] + + # hbmqtt requires a client id to be set. + if client_id is None: + client_id = 'home-assistant' elif broker_config: # If no broker passed in, auto config to internal server broker, port, username, password, certificate, protocol = broker_config From 22776065495edf1d9a3bcb25946f8f2ee00cfd5f Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Tue, 4 Jul 2017 21:13:50 -0700 Subject: [PATCH 4/4] Lint --- homeassistant/components/mqtt/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/mqtt/__init__.py b/homeassistant/components/mqtt/__init__.py index a10a4f4060600..64c963a6b8e11 100644 --- a/homeassistant/components/mqtt/__init__.py +++ b/homeassistant/components/mqtt/__init__.py @@ -315,7 +315,7 @@ def async_setup(hass, config): client_cert = conf.get(CONF_CLIENT_CERT) tls_insecure = conf.get(CONF_TLS_INSECURE) protocol = conf[CONF_PROTOCOL] - + # hbmqtt requires a client id to be set. if client_id is None: client_id = 'home-assistant'