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(); config.AddProfile(); }) .AddTransient() .AddSingleton(TimeProvider.System) .AddScoped() .Configure(context.Configuration.GetSection(NordPoolOptions.SectionName)) .AddNordPool(context.Configuration) .Configure(context.Configuration.GetSection(PowerMonitorOptions.SectionName)) .AddPowerMonitor(context.Configuration) .Configure(context.Configuration.GetSection(BoilerMonitorOptions.SectionName)) .AddBoilerMonitor(context.Configuration) .Configure(context.Configuration.GetSection(ShowerMonitorOptions.SectionName)) .AddShowerMonitor(context.Configuration) .Configure(context.Configuration.GetSection(LightMonitorOptions.SectionName)) .AddLightMonitor(context.Configuration) .Configure(context.Configuration.GetSection(BatteryMonitorOptions.SectionName)) .AddBatteryMonitor(context.Configuration) .Configure(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; }