As far as I know the toniebox has no internal clock unfortunately. So I think I can answer my first question by myself. However you guys know better what is really in the box and what’s not.
The thing is, my kids use the toniebox during the day but also in the evening when falling asleep. But sometimes one of my kids is early up and puts on the max allowed volume which is kinda loud (cause using it during day). So by now I have to set the max volume to the lowest in teddycloud and refresh the box before they go to bed, and then again in the morning to max middle volume. And when I forget that in the evening everybody is up at 5 in the morning because it’s to loud.
So I thought there could be a way of setting the max volume by time. But with no internal clock it won’t be possible I think. Is there maybe another technical solution? Like having an command on the self made tonies so that it refreshes automatically and syncs with the cloud.
To set the max volume in the cloud is not the problem. I can handle that somehow, for example with a python script. But the problem is to get these settings onto the box. I think there is really no possibility for that. But you guys know best. Maybe the is a surprise
You could use a small Python script to access Teddycloud’s API directly and automatically change the maximum volume at specified times.
To do this, you would need to find the API endpoints and have the volume changed at the appropriate times.
You would also need to configure the script to start automatically with your system (systemd)…
Here’s an example script that might work (I haven’t tested it myself, as it still needs to be adapted)!
import requests
import schedule
import time
import sys
# --- ANPASSBARE EINSTELLUNGEN ---
# Ersetze dies mit der IP-Adresse und dem Port deines TeddyCloud-Servers
TEDDYCLOUD_URL = "http://192.168.1.50:9000"
# Dies ist ein ANGENOMMENER API-Endpunkt. Bitte prüfe die TeddyCloud-Doku!
API_ENDPOINT = "/api/v1/settings/max_volume"
# Lautstärke-Level
VOLUME_DAY = 15 # Maximale Lautstärke für den Tag (z.B. von 0-30)
VOLUME_NIGHT = 7 # Maximale Lautstärke für die Nacht
# --- FUNKTION ZUR LAUTSTÄRKEÄNDERUNG ---
def set_max_volume(volume_level: int):
"""
Sendet eine Anfrage an die TeddyCloud API, um die maximale Lautstärke zu ändern.
"""
full_url = TEDDYCLOUD_URL + API_ENDPOINT
# Der Payload ist eine Annahme. Es könnte sein, dass die API ein anderes
# Format erwartet, z.B. {"max_vol_spk": volume_level}. Bitte Doku prüfen!
payload = {
"speaker": volume_level,
"headphone": volume_level
}
print(f"Versuche, die maximale Lautstärke auf '{volume_level}' zu setzen...")
try:
# Sendet eine POST-Anfrage. Es könnte auch PUT sein.
response = requests.post(full_url, json=payload, timeout=10)
# Prüft, ob die Anfrage erfolgreich war (Status-Code 2xx)
response.raise_for_status()
print(f"✅ Erfolgreich! Antwort vom Server: {response.status_code}")
except requests.exceptions.RequestException as e:
print(f"❌ Fehler bei der API-Anfrage: {e}", file=sys.stderr)
# --- ZEITPLANUNG DER AUFGABEN ---
def setup_schedule():
"""
Definiert die Zeitpunkte, zu denen die Lautstärke geändert werden soll.
"""
# Jeden Tag um 07:00 Uhr die Lautstärke für den Tag setzen
schedule.every().day.at("07:00").do(set_max_volume, volume_level=VOLUME_DAY)
# Jeden Tag um 20:00 Uhr die Lautstärke für die Nacht setzen
schedule.every().day.at("20:00").do(set_max_volume, volume_level=VOLUME_NIGHT)
print("🕰️ Zeitplan eingerichtet. Warte auf die Ausführung der Aufgaben...")
print(f" - Nächste Tages-Einstellung ({VOLUME_DAY}): {schedule.next_run.strftime('%Y-%m-%d %H:%M:%S')}")
# --- HAUPTPROGRAMM ---
if __name__ == "__main__":
setup_schedule()
# Unendliche Schleife, um das Skript am Laufen zu halten
# und die geplanten Aufgaben auszuführen.
while True:
schedule.run_pending()
time.sleep(1) # Wartet eine Sekunde, um die CPU nicht zu überlasten