nixos-configs/configurations/homie/modules/home-assistant/netdaemon/apps/Spotify/PauseUnpause/PauseUnpause.cs
matt1432 f7f8b2ec19
All checks were successful
Discord / discord commits (push) Has been skipped
feat(netd): attempt to fix timeout issue with spotifyplus
2025-02-19 12:21:51 -05:00

41 lines
1.1 KiB
C#

using HomeAssistantGenerated;
using NetDaemon.AppModel;
using NetDaemon.HassModel;
using NetDaemon.HassModel.Integration;
using NetDaemonConfig.Apps.Spotify.Types;
namespace NetDaemonConfig.Apps.Spotify.PauseUnpause
{
public record PauseUnpauseData(bool pause);
[NetDaemonApp]
public class PauseUnpause
{
private static void CallBack(PauseUnpauseData e, Services services)
{
if (e.pause)
{
services.Spotifyplus.PlayerMediaPause(
entityId: Globals.DefaultEntityId,
deviceId: Globals.DefaultDevId);
}
else
{
services.Spotifyplus.PlayerMediaResume(
entityId: Globals.DefaultEntityId,
deviceId: Globals.DefaultDevId);
}
}
public PauseUnpause(IHaContext ha, Services services)
{
ha.RegisterServiceCallBack<PauseUnpauseData>(
"spotify_pause_unpause",
(e) => Globals.RunSpotifyCallback(services, e, CallBack)
);
}
}
}