diff --git a/app/Models/Device.php b/app/Models/Device.php
index 6d5993b..21f5c6c 100644
--- a/app/Models/Device.php
+++ b/app/Models/Device.php
@@ -2,6 +2,8 @@
namespace App\Models;
+use Carbon\Carbon;
+use DateTimeInterface;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
@@ -27,6 +29,7 @@ class Device extends Model
'sleep_mode_from' => 'datetime:H:i',
'sleep_mode_to' => 'datetime:H:i',
'special_function' => 'string',
+ 'pause_until' => 'datetime',
];
public function getBatteryPercentAttribute()
@@ -190,35 +193,41 @@ class Device extends Model
return $this->belongsTo(User::class);
}
- public function isSleepModeActive(?\DateTimeInterface $now = null): bool
+ public function isSleepModeActive(?DateTimeInterface $now = null): bool
{
- if (!$this->sleep_mode_enabled || !$this->sleep_mode_from || !$this->sleep_mode_to) {
+ if (! $this->sleep_mode_enabled || ! $this->sleep_mode_from || ! $this->sleep_mode_to) {
return false;
}
- $now = $now ? \Carbon\Carbon::instance($now) : now();
- $from = $this->sleep_mode_from instanceof \Carbon\Carbon ? $this->sleep_mode_from : \Carbon\Carbon::createFromFormat('H:i:s', $this->sleep_mode_from);
- $to = $this->sleep_mode_to instanceof \Carbon\Carbon ? $this->sleep_mode_to : \Carbon\Carbon::createFromFormat('H:i:s', $this->sleep_mode_to);
+
+ $now = $now ? Carbon::instance($now) : now();
+
// Handle overnight ranges (e.g. 22:00 to 06:00)
- return $from < $to
- ? $now->between($from, $to)
- : ($now->gte($from) || $now->lte($to));
+ return $this->sleep_mode_from < $this->sleep_mode_to
+ ? $now->between($this->sleep_mode_from, $this->sleep_mode_to)
+ : ($now->gte($this->sleep_mode_from) || $now->lte($this->sleep_mode_to));
}
- public function getSleepModeEndsInSeconds(?\DateTimeInterface $now = null): ?int
+ public function getSleepModeEndsInSeconds(?DateTimeInterface $now = null): ?int
{
- if (!$this->sleep_mode_enabled || !$this->sleep_mode_from || !$this->sleep_mode_to) {
+ if (! $this->sleep_mode_enabled || ! $this->sleep_mode_from || ! $this->sleep_mode_to) {
return null;
}
- $now = $now ? \Carbon\Carbon::instance($now) : now();
- $from = $this->sleep_mode_from instanceof \Carbon\Carbon ? $this->sleep_mode_from : \Carbon\Carbon::createFromFormat('H:i:s', $this->sleep_mode_from);
- $to = $this->sleep_mode_to instanceof \Carbon\Carbon ? $this->sleep_mode_to : \Carbon\Carbon::createFromFormat('H:i:s', $this->sleep_mode_to);
+ $now = $now ? Carbon::instance($now) : now();
+ $from = $this->sleep_mode_from;
+ $to = $this->sleep_mode_to;
// Handle overnight ranges (e.g. 22:00 to 06:00)
- if ($from < $to) {
- return $now->between($from, $to) ? $now->diffInSeconds($to, false) : null;
- } else {
- return ($now->gte($from) || $now->lt($to)) ? $now->diffInSeconds($to->addDay(), false) : null;
+ if ($this->sleep_mode_from < $to) {
+ return $now->between($from, $to) ? (int) $now->diffInSeconds($to, false) : null;
}
+
+ return ($now->gte($from) || $now->lt($to)) ? (int) $now->diffInSeconds($to->addDay(), false) : null;
+
+ }
+
+ public function isPauseActive(): bool
+ {
+ return $this->pause_until && $this->pause_until->isFuture();
}
}
diff --git a/app/Models/Playlist.php b/app/Models/Playlist.php
index d24356f..d20798c 100644
--- a/app/Models/Playlist.php
+++ b/app/Models/Playlist.php
@@ -58,6 +58,7 @@ class Playlist extends Model
return true;
}
}
+
return false;
}
diff --git a/app/Notifications/Channels/WebhookChannel.php b/app/Notifications/Channels/WebhookChannel.php
index f115c44..d116200 100644
--- a/app/Notifications/Channels/WebhookChannel.php
+++ b/app/Notifications/Channels/WebhookChannel.php
@@ -9,7 +9,7 @@ use GuzzleHttp\Psr7\Response;
use Illuminate\Notifications\Notification;
use Illuminate\Support\Arr;
-class WebhookChannel
+class WebhookChannel extends Notification
{
/** @var Client */
protected $client;
diff --git a/app/Notifications/Messages/WebhookMessage.php b/app/Notifications/Messages/WebhookMessage.php
index 6da9f55..920c16d 100644
--- a/app/Notifications/Messages/WebhookMessage.php
+++ b/app/Notifications/Messages/WebhookMessage.php
@@ -2,7 +2,9 @@
namespace App\Notifications\Messages;
-final class WebhookMessage
+use Illuminate\Notifications\Notification;
+
+final class WebhookMessage extends Notification
{
/**
* The GET parameters of the request.
diff --git a/database/migrations/2025_07_10_164606_add_pause_until_to_devices_table.php b/database/migrations/2025_07_10_164606_add_pause_until_to_devices_table.php
new file mode 100644
index 0000000..69181df
--- /dev/null
+++ b/database/migrations/2025_07_10_164606_add_pause_until_to_devices_table.php
@@ -0,0 +1,22 @@
+dateTime('pause_until')->nullable()->after('last_refreshed_at');
+ });
+ }
+
+ public function down(): void
+ {
+ Schema::table('devices', function (Blueprint $table) {
+ $table->dropColumn('pause_until');
+ });
+ }
+};
diff --git a/resources/views/livewire/devices/configure.blade.php b/resources/views/livewire/devices/configure.blade.php
index 6d9bb8a..bbfa7d3 100644
--- a/resources/views/livewire/devices/configure.blade.php
+++ b/resources/views/livewire/devices/configure.blade.php
@@ -314,6 +314,13 @@ new class extends Component {
-
+{"default_refresh_interval": 900, "sleep_mode_enabled": true, "pause_until": "2025-07-10T22:00:00+02:00"}
+
+