ada3c77778
- DateTimeTypeConverter parses with the invariant culture instead of the ambient one (NordPool timestamps arrive as ISO-8601) - Shower last-shower-time state is formatted with the invariant culture - PresenceServiceTests no longer captures the loop variable in a Moq setup - CheapestIntervalsFinderTests compare prices with a tolerance instead of floating-point equality - MqttRecreateApp logs the unit_of_measurement read failure instead of silently swallowing every exception - LightMonitorOptions moves to LightMonitor.Models so the namespace matches the project and file location
79 lines
3.9 KiB
C#
79 lines
3.9 KiB
C#
using System;
|
|
using System.Reflection;
|
|
using HomeAssistant.Entities;
|
|
using HomeAssistant.Entities.Interfaces;
|
|
using HomeAssistantGenerated;
|
|
using HomeAssistantServer;
|
|
using LightMonitor.Models;
|
|
using Mappings;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Hosting;
|
|
using NetDaemon.AppModel;
|
|
using NetDaemon.Extensions.MqttEntityManager;
|
|
using NetDaemon.Extensions.Scheduler;
|
|
using NetDaemon.Extensions.Tts;
|
|
using NetDaemon.Runtime;
|
|
using BoilerMonitorManager;
|
|
using BoilerMonitorManager.Models;
|
|
using NordPoolManager;
|
|
using NordPoolManager.Models;
|
|
using PowerMonitorManager;
|
|
using PowerMonitorManager.Models;
|
|
using ShowerMonitorManager;
|
|
using ShowerMonitorManager.Models;
|
|
using LightMonitorManager;
|
|
using BatteryMonitorManager;
|
|
using BatteryMonitorManager.Models;
|
|
using LeakMonitorManager;
|
|
using LeakMonitorManager.Models;
|
|
|
|
try
|
|
{
|
|
var app = Host.CreateDefaultBuilder(args)
|
|
.UseNetDaemonAppSettings()
|
|
.UseCustomLogging()
|
|
.UseNetDaemonRuntime()
|
|
.UseNetDaemonTextToSpeech()
|
|
.ConfigureServices((context, services) =>
|
|
{
|
|
services
|
|
.AddNetDaemonMqttEntityManagement()
|
|
.AddAppsFromAssembly(Assembly.GetExecutingAssembly())
|
|
.AddNetDaemonStateManager()
|
|
.AddNetDaemonScheduler()
|
|
.AddHomeAssistantGenerated()
|
|
.AddAutoMapper(config =>
|
|
{
|
|
config.LicenseKey =
|
|
"eyJhbGciOiJSUzI1NiIsImtpZCI6Ikx1Y2t5UGVubnlTb2Z0d2FyZUxpY2Vuc2VLZXkvYmJiMTNhY2I1OTkwNGQ4OWI0Y2IxYzg1ZjA4OGNjZjkiLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJodHRwczovL2x1Y2t5cGVubnlzb2Z0d2FyZS5jb20iLCJhdWQiOiJMdWNreVBlbm55U29mdHdhcmUiLCJleHAiOiIxODMwMDM4NDAwIiwiaWF0IjoiMTc2NDAwNTE3OSIsImFjY291bnRfaWQiOiIwMTlhYjZlNjFjZWM3ZjhhYWQzMjE4ZmQ0ODdkYTgwNiIsImN1c3RvbWVyX2lkIjoiMDE5YWI2ZTYxY2VjN2Y4YWFkMzIxOGZkNDg3ZGE4MDYiLCJzdWJfaWQiOiItIiwiZWRpdGlvbiI6IjAiLCJ0eXBlIjoiMiIsInRlcm1fZW5kIjoiMTgyNzQ0NjQwMCJ9.VgEgdxh9xBudubLZr90mUiCORAhLx00Fz7lw1bUMhLWICjBposFrBWrgccKb_irFis_6qUyi567VbsmbjTDxAp9-f0QI0VW4_Zr9wcNeCrDzE0U-DKdcWoMpHoJYUf62tMscGcgVJEKgMX27KLWWqAQzcJm8X-O072A7pW1_x_xkAorFOIfahKXdECnUUdHpPUdrClUbxfWS-wkkKBP0AnrnYY1N2FGlqsJj5_ro1Mmcpijx0sxUKSl1FKaHmx6pOHq-rvJEF7Vvi35vO4HQYFnyP-hN2fQSkgK-Eg8LG6BqBLDXK33VlI6WMO0nOUG62KWAI7jXPSZhrSjBZfxy0g";
|
|
config.AddProfile<NordPoolMappingProfile>();
|
|
config.AddProfile<GlobalMappingProfile>();
|
|
})
|
|
.AddTransient<IEntityManager, EntityManager>()
|
|
.AddSingleton(TimeProvider.System)
|
|
.AddScoped<BoilerMonitor.Models.IBoilerConfigReader, BoilerConfigReader>()
|
|
.Configure<NordPoolOptions>(context.Configuration.GetSection(NordPoolOptions.SectionName))
|
|
.AddNordPool(context.Configuration)
|
|
.Configure<PowerMonitorOptions>(context.Configuration.GetSection(PowerMonitorOptions.SectionName))
|
|
.AddPowerMonitor(context.Configuration)
|
|
.Configure<BoilerMonitorOptions>(context.Configuration.GetSection(BoilerMonitorOptions.SectionName))
|
|
.AddBoilerMonitor(context.Configuration)
|
|
.Configure<ShowerMonitorOptions>(context.Configuration.GetSection(ShowerMonitorOptions.SectionName))
|
|
.AddShowerMonitor(context.Configuration)
|
|
.Configure<LightMonitorOptions>(context.Configuration.GetSection(LightMonitorOptions.SectionName))
|
|
.AddLightMonitor(context.Configuration)
|
|
.Configure<BatteryMonitorOptions>(context.Configuration.GetSection(BatteryMonitorOptions.SectionName))
|
|
.AddBatteryMonitor(context.Configuration)
|
|
.Configure<LeakMonitorOptions>(context.Configuration.GetSection(LeakMonitorOptions.SectionName))
|
|
.AddLeakMonitor(context.Configuration);
|
|
})
|
|
.Build();
|
|
|
|
await app.RunAsync().ConfigureAwait(false);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Console.WriteLine($"Failed to start host... {e}");
|
|
|
|
throw;
|
|
} |