Always print invalid configuration data (#21972)
* Always print invalide configuration data * Print offending data as yaml * Revert "Print offending data as yaml" This reverts commit 01721a21a9ff918ed2c8595151ebfe55eb2f7d36. * Do not print sensitive data * Print MQTT topic * Add line break * Review comments * review comments
This commit is contained in:
1 parent
4c4f0e38d4
commit
8d775caaac
2 files changed
+59
-21
No files matched your search
@@ -210,6 +210,12 @@ def clear_discovery_hash(hass, discovery_hash):
|
||||
del hass.data[ALREADY_DISCOVERED][discovery_hash]
|
||||
|
||||
|
||||
class MQTTConfig(dict):
|
||||
"""Dummy class to allow adding attributes."""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
async def async_start(hass: HomeAssistantType, discovery_topic, hass_config,
|
||||
config_entry=None) -> bool:
|
||||
"""Initialize of MQTT Discovery."""
|
||||
@@ -236,7 +242,7 @@ async def async_start(hass: HomeAssistantType, discovery_topic, hass_config,
|
||||
object_id, payload)
|
||||
return
|
||||
|
||||
payload = dict(payload)
|
||||
payload = MQTTConfig(payload)
|
||||
|
||||
for key in list(payload.keys()):
|
||||
abbreviated_key = key
|
||||
@@ -264,6 +270,10 @@ async def async_start(hass: HomeAssistantType, discovery_topic, hass_config,
|
||||
discovery_hash = (component, discovery_id)
|
||||
|
||||
if payload:
|
||||
# Attach MQTT topic to the payload, used for debug prints
|
||||
setattr(payload, '__configuration_source__',
|
||||
"MQTT (topic: '{}')".format(topic))
|
||||
|
||||
if CONF_PLATFORM in payload and 'schema' not in payload:
|
||||
platform = payload[CONF_PLATFORM]
|
||||
if (component in DEPRECATED_PLATFORM_TO_SCHEMA and
|
||||
|
||||
Reference in new issue
Block a user