Lights Off Timer: Jellyfin sleep timer that turns off Home Assistant lights
Jellyfin 12.2 plugin that adds a sleep-timer button next to the volume control in the web player (end of this episode/movie, or N minutes). When playback stops with the timer on, it calls a Home Assistant webhook that turns the lights off after a cooldown; starting playback cancels it. The repository doubles as a Jellyfin plugin repository: manifest.json at the root points at the release zips in dist/. build.sh builds in the .NET 10 SDK container and adds new versions to the manifest. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
8d456442e6
15 files changed
+934
No files matched your search
@@ -0,0 +1,18 @@
|
||||
using MediaBrowser.Model.Plugins;
|
||||
|
||||
namespace Jellyfin.Plugin.LightsOffTimer.Configuration;
|
||||
|
||||
public class PluginConfiguration : BasePluginConfiguration
|
||||
{
|
||||
/// <summary>Home Assistant webhook, e.g. https://ha.example/api/webhook/secret-id.</summary>
|
||||
public string WebhookUrl { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>Minutes Home Assistant waits after playback stops before turning the lights off.</summary>
|
||||
public int CooldownMinutes { get; set; } = 15;
|
||||
|
||||
/// <summary>Also start the lights-off countdown on every playback stop, not only when the sleep timer is on.</summary>
|
||||
public bool CountdownOnEveryStop { get; set; }
|
||||
|
||||
/// <summary>Comma-separated minute presets shown in the player menu.</summary>
|
||||
public string MinutePresets { get; set; } = "15,30,45,60,90";
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Lights Off Timer</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="LightsOffTimerConfigPage" data-role="page" class="page type-interior pluginConfigurationPage" data-require="emby-input,emby-button,emby-checkbox">
|
||||
<div data-role="content">
|
||||
<div class="content-primary">
|
||||
<form id="LightsOffTimerConfigForm">
|
||||
<h2>Lights Off Timer</h2>
|
||||
<p>Adds a sleep-timer button next to the volume control in the web player. When playback stops with the
|
||||
timer on, Home Assistant is told, and it turns the lights off after the cooldown below. Starting
|
||||
playback again cancels it.</p>
|
||||
<div class="inputContainer">
|
||||
<label class="inputLabel inputLabelUnfocused" for="WebhookUrl">Home Assistant webhook URL</label>
|
||||
<input id="WebhookUrl" name="WebhookUrl" type="url" is="emby-input" />
|
||||
<div class="fieldDescription">https://your-home-assistant/api/webhook/<webhook id>. Keep it secret.</div>
|
||||
</div>
|
||||
<div class="inputContainer">
|
||||
<label class="inputLabel inputLabelUnfocused" for="CooldownMinutes">Lights off after (minutes)</label>
|
||||
<input id="CooldownMinutes" name="CooldownMinutes" type="number" min="1" max="240" is="emby-input" />
|
||||
</div>
|
||||
<div class="inputContainer">
|
||||
<label class="inputLabel inputLabelUnfocused" for="MinutePresets">Timer presets (minutes, comma separated)</label>
|
||||
<input id="MinutePresets" name="MinutePresets" type="text" is="emby-input" />
|
||||
</div>
|
||||
<div class="checkboxContainer checkboxContainer-withDescription">
|
||||
<label class="emby-checkbox-label">
|
||||
<input id="CountdownOnEveryStop" name="CountdownOnEveryStop" type="checkbox" is="emby-checkbox" />
|
||||
<span>Start the lights-off countdown on every playback stop</span>
|
||||
</label>
|
||||
<div class="fieldDescription checkboxFieldDescription">Off: only when the sleep timer was on for that playback.</div>
|
||||
</div>
|
||||
<div>
|
||||
<button is="emby-button" type="submit" class="raised button-submit block emby-button"><span>Save</span></button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
var LightsOffTimerConfig = { pluginUniqueId: '6b1c3f0e-6f2a-4c55-9d1e-4a7e2c9b5d31' };
|
||||
|
||||
document.querySelector('#LightsOffTimerConfigPage').addEventListener('pageshow', function () {
|
||||
Dashboard.showLoadingMsg();
|
||||
ApiClient.getPluginConfiguration(LightsOffTimerConfig.pluginUniqueId).then(function (config) {
|
||||
document.querySelector('#WebhookUrl').value = config.WebhookUrl || '';
|
||||
document.querySelector('#CooldownMinutes').value = config.CooldownMinutes || 15;
|
||||
document.querySelector('#MinutePresets').value = config.MinutePresets || '15,30,45,60,90';
|
||||
document.querySelector('#CountdownOnEveryStop').checked = !!config.CountdownOnEveryStop;
|
||||
Dashboard.hideLoadingMsg();
|
||||
});
|
||||
});
|
||||
|
||||
document.querySelector('#LightsOffTimerConfigForm').addEventListener('submit', function (e) {
|
||||
Dashboard.showLoadingMsg();
|
||||
ApiClient.getPluginConfiguration(LightsOffTimerConfig.pluginUniqueId).then(function (config) {
|
||||
config.WebhookUrl = document.querySelector('#WebhookUrl').value.trim();
|
||||
config.CooldownMinutes = parseInt(document.querySelector('#CooldownMinutes').value, 10) || 15;
|
||||
config.MinutePresets = document.querySelector('#MinutePresets').value.trim();
|
||||
config.CountdownOnEveryStop = document.querySelector('#CountdownOnEveryStop').checked;
|
||||
ApiClient.updatePluginConfiguration(LightsOffTimerConfig.pluginUniqueId, config).then(function (result) {
|
||||
Dashboard.processPluginConfigurationUpdateResult(result);
|
||||
});
|
||||
});
|
||||
e.preventDefault();
|
||||
return false;
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in new issue
Block a user