Skip to content

Passive vs Active automations

Leonard Sperry edited this page Jan 4, 2025 · 3 revisions

V11.1

All automations in HaKafkaNet are passive unless specifically changed to "Active". Rarely should you need to use an active automation and are only needed in certain use cases. HaKafkaNet uses state changes to trigger automations. However, there are times you may have an entity that holds information needed to trigger automations, but the entity itself does not update very often. For example, if you have a "Date and/or Time" helper set to a specific time of day, and you want to trigger an automation at that time every day. The entity that is that helper will not update. You set it and forget it. Therefore, it never has a state change and wouldn't normally trigger an automation in HaKafkaNet. That is where "Active" automations are beneficial.

When an automation is active, an IAutomatinActivator (internally used) can actively trigger an automation instead of passively waiting for a state change. When the activator receives a request to trigger or activate an automation it does the following:

  1. It fetches the most recent state of all the entities used by the automation as a trigger.
  2. It uses the latest state of those to use as a state change to trigger the automation.
  3. If no state can be found, an exception is thrown.

Setting an automation to active causes the automation to be actively triggered at the following times:

  1. At startup, after initialization
  2. If the automation is IDelayableAutomation (all conditional and schedulable) after a delayed execution
Clone this wiki locally