Skip to content

Commit

Permalink
Possible to disable load local assemblies
Browse files Browse the repository at this point in the history
  • Loading branch information
helto4real committed May 2, 2020
1 parent 2c9d3c2 commit 257a7bf
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/App/NetDaemon.App/NetDaemon.App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="JoySoftware.HassClient" Version="0.1.3-alpha" />
<PackageReference Include="JoySoftware.HassClient" Version="0.2.0-alpha" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="3.1.3" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/Daemon/NetDaemon.Daemon/NetDaemon.Daemon.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

</PropertyGroup>
<ItemGroup>
<PackageReference Include="JoySoftware.HassClient" Version="0.1.3-alpha" />
<PackageReference Include="JoySoftware.HassClient" Version="0.2.0-alpha" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.3" />
</ItemGroup>
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/DaemonRunner/DaemonRunner/DaemonRunner.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

</PropertyGroup>
<ItemGroup>
<PackageReference Include="JoySoftware.HassClient" Version="0.1.3-alpha" />
<PackageReference Include="JoySoftware.HassClient" Version="0.2.0-alpha" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.5.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.3" />
<PackageReference Include="YamlDotNet" Version="8.1.1" />
Expand Down
4 changes: 4 additions & 0 deletions src/DaemonRunner/DaemonRunner/Service/App/CodeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,10 @@ public async Task<IEnumerable<INetDaemonApp>> InstanceAndInitApplications(INetDa

private void LoadLocalAssemblyApplicationsForDevelopment()
{
var disableLoadLocalAssemblies = Environment.GetEnvironmentVariable("HASS_DISABLE_LOCAL_ASM");
if (disableLoadLocalAssemblies is object && disableLoadLocalAssemblies == "true")
return;

// Get daemon apps in entry assembly (mainly for development)
var apps = Assembly.GetEntryAssembly()?.GetTypes().Where(type => type.IsClass && type.IsSubclassOf(typeof(NetDaemonApp)));
if (apps != null)
Expand Down
24 changes: 23 additions & 1 deletion tests/NetDaemon.Daemon.Tests/Fluent/FluentTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,29 @@ public async Task EntityOnStateChangedLamdaTurnOnLightCallsCorrectServiceCall()
}

[Fact]
public async Task EntityOnStateChangedLamdaToggleLightCallsCorrectServiceCall()
public async Task EntityOnStateChangedLamdaWithMultipleEntitiesCallsCorrectServiceCall()
{
// ARRANGE
DefaultHassClientMock.AddChangedEvent("binary_sensor.pir", "off", "on");

var cancelSource = DefaultHassClientMock.GetSourceWithTimeout();
var MotionEnabled = true;

DefaultDaemonApp
.Entities(new string[] { "binary_sensor.pir", "binary_sensor-pir2" })
.WhenStateChange((to, from) => @from?.State == "off" && to?.State == "on" && MotionEnabled)
.UseEntity("light.correct_entity")
.Toggle()
.Execute();

await RunDefauldDaemonUntilCanceled();

DefaultHassClientMock.VerifyCallServiceTimes("toggle", Times.Once());
DefaultHassClientMock.VerifyCallService("light", "toggle", ("entity_id", "light.correct_entity"));
}

[Fact]
public async Task OneEntityWithSeveralShouldCallsCorrectServiceCall()
{
// ARRANGE
DefaultHassClientMock.AddChangedEvent("binary_sensor.pir", "off", "on");
Expand Down

0 comments on commit 257a7bf

Please sign in to comment.