Apply code formatting cleanup across monitor projects

- Reindent appsettings.json and the MSBuild project files
- Collapse single-statement guard blocks and tidy using and member order
- Normalize XML doc indentation and file endings
- Reorder BatteryMonitor test-data helpers and move the exclusion tests into
  their own region
- Carry the same formatting through the boiler config, control, entity and
  test files
This commit is contained in:
2026-11-30 11:52:06 +02:00
parent cf8c9434c8
commit 24729ee267
165 changed files with 2513 additions and 2470 deletions
+5 -9
View File
@@ -4,15 +4,11 @@ namespace NordPool.Models;
public class CheapestIntervalResult
{
[JsonPropertyName("start")]
public DateTime Start { get; init; }
[JsonPropertyName("start")] public DateTime Start { get; init; }
[JsonPropertyName("end")]
public DateTime End { get; init; }
[JsonPropertyName("end")] public DateTime End { get; init; }
[JsonPropertyName("price")]
public double Price { get; init; }
[JsonPropertyName("price")] public double Price { get; init; }
[JsonPropertyName("rank")]
public int Rank { get; init; }
}
[JsonPropertyName("rank")] public int Rank { get; init; }
}
+4 -16
View File
@@ -40,31 +40,23 @@ public readonly struct CompactNordPoolDayPrice
internal sealed class CompactNordPoolDayPriceConverter : JsonConverter<CompactNordPoolDayPrice>
{
public override CompactNordPoolDayPrice Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
public override CompactNordPoolDayPrice Read(ref Utf8JsonReader reader, Type typeToConvert,
JsonSerializerOptions options)
{
if (reader.TokenType != JsonTokenType.StartArray)
{
throw new JsonException("Expected start of array.");
}
if (reader.TokenType != JsonTokenType.StartArray) throw new JsonException("Expected start of array.");
if (!reader.Read() || reader.TokenType != JsonTokenType.Number)
{
throw new JsonException("Expected number for Start at position 0.");
}
var start = reader.GetInt64();
if (!reader.Read() || reader.TokenType != JsonTokenType.Number)
{
throw new JsonException("Expected number for End at position 1.");
}
var end = reader.GetInt64();
if (!reader.Read() || (reader.TokenType != JsonTokenType.Number && reader.TokenType != JsonTokenType.Null))
{
throw new JsonException("Expected number or null for Price at position 2.");
}
double? price = reader.TokenType == JsonTokenType.Null ? null : reader.GetDouble();
@@ -82,14 +74,10 @@ internal sealed class CompactNordPoolDayPriceConverter : JsonConverter<CompactNo
writer.WriteNumberValue(value.End);
if (value.Price.HasValue)
{
writer.WriteNumberValue(value.Price.Value);
}
else
{
writer.WriteNullValue();
}
writer.WriteEndArray();
}
}
}
+5 -6
View File
@@ -4,10 +4,9 @@ namespace NordPool.Models.Dtos;
public class NordPoolDayPriceDto
{
[JsonPropertyName("start")]
public string? Start { get; init; }
[JsonPropertyName("end")]
public string? End { get; init; }
[JsonPropertyName("price")]
public double? Price { get; init; }
[JsonPropertyName("start")] public string? Start { get; init; }
[JsonPropertyName("end")] public string? End { get; init; }
[JsonPropertyName("price")] public double? Price { get; init; }
}
@@ -4,6 +4,5 @@ namespace NordPool.Models.Dtos;
public class NordPoolPriceResultDto
{
[JsonPropertyName("LT")]
public List<NordPoolDayPriceDto>? Prices { get; init; }
[JsonPropertyName("LT")] public List<NordPoolDayPriceDto>? Prices { get; init; }
}
+2 -2
View File
@@ -7,11 +7,11 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NetDaemon.Extensions.Mqtt" Version="26.43.1" />
<PackageReference Include="NetDaemon.Extensions.Mqtt" Version="26.43.1"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\HomeAssistant.Models\HomeAssistant.Models.csproj" />
<ProjectReference Include="..\HomeAssistant.Models\HomeAssistant.Models.csproj"/>
</ItemGroup>
</Project>
+9 -9
View File
@@ -5,23 +5,23 @@ public static class NordPoolConsts
public const string ConfigEntry = "01K9HYQE4Y0E7KC36JZV11MEXH";
/// <summary>
/// NordPool electricity market uses 15-minute trading intervals.
/// NordPool electricity market uses 15-minute trading intervals.
/// </summary>
public const int MinutesPerInterval = 15;
/// <summary>
/// Number of 15-minute intervals in one hour.
/// Number of 15-minute intervals in one hour.
/// </summary>
public const int IntervalsPerHour = 4;
/// <summary>
/// Maximum number of 15-minute intervals in a single day (96 = 24h * 4).
/// Maximum number of 15-minute intervals in a single day (96 = 24h * 4).
/// </summary>
public const int MaxDailyIntervals = 96;
/// <summary>
/// Maximum expected price entries when today and tomorrow are both available
/// (96 intervals per day x 2 days). Used for logging a warning if exceeded.
/// Maximum expected price entries when today and tomorrow are both available
/// (96 intervals per day x 2 days). Used for logging a warning if exceeded.
/// </summary>
public const int MaxExpectedPriceEntries = 192;
@@ -30,22 +30,22 @@ public static class NordPoolConsts
public const string DeviceManufacturer = "HomeAssistant App Daemon";
/// <summary>
/// Home Assistant entity id for the Nord Pool current price sensor published by this integration.
/// Home Assistant entity id for the Nord Pool current price sensor published by this integration.
/// </summary>
public const string CurrentPriceEntityId = "sensor.nordpool_current_price";
/// <summary>
/// Home Assistant entity id for the button that triggers a manual NordPool price fetch + entity update.
/// Home Assistant entity id for the button that triggers a manual NordPool price fetch + entity update.
/// </summary>
public const string FetchPricesButtonEntityId = "button.nordpool_fetch_prices";
/// <summary>
/// Maximum number of retry attempts when fetching prices from the NordPool API.
/// Maximum number of retry attempts when fetching prices from the NordPool API.
/// </summary>
public const int MaxFetchRetryAttempts = 3;
/// <summary>
/// Base delay in seconds between retry attempts (used with exponential backoff).
/// Base delay in seconds between retry attempts (used with exponential backoff).
/// </summary>
public const int RetryBaseDelaySeconds = 5;
}
@@ -8,4 +8,4 @@ public static class NordPoolDayPriceExtensions
? []
: [.. prices.Select(CompactNordPoolDayPrice.FromDayPrice)];
}
}
}
+6 -6
View File
@@ -13,10 +13,6 @@ public class NordPoolEntity : EntityCreateModel
manufacturer = NordPoolConsts.DeviceManufacturer
};
public string Domain { get; }
public string Identifier { get; }
public string Name { get; }
public NordPoolEntity(string domain, string identifier, string name)
{
Domain = domain;
@@ -33,9 +29,13 @@ public class NordPoolEntity : EntityCreateModel
AdditionalConfig = new { device = DeviceBlock };
}
public string Domain { get; }
public string Identifier { get; }
public string Name { get; }
/// <summary>
/// Creates an AdditionalConfig that merges custom properties with the NordPool device block.
/// Use this when an entity needs extra config beyond the default device assignment.
/// Creates an AdditionalConfig that merges custom properties with the NordPool device block.
/// Use this when an entity needs extra config beyond the default device assignment.
/// </summary>
public static object CreateAdditionalConfig(object extraProperties)
{