mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 17:27:52 +00:00
Fix MQTT payload decode returning prematurely (#12420)
* Fix MQTT returning prematurely * Add test
This commit is contained in:
parent
c25c4c85d6
commit
5d4b1ecd3b
@ -607,7 +607,7 @@ class MQTT(object):
|
||||
"with encoding %s",
|
||||
msg.payload, msg.topic,
|
||||
subscription.encoding)
|
||||
return
|
||||
continue
|
||||
|
||||
self.hass.async_run_job(subscription.callback,
|
||||
msg.topic, payload, msg.qos)
|
||||
|
@ -172,6 +172,17 @@ class TestMQTTCallbacks(unittest.TestCase):
|
||||
"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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user