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 self.connected = True
async_dispatcher_send(self.hass, MQTT_CONNECTED) async_dispatcher_send(self.hass, MQTT_CONNECTED)
_LOGGER.info( _LOGGER.debug(
"Connected to MQTT server %s:%s (%s)", "Connected to MQTT server %s:%s (%s)",
self.conf[CONF_BROKER], self.conf[CONF_BROKER],
self.conf.get(CONF_PORT, DEFAULT_PORT), 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 @callback
def async_log_discovery_origin_info( def async_log_discovery_origin_info(
message: str, discovery_payload: MQTTDiscoveryPayload message: str, discovery_payload: MQTTDiscoveryPayload, level: int = logging.INFO
) -> None: ) -> None:
"""Log information about the discovery and origin.""" """Log information about the discovery and origin."""
if CONF_ORIGIN not in discovery_payload: if CONF_ORIGIN not in discovery_payload:
_LOGGER.info(message) _LOGGER.log(level, message)
return return
origin_info: MqttOriginInfo = discovery_payload[CONF_ORIGIN] origin_info: MqttOriginInfo = discovery_payload[CONF_ORIGIN]
sw_version_log = "" sw_version_log = ""
@ -136,7 +136,8 @@ def async_log_discovery_origin_info(
support_url_log = "" support_url_log = ""
if support_url := origin_info.get("support_url"): if support_url := origin_info.get("support_url"):
support_url_log = f", support URL: {support_url}" support_url_log = f", support URL: {support_url}"
_LOGGER.info( _LOGGER.log(
level,
"%s from external application %s%s%s", "%s from external application %s%s%s",
message, message,
origin_info["name"], origin_info["name"],
@ -343,7 +344,7 @@ async def async_start( # noqa: C901
elif already_discovered: elif already_discovered:
# Dispatch update # Dispatch update
message = f"Component has already been discovered: {component} {discovery_id}, sending 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( async_dispatcher_send(
hass, MQTT_DISCOVERY_UPDATED.format(*discovery_hash), payload 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( self._remove_device_updated = async_track_device_registry_updated_event(
hass, device_id, self._async_device_removed hass, device_id, self._async_device_removed
) )
_LOGGER.info( _LOGGER.debug(
"%s %s has been initialized", "%s %s has been initialized",
self.log_name, self.log_name,
discovery_hash, discovery_hash,
@ -837,7 +837,7 @@ class MqttDiscoveryDeviceUpdate(ABC):
) -> None: ) -> None:
"""Handle discovery update.""" """Handle discovery update."""
discovery_hash = get_discovery_hash(self._discovery_data) discovery_hash = get_discovery_hash(self._discovery_data)
_LOGGER.info( _LOGGER.debug(
"Got update for %s with hash: %s '%s'", "Got update for %s with hash: %s '%s'",
self.log_name, self.log_name,
discovery_hash, discovery_hash,
@ -847,8 +847,8 @@ class MqttDiscoveryDeviceUpdate(ABC):
discovery_payload discovery_payload
and discovery_payload != self._discovery_data[ATTR_DISCOVERY_PAYLOAD] and discovery_payload != self._discovery_data[ATTR_DISCOVERY_PAYLOAD]
): ):
_LOGGER.info( _LOGGER.debug(
"%s %s updating", "Updating %s with hash %s",
self.log_name, self.log_name,
discovery_hash, discovery_hash,
) )
@ -864,7 +864,7 @@ class MqttDiscoveryDeviceUpdate(ABC):
) )
await self._async_tear_down() await self._async_tear_down()
send_discovery_done(self.hass, self._discovery_data) send_discovery_done(self.hass, self._discovery_data)
_LOGGER.info( _LOGGER.debug(
"%s %s has been removed", "%s %s has been removed",
self.log_name, self.log_name,
discovery_hash, discovery_hash,
@ -872,7 +872,7 @@ class MqttDiscoveryDeviceUpdate(ABC):
else: else:
# Normal update without change # Normal update without change
send_discovery_done(self.hass, self._discovery_data) send_discovery_done(self.hass, self._discovery_data)
_LOGGER.info( _LOGGER.debug(
"%s %s no changes", "%s %s no changes",
self.log_name, self.log_name,
discovery_hash, discovery_hash,