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:
@@ -25,14 +25,6 @@ public sealed class ShowerMonitorEntityService(
|
||||
CleanupButtonEntityId
|
||||
];
|
||||
|
||||
private static object CreateDeviceBlock() => new
|
||||
{
|
||||
identifiers = new[] { DeviceIdentifier },
|
||||
name = DeviceName,
|
||||
model = DeviceName,
|
||||
manufacturer = DeviceManufacturer
|
||||
};
|
||||
|
||||
public async Task CreateEntitiesAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
@@ -91,6 +83,17 @@ public sealed class ShowerMonitorEntityService(
|
||||
}
|
||||
}
|
||||
|
||||
private static object CreateDeviceBlock()
|
||||
{
|
||||
return new
|
||||
{
|
||||
identifiers = new[] { DeviceIdentifier },
|
||||
name = DeviceName,
|
||||
model = DeviceName,
|
||||
manufacturer = DeviceManufacturer
|
||||
};
|
||||
}
|
||||
|
||||
private static ICollection<ShowerMonitorEntity> GetAllEntities()
|
||||
{
|
||||
var device = CreateDeviceBlock();
|
||||
@@ -107,7 +110,8 @@ public sealed class ShowerMonitorEntityService(
|
||||
},
|
||||
new ShowerMonitorEntity("sensor", "showermonitor_differential_humidity", "Bathroom differential humidity")
|
||||
{
|
||||
AdditionalConfig = new { unit_of_measurement = "%", icon = "mdi:water-percent", device_class = "humidity", device }
|
||||
AdditionalConfig = new
|
||||
{ unit_of_measurement = "%", icon = "mdi:water-percent", device_class = "humidity", device }
|
||||
},
|
||||
new ShowerMonitorEntity("sensor", "showermonitor_humidity_rate", "Humidity rate of change")
|
||||
{
|
||||
@@ -119,7 +123,8 @@ public sealed class ShowerMonitorEntityService(
|
||||
},
|
||||
new ShowerMonitorEntity("sensor", "showermonitor_last_shower_duration", "Last shower duration")
|
||||
{
|
||||
AdditionalConfig = new { unit_of_measurement = "s", icon = "mdi:timer", device_class = "duration", device }
|
||||
AdditionalConfig = new
|
||||
{ unit_of_measurement = "s", icon = "mdi:timer", device_class = "duration", device }
|
||||
},
|
||||
new ShowerMonitorEntity("sensor", "showermonitor_last_shower_time", "Last shower time")
|
||||
{
|
||||
@@ -134,7 +139,8 @@ public sealed class ShowerMonitorEntityService(
|
||||
|
||||
private async Task UpdateDifferentialAsync(double differential, string timestamp)
|
||||
{
|
||||
await SetEntityStateSafe(DifferentialEntityId, Math.Round(differential, 1).ToString(CultureInfo.InvariantCulture)).ConfigureAwait(false);
|
||||
await SetEntityStateSafe(DifferentialEntityId,
|
||||
Math.Round(differential, 1).ToString(CultureInfo.InvariantCulture)).ConfigureAwait(false);
|
||||
await SetEntityAttributesSafe(DifferentialEntityId, new
|
||||
{
|
||||
unit_of_measurement = "%",
|
||||
@@ -145,7 +151,8 @@ public sealed class ShowerMonitorEntityService(
|
||||
|
||||
private async Task UpdateHumidityRateAsync(double rate, string timestamp)
|
||||
{
|
||||
await SetEntityStateSafe(HumidityRateEntityId, Math.Round(rate, 2).ToString(CultureInfo.InvariantCulture)).ConfigureAwait(false);
|
||||
await SetEntityStateSafe(HumidityRateEntityId, Math.Round(rate, 2).ToString(CultureInfo.InvariantCulture))
|
||||
.ConfigureAwait(false);
|
||||
await SetEntityAttributesSafe(HumidityRateEntityId, new
|
||||
{
|
||||
unit_of_measurement = "%/min",
|
||||
@@ -156,7 +163,8 @@ public sealed class ShowerMonitorEntityService(
|
||||
|
||||
private async Task UpdateTodaySessionCountAsync(int count, string timestamp)
|
||||
{
|
||||
await SetEntityStateSafe(TodaySessionCountEntityId, count.ToString(CultureInfo.InvariantCulture)).ConfigureAwait(false);
|
||||
await SetEntityStateSafe(TodaySessionCountEntityId, count.ToString(CultureInfo.InvariantCulture))
|
||||
.ConfigureAwait(false);
|
||||
await SetEntityAttributesSafe(TodaySessionCountEntityId, new
|
||||
{
|
||||
friendly_name = "Showers today",
|
||||
@@ -166,13 +174,11 @@ public sealed class ShowerMonitorEntityService(
|
||||
|
||||
private async Task UpdateLastShowerAsync(ShowerSession? session, string timestamp)
|
||||
{
|
||||
if (session is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (session is null) return;
|
||||
|
||||
var durationSeconds = (int)session.Duration.TotalSeconds;
|
||||
await SetEntityStateSafe(LastShowerDurationEntityId, durationSeconds.ToString(CultureInfo.InvariantCulture)).ConfigureAwait(false);
|
||||
await SetEntityStateSafe(LastShowerDurationEntityId, durationSeconds.ToString(CultureInfo.InvariantCulture))
|
||||
.ConfigureAwait(false);
|
||||
await SetEntityAttributesSafe(LastShowerDurationEntityId, new
|
||||
{
|
||||
formatted = FormatDuration(session.Duration),
|
||||
@@ -181,7 +187,8 @@ public sealed class ShowerMonitorEntityService(
|
||||
last_updated = timestamp
|
||||
}).ConfigureAwait(false);
|
||||
|
||||
await SetEntityStateSafe(LastShowerTimeEntityId, session.StartTime.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture)).ConfigureAwait(false);
|
||||
await SetEntityStateSafe(LastShowerTimeEntityId,
|
||||
session.StartTime.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture)).ConfigureAwait(false);
|
||||
await SetEntityAttributesSafe(LastShowerTimeEntityId, new
|
||||
{
|
||||
friendly_name = "Last shower time",
|
||||
@@ -217,7 +224,7 @@ public sealed class ShowerMonitorEntityService(
|
||||
{
|
||||
var totalMinutes = (int)ts.TotalMinutes;
|
||||
var seconds = ts.Seconds;
|
||||
|
||||
|
||||
return $"{totalMinutes}m {seconds}s";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user