Add the QoS in the MQTT debug log (#83195)
Logging the MQTT QoS in the debug log
This commit is contained in:
parent
44d3f2192c
commit
de77132a5a
2 changed files with 7 additions and 5 deletions
|
@ -424,11 +424,12 @@ class MQTT:
|
||||||
self._mqttc.publish, topic, payload, qos, retain
|
self._mqttc.publish, topic, payload, qos, retain
|
||||||
)
|
)
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"Transmitting%s message on %s: '%s', mid: %s",
|
"Transmitting%s message on %s: '%s', mid: %s, qos: %s",
|
||||||
" retained" if retain else "",
|
" retained" if retain else "",
|
||||||
topic,
|
topic,
|
||||||
payload,
|
payload,
|
||||||
msg_info.mid,
|
msg_info.mid,
|
||||||
|
qos,
|
||||||
)
|
)
|
||||||
_raise_on_error(msg_info.rc)
|
_raise_on_error(msg_info.rc)
|
||||||
await self._wait_for_mid(msg_info.mid)
|
await self._wait_for_mid(msg_info.mid)
|
||||||
|
@ -551,7 +552,7 @@ class MQTT:
|
||||||
for topic, qos in subscriptions:
|
for topic, qos in subscriptions:
|
||||||
result, mid = self._mqttc.subscribe(topic, qos)
|
result, mid = self._mqttc.subscribe(topic, qos)
|
||||||
subscribe_result_list.append((result, mid))
|
subscribe_result_list.append((result, mid))
|
||||||
_LOGGER.debug("Subscribing to %s, mid: %s", topic, mid)
|
_LOGGER.debug("Subscribing to %s, mid: %s, qos: %s", topic, mid, qos)
|
||||||
return subscribe_result_list
|
return subscribe_result_list
|
||||||
|
|
||||||
async with self._paho_lock:
|
async with self._paho_lock:
|
||||||
|
@ -654,9 +655,10 @@ class MQTT:
|
||||||
@callback
|
@callback
|
||||||
def _mqtt_handle_message(self, msg: mqtt.MQTTMessage) -> None:
|
def _mqtt_handle_message(self, msg: mqtt.MQTTMessage) -> None:
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"Received%s message on %s: %s",
|
"Received%s message on %s (qos=%s): %s",
|
||||||
" retained" if msg.retain else "",
|
" retained" if msg.retain else "",
|
||||||
msg.topic,
|
msg.topic,
|
||||||
|
msg.qos,
|
||||||
msg.payload[0:8192],
|
msg.payload[0:8192],
|
||||||
)
|
)
|
||||||
timestamp = dt_util.utcnow()
|
timestamp = dt_util.utcnow()
|
||||||
|
|
|
@ -1429,14 +1429,14 @@ async def test_handle_message_callback(
|
||||||
):
|
):
|
||||||
"""Test for handling an incoming message callback."""
|
"""Test for handling an incoming message callback."""
|
||||||
await mqtt_mock_entry_no_yaml_config()
|
await mqtt_mock_entry_no_yaml_config()
|
||||||
msg = ReceiveMessage("some-topic", b"test-payload", 0, False)
|
msg = ReceiveMessage("some-topic", b"test-payload", 1, False)
|
||||||
mqtt_client_mock.on_connect(mqtt_client_mock, None, None, 0)
|
mqtt_client_mock.on_connect(mqtt_client_mock, None, None, 0)
|
||||||
await mqtt.async_subscribe(hass, "some-topic", lambda *args: 0)
|
await mqtt.async_subscribe(hass, "some-topic", lambda *args: 0)
|
||||||
mqtt_client_mock.on_message(mock_mqtt, None, msg)
|
mqtt_client_mock.on_message(mock_mqtt, None, msg)
|
||||||
|
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert "Received message on some-topic: b'test-payload'" in caplog.text
|
assert "Received message on some-topic (qos=1): b'test-payload'" in caplog.text
|
||||||
|
|
||||||
|
|
||||||
async def test_setup_override_configuration(hass, caplog, tmp_path):
|
async def test_setup_override_configuration(hass, caplog, tmp_path):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue