Skip to content

Commit

Permalink
Merge pull request #2036 from custom-components/dev
Browse files Browse the repository at this point in the history
chore: release 2023-09-22
  • Loading branch information
alandtse authored Sep 22, 2023
2 parents 87efe70 + a56374c commit ed7d047
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions custom_components/alexa_media/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
STATE_STANDBY,
STATE_UNAVAILABLE,
)
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.helpers.discovery import async_load_platform
from homeassistant.helpers.dispatcher import async_dispatcher_connect
Expand Down Expand Up @@ -98,12 +99,29 @@
DEPENDENCIES = [ALEXA_DOMAIN]


async def create_www_directory(hass: HomeAssistant):
"""Create www directory."""
paths = [
hass.config.path("www"), # http://homeassistant.local:8123/local
hass.config.path(
UPLOAD_PATH
), # http://homeassistant.local:8123/local/alexa_tts
]

def mkdir() -> None:
"""Create a directory."""
for path in paths:
if not os.path.exists(path):
_LOGGER.debug("Creating directory: %s", path)
os.makedirs(path, exist_ok=True)

await hass.async_add_executor_job(mkdir)


# @retry_async(limit=5, delay=2, catch_exceptions=True)
async def async_setup_platform(hass, config, add_devices_callback, discovery_info=None):
"""Set up the Alexa media player platform."""
upload_path = hass.config.path(UPLOAD_PATH)
if not os.path.exists(upload_path):
os.mkdir(upload_path)
await create_www_directory(hass)

devices = [] # type: List[AlexaClient]
account = None
Expand Down

0 comments on commit ed7d047

Please sign in to comment.