Files
HomeAssistant/HomeAssistant.Server/program.cs
T
gitea_admin 24729ee267 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
2026-11-30 11:52:06 +02:00

80 lines
3.9 KiB
C#

using System;
using System.Reflection;
using BatteryMonitorManager;
using BatteryMonitorManager.Models;
using BoilerMonitor.Models;
using BoilerMonitorManager;
using BoilerMonitorManager.Models;
using HomeAssistant.Entities;
using HomeAssistant.Entities.Interfaces;
using HomeAssistantGenerated;
using HomeAssistantServer;
using LeakMonitorManager;
using LeakMonitorManager.Models;
using LightMonitor.Models;
using LightMonitorManager;
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 NordPoolManager;
using NordPoolManager.Models;
using PowerMonitorManager;
using PowerMonitorManager.Models;
using ShowerMonitorManager;
using ShowerMonitorManager.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<IBoilerConfigReader, BoilerConfigReader>()
.Configure<NordPoolOptions>(context.Configuration.GetSection(NordPoolOptions.SectionName))
.AddNordPool()
.Configure<PowerMonitorOptions>(context.Configuration.GetSection(PowerMonitorOptions.SectionName))
.AddPowerMonitor()
.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;
}