-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathProgram.cs
41 lines (33 loc) · 1.13 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// SPDX-FileCopyrightText: 2023 smdn <[email protected]>
// SPDX-License-Identifier: MIT
using System.Net;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Smdn.TPSmartHomeDevices.Tapo;
var services = new ServiceCollection();
// Adds logging services to the ServiceCollection.
services
.AddLogging(
static builder => builder
.AddSimpleConsole(static options => {
// By setting IncludeScopes to true enables the current endpoint information
// to be output as a operation scope (see ILogger.BeginScope).
options.IncludeScopes = true;
options.SingleLine = true;
})
.AddFilter(
// The log output from this library can be filtered by the
// category name 'Smdn.TPSmartHomeDevices.Tapo.Protocol.TapoClient'.
category: typeof(Smdn.TPSmartHomeDevices.Tapo.Protocol.TapoClient).FullName,
level: LogLevel.Trace
)
);
using var plug = new P105(
IPAddress.Parse("192.0.2.1"),
"password",
services.BuildServiceProvider()
);
await plug.TurnOnAsync();
await Task.Delay(2000);
await plug.TurnOffAsync();