Skip to content

Commit fa26feb

Browse files
JohannJohann
authored andcommitted
fix: restore async_copy_sounds function
1 parent 4d2240c commit fa26feb

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

custom_components/nida/__init__.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,31 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
6868
_LOGGER.debug(f"All sounds already present in {sounds_dst}")
6969

7070

71+
72+
async def async_copy_sounds(hass):
73+
"""Copy sounds from integration to /config/www/nida/sounds/"""
74+
75+
def _copy_sounds():
76+
import os, shutil
77+
sounds_src = os.path.join(os.path.dirname(__file__), "sounds")
78+
sounds_dst = hass.config.path("www/nida/sounds")
79+
80+
if not os.path.isdir(sounds_src):
81+
return 0
82+
83+
os.makedirs(sounds_dst, exist_ok=True)
84+
copied = 0
85+
for f in sorted(os.listdir(sounds_src)):
86+
if f.endswith(".mp3"):
87+
src = os.path.join(sounds_src, f)
88+
dst = os.path.join(sounds_dst, f)
89+
if not os.path.exists(dst):
90+
shutil.copy2(src, dst)
91+
copied += 1
92+
return copied
93+
94+
copied = await hass.async_add_executor_job(_copy_sounds)
95+
7196
async def async_setup_adhan_scheduler(hass: HomeAssistant, entry: ConfigEntry, coordinator):
7297
"""Schedule adhan at prayer times."""
7398

0 commit comments

Comments
 (0)