feat: add BatteryMonitor implementation with discovery, notification, and scheduling services
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using NetDaemon.AppModel;
|
||||
using ShowerMonitorManager.Interface;
|
||||
using ShowerMonitorManager.Models;
|
||||
using static ShowerMonitor.Models.ShowerMonitorConsts;
|
||||
|
||||
namespace ShowerMonitorManager;
|
||||
|
||||
public static class ShowerMonitorServiceRegistration
|
||||
{
|
||||
public static IServiceCollection AddShowerMonitor(this IServiceCollection services, IConfiguration configuration)
|
||||
{
|
||||
var options = configuration
|
||||
.GetSection(ShowerMonitorOptions.SectionName)
|
||||
.Get<ShowerMonitorOptions>() ?? new ShowerMonitorOptions();
|
||||
|
||||
if (!options.Enabled)
|
||||
{
|
||||
return services;
|
||||
}
|
||||
|
||||
services
|
||||
.AddNetDaemonApp<ShowerMonitorInit>()
|
||||
.AddSingleton<IHumidityRateCalculator>(_ => new HumidityRateCalculator(options.RateWindowSize))
|
||||
.AddSingleton<IShowerDetectionService, ShowerDetectionService>()
|
||||
.AddSingleton<IExhaustFanControlService, ExhaustFanControlService>()
|
||||
.AddTransient<IShowerMonitorEntityService, ShowerMonitorEntityService>();
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user