Skip to content

Commit

Permalink
Clean debug code
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankBakkerNl committed Apr 27, 2024
1 parent 1a7618d commit 45b0c11
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 32 deletions.
39 changes: 8 additions & 31 deletions src/debug/DebugHost/apps/HelloApp/HelloApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,23 @@
using Microsoft.Extensions.Logging;
using NetDaemon.AppModel;
using NetDaemon.HassModel;
using NetDaemon.HassModel.Entities;

namespace Apps;

[NetDaemonApp]
[Focus]
public sealed class HelloApp2 : IAsyncDisposable
public sealed class HelloApp : IAsyncDisposable
{
private readonly ILogger<HelloApp2> _logger;
private readonly ILogger<HelloApp> _logger;

public HelloApp2(IHaContext ha, ILogger<HelloApp2> logger, IHaRegistry registry)
public HelloApp(IHaContext ha, ILogger<HelloApp> logger)
{
var home = new Home(registry);
var x = home.Floors.Downstairs.Areas.SelectMany(a => a.Entities);

_logger = logger;
var boilerConnected = ha.Entity("switch.heating_valve_kitchen");
var labels = boilerConnected.Registration?.Labels;
var all = registry.Entities;
var criticalEntities = ha.GetAllEntities().Where(e => e.Registration?.Labels.Any(l => l.Name == "critical") ?? false);
//criticalEntities.StateChanges().Where(s => s.New?.State == "unavailable").Subscribe(e => logger.LogCritical("Entity {Entity} became unavailable", e.Entity.EntityId));
ha.Events.Where(n => n.EventType == "test_event").Subscribe( _ =>
{
logger.LogInformation("Hello testevent");
});
ha.CallService("notify", "persistent_notification", data: new { message = "Notify me", title = "Hello world!" });
}

public async ValueTask DisposeAsync()
Expand All @@ -32,22 +28,3 @@ public async ValueTask DisposeAsync()
//return ValueTask.CompletedTask;
}
}

record Home(IHaRegistry HaRegistry)
{
public MyFloors Floors => new MyFloors(HaRegistry);
}

record MyFloors(IHaRegistry Registry)
{
public Floor Downstairs => Registry.GetFloor("downstairs")!;
public Floor Upstairs => Registry.GetFloor("upstairs")!;
public Floor Attic => Registry.GetFloor("upstairs")!;
}

record AtticFloorAreas(IHaRegistry HaRegistry)
{
public IEnumerable<Area>? Areas { get; }
public Area Study => HaRegistry.GetArea("study")!;

}
2 changes: 1 addition & 1 deletion src/debug/DebugHost/apps_src/hellow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace Apps;

[NetDaemonApp]
//[Focus]
[Focus]
public sealed class HelloAppSrc : IAsyncDisposable
{
private readonly ILogger<HelloAppSrc> _logger;
Expand Down

0 comments on commit 45b0c11

Please sign in to comment.