feat: add PowerMonitor service registration and default configuration tests

This commit is contained in:
Marius
2026-03-19 16:32:47 +02:00
parent cd5f9d0352
commit 4c6b6938e8
5 changed files with 105 additions and 7 deletions
@@ -0,0 +1,31 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using NetDaemon.AppModel;
using PowerMonitorManager.Interface;
using PowerMonitorManager.Models;
namespace PowerMonitorManager;
public static class PowerMonitorServiceRegistration
{
public static IServiceCollection AddPowerMonitor(this IServiceCollection services, IConfiguration configuration)
{
var options = configuration
.GetSection(PowerMonitorOptions.SectionName)
.Get<PowerMonitorOptions>() ?? new PowerMonitorOptions();
if (!options.Enabled)
{
return services;
}
services
.AddNetDaemonApp<PowerMonitorInit>()
.AddScoped<IPowerSensorDiscoveryService, PowerSensorDiscoveryService>()
.AddSingleton<IOtherPowerCalculationService, OtherPowerCalculationService>()
.AddSingleton<IPowerCostCalculationService, PowerCostCalculationService>()
.AddTransient<IPowerMonitorEntityService, PowerMonitorEntityService>();
return services;
}
}