Files
MusicCast.Net/MusicCast.Net.Test/Program.cs
2025-05-24 20:47:01 +02:00

39 lines
1.4 KiB
C#

// See https://aka.ms/new-console-template for more information
// API requires no authentication, so use the anonymous
// authentication provider
using System.Text.Json;
using Microsoft.Kiota.Abstractions.Authentication;
using Microsoft.Kiota.Http.HttpClientLibrary;
using MusicCast.Net.Api.Client;
using MusicCast.Net.Api.Client.YamahaExtendedControl.V1.Main.SetPower;
// API requires no authentication, so use the anonymous
// authentication provider
var authProvider = new AnonymousAuthenticationProvider();
// Create request adapter using the HttpClient-based implementation
using var adapter = new HttpClientRequestAdapter(authProvider);
adapter.BaseUrl = "http://192.168.129.21";
var client = new MusicCastApiClient(adapter);
var status = await client.YamahaExtendedControl.V1.Main.GetStatus.GetAsync();
Console.WriteLine(status!.Power);
await client.YamahaExtendedControl.V1.Main.SetPower.GetAsync(conf => conf.QueryParameters.Power = GetPowerQueryParameterType.On);
await Task.Delay(5000);
status = await client.YamahaExtendedControl.V1.Main.GetStatus.GetAsync();
Console.WriteLine(status!.Power);
await client.YamahaExtendedControl.V1.Main.SetPower.GetAsync(r =>
r.QueryParameters.Power = GetPowerQueryParameterType.Standby
);
await Task.Delay(5000);
status = await client.YamahaExtendedControl.V1.Main.GetStatus.GetAsync();
Console.WriteLine(status!.Power);