Init
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"version": 1,
|
||||
"isRoot": true,
|
||||
"tools": {
|
||||
"netdaemon.hassmodel.codegen": {
|
||||
"version": "26.3.0",
|
||||
"commands": [
|
||||
"nd-codegen"
|
||||
],
|
||||
"rollForward": false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
FROM mcr.microsoft.com/dotnet/sdk:9.0
|
||||
|
||||
ENV PATH="/root/.dotnet/tools:${PATH}"
|
||||
RUN dotnet tool install -g NetDaemon.HassModel.CodeGen
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"name": "NetDaemon App-development",
|
||||
"dockerFile": "./Dockerfile",
|
||||
"postCreateCommand": "dotnet restore *.csproj",
|
||||
"settings": {
|
||||
"terminal.integrated.shell.linux": "/bin/bash",
|
||||
"terminal.integrated.fontSize": 10
|
||||
},
|
||||
"extensions": [
|
||||
"ms-dotnettools.csharp"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
obj
|
||||
bin
|
||||
appsettings.Development.json
|
||||
.vs
|
||||
*.gen
|
||||
.idea
|
||||
#appsettings.json
|
||||
#HomeAssistantGenerated.cs
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Debug Apps",
|
||||
"type": "coreclr",
|
||||
"request": "launch",
|
||||
"preLaunchTask": "build",
|
||||
"program": "${workspaceFolder}/bin/Debug/net10.0/HomeAssistantServer.dll",
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}",
|
||||
"env": {
|
||||
"DOTNET_ENVIRONMENT": "Development",
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"stopAtEntry": false,
|
||||
"logging": {
|
||||
"moduleLoad": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": ".NET Core Attach",
|
||||
"type": "coreclr",
|
||||
"request": "attach",
|
||||
"processId": "${command:pickProcess}"
|
||||
}
|
||||
]
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "build",
|
||||
"command": "dotnet",
|
||||
"type": "process",
|
||||
"args": [
|
||||
"build",
|
||||
"${workspaceFolder}/HomeAssistantServer.csproj",
|
||||
"/property:GenerateFullPaths=true",
|
||||
"/consoleloggerparameters:NoSummary"
|
||||
],
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
{
|
||||
"label": "publish",
|
||||
"command": "dotnet",
|
||||
"type": "process",
|
||||
"args": [
|
||||
"publish",
|
||||
"${workspaceFolder}/HomeAssistantServer.csproj",
|
||||
"/property:GenerateFullPaths=true",
|
||||
"/consoleloggerparameters:NoSummary"
|
||||
],
|
||||
"problemMatcher": "$msCompile"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Serilog;
|
||||
|
||||
namespace HomeAssistantServer;
|
||||
|
||||
public static class CustomLoggingProvider
|
||||
{
|
||||
public static IHostBuilder UseCustomLogging(this IHostBuilder builder)
|
||||
{
|
||||
var configuration = new ConfigurationBuilder()
|
||||
.AddJsonFile("appsettings.json")
|
||||
.AddJsonFile($"appsettings.{Environment.GetEnvironmentVariable("DOTNET_ENVIRONMENT") ?? "Production"}.json", optional: true)
|
||||
.Build();
|
||||
|
||||
var logger = new LoggerConfiguration()
|
||||
.ReadFrom.Configuration(configuration)
|
||||
.CreateLogger();
|
||||
|
||||
return builder.UseSerilog(logger);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build-env
|
||||
WORKDIR /app
|
||||
|
||||
# Copy csproj and restore as distinct layers
|
||||
COPY *.csproj ./
|
||||
RUN dotnet restore
|
||||
|
||||
# Copy everything else and build
|
||||
COPY . ./
|
||||
RUN dotnet publish -c Release -o out ./HomeAssistantServer.csproj
|
||||
|
||||
# Build runtime image
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:10.0
|
||||
WORKDIR /app
|
||||
COPY --from=build-env /app/out .
|
||||
ENTRYPOINT ["dotnet", "HomeAssistantServer.dll"]
|
||||
@@ -0,0 +1,54 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<LangVersion>14.0</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
<RootNamespace>HomeAssistantServer</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="$(MSBuildProjectDir)appsettings.Development.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
|
||||
</None>
|
||||
<None Update="$(MSBuildProjectDir)appsettings.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="$(MSBuildProjectDir)**\*.yaml">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||
</None>
|
||||
<None Update="appsettings.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="appsettings.development.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<Target Name="AfterPublishMessage" AfterTargets="Publish">
|
||||
<Message Text="Publish done! Copy all content in directory: $(PublishDir) to the `/config/netdaemon4' folder for add-on or your custom folder to deploy." Importance="high"/>
|
||||
</Target>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AutoMapper" Version="16.0.0" />
|
||||
<PackageReference Include="NetDaemon.AppModel" Version="26.3.0" />
|
||||
<PackageReference Include="NetDaemon.Runtime" Version="26.3.0" />
|
||||
<PackageReference Include="NetDaemon.HassModel" Version="26.3.0" />
|
||||
<PackageReference Include="NetDaemon.Client" Version="26.3.0" />
|
||||
<PackageReference Include="NetDaemon.Extensions.Scheduling" Version="26.3.0" />
|
||||
<PackageReference Include="NetDaemon.Extensions.Logging" Version="26.3.0" />
|
||||
<PackageReference Include="NetDaemon.Extensions.Tts" Version="26.3.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\HomeAssistant.Entities\HomeAssistant.Entities.csproj" />
|
||||
<ProjectReference Include="..\Mappings\Mappings.csproj" />
|
||||
<ProjectReference Include="..\NordPool.Manager\NordPool.Manager.csproj" />
|
||||
<ProjectReference Include="..\NordPool.Models\NordPool.Models.csproj" />
|
||||
<ProjectReference Include="..\PowerMonitor.Manager\PowerMonitor.Manager.csproj" />
|
||||
<ProjectReference Include="..\PowerMonitor.Models\PowerMonitor.Models.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"profiles": {
|
||||
"HomeAssistantServer": {
|
||||
"commandName": "Project",
|
||||
"workingDirectory": "$(ProjectDir)",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development",
|
||||
"DOTNET_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
# Project template for binary deploy
|
||||
This is the project template for binary deploy. This allows you to build a binary package and deploy it to NetDaemon.
|
||||
|
||||
This is generated using NetDaemon runtime version 5 and .NET 9.
|
||||
|
||||
## Getting started
|
||||
Please see [netdaemon.xyz](https://netdaemon.xyz/docs) more information about getting starting developing apps for Home Assistant using NetDaemon.
|
||||
|
||||
Please add code generation features in `program.cs` when using code generation features by removing comments!
|
||||
|
||||
## Use the code generator
|
||||
See https://netdaemon.xyz/docs/hass_model/hass_model_codegen
|
||||
|
||||
## Issues
|
||||
|
||||
- If you have issues or suggestions of improvements to this template, please [add an issue](https://github.com/net-daemon/netdaemon-app-template)
|
||||
- If you have issues or suggestions of improvements to NetDaemon, please [add an issue](https://github.com/net-daemon/netdaemon/issues)
|
||||
|
||||
## Discuss the NetDaemon
|
||||
|
||||
Please [join the Discord server](https://discord.gg/K3xwfcX) to get support or if you want to contribute and help others.
|
||||
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"Serilog": {
|
||||
"MinimumLevel": {
|
||||
"Default": "Warning",
|
||||
"Override": {
|
||||
"System.Net.Http.HttpClient": "Warning",
|
||||
"NordPoolManager": "Information",
|
||||
"PowerMonitorManager": "Information"
|
||||
}
|
||||
},
|
||||
"WriteTo": [
|
||||
{
|
||||
"Name": "Console",
|
||||
"Args": {
|
||||
"theme": "Serilog.Sinks.SystemConsole.Themes.AnsiConsoleTheme::Code, Serilog.Sinks.Console",
|
||||
"outputTemplate": "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj} <s:{SourceContext}>{NewLine}{Exception}"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"HomeAssistant": {
|
||||
"Host": "192.168.1.206",
|
||||
"Port": 8123,
|
||||
"Ssl": false
|
||||
},
|
||||
"NetDaemon": {
|
||||
"ApplicationConfigurationFolder": "./apps"
|
||||
},
|
||||
"CodeGeneration": {
|
||||
"Namespace": "HomeAssistantGenerated",
|
||||
"OutputFile": "HomeAssistantGenerated.cs",
|
||||
"UseAttributeBaseClasses" : "false"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using HomeAssistant.Entities;
|
||||
using HomeAssistant.Entities.Interfaces;
|
||||
using HomeAssistantGenerated;
|
||||
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.Interface;
|
||||
using HomeAssistantServer;
|
||||
using PowerMonitorManager;
|
||||
using PowerMonitorManager.Interface;
|
||||
|
||||
#pragma warning disable CA1812
|
||||
|
||||
try
|
||||
{
|
||||
await Host.CreateDefaultBuilder(args)
|
||||
.UseNetDaemonAppSettings()
|
||||
.UseCustomLogging()
|
||||
.UseNetDaemonRuntime()
|
||||
.UseNetDaemonTextToSpeech()
|
||||
.ConfigureServices((_, services) =>
|
||||
services
|
||||
.AddNetDaemonMqttEntityManagement()
|
||||
.AddAppsFromAssembly(Assembly.GetExecutingAssembly())
|
||||
.AddNetDaemonStateManager()
|
||||
.AddNetDaemonScheduler()
|
||||
.AddHomeAssistantGenerated()
|
||||
.AddNetDaemonApp<NordPoolInit>()
|
||||
.AddAutoMapper(config =>
|
||||
{
|
||||
config.LicenseKey =
|
||||
"eyJhbGciOiJSUzI1NiIsImtpZCI6Ikx1Y2t5UGVubnlTb2Z0d2FyZUxpY2Vuc2VLZXkvYmJiMTNhY2I1OTkwNGQ4OWI0Y2IxYzg1ZjA4OGNjZjkiLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJodHRwczovL2x1Y2t5cGVubnlzb2Z0d2FyZS5jb20iLCJhdWQiOiJMdWNreVBlbm55U29mdHdhcmUiLCJleHAiOiIxNzk1NDc4NDAwIiwiaWF0IjoiMTc2NDAwNTE3OSIsImFjY291bnRfaWQiOiIwMTlhYjZlNjFjZWM3ZjhhYWQzMjE4ZmQ0ODdkYTgwNiIsImN1c3RvbWVyX2lkIjoiY3RtXzAxa2F2ZWR3ZHJkNzg0dmZ6NWdqMmVuYzRmIiwic3ViX2lkIjoiLSIsImVkaXRpb24iOiIwIiwidHlwZSI6IjIifQ.n1iwRUZXd60e8zM5_242OERaBGi-ZxOVllchr1rfDlkl6iV0cpflZrT2cwpJSha7xYGJ9gfpe1JWATplQeX_RvvUM6ZxkS1BiJdZkCtu8cMLnXZ1Py6A-myFVLBJA06crl6DJkBa3yCGMsQUaoPQbg5AAxYzrx9JfjxArnyRC1HjI4_6ZMn0zxsaRXQAODF7yPo9TNrtyaQ75bLh3nv9ankzHJ6gibKIbNxiq9m-X_5ejd0NHXSst2ckTf5Eyfevv6Rmi45H_Ry5ePXxLdTNkdqHR6MqLbVZ8cpNBt69NajsBTodGy29UfZg0iiwB3s9ztnnobxvSM2KZ4-WsVKAYA";
|
||||
config.AddProfile<NordPoolMappingProfile>();
|
||||
config.AddProfile<GlobalMappingProfile>();
|
||||
})
|
||||
.AddTransient<IEntityManager, EntityManager>()
|
||||
.AddScoped<INordPoolPriceService, NordPoolPriceService>()
|
||||
.AddTransient<INordPoolEntityService, NordPoolEntityService>()
|
||||
.AddSingleton<ICheapestIntervalsFinder, CheapestIntervalsFinder>()
|
||||
.AddSingleton<IBoilerControlService, BoilerControlService>()
|
||||
.AddNetDaemonApp<PowerMonitorInit>()
|
||||
.AddTransient<IPowerMonitorEntityService, PowerMonitorEntityService>()
|
||||
.AddSingleton<IOtherPowerCalculationService, OtherPowerCalculationService>()
|
||||
)
|
||||
.Build()
|
||||
.RunAsync()
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine($"Failed to start host... {e}");
|
||||
|
||||
throw;
|
||||
}
|
||||
Reference in New Issue
Block a user