Changes some logging statements

This commit is contained in:
samuelspagl 2024-03-12 14:16:11 +01:00
parent 09c1640839
commit 7c7648e51a
2 changed files with 8 additions and 6 deletions

View File

@ -20,9 +20,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up component from a config entry, config_entry contains data from config entry database.""" """Set up component from a config entry, config_entry contains data from config entry database."""
# store shell object # store shell object
_LOGGER.info(f"[{DOMAIN}] Starting to setup ConfigEntry {entry.data}") _LOGGER.info(f"[{DOMAIN}] Starting to setup a ConfigEntry")
_LOGGER.debug(f"[{DOMAIN}] Setting up ConfigEntry with the following data: {entry.data}")
if not DOMAIN in hass.data: if not DOMAIN in hass.data:
_LOGGER.info(f"[{DOMAIN}] Domain not found in hass.data setting default") _LOGGER.debug(f"[{DOMAIN}] Domain not found in hass.data setting default")
hass.data[DOMAIN] = SoundbarConfig( hass.data[DOMAIN] = SoundbarConfig(
SmartThings( SmartThings(
async_get_clientsession(hass), entry.data.get(CONF_ENTRY_API_KEY) async_get_clientsession(hass), entry.data.get(CONF_ENTRY_API_KEY)
@ -31,10 +32,11 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
) )
domain_config: SoundbarConfig = hass.data[DOMAIN] domain_config: SoundbarConfig = hass.data[DOMAIN]
_LOGGER.info(f"[{DOMAIN}] Retrieved Domain Config: {domain_config}") _LOGGER.debug(f"[{DOMAIN}] Retrieved Domain Config: {domain_config}")
if not entry.data.get(CONF_ENTRY_DEVICE_ID) in domain_config.devices: if not entry.data.get(CONF_ENTRY_DEVICE_ID) in domain_config.devices:
_LOGGER.info( _LOGGER.info(f"[{DOMAIN}] Setting up new Soundbar device")
_LOGGER.debug(
f"[{DOMAIN}] DeviceId: {entry.data.get(CONF_ENTRY_DEVICE_ID)} not found in domain_config, setting up new device." f"[{DOMAIN}] DeviceId: {entry.data.get(CONF_ENTRY_DEVICE_ID)} not found in domain_config, setting up new device."
) )
smart_things_device = await domain_config.api.device( smart_things_device = await domain_config.api.device(
@ -51,7 +53,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
domain_config.devices[entry.data.get(CONF_ENTRY_DEVICE_ID)] = DeviceConfig( domain_config.devices[entry.data.get(CONF_ENTRY_DEVICE_ID)] = DeviceConfig(
entry.data, soundbar_device entry.data, soundbar_device
) )
_LOGGER.info(f"[{DOMAIN}] after initializing Soundbar device") _LOGGER.info(f"[{DOMAIN}] Successfully initialized new Soundbar device")
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS) await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
return True return True

View File

@ -35,7 +35,7 @@ class ExampleConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
) )
return self.async_create_entry(title=DOMAIN, data=user_input) return self.async_create_entry(title=DOMAIN, data=user_input)
except Exception as excp: except Exception as excp:
_LOGGER.error(f"Example Flow triggered an exception {excp}") _LOGGER.error(f"The ConfigFlow triggered an exception {excp}")
return self.async_abort(reason="fetch_failed") return self.async_abort(reason="fetch_failed")
return self.async_show_form( return self.async_show_form(