Init
This commit is contained in:
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,19 @@
|
||||
# Update the codegen
|
||||
dotnet tool update -g NetDaemon.HassModel.CodeGen
|
||||
|
||||
# Update all nugets to latest versions
|
||||
$regex = 'PackageReference Include="([^"]*)" Version="([^"]*)"'
|
||||
|
||||
ForEach ($file in Get-ChildItem . -Recurse | Where-Object { $_.Extension -like "*proj" }) {
|
||||
$packages = Get-Content $file.FullName |
|
||||
Select-String -Pattern $regex -AllMatches |
|
||||
ForEach-Object { $_.Matches } |
|
||||
ForEach-Object { $_.Groups[1].Value.ToString() } |
|
||||
Sort-Object -Unique
|
||||
|
||||
ForEach ($package in $packages) {
|
||||
Write-Host "Update $file package :$package" -ForegroundColor Magenta
|
||||
$fullName = $file.FullName
|
||||
& dotnet add $fullName package $package
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using HomeAssistant.Entities.Interfaces;
|
||||
using HomeAssistant.Models;
|
||||
using NetDaemon.Extensions.MqttEntityManager;
|
||||
|
||||
namespace HomeAssistant.Entities;
|
||||
|
||||
public class EntityManager(IMqttEntityManager entityManager) : IEntityManager
|
||||
{
|
||||
public async Task CreateEntitiesAsync(ICollection<EntityCreateModel> entities)
|
||||
{
|
||||
await Task.WhenAll(entities.Select(CreateEntityAsync));
|
||||
}
|
||||
|
||||
public async Task CreateEntityAsync(EntityCreateModel createModel)
|
||||
{
|
||||
if (createModel.EntityId != null)
|
||||
{
|
||||
await entityManager.CreateAsync(createModel.EntityId, createModel.Options, createModel.AdditionalConfig);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task SetEntityState(string entityId, string state)
|
||||
{
|
||||
await entityManager.SetStateAsync(entityId, state);
|
||||
}
|
||||
|
||||
public async Task SetEntityAttributes(string entityId, object attributes)
|
||||
{
|
||||
await entityManager.SetAttributesAsync(entityId, attributes);
|
||||
}
|
||||
|
||||
public async Task RemoveEntity(string entityId)
|
||||
{
|
||||
await entityManager.RemoveAsync(entityId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="NetDaemon.AppModel" Version="26.3.0" />
|
||||
<PackageReference Include="NetDaemon.Extensions.Mqtt" 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.Models\HomeAssistant.Models.csproj" />
|
||||
<ProjectReference Include="..\NordPool.Models\NordPool.Models.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,12 @@
|
||||
using HomeAssistant.Models;
|
||||
|
||||
namespace HomeAssistant.Entities.Interfaces;
|
||||
|
||||
public interface IEntityManager
|
||||
{
|
||||
Task CreateEntitiesAsync(ICollection<EntityCreateModel> entities);
|
||||
Task CreateEntityAsync(EntityCreateModel createModel);
|
||||
Task SetEntityState(string entityId, string state);
|
||||
Task SetEntityAttributes(string entityId, object attributes);
|
||||
Task RemoveEntity(string entityId);
|
||||
}
|
||||
Reference in New Issue
Block a user