Use async_register_static_paths instead of register_static_path as users will begin to receive warnings that it does blocking I/O in the event loop and the function itself will be deprecated in HA 2025.7.
Registering View
The register_view function now also passes the hass object so that it can be utilized to call the async_add_executor_job function within ListingView's get function - more on that below.
Walk I/O blocking
The OS walk function does blocking disk I/O and users will get warnings about this. To get around this, we can use hass.async_add_executor_job to call it. However, this doesn't fully solve the problem since walk also calls scandir within itself, resulting in Home Assistant complaining about blocking still occurring. To get around this, I have added a get_icons_list helper function which is run in the executor instead of directly calling walk in the executor.
Static Path
async_register_static_paths
instead ofregister_static_path
as users will begin to receive warnings that it does blocking I/O in the event loop and the function itself will be deprecated in HA 2025.7.Registering View
register_view
function now also passes thehass
object so that it can be utilized to call theasync_add_executor_job
function within ListingView'sget
function - more on that below.Walk I/O blocking
The OS
walk
function does blocking disk I/O and users will get warnings about this. To get around this, we can usehass.async_add_executor_job
to call it. However, this doesn't fully solve the problem sincewalk
also callsscandir
within itself, resulting in Home Assistant complaining about blocking still occurring. To get around this, I have added aget_icons_list
helper function which is run in the executor instead of directly callingwalk
in the executor.Associated Issues