using System; using System.Reflection; using HomeAssistant.Entities; using HomeAssistant.Entities.Interfaces; using HomeAssistantGenerated; using HomeAssistantServer; 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.Interface; using NordPoolManager.Models; using PowerMonitorManager; using PowerMonitorManager.Models; using ShowerMonitorManager; using ShowerMonitorManager.Models; using LightMonitorManager; using LightMonitorManager.Models; 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() .AddNetDaemonApp() .AddAutoMapper(config => { config.LicenseKey = "eyJhbGciOiJSUzI1NiIsImtpZCI6Ikx1Y2t5UGVubnlTb2Z0d2FyZUxpY2Vuc2VLZXkvYmJiMTNhY2I1OTkwNGQ4OWI0Y2IxYzg1ZjA4OGNjZjkiLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJodHRwczovL2x1Y2t5cGVubnlzb2Z0d2FyZS5jb20iLCJhdWQiOiJMdWNreVBlbm55U29mdHdhcmUiLCJleHAiOiIxNzk1NDc4NDAwIiwiaWF0IjoiMTc2NDAwNTE3OSIsImFjY291bnRfaWQiOiIwMTlhYjZlNjFjZWM3ZjhhYWQzMjE4ZmQ0ODdkYTgwNiIsImN1c3RvbWVyX2lkIjoiY3RtXzAxa2F2ZWR3ZHJkNzg0dmZ6NWdqMmVuYzRmIiwic3ViX2lkIjoiLSIsImVkaXRpb24iOiIwIiwidHlwZSI6IjIifQ.n1iwRUZXd60e8zM5_242OERaBGi-ZxOVllchr1rfDlkl6iV0cpflZrT2cwpJSha7xYGJ9gfpe1JWATplQeX_RvvUM6ZxkS1BiJdZkCtu8cMLnXZ1Py6A-myFVLBJA06crl6DJkBa3yCGMsQUaoPQbg5AAxYzrx9JfjxArnyRC1HjI4_6ZMn0zxsaRXQAODF7yPo9TNrtyaQ75bLh3nv9ankzHJ6gibKIbNxiq9m-X_5ejd0NHXSst2ckTf5Eyfevv6Rmi45H_Ry5ePXxLdTNkdqHR6MqLbVZ8cpNBt69NajsBTodGy29UfZg0iiwB3s9ztnnobxvSM2KZ4-WsVKAYA"; config.AddProfile(); config.AddProfile(); }) .AddTransient() .Configure(context.Configuration.GetSection(NordPoolOptions.SectionName)) .AddScoped() .AddTransient() .AddSingleton() .AddScoped() .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; }