-
Notifications
You must be signed in to change notification settings - Fork 0
Automation Metadata
The AutomationMetaData
model is used by the framework to display information in the UI about your automation and to track if it is enabled or not.
public record AutomationMetaData
{
public bool Enabled { get; set; } = true;
public required string Name { get; init; }
public string? Description { get; init;}
public string? KeyRequest { get; set; }
public IEnumerable<string>? AdditionalEntitiesToTrack { get; set; }
public bool TriggerOnBadState { get; set; } = false;
public string GivenKey { get; internal set; } = string.Empty;
public string? UnderlyingType { get; internal set; }
public bool IsDelayable { get; internal set; }
public string? Source { get; internal set; }
public DateTime? LastTriggered { get; internal set; }
public DateTime? LastExecuted { get; internal set; }
}
It is always optional to provide meta data. If you do not provide it, one will be created for you by default. Some of the properties are available internally to the framework only. They are used for display purposes to give you information about what they are and how the framework found them.
The first 5 properties are accessible to you. All of them are optional. Here is what they will be defaulted to
- Enabled - true
- Name -
GetType().Name
- Description -
GetType().FullName
- KeyRequest - If not specified by you, the framework will generate a unique key based on the name of your automation. This means that if you do not specify a name, the type will be used.
- AdditionalEntitiesToTrack - If you are using the System Monitor, any entities listed here will be tracked in addition to any trigger entities.
- TriggerOnBadState - When set to false, if the
Bad()
extension method returns true, your automation will not trigger. Otherwise, it will.
The rest of the properties are set internally by the framework.
Note: It is worth noting that the framework uses the
GivenKey
for several pieces of functionality. TheGivenKey
is generated based on theKeyRequest
which could be derived from the name of your automation or the type. Any changes causing a change to theGivenKey
will result in information from before the change to not be easily discoverable in the UI. Information will still exist in the cache for up to 30 days.
Depending on how you create your automations, there are three ways of setting metadata.
- If you implement either the
IAutomation
or one of theIDelayableAutomation
interfaces directly, you can define meta data by also implementing theIAutomationMeta
interface. An example can be found here. -
IAutomationFactory
- When creating automations using theIAutomationFactory
you can use theWithMeta()
extension method. An example can be found here. -
IAutomationBuilder
- The objects returned by theIAutomationBuilder
have extension methods for setting metadata. Example here