mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Bump brother to 0.1.18 (#41056)
This commit is contained in:
parent
44a3278ba8
commit
13f0ea506e
@ -6,7 +6,7 @@ import logging
|
||||
from brother import Brother, SnmpError, UnsupportedModel
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_HOST, CONF_TYPE
|
||||
from homeassistant.const import CONF_HOST, CONF_TYPE, EVENT_HOMEASSISTANT_STOP
|
||||
from homeassistant.core import Config, HomeAssistant
|
||||
from homeassistant.exceptions import ConfigEntryNotReady
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||
@ -58,7 +58,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
|
||||
)
|
||||
)
|
||||
if unload_ok:
|
||||
hass.data[DOMAIN].pop(entry.entry_id)
|
||||
hass.data[DOMAIN].pop(entry.entry_id).shutdown()
|
||||
|
||||
return unload_ok
|
||||
|
||||
@ -69,6 +69,9 @@ class BrotherDataUpdateCoordinator(DataUpdateCoordinator):
|
||||
def __init__(self, hass, host, kind):
|
||||
"""Initialize."""
|
||||
self.brother = Brother(host, kind=kind)
|
||||
self._unsub_stop = hass.bus.async_listen(
|
||||
EVENT_HOMEASSISTANT_STOP, self._handle_ha_stop
|
||||
)
|
||||
|
||||
super().__init__(
|
||||
hass,
|
||||
@ -79,8 +82,22 @@ class BrotherDataUpdateCoordinator(DataUpdateCoordinator):
|
||||
|
||||
async def _async_update_data(self):
|
||||
"""Update data via library."""
|
||||
# Race condition on shutdown. Stop all the fetches.
|
||||
if self._unsub_stop is None:
|
||||
return None
|
||||
|
||||
try:
|
||||
await self.brother.async_update()
|
||||
except (ConnectionError, SnmpError, UnsupportedModel) as error:
|
||||
raise UpdateFailed(error) from error
|
||||
return self.brother.data
|
||||
|
||||
def shutdown(self):
|
||||
"""Shutdown the Brother coordinator."""
|
||||
self._unsub_stop()
|
||||
self._unsub_stop = None
|
||||
self.brother.shutdown()
|
||||
|
||||
def _handle_ha_stop(self, _):
|
||||
"""Handle Home Assistant stopping."""
|
||||
self.shutdown()
|
||||
|
@ -50,6 +50,7 @@ class BrotherConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
brother = Brother(user_input[CONF_HOST])
|
||||
await brother.async_update()
|
||||
brother.shutdown()
|
||||
|
||||
await self.async_set_unique_id(brother.serial.lower())
|
||||
self._abort_if_unique_id_configured()
|
||||
|
@ -3,7 +3,7 @@
|
||||
"name": "Brother Printer",
|
||||
"documentation": "https://www.home-assistant.io/integrations/brother",
|
||||
"codeowners": ["@bieniu"],
|
||||
"requirements": ["brother==0.1.17"],
|
||||
"requirements": ["brother==0.1.18"],
|
||||
"zeroconf": [{"type": "_printer._tcp.local.", "name":"brother*"}],
|
||||
"config_flow": true,
|
||||
"quality_scale": "platinum"
|
||||
|
@ -386,7 +386,7 @@ bravia-tv==1.0.6
|
||||
broadlink==0.15.0
|
||||
|
||||
# homeassistant.components.brother
|
||||
brother==0.1.17
|
||||
brother==0.1.18
|
||||
|
||||
# homeassistant.components.brottsplatskartan
|
||||
brottsplatskartan==0.0.1
|
||||
|
@ -207,7 +207,7 @@ bravia-tv==1.0.6
|
||||
broadlink==0.15.0
|
||||
|
||||
# homeassistant.components.brother
|
||||
brother==0.1.17
|
||||
brother==0.1.18
|
||||
|
||||
# homeassistant.components.bsblan
|
||||
bsblan==0.3.7
|
||||
|
Loading…
x
Reference in New Issue
Block a user