From a8719e110217551fe3ccce8e1c5f3b2e5e0cc1ef Mon Sep 17 00:00:00 2001 From: Tim Ittermann Date: Wed, 3 Apr 2024 14:05:14 +0200 Subject: [PATCH] Fix HASS --- HomeAssistant/HassExtensions.cs | 3 ++- HomeAssistant/HassHostedService.cs | 2 +- Template/TemplateRenderer.cs | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/HomeAssistant/HassExtensions.cs b/HomeAssistant/HassExtensions.cs index 80f4b6c..13c71f2 100644 --- a/HomeAssistant/HassExtensions.cs +++ b/HomeAssistant/HassExtensions.cs @@ -1,3 +1,4 @@ +using DisplayUtil.Template; using DisplayUtil.Utils; using NetDaemon.Client.Extensions; using NetDaemon.Client.Settings; @@ -19,7 +20,7 @@ public static IHostApplicationBuilder AddHassSupport(this IHostApplicationBuilde builder.Services .AddHomeAssistantClient() - .AddScoped(); + .AddScoped(); // Hack: Initialize Hass Model var extensionType = typeof(DependencyInjectionSetup); diff --git a/HomeAssistant/HassHostedService.cs b/HomeAssistant/HassHostedService.cs index a11cfe6..66784fc 100644 --- a/HomeAssistant/HassHostedService.cs +++ b/HomeAssistant/HassHostedService.cs @@ -35,8 +35,8 @@ public Task StartAsync(CancellationToken cancellationToken) private async Task OnConnection(IHomeAssistantConnection connection) { - logger.LogInformation("Hass Connection initialized"); await cacheManager.InitializeAsync(_cancellationTokenSource.Token); + logger.LogInformation("Hass Connection initialized"); } public Task StopAsync(CancellationToken cancellationToken) diff --git a/Template/TemplateRenderer.cs b/Template/TemplateRenderer.cs index 75b07c4..edc9eb0 100644 --- a/Template/TemplateRenderer.cs +++ b/Template/TemplateRenderer.cs @@ -14,7 +14,7 @@ public async Task RenderToStreamAsync(string content) { var template = Scriban.Template.Parse(content); var rendered = await template.RenderAsync(contextProvider - .GetTemplateContext()); + .GetTemplateContext(EnrichScope.ScreenRendering)); var memoryStream = new MemoryStream(); memoryStream.Write(Encoding.UTF8.GetBytes(rendered));