diff --git a/adhan-webapp/app.py b/adhan-webapp/app.py index 3487221..2981ee5 100644 --- a/adhan-webapp/app.py +++ b/adhan-webapp/app.py @@ -6,9 +6,6 @@ from hijridate import Gregorian from functools import lru_cache import time from concurrent.futures import ThreadPoolExecutor -import asyncio -import aiohttp -from functools import wraps app = Flask(__name__) @@ -18,12 +15,6 @@ last_api_call = {} cached_data = {} executor = ThreadPoolExecutor(max_workers=3) # Voor parallelle API calls -def async_route(f): - @wraps(f) - def wrapped(*args, **kwargs): - return asyncio.run(f(*args, **kwargs)) - return wrapped - def get_cached_data(key, fetch_func, duration=CACHE_DURATION): """Haal data uit cache of voer fetch_func uit als cache verlopen is""" current_time = time.time() @@ -37,67 +28,14 @@ def get_cached_data(key, fetch_func, duration=CACHE_DURATION): last_api_call[key] = current_time return data -async def fetch_weather_data_async(): - """Asynchrone versie van weather data ophalen""" - try: - async with aiohttp.ClientSession() as session: - params = { - 'q': WEATHER_LOCATION, - 'appid': OPENWEATHER_API_KEY, - 'units': 'metric', - 'lang': 'nl' - } - async with session.get('https://api.openweathermap.org/data/2.5/weather', params=params, timeout=5) as response: - data = await response.json() - - weather_info = { - 'temperature': round(data['main']['temp']), - 'feels_like': round(data['main']['feels_like']), - 'description': data['weather'][0]['description'].capitalize(), - 'humidity': data['main']['humidity'], - 'wind_speed': round(data['wind']['speed'] * 3.6), - 'icon': data['weather'][0]['icon'] - } - return weather_info - except Exception as e: - print(f"⚠️ Fout bij ophalen weerdata: {e}") - return { - 'temperature': '--', - 'feels_like': '--', - 'description': 'Weer niet beschikbaar', - 'humidity': '--', - 'wind_speed': '--', - 'icon': '01d' - } - -async def fetch_sonos_zones_async(): - """Asynchrone versie van Sonos zones ophalen""" - try: - async with aiohttp.ClientSession() as session: - async with session.get(f'http://{SONOS_API_IP}:5005/zones', timeout=5) as response: - data = await response.json() - zones = [] - for group in data: - for player in group['members']: - zones.append(player['roomName']) - return sorted(set(zones)) - except Exception as e: - print(f'Fout bij ophalen Sonos-zones: {e}') - return ['Woonkamer', 'Slaapkamer', 'Keuken'] - -async def fetch_data_parallel_async(): - """Haal alle data parallel op met asyncio""" - weather_task = asyncio.create_task(fetch_weather_data_async()) - sonos_task = asyncio.create_task(fetch_sonos_zones_async()) - date_task = asyncio.create_task(asyncio.to_thread(get_date_info)) - - weather, sonos, date = await asyncio.gather(weather_task, sonos_task, date_task) - - return { - 'weather': weather, - 'sonos': sonos, - 'date': date +def fetch_data_parallel(): + """Haal alle data parallel op""" + futures = { + 'weather': executor.submit(fetch_weather_data), + 'sonos': executor.submit(fetch_sonos_zones), + 'date': executor.submit(get_date_info) } + return {key: future.result() for key, future in futures.items()} # Voeg cache-control headers toe voor statische bestanden @app.after_request @@ -394,8 +332,7 @@ def index(): date_info=date_info) @app.route('/instellingen', methods=['GET', 'POST']) -@async_route -async def instellingen(): +def instellingen(): if request.method == 'POST': try: # Nieuwe volume instellingen @@ -472,9 +409,9 @@ async def instellingen(): print(f"❌ Fout bij opslaan instellingen: {e}") # Probeer alsnog door te gaan zonder de Pi volume instelling return redirect('/instellingen') - - # Haal alle data parallel op met asyncio - data = await fetch_data_parallel_async() + + # Haal alle data parallel op + data = fetch_data_parallel() return render_template('settings.html', settings=load_settings(), diff --git a/adhan-webapp/templates/adzkaar.html b/adhan-webapp/templates/adzkaar.html index 100fe00..eb81bd5 100644 --- a/adhan-webapp/templates/adzkaar.html +++ b/adhan-webapp/templates/adzkaar.html @@ -3,6 +3,8 @@ Adzkaar na het Gebed + + @@ -208,40 +210,28 @@
- - -
- 5:00 -
-
-

أذكار بعد الصلاة

-

Adzkaar na het Gebed

+

Adzkaar na het Gebed

+

Herinneringen voor na het gebed

- - -
- 1 / 6 -
- -
-
-
-
أَسْتَغْفِرُ اللَّهَ
-
Astaghfirullah
-
Ik vraag Allah om vergeving
-
3x
+
+
+
سُبْحَانَ اللَّهِ
+
Subhanallah
+
Glorie zij Allah
+
33x
@@ -252,27 +242,20 @@
-
سُبْحَانَ اللَّهِ
-
Subhan Allah
-
Glorie zij Allah
-
33x
-
- -
الْحَمْدُ لِلَّهِ
Alhamdulillah
Alle lof zij Allah
33x
-
+
اللَّهُ أَكْبَرُ
Allahu Akbar
Allah is de Grootste
34x
-
+
لاَ إِلَهَ إِلاَّ اللَّهُ وَحْدَهُ لاَ شَرِيكَ لَهُ لَهُ الْمُلْكُ وَلَهُ الْحَمْدُ وَهُوَ عَلَى كُلِّ شَيْءٍ قَدِيرٌ
La ilaha illa Allah wahdahu la sharika lah, lahu al-mulku wa lahu al-hamdu wa huwa 'ala kulli shay'in qadir
Er is geen god behalve Allah alleen, Hij heeft geen partner. Aan Hem behoort de heerschappij en aan Hem behoort alle lof, en Hij heeft macht over alle dingen
@@ -280,109 +263,85 @@
+ +
00:00
+
\ No newline at end of file diff --git a/adhan-webapp/templates/index.html b/adhan-webapp/templates/index.html index ee46084..89f4699 100644 --- a/adhan-webapp/templates/index.html +++ b/adhan-webapp/templates/index.html @@ -4,8 +4,17 @@ Gebedstijden Display + + +
@@ -164,6 +173,14 @@
- - + diff --git a/done b/done index 18da2b4..5996268 100644 --- a/done +++ b/done @@ -77,4 +77,4 @@ Wed May 28 14:02:31 CEST 2025: Debug tijd synchronisatie toegevoegd tussen debug 2025-05-29 16:54:45 - Hardcore boot optimalisaties toegevoegd: CPU overclock, SD overclock, meer services disabled, fastboot parameter, RAM optimalisaties voor sub-60sec boot 2025-05-29 17:03:53 - Chrome translate banner uitgeschakeld: --disable-translate, --disable-features=Translate, --lang=nl flags toegevoegd aan beide setup scripts 2025-05-29 17:07:38 - Browser gewijzigd van Chromium naar Puffin: 4x sneller, 80MB minder RAM, cloud rendering voor betere Pi3 prestaties -2025-05-29 17:28:00 - Terug naar Chromium: Puffin werkte niet goed op Pi3 \ No newline at end of file +2025-05-29 17:28:00 - Terug naar Chromium: Puffin werkte niet goed op Pi32025-05-29 21:32:16 - Geoptimaliseerde index.html en adzkaar.html voor betere performance