Skip to content

Commit

Permalink
Updates to example app post V10
Browse files Browse the repository at this point in the history
  • Loading branch information
leosperry committed Oct 26, 2024
1 parent 79383f2 commit 2ae3182
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@

<PackageReference Include="Moq" Version="4.20.70" />

<PackageReference Include="HaKafkaNet.TestHarness" Version="9.2.0" />
<!-- <PackageReference Include="HaKafkaNet.TestHarness" Version="10.*" /> -->

</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\HaKafkaNet.ExampleApp\HaKafkaNet.ExampleApp.csproj" />
</ItemGroup>

<!-- <ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\HaKafkaNet.TestHarness\HaKafkaNet.TestHarness.csproj" />
</ItemGroup> -->
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ public AdvancedTutorialRegistry(IAutomationBuilder builder, IHaServices services
}
public void Register(IRegistrar reg)
{
reg.Register(DoorAlert("binary_sensor.front_door_contact", "front door"));
reg.Register(DoorAlert("binary_sensor.back_door_contact", "back door"));
reg.TryRegister(
() => DoorAlert("binary_sensor.front_door_contact", "front door"),
() => DoorAlert("binary_sensor.back_door_contact", "back door")
);
}

IConditionalAutomation DoorAlert(string entityId, string friendlyName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ public AutomationRegistry(IHaServices services, IAutomationBuilder builder, IAut
/// <param name="reg"></param>
public void Register(IRegistrar reg)
{
reg.RegisterMultiple(Register());
reg.RegisterMultiple(RegisterContitionals());
reg.Register(Register().ToArray());
reg.RegisterDelayed(RegisterContitionals().ToArray());

// new feature! Turn on front porch light 15 minutes before sunset
reg.Register(_automationFactory.SunSetAutomation(
reg.RegisterDelayed(_automationFactory.SunSetAutomation(
ct => _services.Api.TurnOn("light.front_porch"),
TimeSpan.FromMinutes(-15)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public LightOffRegistry(IHaServices services, IAutomationFactory automationFacto

public void Register(IRegistrar reg)
{
reg.RegisterMultiple(RegisterContitionals());
reg.TryRegister(RegisterContitionals().ToArray());
}

public IEnumerable<IAutomation> Register()
Expand Down
9 changes: 6 additions & 3 deletions example/HaKafkaNet.ExampleApp/Automations/LightOnRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public LightOnRegistry(IHaServices services, IAutomationBuilder builder, IAutoma

public void Register(IRegistrar reg)
{
reg.RegisterMultiple(Register());
reg.RegisterMultiple(RegisterContitionals());
reg.Register(Register().ToArray());
reg.RegisterDelayed(RegisterContitionals().ToArray());
}

public IEnumerable<IAutomation> Register()
Expand Down Expand Up @@ -98,7 +98,10 @@ public IEnumerable<IConditionalAutomation> RegisterContitionals()
.WithDescription("from builder using conditional")
.WithTriggers(OFFICE_MOTION)
.When(sc => sc.New.State == "on") // there is an asynchronous overload for this method should you need to call services
.Then(ct => _services.Api.TurnOn(OFFICE_LIGHT, ct))
.Then(async ct =>
{
await _services.Api.TurnOn(OFFICE_LIGHT, ct);
})
.Build();
}
}
2 changes: 1 addition & 1 deletion example/HaKafkaNet.ExampleApp/HaKafkaNet.ExampleApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</ItemGroup>

<ItemGroup>
<!-- <PackageReference Include="HaKafkaNet" Version="9.2.0" /> -->
<!-- <PackageReference Include="HaKafkaNet" Version="10.*" /> -->
<PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" Version="9.0.0-preview.3.24172.13" />
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="9.0.0-preview.3.24172.13" />
<PackageReference Include="OpenTelemetry" Version="1.9.0" />
Expand Down

0 comments on commit 2ae3182

Please sign in to comment.