nixos-configs/configurations/homie/modules/home-assistant/netdaemon/apps/Spotify/PauseUnpause/PauseUnpause.cs

42 lines
1.1 KiB
C#
Raw Normal View History

2024-12-02 11:03:43 -05:00
using HomeAssistantGenerated;
using NetDaemon.AppModel;
using NetDaemon.HassModel;
using NetDaemon.HassModel.Integration;
2024-12-18 19:25:22 -05:00
using NetDaemonConfig.Apps.Spotify.Types;
2024-12-02 11:03:43 -05:00
namespace NetDaemonConfig.Apps.Spotify.PauseUnpause
{
public record PauseUnpauseData(bool pause);
[NetDaemonApp]
public class PauseUnpause
2024-12-02 11:03:43 -05:00
{
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)
2024-12-02 11:03:43 -05:00
{
ha.RegisterServiceCallBack<PauseUnpauseData>(
"spotify_pause_unpause",
(e) => Globals.RunSpotifyCallback(services, e, CallBack)
2024-12-02 11:03:43 -05:00
);
}
}
}