fix: change PowerSensorDiscoveryService to scoped lifetime to resolve IHaContext DI error

Made-with: Cursor
This commit is contained in:
Marius
2026-03-17 13:05:42 +02:00
parent ba31ed6a45
commit 1909eedc6b
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -27,8 +27,8 @@
"UseAttributeBaseClasses" : "false"
},
"PowerMonitor": {
"MainMeterEntityId": "sensor.p1_meter_power",
"PollIntervalSeconds": 15,
"MainMeterEntityId": "sensor.sonoff_100267d63f_power",
"PollIntervalSeconds": 5,
"SmoothingWindowSize": 10,
"AnomalyThresholdWatts": 500,
"ExcludedSensorPatterns": [
+1 -1
View File
@@ -50,7 +50,7 @@ try
.Configure<PowerMonitorOptions>(
context.Configuration.GetSection(PowerMonitorOptions.SectionName))
.AddNetDaemonApp<PowerMonitorInit>()
.AddSingleton<IPowerSensorDiscoveryService, PowerSensorDiscoveryService>()
.AddScoped<IPowerSensorDiscoveryService, PowerSensorDiscoveryService>()
.AddSingleton<IOtherPowerCalculationService, OtherPowerCalculationService>()
.AddSingleton<IPowerCostCalculationService, PowerCostCalculationService>()
.AddTransient<IPowerMonitorEntityService, PowerMonitorEntityService>()