Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save smdn/d0107c64e77cc315bb41aab287b9bfc3 to your computer and use it in GitHub Desktop.
Save smdn/d0107c64e77cc315bb41aab287b9bfc3 to your computer and use it in GitHub Desktop.
Smdn.TPSmartHomeDevices.Primitives 1.1.0-preview1 Release Notes

main/Smdn.TPSmartHomeDevices.Primitives-1.1.0-preview1

diff --git a/doc/api-list/Smdn.TPSmartHomeDevices.Primitives/Smdn.TPSmartHomeDevices.Primitives-net6.0.apilist.cs b/doc/api-list/Smdn.TPSmartHomeDevices.Primitives/Smdn.TPSmartHomeDevices.Primitives-net6.0.apilist.cs
index b131bc1..c08ab54 100644
--- a/doc/api-list/Smdn.TPSmartHomeDevices.Primitives/Smdn.TPSmartHomeDevices.Primitives-net6.0.apilist.cs
+++ b/doc/api-list/Smdn.TPSmartHomeDevices.Primitives/Smdn.TPSmartHomeDevices.Primitives-net6.0.apilist.cs
@@ -1,105 +1,124 @@
-// Smdn.TPSmartHomeDevices.Primitives.dll (Smdn.TPSmartHomeDevices.Primitives-1.0.1)
+// Smdn.TPSmartHomeDevices.Primitives.dll (Smdn.TPSmartHomeDevices.Primitives-1.1.0-preview1)
// Name: Smdn.TPSmartHomeDevices.Primitives
-// AssemblyVersion: 1.0.1.0
-// InformationalVersion: 1.0.1+934aee650dc331b389f51ddc76cb1f8042d47bf5
+// AssemblyVersion: 1.1.0.0
+// InformationalVersion: 1.1.0-preview1+d9122eb664899e2e3470e87efca152f3456eb904
// TargetFramework: .NETCoreApp,Version=v6.0
// Configuration: Release
// Referenced assemblies:
// Microsoft.Extensions.DependencyInjection.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
// System.Net.NetworkInformation, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
// System.Net.Primitives, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
// System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
// System.Text.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
#nullable enable annotations
using System;
using System.Net;
using System.Net.NetworkInformation;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Smdn.TPSmartHomeDevices;
using Smdn.TPSmartHomeDevices.Json;
namespace Smdn.TPSmartHomeDevices {
public interface IDeviceEndPoint {
ValueTask<EndPoint?> ResolveAsync(CancellationToken cancellationToken = default);
}
public interface IDeviceEndPointFactory<TAddress> where TAddress : notnull {
IDeviceEndPoint Create(TAddress address);
}
public interface IDynamicDeviceEndPoint : IDeviceEndPoint {
void Invalidate();
}
+ public interface IMulticolorSmartLight : ISmartDevice {
+ ValueTask SetBrightnessAsync(int brightness, TimeSpan transitionPeriod, CancellationToken cancellationToken);
+ ValueTask SetColorAsync(int hue, int saturation, int? brightness, TimeSpan transitionPeriod, CancellationToken cancellationToken);
+ ValueTask SetColorTemperatureAsync(int colorTemperature, int? brightness, TimeSpan transitionPeriod, CancellationToken cancellationToken);
+ virtual ValueTask SetOnOffStateAsync(bool newOnOffState, TimeSpan transitionPeriod, CancellationToken cancellationToken) {}
+ virtual ValueTask TurnOffAsync(TimeSpan transitionPeriod, CancellationToken cancellationToken) {}
+ virtual ValueTask TurnOnAsync(TimeSpan transitionPeriod, CancellationToken cancellationToken) {}
+ }
+
+ public interface ISmartDevice {
+ ValueTask<bool> GetOnOffStateAsync(CancellationToken cancellationToken);
+ ValueTask SetOnOffStateAsync(bool newOnOffState, CancellationToken cancellationToken);
+ virtual ValueTask TurnOffAsync(CancellationToken cancellationToken = default) {}
+ virtual ValueTask TurnOnAsync(CancellationToken cancellationToken = default) {}
+ }
+
+ public interface ISmartPlug : ISmartDevice {
+ }
+
public static class DeviceEndPoint {
public static IDeviceEndPoint Create(EndPoint endPoint) {}
public static IDeviceEndPoint Create(IPAddress ipAddress) {}
public static IDeviceEndPoint Create(string host) {}
public static IDeviceEndPoint Create<TAddress>(TAddress address, IDeviceEndPointFactory<TAddress> endPointFactory) where TAddress : notnull {}
}
public static class DeviceEndPointFactoryServiceCollectionExtensions {
public static IServiceCollection AddDeviceEndPointFactory<TAddress>(this IServiceCollection services, IDeviceEndPointFactory<TAddress> endPointFactory) where TAddress : notnull {}
}
public class DeviceEndPointResolutionException : Exception {
public DeviceEndPointResolutionException(IDeviceEndPoint deviceEndPoint) {}
public DeviceEndPointResolutionException(IDeviceEndPoint deviceEndPoint, string message, Exception? innerException) {}
public IDeviceEndPoint DeviceEndPoint { get; }
}
public static class IDeviceEndPointExtensions {
public static ValueTask<EndPoint> ResolveOrThrowAsync(this IDeviceEndPoint deviceEndPoint, int defaultPort, CancellationToken cancellationToken = default) {}
}
public sealed class StaticDeviceEndPoint : IDeviceEndPoint {
public StaticDeviceEndPoint(EndPoint endPoint) {}
public ValueTask<EndPoint?> ResolveAsync(CancellationToken cancellationToken = default) {}
public override string? ToString() {}
}
}
namespace Smdn.TPSmartHomeDevices.Json {
public sealed class GeolocationInDecimalDegreesJsonConverter : JsonConverter<decimal?> {
public GeolocationInDecimalDegreesJsonConverter() {}
public override decimal? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) {}
public override void Write(Utf8JsonWriter writer, decimal? @value, JsonSerializerOptions options) {}
}
public sealed class MacAddressJsonConverter : JsonConverter<PhysicalAddress> {
public MacAddressJsonConverter() {}
public override PhysicalAddress? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) {}
public override void Write(Utf8JsonWriter writer, PhysicalAddress @value, JsonSerializerOptions options) {}
}
public sealed class TimeSpanInMinutesJsonConverter : TimeSpanJsonConverter {
public TimeSpanInMinutesJsonConverter() {}
protected override TimeSpan ToTimeSpan(int @value) {}
}
public sealed class TimeSpanInSecondsJsonConverter : TimeSpanJsonConverter {
public TimeSpanInSecondsJsonConverter() {}
protected override TimeSpan ToTimeSpan(int @value) {}
}
public abstract class TimeSpanJsonConverter : JsonConverter<TimeSpan?> {
protected TimeSpanJsonConverter() {}
public override TimeSpan? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) {}
protected abstract TimeSpan ToTimeSpan(int @value);
public override void Write(Utf8JsonWriter writer, TimeSpan? @value, JsonSerializerOptions options) {}
}
}
-// API list generated by Smdn.Reflection.ReverseGenerating.ListApi.MSBuild.Tasks v1.2.2.0.
+// API list generated by Smdn.Reflection.ReverseGenerating.ListApi.MSBuild.Tasks v1.3.2.0.
// Smdn.Reflection.ReverseGenerating.ListApi.Core v1.2.0.0 (https://github.com/smdn/Smdn.Reflection.ReverseGenerating)
diff --git a/doc/api-list/Smdn.TPSmartHomeDevices.Primitives/Smdn.TPSmartHomeDevices.Primitives-netstandard2.0.apilist.cs b/doc/api-list/Smdn.TPSmartHomeDevices.Primitives/Smdn.TPSmartHomeDevices.Primitives-netstandard2.0.apilist.cs
index 08f749b..ea57885 100644
--- a/doc/api-list/Smdn.TPSmartHomeDevices.Primitives/Smdn.TPSmartHomeDevices.Primitives-netstandard2.0.apilist.cs
+++ b/doc/api-list/Smdn.TPSmartHomeDevices.Primitives/Smdn.TPSmartHomeDevices.Primitives-netstandard2.0.apilist.cs
@@ -1,104 +1,118 @@
-// Smdn.TPSmartHomeDevices.Primitives.dll (Smdn.TPSmartHomeDevices.Primitives-1.0.1)
+// Smdn.TPSmartHomeDevices.Primitives.dll (Smdn.TPSmartHomeDevices.Primitives-1.1.0-preview1)
// Name: Smdn.TPSmartHomeDevices.Primitives
-// AssemblyVersion: 1.0.1.0
-// InformationalVersion: 1.0.1+934aee650dc331b389f51ddc76cb1f8042d47bf5
+// AssemblyVersion: 1.1.0.0
+// InformationalVersion: 1.1.0-preview1+d9122eb664899e2e3470e87efca152f3456eb904
// TargetFramework: .NETStandard,Version=v2.0
// Configuration: Release
// Referenced assemblies:
// Microsoft.Extensions.DependencyInjection.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
// System.Text.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
// System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
// netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
#nullable enable annotations
using System;
using System.Net;
using System.Net.NetworkInformation;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Smdn.TPSmartHomeDevices;
using Smdn.TPSmartHomeDevices.Json;
namespace Smdn.TPSmartHomeDevices {
public interface IDeviceEndPoint {
ValueTask<EndPoint?> ResolveAsync(CancellationToken cancellationToken = default);
}
public interface IDeviceEndPointFactory<TAddress> where TAddress : notnull {
IDeviceEndPoint Create(TAddress address);
}
public interface IDynamicDeviceEndPoint : IDeviceEndPoint {
void Invalidate();
}
+ public interface IMulticolorSmartLight : ISmartDevice {
+ ValueTask SetBrightnessAsync(int brightness, TimeSpan transitionPeriod, CancellationToken cancellationToken);
+ ValueTask SetColorAsync(int hue, int saturation, int? brightness, TimeSpan transitionPeriod, CancellationToken cancellationToken);
+ ValueTask SetColorTemperatureAsync(int colorTemperature, int? brightness, TimeSpan transitionPeriod, CancellationToken cancellationToken);
+ }
+
+ public interface ISmartDevice {
+ ValueTask<bool> GetOnOffStateAsync(CancellationToken cancellationToken);
+ ValueTask SetOnOffStateAsync(bool newOnOffState, CancellationToken cancellationToken);
+ }
+
+ public interface ISmartPlug : ISmartDevice {
+ }
+
public static class DeviceEndPoint {
public static IDeviceEndPoint Create(EndPoint endPoint) {}
public static IDeviceEndPoint Create(IPAddress ipAddress) {}
public static IDeviceEndPoint Create(string host) {}
public static IDeviceEndPoint Create<TAddress>(TAddress address, IDeviceEndPointFactory<TAddress> endPointFactory) where TAddress : notnull {}
}
public static class DeviceEndPointFactoryServiceCollectionExtensions {
public static IServiceCollection AddDeviceEndPointFactory<TAddress>(this IServiceCollection services, IDeviceEndPointFactory<TAddress> endPointFactory) where TAddress : notnull {}
}
public class DeviceEndPointResolutionException : Exception {
public DeviceEndPointResolutionException(IDeviceEndPoint deviceEndPoint) {}
public DeviceEndPointResolutionException(IDeviceEndPoint deviceEndPoint, string message, Exception? innerException) {}
public IDeviceEndPoint DeviceEndPoint { get; }
}
public static class IDeviceEndPointExtensions {
public static ValueTask<EndPoint> ResolveOrThrowAsync(this IDeviceEndPoint deviceEndPoint, int defaultPort, CancellationToken cancellationToken = default) {}
}
public sealed class StaticDeviceEndPoint : IDeviceEndPoint {
public StaticDeviceEndPoint(EndPoint endPoint) {}
public ValueTask<EndPoint?> ResolveAsync(CancellationToken cancellationToken = default) {}
public override string? ToString() {}
}
}
namespace Smdn.TPSmartHomeDevices.Json {
public sealed class GeolocationInDecimalDegreesJsonConverter : JsonConverter<decimal?> {
public GeolocationInDecimalDegreesJsonConverter() {}
public override decimal? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) {}
public override void Write(Utf8JsonWriter writer, decimal? @value, JsonSerializerOptions options) {}
}
public sealed class MacAddressJsonConverter : JsonConverter<PhysicalAddress> {
public MacAddressJsonConverter() {}
public override PhysicalAddress? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) {}
public override void Write(Utf8JsonWriter writer, PhysicalAddress @value, JsonSerializerOptions options) {}
}
public sealed class TimeSpanInMinutesJsonConverter : TimeSpanJsonConverter {
public TimeSpanInMinutesJsonConverter() {}
protected override TimeSpan ToTimeSpan(int @value) {}
}
public sealed class TimeSpanInSecondsJsonConverter : TimeSpanJsonConverter {
public TimeSpanInSecondsJsonConverter() {}
protected override TimeSpan ToTimeSpan(int @value) {}
}
public abstract class TimeSpanJsonConverter : JsonConverter<TimeSpan?> {
protected TimeSpanJsonConverter() {}
public override TimeSpan? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) {}
protected abstract TimeSpan ToTimeSpan(int @value);
public override void Write(Utf8JsonWriter writer, TimeSpan? @value, JsonSerializerOptions options) {}
}
}
-// API list generated by Smdn.Reflection.ReverseGenerating.ListApi.MSBuild.Tasks v1.2.2.0.
+// API list generated by Smdn.Reflection.ReverseGenerating.ListApi.MSBuild.Tasks v1.3.2.0.
// Smdn.Reflection.ReverseGenerating.ListApi.Core v1.2.0.0 (https://github.com/smdn/Smdn.Reflection.ReverseGenerating)
diff --git a/doc/api-list/Smdn.TPSmartHomeDevices.Primitives/Smdn.TPSmartHomeDevices.Primitives-netstandard2.1.apilist.cs b/doc/api-list/Smdn.TPSmartHomeDevices.Primitives/Smdn.TPSmartHomeDevices.Primitives-netstandard2.1.apilist.cs
index 4d14d90..41e5cc8 100644
--- a/doc/api-list/Smdn.TPSmartHomeDevices.Primitives/Smdn.TPSmartHomeDevices.Primitives-netstandard2.1.apilist.cs
+++ b/doc/api-list/Smdn.TPSmartHomeDevices.Primitives/Smdn.TPSmartHomeDevices.Primitives-netstandard2.1.apilist.cs
@@ -1,103 +1,117 @@
-// Smdn.TPSmartHomeDevices.Primitives.dll (Smdn.TPSmartHomeDevices.Primitives-1.0.1)
+// Smdn.TPSmartHomeDevices.Primitives.dll (Smdn.TPSmartHomeDevices.Primitives-1.1.0-preview1)
// Name: Smdn.TPSmartHomeDevices.Primitives
-// AssemblyVersion: 1.0.1.0
-// InformationalVersion: 1.0.1+934aee650dc331b389f51ddc76cb1f8042d47bf5
+// AssemblyVersion: 1.1.0.0
+// InformationalVersion: 1.1.0-preview1+d9122eb664899e2e3470e87efca152f3456eb904
// TargetFramework: .NETStandard,Version=v2.1
// Configuration: Release
// Referenced assemblies:
// Microsoft.Extensions.DependencyInjection.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
// System.Text.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
// netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
#nullable enable annotations
using System;
using System.Net;
using System.Net.NetworkInformation;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Smdn.TPSmartHomeDevices;
using Smdn.TPSmartHomeDevices.Json;
namespace Smdn.TPSmartHomeDevices {
public interface IDeviceEndPoint {
ValueTask<EndPoint?> ResolveAsync(CancellationToken cancellationToken = default);
}
public interface IDeviceEndPointFactory<TAddress> where TAddress : notnull {
IDeviceEndPoint Create(TAddress address);
}
public interface IDynamicDeviceEndPoint : IDeviceEndPoint {
void Invalidate();
}
+ public interface IMulticolorSmartLight : ISmartDevice {
+ ValueTask SetBrightnessAsync(int brightness, TimeSpan transitionPeriod, CancellationToken cancellationToken);
+ ValueTask SetColorAsync(int hue, int saturation, int? brightness, TimeSpan transitionPeriod, CancellationToken cancellationToken);
+ ValueTask SetColorTemperatureAsync(int colorTemperature, int? brightness, TimeSpan transitionPeriod, CancellationToken cancellationToken);
+ }
+
+ public interface ISmartDevice {
+ ValueTask<bool> GetOnOffStateAsync(CancellationToken cancellationToken);
+ ValueTask SetOnOffStateAsync(bool newOnOffState, CancellationToken cancellationToken);
+ }
+
+ public interface ISmartPlug : ISmartDevice {
+ }
+
public static class DeviceEndPoint {
public static IDeviceEndPoint Create(EndPoint endPoint) {}
public static IDeviceEndPoint Create(IPAddress ipAddress) {}
public static IDeviceEndPoint Create(string host) {}
public static IDeviceEndPoint Create<TAddress>(TAddress address, IDeviceEndPointFactory<TAddress> endPointFactory) where TAddress : notnull {}
}
public static class DeviceEndPointFactoryServiceCollectionExtensions {
public static IServiceCollection AddDeviceEndPointFactory<TAddress>(this IServiceCollection services, IDeviceEndPointFactory<TAddress> endPointFactory) where TAddress : notnull {}
}
public class DeviceEndPointResolutionException : Exception {
public DeviceEndPointResolutionException(IDeviceEndPoint deviceEndPoint) {}
public DeviceEndPointResolutionException(IDeviceEndPoint deviceEndPoint, string message, Exception? innerException) {}
public IDeviceEndPoint DeviceEndPoint { get; }
}
public static class IDeviceEndPointExtensions {
public static ValueTask<EndPoint> ResolveOrThrowAsync(this IDeviceEndPoint deviceEndPoint, int defaultPort, CancellationToken cancellationToken = default) {}
}
public sealed class StaticDeviceEndPoint : IDeviceEndPoint {
public StaticDeviceEndPoint(EndPoint endPoint) {}
public ValueTask<EndPoint?> ResolveAsync(CancellationToken cancellationToken = default) {}
public override string? ToString() {}
}
}
namespace Smdn.TPSmartHomeDevices.Json {
public sealed class GeolocationInDecimalDegreesJsonConverter : JsonConverter<decimal?> {
public GeolocationInDecimalDegreesJsonConverter() {}
public override decimal? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) {}
[...] public override <unknown> Write(...) {}
}
public sealed class MacAddressJsonConverter : JsonConverter<PhysicalAddress> {
public MacAddressJsonConverter() {}
public override PhysicalAddress? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) {}
[...] public override <unknown> Write(...) {}
}
public sealed class TimeSpanInMinutesJsonConverter : TimeSpanJsonConverter {
public TimeSpanInMinutesJsonConverter() {}
protected override TimeSpan ToTimeSpan(int @value) {}
}
public sealed class TimeSpanInSecondsJsonConverter : TimeSpanJsonConverter {
public TimeSpanInSecondsJsonConverter() {}
protected override TimeSpan ToTimeSpan(int @value) {}
}
public abstract class TimeSpanJsonConverter : JsonConverter<TimeSpan?> {
protected TimeSpanJsonConverter() {}
public override TimeSpan? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) {}
protected abstract TimeSpan ToTimeSpan(int @value);
[...] public override <unknown> Write(...) {}
}
}
-// API list generated by Smdn.Reflection.ReverseGenerating.ListApi.MSBuild.Tasks v1.2.2.0.
+// API list generated by Smdn.Reflection.ReverseGenerating.ListApi.MSBuild.Tasks v1.3.2.0.
// Smdn.Reflection.ReverseGenerating.ListApi.Core v1.2.0.0 (https://github.com/smdn/Smdn.Reflection.ReverseGenerating)
--- Smdn.TPSmartHomeDevices.Primitives.latest.nuspec
+++ Smdn.TPSmartHomeDevices.Primitives.1.1.0-preview1.nuspec
@@ -1,33 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
-<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
+<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>Smdn.TPSmartHomeDevices.Primitives</id>
- <version>1.0.1</version>
+ <version>1.1.0-preview1</version>
<title>Smdn.TPSmartHomeDevices.Primitives</title>
<authors>smdn</authors>
<license type="expression">MIT</license>
<licenseUrl>https://licenses.nuget.org/MIT</licenseUrl>
<icon>Smdn.TPSmartHomeDevices.Primitives.png</icon>
<readme>README.md</readme>
<projectUrl>https://github.com/smdn/Smdn.TPSmartHomeDevices/</projectUrl>
<description>Provides common types for Smdn.TPSmartHomeDevices.Tapo and Smdn.TPSmartHomeDevices.Kasa, including abstraction interfaces, extension methods and custom JsonConverter's. This library does not provide any specific implementations to operate Kasa and Tapo devices.</description>
- <releaseNotes>https://github.com/smdn/Smdn.TPSmartHomeDevices/releases/tag/releases%2FSmdn.TPSmartHomeDevices.Primitives-1.0.1</releaseNotes>
+ <releaseNotes>https://github.com/smdn/Smdn.TPSmartHomeDevices/releases/tag/releases%2FSmdn.TPSmartHomeDevices.Primitives-1.1.0-preview1</releaseNotes>
<copyright>Copyright © 2023 smdn</copyright>
<tags>smdn.jp tplink-kasa,kasa,tplink-tapo,tapo,common,smarthome,homeautomation,smartdevice</tags>
- <repository type="git" url="https://github.com/smdn/Smdn.TPSmartHomeDevices" branch="main" commit="934aee650dc331b389f51ddc76cb1f8042d47bf5" />
+ <repository type="git" url="https://github.com/smdn/Smdn.TPSmartHomeDevices" commit="d9122eb664899e2e3470e87efca152f3456eb904" />
<dependencies>
<group targetFramework="net6.0">
<dependency id="Microsoft.Extensions.DependencyInjection.Abstractions" version="6.0.0" exclude="Build,Analyzers" />
<dependency id="System.Text.Json" version="6.0.0" exclude="Build,Analyzers" />
</group>
<group targetFramework=".NETStandard2.0">
<dependency id="Microsoft.Extensions.DependencyInjection.Abstractions" version="6.0.0" exclude="Build,Analyzers" />
<dependency id="System.Text.Json" version="6.0.0" exclude="Build,Analyzers" />
</group>
<group targetFramework=".NETStandard2.1">
<dependency id="Microsoft.Extensions.DependencyInjection.Abstractions" version="6.0.0" exclude="Build,Analyzers" />
<dependency id="System.Text.Json" version="6.0.0" exclude="Build,Analyzers" />
</group>
</dependencies>
</metadata>
</package>
\ No newline at end of file
diff --git a/src/Smdn.TPSmartHomeDevices.Primitives/Smdn.TPSmartHomeDevices.Primitives.csproj b/src/Smdn.TPSmartHomeDevices.Primitives/Smdn.TPSmartHomeDevices.Primitives.csproj
index eb9be72..8bc7374 100644
--- a/src/Smdn.TPSmartHomeDevices.Primitives/Smdn.TPSmartHomeDevices.Primitives.csproj
+++ b/src/Smdn.TPSmartHomeDevices.Primitives/Smdn.TPSmartHomeDevices.Primitives.csproj
@@ -5,9 +5,10 @@ SPDX-License-Identifier: MIT
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;net6.0</TargetFrameworks>
- <VersionPrefix>1.0.1</VersionPrefix>
- <VersionSuffix></VersionSuffix>
- <!-- <PackageValidationBaselineVersion>1.0.0</PackageValidationBaselineVersion> -->
+ <VersionPrefix>1.1.0</VersionPrefix>
+ <VersionSuffix>preview1</VersionSuffix>
+ <PackageValidationBaselineVersion>1.0.0</PackageValidationBaselineVersion>
+ <RootNamespace/> <!-- empty the root namespace so that the namespace is determined only by the directory name, for code style rule IDE0030 -->
<Nullable>enable</Nullable>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<EnableTrimAnalyzer>false</EnableTrimAnalyzer>
@@ -35,10 +36,6 @@ This library does not provide any specific implementations to operate Kasa and T
<StyleCopAnalyzersConfigurationFile>..\stylecop.json</StyleCopAnalyzersConfigurationFile>
</PropertyGroup>
- <ItemGroup>
- <GlobalAnalyzerConfigFiles Include="..\CodeAnalysis.globalconfig" />
- </ItemGroup>
-
<ItemGroup>
<PackageReference Include="System.Text.Json" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
diff --git a/src/Smdn.TPSmartHomeDevices.Primitives/Smdn.TPSmartHomeDevices/DeviceEndPointResolutionException.cs b/src/Smdn.TPSmartHomeDevices.Primitives/Smdn.TPSmartHomeDevices/DeviceEndPointResolutionException.cs
index c699171..1ec138b 100644
--- a/src/Smdn.TPSmartHomeDevices.Primitives/Smdn.TPSmartHomeDevices/DeviceEndPointResolutionException.cs
+++ b/src/Smdn.TPSmartHomeDevices.Primitives/Smdn.TPSmartHomeDevices/DeviceEndPointResolutionException.cs
@@ -1,5 +1,6 @@
// SPDX-FileCopyrightText: 2023 smdn <smdn@smdn.jp>
// SPDX-License-Identifier: MIT
+#pragma warning disable CA1032
using System;
namespace Smdn.TPSmartHomeDevices;
diff --git a/src/Smdn.TPSmartHomeDevices.Primitives/Smdn.TPSmartHomeDevices/IDeviceEndPointExtensions.cs b/src/Smdn.TPSmartHomeDevices.Primitives/Smdn.TPSmartHomeDevices/IDeviceEndPointExtensions.cs
index 26c07a3..8994c4f 100644
--- a/src/Smdn.TPSmartHomeDevices.Primitives/Smdn.TPSmartHomeDevices/IDeviceEndPointExtensions.cs
+++ b/src/Smdn.TPSmartHomeDevices.Primitives/Smdn.TPSmartHomeDevices/IDeviceEndPointExtensions.cs
@@ -68,7 +68,7 @@ public static class IDeviceEndPointExtensions {
? new DnsEndPoint(dnsEndPoint.Host, defaultPort)
: dnsEndPoint,
- /* EndPoint */ _ => endPoint,
+ _ => endPoint, // includes case for the type EndPoint
};
}
}
diff --git a/src/Smdn.TPSmartHomeDevices.Primitives/Smdn.TPSmartHomeDevices/IMulticolorSmartLight.cs b/src/Smdn.TPSmartHomeDevices.Primitives/Smdn.TPSmartHomeDevices/IMulticolorSmartLight.cs
new file mode 100644
index 0000000..2eab066
--- /dev/null
+++ b/src/Smdn.TPSmartHomeDevices.Primitives/Smdn.TPSmartHomeDevices/IMulticolorSmartLight.cs
@@ -0,0 +1,204 @@
+// SPDX-FileCopyrightText: 2024 smdn <smdn@smdn.jp>
+// SPDX-License-Identifier: MIT
+using System;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Smdn.TPSmartHomeDevices;
+
+/// <summary>
+/// Provides a mechanism for abstracting the multicolor smart light including smart bulb, smart strip, etc. that can be specified in any one color and its functionality.
+/// </summary>
+public interface IMulticolorSmartLight : ISmartDevice {
+ /// <summary>
+ /// Turns the light on and sets the light brightness.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// If the device does not support gradual state transitions, the parameter <paramref name="transitionPeriod"/> is ignored and the new state is set immediately.
+ /// </para>
+ /// <para>
+ /// The device cannot be turned off by setting the <paramref name="brightness"/> to <c>0</c>.
+ /// Use <see cref="ISmartDevice.SetOnOffStateAsync(bool, CancellationToken)"/> to turn off the device.
+ /// </para>
+ /// </remarks>
+ /// <param name="brightness">
+ /// The brightness in percent value, in range of 1~100[%].
+ /// </param>
+ /// <param name="transitionPeriod">
+ /// The <see cref="TimeSpan" /> value that indicates the time interval between completion of gradual state transition.
+ /// If the value is <see cref="TimeSpan.Zero"/>, the state transition will be performed immediately rather than gradual change.
+ /// </param>
+ /// <param name="cancellationToken">
+ /// The <see cref="CancellationToken" /> to monitor for cancellation requests.
+ /// The default value is <see langword="default" />.
+ /// </param>
+ /// <exception cref="ArgumentOutOfRangeException">
+ /// <list type="bullet">
+ /// <item><description><paramref name="brightness"/> is less than 1 or greater than 100.</description></item>
+ /// <item><description><paramref name="transitionPeriod"/> is less than <see cref="TimeSpan.Zero"/>.</description></item>
+ /// </list>
+ /// </exception>
+ ValueTask SetBrightnessAsync(
+ int brightness,
+ TimeSpan transitionPeriod,
+ CancellationToken cancellationToken
+ );
+
+ /// <summary>
+ /// Turns the light on and sets the light color to the specified color temperature.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// If the device does not support gradual state transitions, the parameter <paramref name="transitionPeriod"/> is ignored and the new state is set immediately.
+ /// </para>
+ /// <para>
+ /// The device cannot be turned off by setting the <paramref name="brightness"/> to <c>0</c>.
+ /// Use <see cref="ISmartDevice.SetOnOffStateAsync(bool, CancellationToken)"/> to turn off the device.
+ /// </para>
+ /// </remarks>
+ /// <param name="colorTemperature">
+ /// The color temperature in kelvin [K].
+ /// Available color temperatures depend on the device model.
+ /// </param>
+ /// <param name="brightness">
+ /// The brightness in percent value, in range of 1~100[%].
+ /// If <see langword="null"/>, the current brightness will be kept.
+ /// </param>
+ /// <param name="transitionPeriod">
+ /// The <see cref="TimeSpan" /> value that indicates the time interval between completion of gradual state transition.
+ /// If the value is <see cref="TimeSpan.Zero"/>, the state transition will be performed immediately rather than gradual change.
+ /// </param>
+ /// <param name="cancellationToken">
+ /// The <see cref="CancellationToken" /> to monitor for cancellation requests.
+ /// The default value is <see langword="default" />.
+ /// </param>
+ /// <exception cref="ArgumentOutOfRangeException">
+ /// <list type="bullet">
+ /// <item><description><paramref name="colorTemperature"/> is out of the range that can be specified for the device.</description></item>
+ /// <item><description><paramref name="brightness"/> is less than 1 or greater than 100.</description></item>
+ /// <item><description><paramref name="transitionPeriod"/> is less than <see cref="TimeSpan.Zero"/>.</description></item>
+ /// </list>
+ /// </exception>
+ ValueTask SetColorTemperatureAsync(
+ int colorTemperature,
+ int? brightness,
+ TimeSpan transitionPeriod,
+ CancellationToken cancellationToken
+ );
+
+ /// <summary>
+ /// Turns the light on and sets the light color to the specified color represented by <paramref name="hue"/> and <paramref name="saturation"/>.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// If the device does not support gradual state transitions, the parameter <paramref name="transitionPeriod"/> is ignored and the new state is set immediately.
+ /// </para>
+ /// <para>
+ /// The device cannot be turned off by setting the <paramref name="brightness"/> to <c>0</c>.
+ /// Use <see cref="ISmartDevice.SetOnOffStateAsync(bool, CancellationToken)"/> to turn off the device.
+ /// </para>
+ /// </remarks>
+ /// <param name="hue">
+ /// The hue of the color in degree, in range of 0~360[°].
+ /// </param>
+ /// <param name="saturation">
+ /// The saturation of the color in percent value, in range of 0~100[%].
+ /// </param>
+ /// <param name="brightness">
+ /// The brightness in percent value, in range of 1~100[%].
+ /// If <see langword="null"/>, the current brightness will be kept.
+ /// </param>
+ /// <param name="transitionPeriod">
+ /// The <see cref="TimeSpan" /> value that indicates the time interval between completion of gradual state transition.
+ /// If the value is <see cref="TimeSpan.Zero"/>, the state transition will be performed immediately rather than gradual change.
+ /// </param>
+ /// <param name="cancellationToken">
+ /// The <see cref="CancellationToken" /> to monitor for cancellation requests.
+ /// The default value is <see langword="default" />.
+ /// </param>
+ /// <exception cref="ArgumentOutOfRangeException">
+ /// <list type="bullet">
+ /// <item><description><paramref name="hue"/> is less than 0 or greater than 360.</description></item>
+ /// <item><description><paramref name="saturation"/> is less than 0 or greater than 360.</description></item>
+ /// <item><description><paramref name="brightness"/> is less than 1 or greater than 100.</description></item>
+ /// <item><description><paramref name="transitionPeriod"/> is less than <see cref="TimeSpan.Zero"/>.</description></item>
+ /// </list>
+ /// </exception>
+ ValueTask SetColorAsync(
+ int hue,
+ int saturation,
+ int? brightness,
+ TimeSpan transitionPeriod,
+ CancellationToken cancellationToken
+ );
+
+#if NET6_0_OR_GREATER // default interface methods; .NET Core 3.x + C# 8.0
+ /// <summary>
+ /// Sets the on/off state of the light according to the parameter <paramref name="newOnOffState" />.
+ /// </summary>
+ /// <param name="newOnOffState">
+ /// The value that indicates new on/off state to be set. <see langword="true"/> for on, otherwise off.
+ /// </param>
+ /// <param name="transitionPeriod">
+ /// The <see cref="TimeSpan" /> value that indicates the time interval between completion of gradual state transition.
+ /// If the value is <see cref="TimeSpan.Zero"/>, the state transition will be performed immediately rather than gradual change.
+ /// </param>
+ /// <param name="cancellationToken">
+ /// The <see cref="CancellationToken" /> to monitor for cancellation requests.
+ /// The default value is <see langword="default" />.
+ /// </param>
+ ValueTask SetOnOffStateAsync(
+ bool newOnOffState,
+ TimeSpan transitionPeriod,
+ CancellationToken cancellationToken
+ )
+ // ignores the value of transitionPeriod
+ => SetOnOffStateAsync(
+ newOnOffState: newOnOffState,
+ cancellationToken: cancellationToken
+ );
+
+ /// <summary>
+ /// Turns on the light.
+ /// </summary>
+ /// <param name="transitionPeriod">
+ /// The <see cref="TimeSpan" /> value that indicates the time interval between completion of gradual state transition.
+ /// If the value is <see cref="TimeSpan.Zero"/>, the state transition will be performed immediately rather than gradual change.
+ /// </param>
+ /// <param name="cancellationToken">
+ /// The <see cref="CancellationToken" /> to monitor for cancellation requests.
+ /// The default value is <see langword="default" />.
+ /// </param>
+ ValueTask TurnOnAsync(
+ TimeSpan transitionPeriod,
+ CancellationToken cancellationToken
+ )
+ => SetOnOffStateAsync(
+ newOnOffState: true,
+ transitionPeriod: transitionPeriod,
+ cancellationToken: cancellationToken
+ );
+
+ /// <summary>
+ /// Turns off the light.
+ /// </summary>
+ /// <param name="transitionPeriod">
+ /// The <see cref="TimeSpan" /> value that indicates the time interval between completion of gradual state transition.
+ /// If the value is <see cref="TimeSpan.Zero"/>, the state transition will be performed immediately rather than gradual change.
+ /// </param>
+ /// <param name="cancellationToken">
+ /// The <see cref="CancellationToken" /> to monitor for cancellation requests.
+ /// The default value is <see langword="default" />.
+ /// </param>
+ ValueTask TurnOffAsync(
+ TimeSpan transitionPeriod,
+ CancellationToken cancellationToken
+ )
+ => SetOnOffStateAsync(
+ newOnOffState: false,
+ transitionPeriod: transitionPeriod,
+ cancellationToken: cancellationToken
+ );
+#endif
+}
diff --git a/src/Smdn.TPSmartHomeDevices.Primitives/Smdn.TPSmartHomeDevices/ISmartDevice.cs b/src/Smdn.TPSmartHomeDevices.Primitives/Smdn.TPSmartHomeDevices/ISmartDevice.cs
new file mode 100644
index 0000000..cc3aab6
--- /dev/null
+++ b/src/Smdn.TPSmartHomeDevices.Primitives/Smdn.TPSmartHomeDevices/ISmartDevice.cs
@@ -0,0 +1,59 @@
+// SPDX-FileCopyrightText: 2024 smdn <smdn@smdn.jp>
+// SPDX-License-Identifier: MIT
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Smdn.TPSmartHomeDevices;
+
+/// <summary>
+/// Provides a mechanism for abstracting the smart device and its functionality.
+/// </summary>
+public interface ISmartDevice {
+ /// <summary>
+ /// Sets the on/off state of the device according to the parameter <paramref name="newOnOffState" />.
+ /// </summary>
+ /// <param name="newOnOffState">
+ /// The value that indicates new on/off state to be set. <see langword="true"/> for on, otherwise off.
+ /// </param>
+ /// <param name="cancellationToken">
+ /// The <see cref="CancellationToken" /> to monitor for cancellation requests.
+ /// The default value is <see langword="default" />.
+ /// </param>
+ ValueTask SetOnOffStateAsync(
+ bool newOnOffState,
+ CancellationToken cancellationToken
+ );
+
+#if NET6_0_OR_GREATER // default interface methods; .NET Core 3.x + C# 8.0
+ /// <summary>
+ /// Turns on the device.
+ /// </summary>
+ /// <param name="cancellationToken">
+ /// The <see cref="CancellationToken" /> to monitor for cancellation requests.
+ /// The default value is <see langword="default" />.
+ /// </param>
+ ValueTask TurnOnAsync(CancellationToken cancellationToken = default)
+ => SetOnOffStateAsync(newOnOffState: true, cancellationToken);
+
+ /// <summary>
+ /// Turns off the device.
+ /// </summary>
+ /// <param name="cancellationToken">
+ /// The <see cref="CancellationToken" /> to monitor for cancellation requests.
+ /// The default value is <see langword="default" />.
+ /// </param>
+ ValueTask TurnOffAsync(CancellationToken cancellationToken = default)
+ => SetOnOffStateAsync(newOnOffState: false, cancellationToken);
+#endif
+
+ /// <summary>
+ /// Gets the on/off state of the device.
+ /// </summary>
+ /// <param name="cancellationToken">
+ /// The <see cref="CancellationToken" /> to monitor for cancellation requests.
+ /// The default value is <see langword="default" />.
+ /// </param>
+ ValueTask<bool> GetOnOffStateAsync(
+ CancellationToken cancellationToken
+ );
+}
diff --git a/src/Smdn.TPSmartHomeDevices.Primitives/Smdn.TPSmartHomeDevices/ISmartPlug.cs b/src/Smdn.TPSmartHomeDevices.Primitives/Smdn.TPSmartHomeDevices/ISmartPlug.cs
new file mode 100644
index 0000000..10bebb4
--- /dev/null
+++ b/src/Smdn.TPSmartHomeDevices.Primitives/Smdn.TPSmartHomeDevices/ISmartPlug.cs
@@ -0,0 +1,9 @@
+// SPDX-FileCopyrightText: 2024 smdn <smdn@smdn.jp>
+// SPDX-License-Identifier: MIT
+namespace Smdn.TPSmartHomeDevices;
+
+/// <summary>
+/// Provides a mechanism for abstracting the smart plug and its functionality.
+/// </summary>
+public interface ISmartPlug : ISmartDevice {
+}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment