From 070de2acded0ce34ebaf0b4383ba1b45d12b4453 Mon Sep 17 00:00:00 2001 From: Otto Winter Date: Wed, 14 Feb 2018 23:49:02 +0100 Subject: [PATCH 1/2] Fix MQTT returning prematurely --- 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 30c18953964c3b..0485d82a2741c0 100644 --- a/homeassistant/components/mqtt/__init__.py +++ b/homeassistant/components/mqtt/__init__.py @@ -607,7 +607,7 @@ def _mqtt_handle_message(self, msg): "with encoding %s", msg.payload, msg.topic, subscription.encoding) - return + continue self.hass.async_run_job(subscription.callback, msg.topic, payload, msg.qos) From 6ed7a1c540ce8f903d15595715f0c63980f4c7b3 Mon Sep 17 00:00:00 2001 From: Otto Winter Date: Wed, 14 Feb 2018 23:58:20 +0100 Subject: [PATCH 2/2] Add test --- tests/components/mqtt/test_init.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/components/mqtt/test_init.py b/tests/components/mqtt/test_init.py index a1edff8333dd82..24308bc9a7e236 100644 --- a/tests/components/mqtt/test_init.py +++ b/tests/components/mqtt/test_init.py @@ -172,6 +172,17 @@ def test_receiving_non_utf8_message_gets_logged(self): "b'\\x9a' on test-topic with encoding utf-8", test_handle.output[0]) + def test_all_subscriptions_run_when_decode_fails(self): + """Test all other subscriptions still run when decode fails for one.""" + mqtt.subscribe(self.hass, 'test-topic', self.record_calls, + encoding='ascii') + mqtt.subscribe(self.hass, 'test-topic', self.record_calls) + + fire_mqtt_message(self.hass, 'test-topic', '°C') + + self.hass.block_till_done() + self.assertEqual(1, len(self.calls)) + def test_subscribe_topic(self): """Test the subscription of a topic.""" unsub = mqtt.subscribe(self.hass, 'test-topic', self.record_calls)