64. Main Filter Chain¶
When you are first getting started with filters in SolarNode there are several different approaches you can take to get the filters "wired up" and actively processing datum. This recipe outlines one specific approach: configuring a Datum Filter Chain on the Datum Queue.
This approach supports the following objectives:
- configure any number of filters
- configure Virtual Meter filters (which most often need to be processed on the Datum Queue)
- specify the precise order that filters are applied
- easily add/remove/reorder filters in the future
A Datum Filter Chain is just a configurable list of other filters, grouped together. When a Datum Filter Chain processes a datum (executes), it executes all the other filters that are configured on the chain, in the order you configure them. They provide a convenient way to organise filters into logical groups, which turns out to be super convenient when designing a complex filter processing pipeline in SolarNode.
Tip
Check out the Datum Filters page for general information about filters, the Datum Queue, and how datum are processed in SolarNode.
64.1 Overview¶
The overall steps of this recipe are:
- configure a Datum Filter Chain named
Chain - Main
- configure the Datum Queue to use the
Chain - Main
filter - add a filter to the Main filter chain
Download recipe settings
You can download a complete settings CSV file of this recipe, then import that into your own SolarNode.
64.2 Create a Datum Filter Chain component¶
The first step is to create a Datum Filter Chain.
- Start by navigating to the Settings > Datum Filters page.
- Scroll down to the User Datum Filters section.
- Click on the Manage button next to the Datum Filter Chain item.
This will take you to the management page for Datum Filter Chain components. Click the + Add new Datum Filter Chain button
to create a new filter chain. Give the component a simple name like Main
:
Now configure a Service Name. This can be anything you like, but using a pattern of FilterType - Name can make
the maintenance of filter comopnents easier in the future. For this guide we use Chain - Main
:
Warning
Be sure to click the Save All Changes button at the top of the page after configuring the Service Name setting. You may need to hit Tab or click outside the form field for the button to become enabled.
64.3 Configure the Datum Queue filter¶
The Datum Queue supports configuring just one filter. Using a filter chain makes perfect sense in this situation, so you can actually configure any number of filters to execute on the queue.
- Navigate back to the Settings > Datum Filters page (click the ← Datum Filters button at the top).
- Scroll down to the Datum Queue section.
- In the Datum Filter setting, use the Choose button to select the
Chain - Main
filter.
Warning
Be sure to click the Save All Changes button at the top of the page after configuring the Datum Filter setting.
Congratulations! At this point, the Chain - Main
filter chain, which we might simply refer to as
the "Main filter chain", is integrated with the Datum Queue and ready to be configured with other
filters.
64.4 Add a filter to the Main filter chain¶
The Datum Filter Chain does not actually do anything itself to the datum it processes. You must configure other filters to perform useful functions, then you can add those filters to a chain. For this guide, let's say you have some meter datum sources configured that take readings every 10s but you want to use the Downsample Filter to reduce the amount of data going up to SolarNetwork to 60s.
Configure a Downsample Filter component. For this guide let's say you named it DWS - Meters
so you
end up with the Main
chain and the Meters
downsample filters.
- Click on the Manage button for Datum Filter Chain.
- Click the + button for the Datum Filters setting to add a new filter reference.
- Click the Choose button for the first (and only) filter reference and select the
DWS - Meters
filter. - Click the Save All Changes button at the top of the page.
64.5 Parting thoughts¶
If you need to add more filters in the future, repeat the steps from the previous section: configure
the new filter and then add it to the Main
filter chain. Keep in mind that the filters you
configure will execute in the same order as you define them in the chain. This becomes important
when one filter makes a change that another filter depends on.
Nesting filter chains
You can create multiple Datum Filter Chain components and add those to the Main
chain as
well! The "nested" chains function as just another grouping of other filters, and can be
useful when designing complex datum processing pipelines.