AutomationPipelines 0.2.0
dotnet add package AutomationPipelines --version 0.2.0
NuGet\Install-Package AutomationPipelines -Version 0.2.0
<PackageReference Include="AutomationPipelines" Version="0.2.0" />
<PackageVersion Include="AutomationPipelines" Version="0.2.0" />
<PackageReference Include="AutomationPipelines" />
paket add AutomationPipelines --version 0.2.0
#r "nuget: AutomationPipelines, 0.2.0"
#addin nuget:?package=AutomationPipelines&version=0.2.0
#tool nuget:?package=AutomationPipelines&version=0.2.0
AutomationPipelines
Composable, reactive, and layered logic pipelines for C# automation
In complex systems, multiple conditions often need to influence a single behavior. Instead of funneling all logic into a single block, AutomationPipelines encourages clean separation of concerns using a flexible, node-based pipeline model.
At its core is the Pipeline<TState>
class, which coordinates a chain of self-contained logic units (IPipelineNode<TState>
). Each node can independently process input, produce output, or opt out entirely—while maintaining full support for dependency injection.
Why use AutomationPipelines?
- Modular Logic: Each pipeline node is a focused class with a single responsibility.
- Dependency Injection Support: Nodes can depend on external services, entities, or sensors—perfect for reactive systems like NetDaemon or Home Assistant.
- Prioritized Overrides: Later nodes in the pipeline can override the output of earlier ones, enabling intuitive layering and override mechanisms.
- Reactive and Self-Contained: Nodes are notified when input changes and can independently decide their output—or disable themselves to pass values through untouched.
This approach leads to cleaner, more maintainable automation logic—especially in event-driven or rules-based environments.
Real-World Usage
This library was designed with automation platforms like NetDaemon in mind but is suitable for any scenario where behavior is built from layered rules and inputs.
Check out CodeCasa on GitHub for real-world examples and usage patterns.
Example
[NetDaemonApp]
internal class PipelineTest
{
public PipelineTest(IPipeline<string> messagesPipeline)
{
messagesPipeline
.RegisterNode<DefaultMessageNode>()
.RegisterNode<OfficeLightsMessageNode>()
.RegisterNode<CherryOnTopMessageNode>()
.SetOutputHandler(Console.WriteLine);
}
}
// Provides a default message when no other conditions are met
public class DefaultMessageNode : PipelineNode<string>
{
public DefaultMessageNode()
{
Output = "Default message";
}
}
// Overrides message if the office lights are turned on
public class OfficeLightsMessageNode : PipelineNode<string>
{
public OfficeLightsMessageNode(LightEntities lightEntities)
{
lightEntities.OfficeLights.SubscribeOnOff(
() => Output = "ON",
DisableNode
);
}
}
// Modifies the incoming message by appending a "cherry on top"
public class CherryOnTopMessageNode : PipelineNode<string>
{
protected override void InputReceived(string? input)
{
Output = string.IsNullOrEmpty(input)
? "Just a cherry"
: $"{input} with a cherry on top";
}
}
In this example:
- The
DefaultMessageNode
sets an initial message. - The
OfficeLightsMessageNode
conditionally overrides it based on light state. - The
CherryOnTopMessageNode
decorates the result with additional context.
The output handler is called whenever the final result changes, keeping logic reactive and centralized.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net9.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.4)
- System.Reactive (>= 6.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.