Log some mqtt of the discovery logging at debug level (#117185)

This commit is contained in:
Jan Bouwhuis 2024-05-10 14:49:27 +02:00 committed by GitHub
parent 9f321642b2
commit 96ccf7f2da
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 11 deletions

View file

@ -921,7 +921,7 @@ class MQTT:
self.connected = True
async_dispatcher_send(self.hass, MQTT_CONNECTED)
_LOGGER.info(
_LOGGER.debug(
"Connected to MQTT server %s:%s (%s)",
self.conf[CONF_BROKER],
self.conf.get(CONF_PORT, DEFAULT_PORT),

View file

@ -123,11 +123,11 @@ def set_discovery_hash(hass: HomeAssistant, discovery_hash: tuple[str, str]) ->
@callback
def async_log_discovery_origin_info(
message: str, discovery_payload: MQTTDiscoveryPayload
message: str, discovery_payload: MQTTDiscoveryPayload, level: int = logging.INFO
) -> None:
"""Log information about the discovery and origin."""
if CONF_ORIGIN not in discovery_payload:
_LOGGER.info(message)
_LOGGER.log(level, message)
return
origin_info: MqttOriginInfo = discovery_payload[CONF_ORIGIN]
sw_version_log = ""
@ -136,7 +136,8 @@ def async_log_discovery_origin_info(
support_url_log = ""
if support_url := origin_info.get("support_url"):
support_url_log = f", support URL: {support_url}"
_LOGGER.info(
_LOGGER.log(
level,
"%s from external application %s%s%s",
message,
origin_info["name"],
@ -343,7 +344,7 @@ async def async_start( # noqa: C901
elif already_discovered:
# Dispatch update
message = f"Component has already been discovered: {component} {discovery_id}, sending update"
async_log_discovery_origin_info(message, payload)
async_log_discovery_origin_info(message, payload, logging.DEBUG)
async_dispatcher_send(
hass, MQTT_DISCOVERY_UPDATED.format(*discovery_hash), payload
)

View file

@ -817,7 +817,7 @@ class MqttDiscoveryDeviceUpdate(ABC):
self._remove_device_updated = async_track_device_registry_updated_event(
hass, device_id, self._async_device_removed
)
_LOGGER.info(
_LOGGER.debug(
"%s %s has been initialized",
self.log_name,
discovery_hash,
@ -837,7 +837,7 @@ class MqttDiscoveryDeviceUpdate(ABC):
) -> None:
"""Handle discovery update."""
discovery_hash = get_discovery_hash(self._discovery_data)
_LOGGER.info(
_LOGGER.debug(
"Got update for %s with hash: %s '%s'",
self.log_name,
discovery_hash,
@ -847,8 +847,8 @@ class MqttDiscoveryDeviceUpdate(ABC):
discovery_payload
and discovery_payload != self._discovery_data[ATTR_DISCOVERY_PAYLOAD]
):
_LOGGER.info(
"%s %s updating",
_LOGGER.debug(
"Updating %s with hash %s",
self.log_name,
discovery_hash,
)
@ -864,7 +864,7 @@ class MqttDiscoveryDeviceUpdate(ABC):
)
await self._async_tear_down()
send_discovery_done(self.hass, self._discovery_data)
_LOGGER.info(
_LOGGER.debug(
"%s %s has been removed",
self.log_name,
discovery_hash,
@ -872,7 +872,7 @@ class MqttDiscoveryDeviceUpdate(ABC):
else:
# Normal update without change
send_discovery_done(self.hass, self._discovery_data)
_LOGGER.info(
_LOGGER.debug(
"%s %s no changes",
self.log_name,
discovery_hash,