Implement alarm sound

This commit is contained in:
nemunaire 2022-10-14 20:08:03 +02:00
commit df31c4dcd1
15 changed files with 531 additions and 50 deletions

46
ui/src/lib/alarm.js Normal file
View file

@ -0,0 +1,46 @@
export async function isAlarmActive() {
const res = await fetch('api/alarm', {
headers: {'Accept': 'application/json'},
});
if (res.status == 200) {
return await res.json();
} else {
throw new Error((await res.json()).errmsg);
}
}
export async function runAlarm() {
const res = await fetch('api/alarm/run', {
method: 'POST',
headers: {'Accept': 'application/json'},
});
if (res.status == 200) {
return await res.json();
} else {
throw new Error((await res.json()).errmsg);
}
}
export async function alarmNextTrack() {
const res = await fetch('api/alarm/next', {
method: 'POST',
headers: {'Accept': 'application/json'},
});
if (res.status == 200) {
return await res.json();
} else {
throw new Error((await res.json()).errmsg);
}
}
export async function alarmStop() {
const res = await fetch('api/alarm', {
method: 'DELETE',
headers: {'Accept': 'application/json'},
});
if (res.status == 200) {
return await res.json();
} else {
throw new Error((await res.json()).errmsg);
}
}

View file

@ -5,11 +5,12 @@ export class Settings {
}
}
update({ language, gong_interval, weather_delay, weather_action }) {
update({ language, gong_interval, weather_delay, weather_action, max_run_time }) {
this.language = language;
this.gong_interval = gong_interval;
this.weather_delay = weather_delay;
this.weather_action = weather_action;
this.max_run_time = max_run_time;
}
async save() {