Reduce IPP errors when printer is offline (#44413)

This commit is contained in:
Diogo Gomes 2020-12-21 15:53:47 +00:00 committed by GitHub
parent 0b1791c293
commit cb82f5159e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -48,6 +48,8 @@ async def async_setup(hass: HomeAssistant, config: Dict) -> bool:
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up IPP from a config entry.""" """Set up IPP from a config entry."""
coordinator = hass.data[DOMAIN].get(entry.entry_id)
if not coordinator:
# Create IPP instance for this entry # Create IPP instance for this entry
coordinator = IPPDataUpdateCoordinator( coordinator = IPPDataUpdateCoordinator(
hass, hass,
@ -57,13 +59,13 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
tls=entry.data[CONF_SSL], tls=entry.data[CONF_SSL],
verify_ssl=entry.data[CONF_VERIFY_SSL], verify_ssl=entry.data[CONF_VERIFY_SSL],
) )
hass.data[DOMAIN][entry.entry_id] = coordinator
await coordinator.async_refresh() await coordinator.async_refresh()
if not coordinator.last_update_success: if not coordinator.last_update_success:
raise ConfigEntryNotReady raise ConfigEntryNotReady
hass.data[DOMAIN][entry.entry_id] = coordinator
for component in PLATFORMS: for component in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, component) hass.config_entries.async_forward_entry_setup(entry, component)