Skip to main content Link Search Menu Expand Document (external link)


Triggers specify what will cause the execution blocks to run. Multiple triggers can be defined within the same rule. This section only applies to file-based rules. Triggers for UI-based rules are specified through the UI.

Trigger Attachments

All triggers support event attachments that enable the association of an object to a trigger.

attachattach an object to a triggerchanged Switch, attach: ‘foo’

This enables one to use the same rule and take different actions if the trigger is different. The attached object is passed to the execution block through the event.attachment accessor.

Note: The trigger attachment feature is not available for UI rules.


rule 'Set Dark switch at sunrise and sunset' do
  channel 'astro:sun:home:rise#event', attach: OFF
  channel 'astro:sun:home:set#event', attach: ON
  run { |event| Dark << event.attachment }

Table of contents