Allow USB polling monitor on macOS for development (#141029)

* Allow USB polling on macOS

* Remove `_async_supports_monitoring`
This commit is contained in:
puddly 2025-03-20 20:43:29 -04:00 committed by GitHub
parent 72645dff8b
commit 87c8234cdc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -265,8 +265,15 @@ class USBDiscovery:
async def async_setup(self) -> None: async def async_setup(self) -> None:
"""Set up USB Discovery.""" """Set up USB Discovery."""
if self._async_supports_monitoring(): try:
await self._async_start_monitor() await self._async_start_aiousbwatcher()
except InotifyNotAvailableError as ex:
_LOGGER.info(
"Falling back to periodic filesystem polling for development, "
"aiousbwatcher is not available on this system: %s",
ex,
)
self._async_start_monitor_polling()
self.hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STARTED, self.async_start) self.hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STARTED, self.async_start)
self.hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, self.async_stop) self.hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, self.async_stop)
@ -281,22 +288,6 @@ class USBDiscovery:
if self._request_debouncer: if self._request_debouncer:
self._request_debouncer.async_shutdown() self._request_debouncer.async_shutdown()
@hass_callback
def _async_supports_monitoring(self) -> bool:
return sys.platform == "linux"
async def _async_start_monitor(self) -> None:
"""Start monitoring hardware."""
try:
await self._async_start_aiousbwatcher()
except InotifyNotAvailableError as ex:
_LOGGER.info(
"Falling back to periodic filesystem polling for development, aiousbwatcher "
"is not available on this system: %s",
ex,
)
self._async_start_monitor_polling()
@hass_callback @hass_callback
def _async_start_monitor_polling(self) -> None: def _async_start_monitor_polling(self) -> None:
"""Start monitoring hardware with polling (for development only!).""" """Start monitoring hardware with polling (for development only!)."""