diff --git a/.idea/.idea.Netatmo/.idea/vcs.xml b/.idea/.idea.Netatmo/.idea/vcs.xml
index 288b36b..94a25f7 100644
--- a/.idea/.idea.Netatmo/.idea/vcs.xml
+++ b/.idea/.idea.Netatmo/.idea/vcs.xml
@@ -1,7 +1,6 @@
-
\ No newline at end of file
diff --git a/src/Netatmo/AirClient.cs b/src/Netatmo/AirClient.cs
index af67089..1ef6e14 100644
--- a/src/Netatmo/AirClient.cs
+++ b/src/Netatmo/AirClient.cs
@@ -7,7 +7,7 @@ namespace Netatmo;
public class AirClient(string baseUrl, ICredentialManager credentialManager) : IAirClient
{
public Task> GetHomeCoachsData(string deviceId = null) =>
- baseUrl.ConfigureRequest(Configuration.ConfigureRequest)
+ baseUrl.WithSettings(Configuration.ConfigureRequest)
.AppendPathSegment("/api/gethomecoachsdata")
.WithOAuthBearerToken(credentialManager.AccessToken)
.PostJsonAsync(new GetHomeCoachsDataRequest { DeviceId = deviceId })
diff --git a/src/Netatmo/Configuration.cs b/src/Netatmo/Configuration.cs
index 74e4cee..4570c28 100644
--- a/src/Netatmo/Configuration.cs
+++ b/src/Netatmo/Configuration.cs
@@ -1,19 +1,18 @@
+using System.Text.Json;
+using System.Text.Json.Serialization;
using Flurl.Http.Configuration;
using Netatmo.Converters;
-using Newtonsoft.Json;
namespace Netatmo;
public static class Configuration
{
- public static JsonSerializerSettings JsonSerializer() =>
- new() { NullValueHandling = NullValueHandling.Ignore, Converters = [new TimestampToInstantConverter(), new StringToDateTimeZoneConverter()] };
+ public static JsonSerializerOptions JsonSerializerOptions =>
+ new() { DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, Converters = { new TimestampToInstantConverter(), new StringToDateTimeZoneConverter() } };
public static void ConfigureRequest(FlurlHttpSettings settings)
{
- var jsonSettings = JsonSerializer();
-
- //jsonSettings.ConfigureForNodaTime(DateTimeZoneProviders.Tzdb);
- settings.JsonSerializer = new NewtonsoftJsonSerializer(jsonSettings);
+ // something like maybe miss : jsonSettings.ConfigureForNodaTime(DateTimeZoneProviders.Tzdb);
+ settings.JsonSerializer = new DefaultJsonSerializer(JsonSerializerOptions);
}
}
\ No newline at end of file
diff --git a/src/Netatmo/Converters/StringToDateTimeZoneConverter.cs b/src/Netatmo/Converters/StringToDateTimeZoneConverter.cs
index da74891..3503539 100644
--- a/src/Netatmo/Converters/StringToDateTimeZoneConverter.cs
+++ b/src/Netatmo/Converters/StringToDateTimeZoneConverter.cs
@@ -1,23 +1,13 @@
-using Flurl.Util;
-using Newtonsoft.Json;
+using System.Text.Json;
+using System.Text.Json.Serialization;
using NodaTime;
namespace Netatmo.Converters;
public class StringToDateTimeZoneConverter : JsonConverter
{
- public override void WriteJson(JsonWriter writer, DateTimeZone value, JsonSerializer serializer)
- {
- writer.WriteValue(value?.ToInvariantString());
- }
+ public override DateTimeZone Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) =>
+ DateTimeZoneProviders.Tzdb.GetZoneOrNull(reader.GetString()!);
- public override DateTimeZone ReadJson(JsonReader reader, Type objectType, DateTimeZone existingValue, bool hasExistingValue, JsonSerializer serializer)
- {
- if (reader.Value == null)
- {
- return null;
- }
-
- return DateTimeZoneProviders.Tzdb[reader.Value.ToString()];
- }
+ public override void Write(Utf8JsonWriter writer, DateTimeZone value, JsonSerializerOptions options) => writer.WriteStringValue(value?.Id);
}
\ No newline at end of file
diff --git a/src/Netatmo/Converters/TimestampToInstantConverter.cs b/src/Netatmo/Converters/TimestampToInstantConverter.cs
index d0b288a..4de3e2a 100644
--- a/src/Netatmo/Converters/TimestampToInstantConverter.cs
+++ b/src/Netatmo/Converters/TimestampToInstantConverter.cs
@@ -1,27 +1,12 @@
-using Newtonsoft.Json;
+using System.Text.Json;
+using System.Text.Json.Serialization;
using NodaTime;
namespace Netatmo.Converters;
-public class TimestampToInstantConverter : JsonConverter
+public class TimestampToInstantConverter : JsonConverter
{
- public override void WriteJson(JsonWriter writer, Instant? value, JsonSerializer serializer)
- {
- if (value.HasValue)
- {
- writer.WriteValue(value.Value.ToUnixTimeSeconds().ToString());
- }
- }
+ public override Instant Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) => Instant.FromUnixTimeSeconds(reader.GetInt64());
- public override Instant? ReadJson(JsonReader reader, Type objectType, Instant? existingValue, bool hasExistingValue, JsonSerializer serializer)
- {
- if (reader.Value == null)
- {
- return null;
- }
-
- var value = long.Parse(reader.Value.ToString());
-
- return Instant.FromUnixTimeSeconds(value);
- }
+ public override void Write(Utf8JsonWriter writer, Instant value, JsonSerializerOptions options) => writer.WriteNumberValue(value.ToUnixTimeSeconds());
}
\ No newline at end of file
diff --git a/src/Netatmo/Converters/ZoneIdConverter.cs b/src/Netatmo/Converters/ZoneIdConverter.cs
new file mode 100644
index 0000000..95da8ba
--- /dev/null
+++ b/src/Netatmo/Converters/ZoneIdConverter.cs
@@ -0,0 +1,17 @@
+using System.Text.Json;
+using System.Text.Json.Serialization;
+
+namespace Netatmo.Converters;
+
+public class ZoneIdConverter : JsonConverter
+{
+ public override string Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) =>
+ reader.TokenType switch
+ {
+ JsonTokenType.String => reader.GetString(),
+ JsonTokenType.Number => reader.GetInt32().ToString(),
+ _ => throw new JsonException("Zone.Id must be a string or an integer.")
+ };
+
+ public override void Write(Utf8JsonWriter writer, string value, JsonSerializerOptions options) => writer.WriteNumberValue(int.Parse(value));
+}
\ No newline at end of file
diff --git a/src/Netatmo/EnergyClient.cs b/src/Netatmo/EnergyClient.cs
index 3811600..ac5f2a4 100644
--- a/src/Netatmo/EnergyClient.cs
+++ b/src/Netatmo/EnergyClient.cs
@@ -9,28 +9,28 @@ namespace Netatmo;
public class EnergyClient(string baseUrl, ICredentialManager credentialManager) : IEnergyClient
{
public Task> GetHomesData(string homeId = null, string gatewayTypes = null) =>
- baseUrl.ConfigureRequest(Configuration.ConfigureRequest)
+ baseUrl.WithSettings(Configuration.ConfigureRequest)
.AppendPathSegment("/api/homesdata")
.WithOAuthBearerToken(credentialManager.AccessToken)
.PostJsonAsync(new GetHomesDataRequest { HomeId = homeId, GatewayTypes = gatewayTypes })
.ReceiveJson>();
public async Task> GetHomeStatus(string homeId, string[] deviceTypes = null) =>
- await baseUrl.ConfigureRequest(Configuration.ConfigureRequest)
+ await baseUrl.WithSettings(Configuration.ConfigureRequest)
.AppendPathSegment("/api/homestatus")
.WithOAuthBearerToken(credentialManager.AccessToken)
.PostJsonAsync(new GetHomeStatusRequest { HomeId = homeId, DeviceTypes = deviceTypes })
.ReceiveJson>();
public async Task SetThermMode(string homeId, string mode, Instant? endTime = null) =>
- await baseUrl.ConfigureRequest(Configuration.ConfigureRequest)
+ await baseUrl.WithSettings(Configuration.ConfigureRequest)
.AppendPathSegment("/api/setthermmode")
.WithOAuthBearerToken(credentialManager.AccessToken)
.PostJsonAsync(new SetThermModeRequest { HomeId = homeId, Mode = mode, EndTime = endTime })
.ReceiveJson();
public async Task SetRoomThermPoint(string homeId, string roomId, string mode, double? temp = null, Instant? endTime = null) =>
- await baseUrl.ConfigureRequest(Configuration.ConfigureRequest)
+ await baseUrl.WithSettings(Configuration.ConfigureRequest)
.AppendPathSegment("/api/setroomthermpoint")
.WithOAuthBearerToken(credentialManager.AccessToken)
.PostJsonAsync(
@@ -49,55 +49,55 @@ public async Task> GetRoomMeasure(GetRoomMeasureParameters
{
ValidateGetRoomMeasureParameters(parameters);
- return await baseUrl.ConfigureRequest(Configuration.ConfigureRequest)
+ return await baseUrl.WithSettings(Configuration.ConfigureRequest)
.AppendPathSegment("/api/getroommeasure")
.WithOAuthBearerToken(credentialManager.AccessToken)
- .PostJsonAsync(
- new GetRoomMeasureRequest
+ .SetQueryParams(
+ new
{
- HomeId = parameters.HomeId,
- RoomId = parameters.RoomId,
- Scale = parameters.Scale.Value,
- Type = parameters.Type.Value,
- BeginAt = parameters.BeginAt,
- EndAt = parameters.EndAt,
- Limit = parameters.Limit,
- Optimize = parameters.Optimize,
- RealTime = parameters.RealTime
+ home_id = parameters.HomeId,
+ room_id = parameters.RoomId,
+ scale = parameters.Scale.Value,
+ type = parameters.Type.Value,
+ date_begin = parameters.BeginAt?.ToUnixTimeSeconds(),
+ date_end = parameters.EndAt?.ToUnixTimeSeconds(),
+ limit = parameters.Limit,
+ optimize = parameters.Optimize,
+ real_time = parameters.RealTime
})
- .ReceiveJson>();
+ .GetJsonAsync>();
}
public async Task SwitchHomeSchedule(string homeId, string scheduleId) =>
- await baseUrl.ConfigureRequest(Configuration.ConfigureRequest)
+ await baseUrl.WithSettings(Configuration.ConfigureRequest)
.AppendPathSegment("/api/switchhomeschedule")
.WithOAuthBearerToken(credentialManager.AccessToken)
.PostJsonAsync(new SwitchHomeScheduleRequest { HomeId = homeId, ScheduleId = scheduleId })
.ReceiveJson();
public async Task RenameHomeSchedule(string homeId, string scheduleId, string name) =>
- await baseUrl.ConfigureRequest(Configuration.ConfigureRequest)
+ await baseUrl.WithSettings(Configuration.ConfigureRequest)
.AppendPathSegment("/api/renamehomeschedule")
.WithOAuthBearerToken(credentialManager.AccessToken)
.PostJsonAsync(new RenameHomeScheduleRequest { HomeId = homeId, ScheduleId = scheduleId, Name = name })
.ReceiveJson();
public async Task DeleteHomeSchedule(string homeId, string scheduleId) =>
- await baseUrl.ConfigureRequest(Configuration.ConfigureRequest)
+ await baseUrl.WithSettings(Configuration.ConfigureRequest)
.AppendPathSegment("/api/deletehomeschedule")
.WithOAuthBearerToken(credentialManager.AccessToken)
.PostJsonAsync(new DeleteHomeScheduleRequest { HomeId = homeId, ScheduleId = scheduleId })
.ReceiveJson();
public async Task SyncHomeSchedule(SyncHomeScheduleRequest requestParameters) =>
- await baseUrl.ConfigureRequest(Configuration.ConfigureRequest)
+ await baseUrl.WithSettings(Configuration.ConfigureRequest)
.AppendPathSegment("/api/synchomeschedule")
.WithOAuthBearerToken(credentialManager.AccessToken)
.PostJsonAsync(requestParameters)
.ReceiveJson();
public async Task CreateHomeSchedule(CreateHomeScheduleRequest requestParameters) =>
- await baseUrl.ConfigureRequest(Configuration.ConfigureRequest)
+ await baseUrl.WithSettings(Configuration.ConfigureRequest)
.AppendPathSegment("/api/createnewhomeschedule")
.WithOAuthBearerToken(credentialManager.AccessToken)
.PostJsonAsync(requestParameters)
diff --git a/src/Netatmo/Models/Client/Air/GetHomeCoachsData.cs b/src/Netatmo/Models/Client/Air/GetHomeCoachsData.cs
index bcfe022..2a8ac9f 100644
--- a/src/Netatmo/Models/Client/Air/GetHomeCoachsData.cs
+++ b/src/Netatmo/Models/Client/Air/GetHomeCoachsData.cs
@@ -1,13 +1,13 @@
+using System.Text.Json.Serialization;
using Netatmo.Models.Client.Air.HomesCoachs;
-using Newtonsoft.Json;
namespace Netatmo.Models.Client.Air;
public class GetHomeCoachsData
{
- [JsonProperty("devices")]
+ [JsonPropertyName("devices")]
public Devices[] Devices { get; set; }
- [JsonProperty("user")]
+ [JsonPropertyName("user")]
public User User { get; set; }
}
\ No newline at end of file
diff --git a/src/Netatmo/Models/Client/Air/HomesCoachs/DashBoardData.cs b/src/Netatmo/Models/Client/Air/HomesCoachs/DashBoardData.cs
index 4e005c5..2bb20f2 100644
--- a/src/Netatmo/Models/Client/Air/HomesCoachs/DashBoardData.cs
+++ b/src/Netatmo/Models/Client/Air/HomesCoachs/DashBoardData.cs
@@ -1,43 +1,43 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
using NodaTime;
namespace Netatmo.Models.Client.Air.HomesCoachs;
public class DashBoardData
{
- [JsonProperty("time_utc")]
+ [JsonPropertyName("time_utc")]
public Instant TimeUtc { get; set; }
- [JsonProperty("Temperature")]
+ [JsonPropertyName("Temperature")]
public double Temperature { get; set; }
- [JsonProperty("CO2")]
+ [JsonPropertyName("CO2")]
public int CO2 { get; set; }
- [JsonProperty("Humidity")]
+ [JsonPropertyName("Humidity")]
public int HumidityPercent { get; set; }
- [JsonProperty("Noise")]
+ [JsonPropertyName("Noise")]
public double Noise { get; set; }
- [JsonProperty("Pressure")]
+ [JsonPropertyName("Pressure")]
public double Pressure { get; set; }
- [JsonProperty("AbsolutePressure")]
+ [JsonPropertyName("AbsolutePressure")]
public double AbsolutePressure { get; set; }
- [JsonProperty("health_idx")]
+ [JsonPropertyName("health_idx")]
public HealthIdx HealthIdx { get; set; }
- [JsonProperty("min_temp")]
+ [JsonPropertyName("min_temp")]
public decimal MinTemp { get; set; }
- [JsonProperty("max_temp")]
+ [JsonPropertyName("max_temp")]
public decimal MaxTemp { get; set; }
- [JsonProperty("date_min_temp")]
+ [JsonPropertyName("date_min_temp")]
public Instant DateMinTemp { get; set; }
- [JsonProperty("date_max_temp")]
+ [JsonPropertyName("date_max_temp")]
public Instant DateMaxTemp { get; set; }
}
\ No newline at end of file
diff --git a/src/Netatmo/Models/Client/Air/HomesCoachs/Devices.cs b/src/Netatmo/Models/Client/Air/HomesCoachs/Devices.cs
index c6f394f..130e028 100644
--- a/src/Netatmo/Models/Client/Air/HomesCoachs/Devices.cs
+++ b/src/Netatmo/Models/Client/Air/HomesCoachs/Devices.cs
@@ -1,57 +1,57 @@
+using System.Text.Json.Serialization;
using Netatmo.Enums;
-using Newtonsoft.Json;
using NodaTime;
namespace Netatmo.Models.Client.Air.HomesCoachs;
public class Devices
{
- [JsonProperty("_id")]
+ [JsonPropertyName("_id")]
public string Id { get; set; }
- [JsonProperty("cipher_id")]
+ [JsonPropertyName("cipher_id")]
public string CipherId { get; set; }
- [JsonProperty("last_status_store")]
+ [JsonPropertyName("last_status_store")]
public Instant LastStatusStore { get; set; }
- [JsonProperty("place")]
+ [JsonPropertyName("place")]
public Place Place { get; set; }
- [JsonProperty("type")]
+ [JsonPropertyName("type")]
public string Type { get; set; }
- [JsonProperty("dashboard_data")]
+ [JsonPropertyName("dashboard_data")]
public DashBoardData DashboardData { get; set; }
- [JsonProperty("data_type")]
+ [JsonPropertyName("data_type")]
public string[] DataType { get; set; }
- [JsonProperty("co2_calibrating")]
+ [JsonPropertyName("co2_calibrating")]
public bool Co2Calibrating { get; set; }
- [JsonProperty("reachable")]
+ [JsonPropertyName("reachable")]
public bool Reachable { get; set; }
- [JsonProperty("date_setup")]
+ [JsonPropertyName("date_setup")]
public Instant DateSetup { get; set; }
- [JsonProperty("last_setup")]
+ [JsonPropertyName("last_setup")]
public Instant LastSetup { get; set; }
- [JsonProperty("module_name")]
+ [JsonPropertyName("module_name")]
public string ModuleName { get; set; }
- [JsonProperty("firmware")]
+ [JsonPropertyName("firmware")]
public int Firmware { get; set; }
- [JsonProperty("last_upgrade")]
+ [JsonPropertyName("last_upgrade")]
public Instant LastUpgrade { get; set; }
- [JsonProperty("station_name")]
+ [JsonPropertyName("station_name")]
public string Name { get; set; }
- [JsonProperty("wifi_status")]
+ [JsonPropertyName("wifi_status")]
public int WifiStatus { get; set; }
public WifiStrengthEnum WifiStrength
diff --git a/src/Netatmo/Models/Client/DataResponse.cs b/src/Netatmo/Models/Client/DataResponse.cs
index 53ebe23..c6fab52 100644
--- a/src/Netatmo/Models/Client/DataResponse.cs
+++ b/src/Netatmo/Models/Client/DataResponse.cs
@@ -1,12 +1,12 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
using NodaTime;
namespace Netatmo.Models.Client;
public record DataResponse(
- [property: JsonProperty("status")] string Status,
- [property: JsonProperty("time_exec")] double? TimeExec,
- [property: JsonProperty("time_server")] Instant? TimeServer);
+ [property: JsonPropertyName("status")] string Status,
+ [property: JsonPropertyName("time_exec")] double? TimeExec,
+ [property: JsonPropertyName("time_server")] Instant? TimeServer);
-public record DataResponse(string Status, double? TimeExec, Instant? TimeServer, [property: JsonProperty("body")] T Body)
+public record DataResponse(string Status, double? TimeExec, Instant? TimeServer, [property: JsonPropertyName("body")] T Body)
: DataResponse(Status, TimeExec, TimeServer);
\ No newline at end of file
diff --git a/src/Netatmo/Models/Client/Energy/CreateHomeScheduleRequest.cs b/src/Netatmo/Models/Client/Energy/CreateHomeScheduleRequest.cs
index b83ea4d..81bba35 100644
--- a/src/Netatmo/Models/Client/Energy/CreateHomeScheduleRequest.cs
+++ b/src/Netatmo/Models/Client/Energy/CreateHomeScheduleRequest.cs
@@ -1,4 +1,4 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
namespace Netatmo.Models.Client.Energy;
@@ -23,21 +23,21 @@ public CreateHomeScheduleRequest(string homeId, double hgTemp, double awayTemp,
}
}
- [JsonProperty("home_id")]
+ [JsonPropertyName("home_id")]
public string HomeId { get; set; }
- [JsonProperty("name")]
+ [JsonPropertyName("name")]
public string Name { get; set; }
- [JsonProperty("hg_temp")]
+ [JsonPropertyName("hg_temp")]
public double HgTemp { get; set; }
- [JsonProperty("away_temp")]
+ [JsonPropertyName("away_temp")]
public double AwayTemp { get; set; }
- [JsonProperty("timetable")]
+ [JsonPropertyName("timetable")]
public List Timetables { get; set; } = [];
- [JsonProperty("zones")]
+ [JsonPropertyName("zones")]
public List Zones { get; set; } = [];
}
\ No newline at end of file
diff --git a/src/Netatmo/Models/Client/Energy/CreateHomeScheduleResponse.cs b/src/Netatmo/Models/Client/Energy/CreateHomeScheduleResponse.cs
index 00f6169..8c10bf2 100644
--- a/src/Netatmo/Models/Client/Energy/CreateHomeScheduleResponse.cs
+++ b/src/Netatmo/Models/Client/Energy/CreateHomeScheduleResponse.cs
@@ -1,7 +1,7 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
using NodaTime;
namespace Netatmo.Models.Client.Energy;
-public record CreateHomeScheduleResponse(string Status, double? TimeExec, Instant? TimeServer, [property: JsonProperty("schedule_id")] string ScheduleId)
+public record CreateHomeScheduleResponse(string Status, double? TimeExec, Instant? TimeServer, [property: JsonPropertyName("schedule_id")] string ScheduleId)
: DataResponse(Status, TimeExec, TimeServer);
\ No newline at end of file
diff --git a/src/Netatmo/Models/Client/Energy/DeleteHomeScheduleRequest.cs b/src/Netatmo/Models/Client/Energy/DeleteHomeScheduleRequest.cs
index a2aae6f..8e9f315 100644
--- a/src/Netatmo/Models/Client/Energy/DeleteHomeScheduleRequest.cs
+++ b/src/Netatmo/Models/Client/Energy/DeleteHomeScheduleRequest.cs
@@ -1,12 +1,12 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
namespace Netatmo.Models.Client.Energy;
public class DeleteHomeScheduleRequest
{
- [JsonProperty("home_id")]
+ [JsonPropertyName("home_id")]
public string HomeId { get; set; }
- [JsonProperty("schedule_id")]
+ [JsonPropertyName("schedule_id")]
public string ScheduleId { get; set; }
}
\ No newline at end of file
diff --git a/src/Netatmo/Models/Client/Energy/GetHomeStatusBody.cs b/src/Netatmo/Models/Client/Energy/GetHomeStatusBody.cs
index 110a396..fd6586f 100644
--- a/src/Netatmo/Models/Client/Energy/GetHomeStatusBody.cs
+++ b/src/Netatmo/Models/Client/Energy/GetHomeStatusBody.cs
@@ -1,10 +1,10 @@
+using System.Text.Json.Serialization;
using Netatmo.Models.Client.Energy.HomeStatus;
-using Newtonsoft.Json;
namespace Netatmo.Models.Client.Energy;
public class GetHomeStatusBody
{
- [JsonProperty("home")]
+ [JsonPropertyName("home")]
public Home Home { get; set; }
}
\ No newline at end of file
diff --git a/src/Netatmo/Models/Client/Energy/GetHomeStatusRequest.cs b/src/Netatmo/Models/Client/Energy/GetHomeStatusRequest.cs
index a9b86cd..4a8678f 100644
--- a/src/Netatmo/Models/Client/Energy/GetHomeStatusRequest.cs
+++ b/src/Netatmo/Models/Client/Energy/GetHomeStatusRequest.cs
@@ -1,12 +1,12 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
namespace Netatmo.Models.Client.Energy;
public class GetHomeStatusRequest
{
- [JsonProperty("home_id")]
+ [JsonPropertyName("home_id")]
public string HomeId { get; set; }
- [JsonProperty("device_types")]
+ [JsonPropertyName("device_types")]
public string[] DeviceTypes { get; set; }
}
\ No newline at end of file
diff --git a/src/Netatmo/Models/Client/Energy/GetHomesDataBody.cs b/src/Netatmo/Models/Client/Energy/GetHomesDataBody.cs
index 1f546fd..0c7a2e5 100644
--- a/src/Netatmo/Models/Client/Energy/GetHomesDataBody.cs
+++ b/src/Netatmo/Models/Client/Energy/GetHomesDataBody.cs
@@ -1,13 +1,13 @@
+using System.Text.Json.Serialization;
using Netatmo.Models.Client.Energy.HomesData;
-using Newtonsoft.Json;
namespace Netatmo.Models.Client.Energy;
public class GetHomesDataBody
{
- [JsonProperty("homes")]
+ [JsonPropertyName("homes")]
public Home[] Homes { get; set; }
- [JsonProperty("user")]
+ [JsonPropertyName("user")]
public User User { get; set; }
}
\ No newline at end of file
diff --git a/src/Netatmo/Models/Client/Energy/GetHomesDataRequest.cs b/src/Netatmo/Models/Client/Energy/GetHomesDataRequest.cs
index 48e30b7..b01cd83 100644
--- a/src/Netatmo/Models/Client/Energy/GetHomesDataRequest.cs
+++ b/src/Netatmo/Models/Client/Energy/GetHomesDataRequest.cs
@@ -1,12 +1,12 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
namespace Netatmo.Models.Client.Energy;
public class GetHomesDataRequest
{
- [JsonProperty("home_id")]
+ [JsonPropertyName("home_id")]
public string HomeId { get; set; }
- [JsonProperty("gateway_types")]
+ [JsonPropertyName("gateway_types")]
public string GatewayTypes { get; set; }
}
\ No newline at end of file
diff --git a/src/Netatmo/Models/Client/Energy/GetRoomMeasureRequest.cs b/src/Netatmo/Models/Client/Energy/GetRoomMeasureRequest.cs
index a7457a3..c9928a7 100644
--- a/src/Netatmo/Models/Client/Energy/GetRoomMeasureRequest.cs
+++ b/src/Netatmo/Models/Client/Energy/GetRoomMeasureRequest.cs
@@ -1,34 +1,34 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
using NodaTime;
namespace Netatmo.Models.Client.Energy;
public class GetRoomMeasureRequest
{
- [JsonProperty("home_id")]
+ [JsonPropertyName("home_id")]
public string HomeId { get; set; }
- [JsonProperty("room_id")]
+ [JsonPropertyName("room_id")]
public string RoomId { get; set; }
- [JsonProperty("scale")]
+ [JsonPropertyName("scale")]
public string Scale { get; set; }
- [JsonProperty("type")]
+ [JsonPropertyName("type")]
public string Type { get; set; }
- [JsonProperty("date_begin")]
+ [JsonPropertyName("date_begin")]
public Instant? BeginAt { get; set; }
- [JsonProperty("date_end")]
+ [JsonPropertyName("date_end")]
public Instant? EndAt { get; set; }
- [JsonProperty("limit")]
+ [JsonPropertyName("limit")]
public int? Limit { get; set; }
- [JsonProperty("optimize")]
+ [JsonPropertyName("optimize")]
public bool? Optimize { get; set; }
- [JsonProperty("real_time")]
+ [JsonPropertyName("real_time")]
public bool? RealTime { get; set; }
}
\ No newline at end of file
diff --git a/src/Netatmo/Models/Client/Energy/HomeStatus/Home.cs b/src/Netatmo/Models/Client/Energy/HomeStatus/Home.cs
index d348aec..20938ff 100644
--- a/src/Netatmo/Models/Client/Energy/HomeStatus/Home.cs
+++ b/src/Netatmo/Models/Client/Energy/HomeStatus/Home.cs
@@ -1,15 +1,15 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
namespace Netatmo.Models.Client.Energy.HomeStatus;
public class Home
{
- [JsonProperty("id")]
+ [JsonPropertyName("id")]
public string Id { get; set; }
- [JsonProperty("modules")]
+ [JsonPropertyName("modules")]
public Module[] Modules { get; set; }
- [JsonProperty("rooms")]
+ [JsonPropertyName("rooms")]
public Room[] Rooms { get; set; }
}
\ No newline at end of file
diff --git a/src/Netatmo/Models/Client/Energy/HomeStatus/Module.cs b/src/Netatmo/Models/Client/Energy/HomeStatus/Module.cs
index 0a4ce77..8127171 100644
--- a/src/Netatmo/Models/Client/Energy/HomeStatus/Module.cs
+++ b/src/Netatmo/Models/Client/Energy/HomeStatus/Module.cs
@@ -1,22 +1,22 @@
+using System.Text.Json.Serialization;
using Netatmo.Enums;
-using Newtonsoft.Json;
namespace Netatmo.Models.Client.Energy.HomeStatus;
public class Module
{
- [JsonProperty("id")]
+ [JsonPropertyName("id")]
public string Id { get; set; }
// NATherm1 = thermostat, NRV = valve, NAPlug = relay, NACamera = welcome camera, NOC = presence camera
- [JsonProperty("type")]
+ [JsonPropertyName("type")]
public string Type { get; set; }
- [JsonProperty("bridge")]
+ [JsonPropertyName("bridge")]
public string Bridgereachable { get; set; }
// Wifi signal quality : 56 Good, 71 Average, 86 Bad
- [JsonProperty("wifi_strength")]
+ [JsonPropertyName("wifi_strength")]
public int? WifiStrength { get; set; }
public WifiStrengthEnum WifiStatus
@@ -43,7 +43,7 @@ public WifiStrengthEnum WifiStatus
}
// Radio signal quality : 90 = low, 80 = medium, 70 = high, 60 = full signal
- [JsonProperty("rf_strength")]
+ [JsonPropertyName("rf_strength")]
public int RfStrength { get; set; }
public RfStrengthEnum RfStatus
@@ -70,18 +70,18 @@ public RfStrengthEnum RfStatus
}
// Only for NATherm1
- [JsonProperty("connected_to_boiler")]
+ [JsonPropertyName("connected_to_boiler")]
public bool? ConnectedToBoiler { get; set; }
// Only for NATherm1
- [JsonProperty("boiler_status")]
+ [JsonPropertyName("boiler_status")]
public bool? BoilerStatus { get; set; }
// Only for NATherm1
- [JsonProperty("boiler_valve_comfort_boost")]
+ [JsonPropertyName("boiler_valve_comfort_boost")]
public bool? BoilerValveComfortBoost { get; set; }
- [JsonProperty("battery_level")]
+ [JsonPropertyName("battery_level")]
public int BatteryLevel { get; set; }
public BatteryLevelEnum BatteryStatus
@@ -112,19 +112,19 @@ public BatteryLevelEnum BatteryStatus
}
}
- [JsonProperty("battery_state")]
+ [JsonPropertyName("battery_state")]
public string BatteryState { get; set; }
- [JsonProperty("firmware_revision")]
+ [JsonPropertyName("firmware_revision")]
public int FirmwareRevision { get; set; }
// Only for valve type Number displayed during the pairing with the relay
- [JsonProperty("radio_id")]
+ [JsonPropertyName("radio_id")]
public int? RadioId { get; set; }
- [JsonProperty("anticipating")]
+ [JsonPropertyName("anticipating")]
public bool? Anticipating { get; set; }
- [JsonProperty("reachable")]
+ [JsonPropertyName("reachable")]
public bool? Reachable { get; set; }
}
\ No newline at end of file
diff --git a/src/Netatmo/Models/Client/Energy/HomeStatus/Room.cs b/src/Netatmo/Models/Client/Energy/HomeStatus/Room.cs
index 6f9c89b..f9356c8 100644
--- a/src/Netatmo/Models/Client/Energy/HomeStatus/Room.cs
+++ b/src/Netatmo/Models/Client/Energy/HomeStatus/Room.cs
@@ -1,37 +1,37 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
using NodaTime;
namespace Netatmo.Models.Client.Energy.HomeStatus;
public class Room
{
- [JsonProperty("id")]
+ [JsonPropertyName("id")]
public string Id { get; set; }
- [JsonProperty("reachable")]
+ [JsonPropertyName("reachable")]
public bool Reachable { get; set; }
- [JsonProperty("anticipating")]
+ [JsonPropertyName("anticipating")]
public bool Anticipating { get; set; }
- [JsonProperty("open_window")]
+ [JsonPropertyName("open_window")]
public bool OpenWindow { get; set; }
- [JsonProperty("therm_measured_temperature")]
+ [JsonPropertyName("therm_measured_temperature")]
public double ThermMeasuredTemperature { get; set; }
- [JsonProperty("therm_setpoint_temperature")]
+ [JsonPropertyName("therm_setpoint_temperature")]
public double ThermSetPointTemperature { get; set; }
- [JsonProperty("heating_power_request")]
+ [JsonPropertyName("heating_power_request")]
public int? HeatingPowerRequest { get; set; }
- [JsonProperty("therm_setpoint_mode")]
+ [JsonPropertyName("therm_setpoint_mode")]
public string ThermSetPointMode { get; set; }
- [JsonProperty("therm_setpoint_start_time")]
+ [JsonPropertyName("therm_setpoint_start_time")]
public Instant ThermSetPointStartTime { get; set; }
- [JsonProperty("therm_setpoint_end_time")]
+ [JsonPropertyName("therm_setpoint_end_time")]
public Instant? ThermSetPointEndTime { get; set; }
}
\ No newline at end of file
diff --git a/src/Netatmo/Models/Client/Energy/HomesData/Home.cs b/src/Netatmo/Models/Client/Energy/HomesData/Home.cs
index 25b45c7..4f5865c 100644
--- a/src/Netatmo/Models/Client/Energy/HomesData/Home.cs
+++ b/src/Netatmo/Models/Client/Energy/HomesData/Home.cs
@@ -1,40 +1,40 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
using NodaTime;
namespace Netatmo.Models.Client.Energy.HomesData;
public class Home
{
- [JsonProperty("id")]
+ [JsonPropertyName("id")]
public string Id { get; set; }
- [JsonProperty("name")]
+ [JsonPropertyName("name")]
public string Name { get; set; }
- [JsonProperty("country")]
+ [JsonPropertyName("country")]
public string Country { get; set; }
- [JsonProperty("timezone")]
+ [JsonPropertyName("timezone")]
public DateTimeZone Timezone { get; set; }
- [JsonProperty("schedules")]
+ [JsonPropertyName("schedules")]
public Schedule[] Schedules { get; set; }
- [JsonProperty("coordinates")]
+ [JsonPropertyName("coordinates")]
public double[] Coordinates { get; set; }
- [JsonProperty("therm_setpoint_default_duration")]
+ [JsonPropertyName("therm_setpoint_default_duration")]
public int ThermSetpointDefaultDuration { get; set; }
- [JsonProperty("therm_mode")]
+ [JsonPropertyName("therm_mode")]
public string ThermMode { get; set; }
- [JsonProperty("therm_mode_endtime")]
+ [JsonPropertyName("therm_mode_endtime")]
public Instant? ThermModeEndtime { get; set; }
- [JsonProperty("rooms")]
+ [JsonPropertyName("rooms")]
public Room[] Rooms { get; set; }
- [JsonProperty("modules")]
+ [JsonPropertyName("modules")]
public Module[] Modules { get; set; }
}
\ No newline at end of file
diff --git a/src/Netatmo/Models/Client/Energy/HomesData/Module.cs b/src/Netatmo/Models/Client/Energy/HomesData/Module.cs
index 5b6fec0..1f0e800 100644
--- a/src/Netatmo/Models/Client/Energy/HomesData/Module.cs
+++ b/src/Netatmo/Models/Client/Energy/HomesData/Module.cs
@@ -1,29 +1,29 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
using NodaTime;
namespace Netatmo.Models.Client.Energy.HomesData;
public class Module
{
- [JsonProperty("id")]
+ [JsonPropertyName("id")]
public string Id { get; set; }
- [JsonProperty("name")]
+ [JsonPropertyName("name")]
public string Name { get; set; }
// NATherm1 = thermostat, NRV = valve, NAPlug = relay, NACamera = welcome camera, NOC = presence camera
- [JsonProperty("type")]
+ [JsonPropertyName("type")]
public string Type { get; set; }
- [JsonProperty("setup_date")]
+ [JsonPropertyName("setup_date")]
public Instant SetupAt { get; set; }
- [JsonProperty("modules_bridged")]
+ [JsonPropertyName("modules_bridged")]
public string[] ModulesBridged { get; set; }
- [JsonProperty("bridge")]
+ [JsonPropertyName("bridge")]
public string Bridge { get; set; }
- [JsonProperty("room_id")]
+ [JsonPropertyName("room_id")]
public string RoomId { get; set; }
}
\ No newline at end of file
diff --git a/src/Netatmo/Models/Client/Energy/HomesData/Room.cs b/src/Netatmo/Models/Client/Energy/HomesData/Room.cs
index f05ba78..d5d87d7 100644
--- a/src/Netatmo/Models/Client/Energy/HomesData/Room.cs
+++ b/src/Netatmo/Models/Client/Energy/HomesData/Room.cs
@@ -1,24 +1,24 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
namespace Netatmo.Models.Client.Energy.HomesData;
public class Room
{
- [JsonProperty("id")]
+ [JsonPropertyName("id")]
public string Id { get; set; }
- [JsonProperty("name")]
+ [JsonPropertyName("name")]
public string Name { get; set; }
- [JsonProperty("type")]
+ [JsonPropertyName("type")]
public string Type { get; set; }
- [JsonProperty("measure_offset_NAPlug_estimated_temperature")]
+ [JsonPropertyName("measure_offset_NAPlug_estimated_temperature")]
public double MeasureOffsetNaPlugEstimatedTemperature { get; set; }
- [JsonProperty("measure_offset_NAPlug_temperature")]
+ [JsonPropertyName("measure_offset_NAPlug_temperature")]
public double MeasureOffsetNaPlugTemperature { get; set; }
- [JsonProperty("module_ids")]
+ [JsonPropertyName("module_ids")]
public string[] ModuleIds { get; set; }
}
\ No newline at end of file
diff --git a/src/Netatmo/Models/Client/Energy/HomesData/Schedule.cs b/src/Netatmo/Models/Client/Energy/HomesData/Schedule.cs
index 4b7bca8..a98cac8 100644
--- a/src/Netatmo/Models/Client/Energy/HomesData/Schedule.cs
+++ b/src/Netatmo/Models/Client/Energy/HomesData/Schedule.cs
@@ -1,32 +1,32 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
namespace Netatmo.Models.Client.Energy.HomesData;
public class Schedule
{
- [JsonProperty("id")]
+ [JsonPropertyName("id")]
public string Id { get; set; }
- [JsonProperty("name")]
+ [JsonPropertyName("name")]
public string Name { get; set; }
- [JsonProperty("type")]
+ [JsonPropertyName("type")]
public string Type { get; set; }
// Away temperature value
- [JsonProperty("away_temp")]
+ [JsonPropertyName("away_temp")]
public double AwayTemp { get; set; }
// Frostguard temperature value
- [JsonProperty("hg_temp")]
+ [JsonPropertyName("hg_temp")]
public double HgTemp { get; set; }
- [JsonProperty("selected")]
+ [JsonPropertyName("selected")]
public bool Selected { get; set; }
- [JsonProperty("timetables")]
+ [JsonPropertyName("timetables")]
public Timetable[] Timetables { get; set; }
- [JsonProperty("zones")]
+ [JsonPropertyName("zones")]
public Zone[] Zones { get; set; }
}
\ No newline at end of file
diff --git a/src/Netatmo/Models/Client/Energy/HomesData/User.cs b/src/Netatmo/Models/Client/Energy/HomesData/User.cs
index 60059d8..42b255e 100644
--- a/src/Netatmo/Models/Client/Energy/HomesData/User.cs
+++ b/src/Netatmo/Models/Client/Energy/HomesData/User.cs
@@ -1,31 +1,31 @@
+using System.Text.Json.Serialization;
using Netatmo.Enums;
-using Newtonsoft.Json;
namespace Netatmo.Models.Client.Energy.HomesData;
public class User
{
- [JsonProperty("id")]
+ [JsonPropertyName("id")]
public string Id { get; set; }
- [JsonProperty("email")]
+ [JsonPropertyName("email")]
public string Email { get; set; }
- [JsonProperty("language")]
+ [JsonPropertyName("language")]
public string Language { get; set; }
- [JsonProperty("locale")]
+ [JsonPropertyName("locale")]
public string Locale { get; set; }
- [JsonProperty("feel_like_algorithm")]
+ [JsonPropertyName("feel_like_algorithm")]
public FeelLikeAlgoEnum FeelLikeAlgorithm { get; set; }
- [JsonProperty("unit_pressure")]
+ [JsonPropertyName("unit_pressure")]
public PressureUnitEnum PressureUnit { get; set; }
- [JsonProperty("unit_system")]
+ [JsonPropertyName("unit_system")]
public UnitEnum Unit { get; set; }
- [JsonProperty("unit_wind")]
+ [JsonPropertyName("unit_wind")]
public WindUnitEnum WindUnit { get; set; }
}
\ No newline at end of file
diff --git a/src/Netatmo/Models/Client/Energy/HomesData/Zone.cs b/src/Netatmo/Models/Client/Energy/HomesData/Zone.cs
index 31065ab..364f9b5 100644
--- a/src/Netatmo/Models/Client/Energy/HomesData/Zone.cs
+++ b/src/Netatmo/Models/Client/Energy/HomesData/Zone.cs
@@ -1,18 +1,18 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
namespace Netatmo.Models.Client.Energy.HomesData;
public class Zone : Energy.Zone
{
- [JsonProperty("rooms_temp")]
+ [JsonPropertyName("rooms_temp")]
public RoomTemp[] RoomsTemp { get; set; }
public class RoomTemp
{
- [JsonProperty("room_id")]
+ [JsonPropertyName("room_id")]
public string RoomId { get; set; }
- [JsonProperty("temp")]
+ [JsonPropertyName("temp")]
public double Temp { get; set; }
}
}
\ No newline at end of file
diff --git a/src/Netatmo/Models/Client/Energy/RenameHomeScheduleRequest.cs b/src/Netatmo/Models/Client/Energy/RenameHomeScheduleRequest.cs
index 5f0edb0..ab9a3e9 100644
--- a/src/Netatmo/Models/Client/Energy/RenameHomeScheduleRequest.cs
+++ b/src/Netatmo/Models/Client/Energy/RenameHomeScheduleRequest.cs
@@ -1,15 +1,15 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
namespace Netatmo.Models.Client.Energy;
public class RenameHomeScheduleRequest
{
- [JsonProperty("home_id")]
+ [JsonPropertyName("home_id")]
public string HomeId { get; set; }
- [JsonProperty("schedule_id")]
+ [JsonPropertyName("schedule_id")]
public string ScheduleId { get; set; }
- [JsonProperty("name")]
+ [JsonPropertyName("name")]
public string Name { get; set; }
}
\ No newline at end of file
diff --git a/src/Netatmo/Models/Client/Energy/RoomMeasure/Step.cs b/src/Netatmo/Models/Client/Energy/RoomMeasure/Step.cs
index ca11f54..51fdf27 100644
--- a/src/Netatmo/Models/Client/Energy/RoomMeasure/Step.cs
+++ b/src/Netatmo/Models/Client/Energy/RoomMeasure/Step.cs
@@ -1,16 +1,16 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
using NodaTime;
namespace Netatmo.Models.Client.Energy.RoomMeasure;
public abstract class Step : IStep
{
- [JsonProperty("beg_time")]
+ [JsonPropertyName("beg_time")]
public Instant BeginAt { get; set; }
- [JsonProperty("step_time")]
+ [JsonPropertyName("step_time")]
public int StepTime { get; set; }
- [JsonProperty("value")]
+ [JsonPropertyName("value")]
public T[][] Values { get; set; }
}
\ No newline at end of file
diff --git a/src/Netatmo/Models/Client/Energy/SetRoomThermpointRequest.cs b/src/Netatmo/Models/Client/Energy/SetRoomThermpointRequest.cs
index c930de7..2780f19 100644
--- a/src/Netatmo/Models/Client/Energy/SetRoomThermpointRequest.cs
+++ b/src/Netatmo/Models/Client/Energy/SetRoomThermpointRequest.cs
@@ -1,22 +1,22 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
using NodaTime;
namespace Netatmo.Models.Client.Energy;
public class SetRoomThermpointRequest
{
- [JsonProperty("home_id")]
+ [JsonPropertyName("home_id")]
public string HomeId { get; set; }
- [JsonProperty("room_id")]
+ [JsonPropertyName("room_id")]
public string RoomId { get; set; }
- [JsonProperty("mode")]
+ [JsonPropertyName("mode")]
public string Mode { get; set; }
- [JsonProperty("temp")]
+ [JsonPropertyName("temp")]
public double? Temp { get; set; }
- [JsonProperty("endtime")]
+ [JsonPropertyName("endtime")]
public Instant? EndTime { get; set; }
}
\ No newline at end of file
diff --git a/src/Netatmo/Models/Client/Energy/SetThermModeRequest.cs b/src/Netatmo/Models/Client/Energy/SetThermModeRequest.cs
index 871668e..9461201 100644
--- a/src/Netatmo/Models/Client/Energy/SetThermModeRequest.cs
+++ b/src/Netatmo/Models/Client/Energy/SetThermModeRequest.cs
@@ -1,16 +1,16 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
using NodaTime;
namespace Netatmo.Models.Client.Energy;
public class SetThermModeRequest
{
- [JsonProperty("home_id")]
+ [JsonPropertyName("home_id")]
public string HomeId { get; set; }
- [JsonProperty("mode")]
+ [JsonPropertyName("mode")]
public string Mode { get; set; }
- [JsonProperty("endtime")]
+ [JsonPropertyName("endtime")]
public Instant? EndTime { get; set; }
}
\ No newline at end of file
diff --git a/src/Netatmo/Models/Client/Energy/SwitchHomeScheduleRequest.cs b/src/Netatmo/Models/Client/Energy/SwitchHomeScheduleRequest.cs
index c6d13bd..cf14596 100644
--- a/src/Netatmo/Models/Client/Energy/SwitchHomeScheduleRequest.cs
+++ b/src/Netatmo/Models/Client/Energy/SwitchHomeScheduleRequest.cs
@@ -1,12 +1,12 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
namespace Netatmo.Models.Client.Energy;
public class SwitchHomeScheduleRequest
{
- [JsonProperty("home_id")]
+ [JsonPropertyName("home_id")]
public string HomeId { get; set; }
- [JsonProperty("schedule_id")]
+ [JsonPropertyName("schedule_id")]
public string ScheduleId { get; set; }
}
\ No newline at end of file
diff --git a/src/Netatmo/Models/Client/Energy/SyncHomeScheduleRequest.cs b/src/Netatmo/Models/Client/Energy/SyncHomeScheduleRequest.cs
index 86e92af..00f391d 100644
--- a/src/Netatmo/Models/Client/Energy/SyncHomeScheduleRequest.cs
+++ b/src/Netatmo/Models/Client/Energy/SyncHomeScheduleRequest.cs
@@ -1,4 +1,4 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
namespace Netatmo.Models.Client.Energy;
@@ -40,24 +40,24 @@ public SyncHomeScheduleRequest(string homeId, string scheduleId, double hgTemp,
{
}
- [JsonProperty("home_id")]
+ [JsonPropertyName("home_id")]
public string HomeId { get; set; }
- [JsonProperty("schedule_id")]
+ [JsonPropertyName("schedule_id")]
public string ScheduleId { get; set; }
- [JsonProperty("name")]
+ [JsonPropertyName("name")]
public string Name { get; set; }
- [JsonProperty("hg_temp")]
+ [JsonPropertyName("hg_temp")]
public double HgTemp { get; set; }
- [JsonProperty("away_temp")]
+ [JsonPropertyName("away_temp")]
public double AwayTemp { get; set; }
- [JsonProperty("timetable")]
+ [JsonPropertyName("timetable")]
public List Timetables { get; set; }
- [JsonProperty("zones")]
+ [JsonPropertyName("zones")]
public List Zones { get; set; }
}
\ No newline at end of file
diff --git a/src/Netatmo/Models/Client/Energy/Timetable.cs b/src/Netatmo/Models/Client/Energy/Timetable.cs
index 5380d2f..3dc3291 100644
--- a/src/Netatmo/Models/Client/Energy/Timetable.cs
+++ b/src/Netatmo/Models/Client/Energy/Timetable.cs
@@ -1,4 +1,4 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
namespace Netatmo.Models.Client.Energy;
@@ -14,10 +14,10 @@ public Timetable(string zoneId, int mOffset)
MOffset = mOffset;
}
- [JsonProperty("id")]
+ [JsonPropertyName("id")]
public string ZoneId { get; set; }
// offset in minutes since Monday 00:00:01
- [JsonProperty("m_offset")]
+ [JsonPropertyName("m_offset")]
public int MOffset { get; set; }
}
\ No newline at end of file
diff --git a/src/Netatmo/Models/Client/Energy/Zone.cs b/src/Netatmo/Models/Client/Energy/Zone.cs
index 938672f..b9e4782 100644
--- a/src/Netatmo/Models/Client/Energy/Zone.cs
+++ b/src/Netatmo/Models/Client/Energy/Zone.cs
@@ -1,5 +1,6 @@
+using System.Text.Json.Serialization;
+using Netatmo.Converters;
using Netatmo.Models.Client.Energy.Enums;
-using Newtonsoft.Json;
namespace Netatmo.Models.Client.Energy;
@@ -23,16 +24,17 @@ public Zone(string id, string name, ZoneTypeEnum type, Room[] rooms = null)
}
}
- [JsonProperty("id")]
+ [JsonPropertyName("id")]
+ [JsonConverter(typeof(ZoneIdConverter))]
public string Id { get; set; }
- [JsonProperty("name")]
+ [JsonPropertyName("name")]
public string Name { get; set; }
- [JsonProperty("type")]
+ [JsonPropertyName("type")]
public ZoneTypeEnum Type { get; set; }
- [JsonProperty("rooms")]
+ [JsonPropertyName("rooms")]
public List Rooms { get; set; }
public class Room
@@ -47,10 +49,10 @@ public Room(string id, double thermSetPointTemperature)
ThermSetPointTemperature = thermSetPointTemperature;
}
- [JsonProperty("id")]
+ [JsonPropertyName("id")]
public string Id { get; set; }
- [JsonProperty("therm_setpoint_temperature")]
+ [JsonPropertyName("therm_setpoint_temperature")]
public double ThermSetPointTemperature { get; set; }
}
}
\ No newline at end of file
diff --git a/src/Netatmo/Models/Client/Place.cs b/src/Netatmo/Models/Client/Place.cs
index 291fe38..35da1da 100644
--- a/src/Netatmo/Models/Client/Place.cs
+++ b/src/Netatmo/Models/Client/Place.cs
@@ -1,11 +1,11 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
using NodaTime;
namespace Netatmo.Models.Client;
public record Place(
- [property: JsonProperty("altitude")] double Altitude,
- [property: JsonProperty("city")] string City,
- [property: JsonProperty("country")] string Country,
- [property: JsonProperty("timezone")] DateTimeZone Timezone,
- [property: JsonProperty("location")] double[] Location);
\ No newline at end of file
+ [property: JsonPropertyName("altitude")] double Altitude,
+ [property: JsonPropertyName("city")] string City,
+ [property: JsonPropertyName("country")] string Country,
+ [property: JsonPropertyName("timezone")] DateTimeZone Timezone,
+ [property: JsonPropertyName("location")] double[] Location);
\ No newline at end of file
diff --git a/src/Netatmo/Models/Client/Token.cs b/src/Netatmo/Models/Client/Token.cs
index 8d7b3de..ae32987 100644
--- a/src/Netatmo/Models/Client/Token.cs
+++ b/src/Netatmo/Models/Client/Token.cs
@@ -1,8 +1,8 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
namespace Netatmo.Models.Client;
public record Token(
- [property: JsonProperty("expires_in")] int ExpiresIn,
- [property: JsonProperty("access_token")] string AccessToken,
- [property: JsonProperty("refresh_token")] string RefreshToken);
\ No newline at end of file
+ [property: JsonPropertyName("expires_in")] int ExpiresIn,
+ [property: JsonPropertyName("access_token")] string AccessToken,
+ [property: JsonPropertyName("refresh_token")] string RefreshToken);
\ No newline at end of file
diff --git a/src/Netatmo/Models/Client/User.cs b/src/Netatmo/Models/Client/User.cs
index 83d81c2..68a30e8 100644
--- a/src/Netatmo/Models/Client/User.cs
+++ b/src/Netatmo/Models/Client/User.cs
@@ -1,8 +1,8 @@
+using System.Text.Json.Serialization;
using Netatmo.Models.Client.Weather.StationsData;
-using Newtonsoft.Json;
namespace Netatmo.Models.Client;
public record User(
- [property: JsonProperty("administrative")] Administrative Administrative,
- [property: JsonProperty("mail")] string Mail);
\ No newline at end of file
+ [property: JsonPropertyName("administrative")] Administrative Administrative,
+ [property: JsonPropertyName("mail")] string Mail);
\ No newline at end of file
diff --git a/src/Netatmo/Models/Client/Weather/GetStationsDataBody.cs b/src/Netatmo/Models/Client/Weather/GetStationsDataBody.cs
index 276aabe..4faa138 100644
--- a/src/Netatmo/Models/Client/Weather/GetStationsDataBody.cs
+++ b/src/Netatmo/Models/Client/Weather/GetStationsDataBody.cs
@@ -1,13 +1,13 @@
+using System.Text.Json.Serialization;
using Netatmo.Models.Client.Weather.StationsData;
-using Newtonsoft.Json;
namespace Netatmo.Models.Client.Weather;
public class GetStationsDataBody
{
- [JsonProperty("devices")]
+ [JsonPropertyName("devices")]
public Device[] Devices { get; set; }
- [JsonProperty("user")]
+ [JsonPropertyName("user")]
public User User { get; set; }
}
\ No newline at end of file
diff --git a/src/Netatmo/Models/Client/Weather/GetStationsDataRequest.cs b/src/Netatmo/Models/Client/Weather/GetStationsDataRequest.cs
index 416b2bf..54535aa 100644
--- a/src/Netatmo/Models/Client/Weather/GetStationsDataRequest.cs
+++ b/src/Netatmo/Models/Client/Weather/GetStationsDataRequest.cs
@@ -1,12 +1,12 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
namespace Netatmo.Models.Client.Weather;
public class GetStationsDataRequest
{
- [JsonProperty("device_id")]
+ [JsonPropertyName("device_id")]
public string DeviceId { get; set; }
- [JsonProperty("get_favorites")]
+ [JsonPropertyName("get_favorites")]
public bool? GetFavorites { get; set; }
}
\ No newline at end of file
diff --git a/src/Netatmo/Models/Client/Weather/StationsData/Administrative.cs b/src/Netatmo/Models/Client/Weather/StationsData/Administrative.cs
index e483ded..50ff706 100644
--- a/src/Netatmo/Models/Client/Weather/StationsData/Administrative.cs
+++ b/src/Netatmo/Models/Client/Weather/StationsData/Administrative.cs
@@ -1,28 +1,28 @@
+using System.Text.Json.Serialization;
using Netatmo.Enums;
-using Newtonsoft.Json;
namespace Netatmo.Models.Client.Weather.StationsData;
public class Administrative
{
- [JsonProperty("country")]
+ [JsonPropertyName("country")]
public string Country { get; set; }
- [JsonProperty("feel_like_algo")]
+ [JsonPropertyName("feel_like_algo")]
public FeelLikeAlgoEnum FeelLikeAlgo { get; set; }
- [JsonProperty("lang")]
+ [JsonPropertyName("lang")]
public string Lang { get; set; }
- [JsonProperty("pressureunit")]
+ [JsonPropertyName("pressureunit")]
public PressureUnitEnum PressureUnit { get; set; }
- [JsonProperty("reg_locale")]
+ [JsonPropertyName("reg_locale")]
public string RegLocale { get; set; }
- [JsonProperty("unit")]
+ [JsonPropertyName("unit")]
public UnitEnum Unit { get; set; }
- [JsonProperty("windunit")]
+ [JsonPropertyName("windunit")]
public WindUnitEnum WindUnit { get; set; }
}
\ No newline at end of file
diff --git a/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/BaseStationDashBoardData.cs b/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/BaseStationDashBoardData.cs
index 2bc4b56..f3d80b0 100644
--- a/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/BaseStationDashBoardData.cs
+++ b/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/BaseStationDashBoardData.cs
@@ -1,45 +1,45 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
using NodaTime;
namespace Netatmo.Models.Client.Weather.StationsData.DashboardData;
public class BaseStationDashBoardData : DashBoardData, ICO2DashBoardData, IHumidityDashBoardData, ITemperatureDashBoardData, INoiseDashBoardData, IPressureDashBoardData
{
- [JsonProperty("CO2")]
+ [JsonPropertyName("CO2")]
public int CO2 { get; set; }
- [JsonProperty("Humidity")]
+ [JsonPropertyName("Humidity")]
public int HumidityPercent { get; set; }
- [JsonProperty("Noise")]
+ [JsonPropertyName("Noise")]
public double Noise { get; set; }
- [JsonProperty("AbsolutePressure")]
+ [JsonPropertyName("AbsolutePressure")]
public double AbsolutePressure { get; set; }
- [JsonProperty("Pressure")]
+ [JsonPropertyName("Pressure")]
public double Pressure { get; set; }
// pressure_trend for last 12h (up, down, stable)
- [JsonProperty("pressure_trend")]
+ [JsonPropertyName("pressure_trend")]
public string PressureTrend { get; set; }
- [JsonProperty("Temperature")]
+ [JsonPropertyName("Temperature")]
public double Temperature { get; set; }
// temp_trend for last 12h (up, down, stable)
- [JsonProperty("temp_trend")]
+ [JsonPropertyName("temp_trend")]
public string TempTrend { get; set; }
- [JsonProperty("min_temp")]
+ [JsonPropertyName("min_temp")]
public double MinTemp { get; set; }
- [JsonProperty("max_temp")]
+ [JsonPropertyName("max_temp")]
public double MaxTemp { get; set; }
- [JsonProperty("date_min_temp")]
+ [JsonPropertyName("date_min_temp")]
public Instant MinTempAt { get; set; }
- [JsonProperty("date_max_temp")]
+ [JsonPropertyName("date_max_temp")]
public Instant MaxTempAt { get; set; }
}
\ No newline at end of file
diff --git a/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/DashBoardData.cs b/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/DashBoardData.cs
index 47385b0..4f1509d 100644
--- a/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/DashBoardData.cs
+++ b/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/DashBoardData.cs
@@ -1,10 +1,10 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
using NodaTime;
namespace Netatmo.Models.Client.Weather.StationsData.DashboardData;
public class DashBoardData : IDashBoardData
{
- [JsonProperty("time_utc")]
+ [JsonPropertyName("time_utc")]
public Instant TimeUtc { get; set; }
}
\ No newline at end of file
diff --git a/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/ICO2DashBoardData.cs b/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/ICO2DashBoardData.cs
index 4067d7d..c822e9a 100644
--- a/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/ICO2DashBoardData.cs
+++ b/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/ICO2DashBoardData.cs
@@ -1,9 +1,9 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
namespace Netatmo.Models.Client.Weather.StationsData.DashboardData;
public interface ICO2DashBoardData : IDashBoardData
{
- [JsonProperty("CO2")]
+ [JsonPropertyName("CO2")]
int CO2 { get; set; }
}
\ No newline at end of file
diff --git a/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/IDashBoardData.cs b/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/IDashBoardData.cs
index 664efa3..e95ccfb 100644
--- a/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/IDashBoardData.cs
+++ b/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/IDashBoardData.cs
@@ -1,10 +1,10 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
using NodaTime;
namespace Netatmo.Models.Client.Weather.StationsData.DashboardData;
public interface IDashBoardData
{
- [JsonProperty("time_utc")]
+ [JsonPropertyName("time_utc")]
Instant TimeUtc { get; set; }
}
\ No newline at end of file
diff --git a/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/IGustDashBoardData.cs b/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/IGustDashBoardData.cs
index 4f6b02b..2b12099 100644
--- a/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/IGustDashBoardData.cs
+++ b/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/IGustDashBoardData.cs
@@ -1,12 +1,12 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
namespace Netatmo.Models.Client.Weather.StationsData.DashboardData;
public interface IGustDashBoardData : IDashBoardData
{
- [JsonProperty("GustStrength")]
+ [JsonPropertyName("GustStrength")]
int GustStrength { get; set; }
- [JsonProperty("GustAngle")]
+ [JsonPropertyName("GustAngle")]
int GustAngle { get; set; }
}
\ No newline at end of file
diff --git a/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/IHumidityDashBoardData.cs b/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/IHumidityDashBoardData.cs
index c144c54..35ec10d 100644
--- a/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/IHumidityDashBoardData.cs
+++ b/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/IHumidityDashBoardData.cs
@@ -1,9 +1,9 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
namespace Netatmo.Models.Client.Weather.StationsData.DashboardData;
public interface IHumidityDashBoardData : IDashBoardData
{
- [JsonProperty("Humidity")]
+ [JsonPropertyName("Humidity")]
int HumidityPercent { get; set; }
}
\ No newline at end of file
diff --git a/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/INoiseDashBoardData.cs b/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/INoiseDashBoardData.cs
index 69a5aa3..e8ed94b 100644
--- a/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/INoiseDashBoardData.cs
+++ b/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/INoiseDashBoardData.cs
@@ -1,9 +1,9 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
namespace Netatmo.Models.Client.Weather.StationsData.DashboardData;
public interface INoiseDashBoardData : IDashBoardData
{
- [JsonProperty("Noise")]
+ [JsonPropertyName("Noise")]
double Noise { get; set; }
}
\ No newline at end of file
diff --git a/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/IPressureDashBoardData.cs b/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/IPressureDashBoardData.cs
index 708d9f9..a97104c 100644
--- a/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/IPressureDashBoardData.cs
+++ b/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/IPressureDashBoardData.cs
@@ -1,16 +1,16 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
namespace Netatmo.Models.Client.Weather.StationsData.DashboardData;
public interface IPressureDashBoardData : IDashBoardData
{
- [JsonProperty("AbsolutePressure")]
+ [JsonPropertyName("AbsolutePressure")]
double AbsolutePressure { get; set; }
- [JsonProperty("Pressure")]
+ [JsonPropertyName("Pressure")]
double Pressure { get; set; }
// pressure_trend for last 12h (up, down, stable)
- [JsonProperty("pressure_trend")]
+ [JsonPropertyName("pressure_trend")]
string PressureTrend { get; set; }
}
\ No newline at end of file
diff --git a/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/IRainDashBoardData.cs b/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/IRainDashBoardData.cs
index f8433b1..b852ea0 100644
--- a/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/IRainDashBoardData.cs
+++ b/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/IRainDashBoardData.cs
@@ -1,15 +1,15 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
namespace Netatmo.Models.Client.Weather.StationsData.DashboardData;
public interface IRainDashBoardData : IDashBoardData
{
- [JsonProperty("Rain")]
+ [JsonPropertyName("Rain")]
double Rain { get; set; }
- [JsonProperty("sum_rain_1")]
+ [JsonPropertyName("sum_rain_1")]
double RainLastHour { get; set; }
- [JsonProperty("sum_rain_24")]
+ [JsonPropertyName("sum_rain_24")]
double RainLastDay { get; set; }
}
\ No newline at end of file
diff --git a/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/ITemperatureDashBoardData.cs b/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/ITemperatureDashBoardData.cs
index 96db992..33581f3 100644
--- a/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/ITemperatureDashBoardData.cs
+++ b/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/ITemperatureDashBoardData.cs
@@ -1,26 +1,26 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
using NodaTime;
namespace Netatmo.Models.Client.Weather.StationsData.DashboardData;
public interface ITemperatureDashBoardData : IDashBoardData
{
- [JsonProperty("Temperature")]
+ [JsonPropertyName("Temperature")]
double Temperature { get; set; }
// temp_trend for last 12h (up, down, stable)
- [JsonProperty("temp_trend")]
+ [JsonPropertyName("temp_trend")]
string TempTrend { get; set; }
- [JsonProperty("min_temp")]
+ [JsonPropertyName("min_temp")]
double MinTemp { get; set; }
- [JsonProperty("max_temp")]
+ [JsonPropertyName("max_temp")]
double MaxTemp { get; set; }
- [JsonProperty("date_min_temp")]
+ [JsonPropertyName("date_min_temp")]
Instant MinTempAt { get; set; }
- [JsonProperty("date_max_temp")]
+ [JsonPropertyName("date_max_temp")]
Instant MaxTempAt { get; set; }
}
\ No newline at end of file
diff --git a/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/IWindDashBoardData.cs b/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/IWindDashBoardData.cs
index 5eb942c..c85a68f 100644
--- a/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/IWindDashBoardData.cs
+++ b/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/IWindDashBoardData.cs
@@ -1,13 +1,13 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
namespace Netatmo.Models.Client.Weather.StationsData.DashboardData;
public interface IWindHistory : IDashBoardData
{
- [JsonProperty("WindStrength")]
+ [JsonPropertyName("WindStrength")]
int WindStrength { get; set; }
- [JsonProperty("WindAngle")]
+ [JsonPropertyName("WindAngle")]
int WindAngle { get; set; }
}
diff --git a/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/IndoorDashBoardData.cs b/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/IndoorDashBoardData.cs
index 8d7cc40..a107f93 100644
--- a/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/IndoorDashBoardData.cs
+++ b/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/IndoorDashBoardData.cs
@@ -1,32 +1,32 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
using NodaTime;
namespace Netatmo.Models.Client.Weather.StationsData.DashboardData;
public class IndoorDashBoardData : DashBoardData, ITemperatureDashBoardData, ICO2DashBoardData, IHumidityDashBoardData
{
- [JsonProperty("CO2")]
+ [JsonPropertyName("CO2")]
public int CO2 { get; set; }
- [JsonProperty("Humidity")]
+ [JsonPropertyName("Humidity")]
public int HumidityPercent { get; set; }
- [JsonProperty("Temperature")]
+ [JsonPropertyName("Temperature")]
public double Temperature { get; set; }
// temp_trend for last 12h (up, down, stable)
- [JsonProperty("temp_trend")]
+ [JsonPropertyName("temp_trend")]
public string TempTrend { get; set; }
- [JsonProperty("min_temp")]
+ [JsonPropertyName("min_temp")]
public double MinTemp { get; set; }
- [JsonProperty("max_temp")]
+ [JsonPropertyName("max_temp")]
public double MaxTemp { get; set; }
- [JsonProperty("date_min_temp")]
+ [JsonPropertyName("date_min_temp")]
public Instant MinTempAt { get; set; }
- [JsonProperty("date_max_temp")]
+ [JsonPropertyName("date_max_temp")]
public Instant MaxTempAt { get; set; }
}
\ No newline at end of file
diff --git a/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/OutdoorDashBoardData.cs b/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/OutdoorDashBoardData.cs
index 9fc6cea..7d14478 100644
--- a/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/OutdoorDashBoardData.cs
+++ b/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/OutdoorDashBoardData.cs
@@ -1,29 +1,29 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
using NodaTime;
namespace Netatmo.Models.Client.Weather.StationsData.DashboardData;
public class OutdoorDashBoardData : DashBoardData, ITemperatureDashBoardData, IHumidityDashBoardData
{
- [JsonProperty("Humidity")]
+ [JsonPropertyName("Humidity")]
public int HumidityPercent { get; set; }
- [JsonProperty("Temperature")]
+ [JsonPropertyName("Temperature")]
public double Temperature { get; set; }
// temp_trend for last 12h (up, down, stable)
- [JsonProperty("temp_trend")]
+ [JsonPropertyName("temp_trend")]
public string TempTrend { get; set; }
- [JsonProperty("min_temp")]
+ [JsonPropertyName("min_temp")]
public double MinTemp { get; set; }
- [JsonProperty("max_temp")]
+ [JsonPropertyName("max_temp")]
public double MaxTemp { get; set; }
- [JsonProperty("date_min_temp")]
+ [JsonPropertyName("date_min_temp")]
public Instant MinTempAt { get; set; }
- [JsonProperty("date_max_temp")]
+ [JsonPropertyName("date_max_temp")]
public Instant MaxTempAt { get; set; }
}
\ No newline at end of file
diff --git a/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/RainGaugeDashBoardData.cs b/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/RainGaugeDashBoardData.cs
index 6d3747a..10782b7 100644
--- a/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/RainGaugeDashBoardData.cs
+++ b/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/RainGaugeDashBoardData.cs
@@ -1,15 +1,15 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
namespace Netatmo.Models.Client.Weather.StationsData.DashboardData;
public class RainGaugeDashBoardData : DashBoardData, IRainDashBoardData
{
- [JsonProperty("Rain")]
+ [JsonPropertyName("Rain")]
public double Rain { get; set; }
- [JsonProperty("sum_rain_1")]
+ [JsonPropertyName("sum_rain_1")]
public double RainLastHour { get; set; }
- [JsonProperty("sum_rain_24")]
+ [JsonPropertyName("sum_rain_24")]
public double RainLastDay { get; set; }
}
\ No newline at end of file
diff --git a/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/WindGaugeDashBoardData.cs b/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/WindGaugeDashBoardData.cs
index f405211..159f715 100644
--- a/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/WindGaugeDashBoardData.cs
+++ b/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/WindGaugeDashBoardData.cs
@@ -1,21 +1,21 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
namespace Netatmo.Models.Client.Weather.StationsData.DashboardData;
public class WindGaugeDashBoardData : DashBoardData, IWindDashBoardData, IGustDashBoardData
{
- [JsonProperty("GustStrength")]
+ [JsonPropertyName("GustStrength")]
public int GustStrength { get; set; }
- [JsonProperty("GustAngle")]
+ [JsonPropertyName("GustAngle")]
public int GustAngle { get; set; }
- [JsonProperty("WindHistoric")]
+ [JsonPropertyName("WindHistoric")]
public WindHistoric[] WindHistoric { get; set; }
- [JsonProperty("WindStrength")]
+ [JsonPropertyName("WindStrength")]
public int WindStrength { get; set; }
- [JsonProperty("WindAngle")]
+ [JsonPropertyName("WindAngle")]
public int WindAngle { get; set; }
}
\ No newline at end of file
diff --git a/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/WindHistoric.cs b/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/WindHistoric.cs
index d11d4c3..9017a97 100644
--- a/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/WindHistoric.cs
+++ b/src/Netatmo/Models/Client/Weather/StationsData/DashboardData/WindHistoric.cs
@@ -1,16 +1,16 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
using NodaTime;
namespace Netatmo.Models.Client.Weather.StationsData.DashboardData;
public class WindHistoric : IWindHistory
{
- [JsonProperty("WindStrength")]
+ [JsonPropertyName("WindStrength")]
public int WindStrength { get; set; }
- [JsonProperty("WindAngle")]
+ [JsonPropertyName("WindAngle")]
public int WindAngle { get; set; }
- [JsonProperty("time_utc")]
+ [JsonPropertyName("time_utc")]
public Instant TimeUtc { get; set; }
}
\ No newline at end of file
diff --git a/src/Netatmo/Models/Client/Weather/StationsData/Device.cs b/src/Netatmo/Models/Client/Weather/StationsData/Device.cs
index cd7325c..fbf5629 100644
--- a/src/Netatmo/Models/Client/Weather/StationsData/Device.cs
+++ b/src/Netatmo/Models/Client/Weather/StationsData/Device.cs
@@ -1,27 +1,27 @@
+using System.Text.Json.Serialization;
using Netatmo.Enums;
using Netatmo.Models.Client.Weather.StationsData.DashboardData;
-using Newtonsoft.Json;
using NodaTime;
namespace Netatmo.Models.Client.Weather.StationsData;
public class Device
{
- [JsonProperty("_id")]
+ [JsonPropertyName("_id")]
public string Id { get; set; }
- [JsonProperty("cipher_id")]
+ [JsonPropertyName("cipher_id")]
public string CipherId { get; set; }
- [JsonProperty("station_name")]
+ [JsonPropertyName("station_name")]
public string StationName { get; set; }
// NAMain: Base station, NAModule1: Outdoor Module, NAModule2: Wind Gauge, NAModule3: Rain Gauge, NAModule4: Optional indoor module
- [JsonProperty("type")]
+ [JsonPropertyName("type")]
public string Type { get; set; }
// Wifi signal quality : 56 Good, 71 Average, 86 Bad
- [JsonProperty("wifi_status")]
+ [JsonPropertyName("wifi_status")]
public int WifiStatus { get; set; }
public WifiStrengthEnum WifiStrength
@@ -42,33 +42,33 @@ public WifiStrengthEnum WifiStrength
}
}
- [JsonProperty("module_name")]
+ [JsonPropertyName("module_name")]
public string ModuleName { get; set; }
- [JsonProperty("co2_calibrating")]
+ [JsonPropertyName("co2_calibrating")]
public bool Co2Calibrating { get; set; }
- [JsonProperty("firmware")]
+ [JsonPropertyName("firmware")]
public int Firmware { get; set; }
- [JsonProperty("date_setup")]
+ [JsonPropertyName("date_setup")]
public Instant SetupAt { get; set; }
- [JsonProperty("last_setup")]
+ [JsonPropertyName("last_setup")]
public Instant LastSetupAt { get; set; }
- [JsonProperty("last_status_store")]
+ [JsonPropertyName("last_status_store")]
public Instant LastStatusStoreAt { get; set; }
- [JsonProperty("dashboard_data")]
+ [JsonPropertyName("dashboard_data")]
public BaseStationDashBoardData DashboardData { get; set; }
- [JsonProperty("data_type")]
+ [JsonPropertyName("data_type")]
public string[] DataType { get; set; }
- [JsonProperty("place")]
+ [JsonPropertyName("place")]
public Place Place { get; set; }
- [JsonProperty("modules")]
+ [JsonPropertyName("modules")]
public Module[] Modules { get; set; }
}
\ No newline at end of file
diff --git a/src/Netatmo/Models/Client/Weather/StationsData/Module.cs b/src/Netatmo/Models/Client/Weather/StationsData/Module.cs
index e4a011a..18b2c7d 100644
--- a/src/Netatmo/Models/Client/Weather/StationsData/Module.cs
+++ b/src/Netatmo/Models/Client/Weather/StationsData/Module.cs
@@ -1,25 +1,26 @@
+using System.Text.Json;
+using System.Text.Json.Serialization;
using Netatmo.Enums;
using Netatmo.Models.Client.Weather.StationsData.DashboardData;
-using Newtonsoft.Json;
-using Newtonsoft.Json.Linq;
using NodaTime;
+using JsonSerializer = System.Text.Json.JsonSerializer;
namespace Netatmo.Models.Client.Weather.StationsData;
public class Module
{
- [JsonProperty("_id")]
+ [JsonPropertyName("_id")]
public string Id { get; set; }
// NAMain: Base station, NAModule1: Outdoor Module, NAModule2: Wind Gauge, NAModule3: Rain Gauge, NAModule4: Optional indoor module
- [JsonProperty("type")]
+ [JsonPropertyName("type")]
public string Type { get; set; }
- [JsonProperty("module_name")]
+ [JsonPropertyName("module_name")]
public string ModuleName { get; set; }
// Current radio status per module. (90=low, 60=highest)
- [JsonProperty("rf_status")]
+ [JsonPropertyName("rf_status")]
public int RfStatus { get; set; }
public RfStrengthEnum RfStrength
@@ -46,10 +47,10 @@ public RfStrengthEnum RfStrength
}
// Percentage of battery remaining (10=low)
- [JsonProperty("battery_percent")]
+ [JsonPropertyName("battery_percent")]
public int BatteryPercent { get; set; }
- [JsonProperty("battery_vp")]
+ [JsonPropertyName("battery_vp")]
public int BatteryVp { get; set; }
public BatteryLevelEnum BatteryStatus
@@ -106,55 +107,43 @@ public BatteryLevelEnum BatteryStatus
}
}
- [JsonProperty("firmware")]
+ [JsonPropertyName("firmware")]
public int Firmware { get; set; }
- [JsonProperty("last_message")]
+ [JsonPropertyName("last_message")]
public Instant LastMessageAt { get; set; }
- [JsonProperty("last_seen")]
+ [JsonPropertyName("last_seen")]
public Instant LastSeenAt { get; set; }
- [JsonProperty("last_setup")]
+ [JsonPropertyName("last_setup")]
public Instant LastSetupAt { get; set; }
- [JsonProperty("data_type")]
+ [JsonPropertyName("data_type")]
public string[] DataType { get; set; }
- [JsonProperty("dashboard_data")]
- public JObject DashboardData { get; set; }
+ [JsonPropertyName("dashboard_data")]
+ [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
+ public JsonElement DashboardData { get; set; }
public T GetDashboardData()
where T : IDashBoardData
{
- Type expectedType;
- switch (Type)
+ var expectedType = Type switch
{
- case "NAMain":
- expectedType = typeof(BaseStationDashBoardData);
- break;
- case "NAModule1":
- expectedType = typeof(OutdoorDashBoardData);
- break;
- case "NAModule2":
- expectedType = typeof(WindGaugeDashBoardData);
- break;
- case "NAModule3":
- expectedType = typeof(RainGaugeDashBoardData);
- break;
- case "NAModule4":
- expectedType = typeof(IndoorDashBoardData);
- break;
- default:
- expectedType = typeof(DashBoardData);
- break;
- }
+ "NAMain" => typeof(BaseStationDashBoardData),
+ "NAModule1" => typeof(OutdoorDashBoardData),
+ "NAModule2" => typeof(WindGaugeDashBoardData),
+ "NAModule3" => typeof(RainGaugeDashBoardData),
+ "NAModule4" => typeof(IndoorDashBoardData),
+ _ => typeof(DashBoardData)
+ };
if (expectedType != typeof(T))
{
throw new ArgumentException($"{expectedType.Name} should be expected");
}
- return JsonConvert.DeserializeObject(DashboardData.ToString(), Configuration.JsonSerializer());
+ return JsonSerializer.Deserialize(DashboardData.ToString(), Configuration.JsonSerializerOptions);
}
}
\ No newline at end of file
diff --git a/src/Netatmo/Netatmo.csproj b/src/Netatmo/Netatmo.csproj
index fdb8e49..2158827 100644
--- a/src/Netatmo/Netatmo.csproj
+++ b/src/Netatmo/Netatmo.csproj
@@ -26,7 +26,7 @@
-
+
diff --git a/src/Netatmo/WeatherClient.cs b/src/Netatmo/WeatherClient.cs
index c3d6af4..fb44420 100644
--- a/src/Netatmo/WeatherClient.cs
+++ b/src/Netatmo/WeatherClient.cs
@@ -7,7 +7,7 @@ namespace Netatmo;
public class WeatherClient(string baseUrl, ICredentialManager credentialManager) : IWeatherClient
{
public Task> GetStationsData(string deviceId = null, bool? onlyFavorites = null) =>
- baseUrl.ConfigureRequest(Configuration.ConfigureRequest)
+ baseUrl.WithSettings(Configuration.ConfigureRequest)
.AppendPathSegment("/api/getstationsdata")
.WithOAuthBearerToken(credentialManager.AccessToken)
.PostJsonAsync(new GetStationsDataRequest { DeviceId = deviceId, GetFavorites = onlyFavorites })
diff --git a/tests/Netatmo.Tests/AirClientTest.cs b/tests/Netatmo.Tests/AirClientTest.cs
index 150d85d..61874cb 100644
--- a/tests/Netatmo.Tests/AirClientTest.cs
+++ b/tests/Netatmo.Tests/AirClientTest.cs
@@ -1,4 +1,5 @@
using AutoFixture.Xunit2;
+using Flurl.Http;
using Flurl.Http.Testing;
using Netatmo.Enums;
using Netatmo.Models.Client.Air;
@@ -14,7 +15,7 @@ public class AirClientTest : IDisposable
public AirClientTest()
{
httpTest = new HttpTest();
- httpTest.Configure(Configuration.ConfigureRequest);
+ httpTest.WithSettings(Configuration.ConfigureRequest);
}
public void Dispose()
diff --git a/tests/Netatmo.Tests/CredentialManagerTest.cs b/tests/Netatmo.Tests/CredentialManagerTest.cs
index c7b9043..bca6c19 100644
--- a/tests/Netatmo.Tests/CredentialManagerTest.cs
+++ b/tests/Netatmo.Tests/CredentialManagerTest.cs
@@ -1,4 +1,5 @@
using System.Net.Mail;
+using System.Text.Json.Serialization;
using AutoFixture.Xunit2;
using Flurl.Http.Testing;
using Netatmo.Models;
@@ -118,8 +119,8 @@ public async Task RefreshToken_Should_Refresh_Token(
refreshedToken.Should().NotBe(oldToken);
}
- public record TokenResponse(string AccessToken, uint ExpiresIn, string RefreshToken)
- {
- public override string ToString() => $"{{ access_token = {AccessToken}, expires_in = {ExpiresIn}, refresh_token = {RefreshToken} }}";
- }
+ public record TokenResponse(
+ [property: JsonPropertyName("access_token")] string AccessToken,
+ [property: JsonPropertyName("expires_in")] uint ExpiresIn,
+ [property: JsonPropertyName("refresh_token")] string RefreshToken);
}
\ No newline at end of file
diff --git a/tests/Netatmo.Tests/EnergyClientTest.cs b/tests/Netatmo.Tests/EnergyClientTest.cs
index 73e42c9..eec1122 100644
--- a/tests/Netatmo.Tests/EnergyClientTest.cs
+++ b/tests/Netatmo.Tests/EnergyClientTest.cs
@@ -1,4 +1,5 @@
using AutoFixture.Xunit2;
+using Flurl.Http;
using Flurl.Http.Testing;
using Netatmo.Enums;
using Netatmo.Models.Client;
@@ -17,7 +18,7 @@ public class EnergyClientTest : IDisposable
public EnergyClientTest()
{
httpTest = new HttpTest();
- httpTest.Configure(Configuration.ConfigureRequest);
+ httpTest.WithSettings(Configuration.ConfigureRequest);
}
public void Dispose()
@@ -133,10 +134,9 @@ public async Task GetRoomMeasure_Should_Return_TemperatureSteps([Frozen] ICreden
var result = await sut.GetRoomMeasure(parameters);
httpTest.ShouldHaveCalled("https://api.netatmo.local/api/getroommeasure")
- .WithVerb(HttpMethod.Post)
+ .WithVerb(HttpMethod.Get)
.WithOAuthBearerToken(credentialManager.AccessToken)
- .WithContentType("application/json")
- .WithRequestJson(new GetRoomMeasureRequest { HomeId = parameters.HomeId, RoomId = parameters.RoomId, Scale = parameters.Scale.Value, Type = parameters.Type.Value })
+ .WithQueryParams(new { home_id = parameters.HomeId, room_id = parameters.RoomId, scale = parameters.Scale.Value, type = parameters.Type.Value })
.Times(1);
result.Body[0].BeginAt.Should().Be(Instant.FromDateTimeUtc(DateTime.SpecifyKind(new DateTime(2017, 12, 14, 13, 45, 0), DateTimeKind.Utc)));
diff --git a/tests/Netatmo.Tests/WeatherClientTest.cs b/tests/Netatmo.Tests/WeatherClientTest.cs
index 64d8ea8..3df4b2e 100644
--- a/tests/Netatmo.Tests/WeatherClientTest.cs
+++ b/tests/Netatmo.Tests/WeatherClientTest.cs
@@ -1,4 +1,5 @@
using AutoFixture.Xunit2;
+using Flurl.Http;
using Flurl.Http.Testing;
using Netatmo.Enums;
using Netatmo.Models.Client.Weather;
@@ -15,7 +16,7 @@ public class WeatherClientTest : IDisposable
public WeatherClientTest()
{
httpTest = new HttpTest();
- httpTest.Configure(Configuration.ConfigureRequest);
+ httpTest.WithSettings(Configuration.ConfigureRequest);
}
public void Dispose()
diff --git a/tests/TestApp/Program.cs b/tests/TestApp/Program.cs
index 52797ae..d7f5cdc 100644
--- a/tests/TestApp/Program.cs
+++ b/tests/TestApp/Program.cs
@@ -1,11 +1,13 @@
-using Flurl.Http;
+using System.Text.Json;
+using Flurl.Http;
using Netatmo;
using Netatmo.Models.Client.Energy;
using Netatmo.Models.Client.Energy.RoomMeasure;
-using Newtonsoft.Json;
using NodaTime;
-JsonConvert.DefaultSettings = Configuration.JsonSerializer;
+var jsonSerializerOptions = Configuration.JsonSerializerOptions;
+jsonSerializerOptions.WriteIndented = true;
+
var client = new Client(
SystemClock.Instance,
@@ -36,18 +38,18 @@
Console.WriteLine("Stations data :");
var stationsData = await client.Weather.GetStationsData();
-Console.WriteLine(JsonConvert.SerializeObject(stationsData, Formatting.Indented));
+Console.WriteLine(JsonSerializer.Serialize(stationsData, jsonSerializerOptions));
Console.WriteLine("Energy Homes data :");
var homesData = await client.Energy.GetHomesData();
-Console.WriteLine(JsonConvert.SerializeObject(homesData, Formatting.Indented));
+Console.WriteLine(JsonSerializer.Serialize(homesData, jsonSerializerOptions));
Console.WriteLine("Energy Homes data :");
foreach (var home in homesData.Body.Homes)
{
Console.WriteLine(home.Name);
var homeStatus = await client.Energy.GetHomeStatus(home.Id);
- Console.WriteLine(JsonConvert.SerializeObject(homeStatus, Formatting.Indented));
+ Console.WriteLine(JsonSerializer.Serialize(homeStatus, jsonSerializerOptions));
Console.WriteLine("Energy room measure :");
foreach (var room in home.Rooms)
@@ -71,7 +73,7 @@
try
{
var roomMeasure = await client.Energy.GetRoomMeasure(parameters);
- Console.WriteLine(JsonConvert.SerializeObject(roomMeasure, Formatting.Indented));
+ Console.WriteLine(JsonSerializer.Serialize(roomMeasure, jsonSerializerOptions));
}
catch (FlurlHttpException exception)
{