triggers
- Description:
 Triggers namespace. This namespace allows creation of openHAB rule triggers.
It is possible to skip parameter configuration in triggers by using
undefined.
- Source:
 
Methods
(static) ChannelEventTrigger(channel, event, triggerNameopt)
- Description:
 Creates a trigger that fires upon specific events in a channel.
- Source:
 
Example
ChannelEventTrigger('astro:sun:local:rise#event', 'START');
    Parameters:
| Name | Type | Attributes | Description | 
|---|---|---|---|
channel | 
            
            string | the name of the channel  | 
        |
event | 
            
            string | the name of the event to listen for  | 
        |
triggerName | 
            
            string | 
                
                    <optional> | 
            
            
            the optional name of the trigger to create  | 
        
(static) DateTimeTrigger(itemOrName, timeOnlyopt, offsetopt, triggerNameopt)
- Description:
 Creates a trigger that fires at an (optional) date and time specified in a DateTime Item.
- Source:
 
Example
DateTimeTrigger('MyDateTimeItem');
    Parameters:
| Name | Type | Attributes | Default | Description | 
|---|---|---|---|---|
itemOrName | 
            
            Item | string | the   | 
        ||
timeOnly | 
            
            boolean | 
                
                    <optional> | 
            
            
                
                
                    false
                
                 | 
            
            Specifies whether only the time of the DateTime Item should be compared or the date and time.  | 
        
offset | 
            
            number | 
                
                    <optional> | 
            
            
                
                
                    0
                
                 | 
            
            The offset in seconds to add to the time of the DateTime Item  | 
        
triggerName | 
            
            string | 
                
                    <optional> | 
            
            
                the optional name of the trigger to create  | 
        
(static) GenericCronTrigger(expression, triggerNameopt)
- Description:
 Creates a trigger that fires on a cron schedule. The supplied cron expression defines when the trigger will fire.
- Source:
 
Example
GenericCronTrigger('0 30 16 * * ? *');
    Parameters:
| Name | Type | Attributes | Description | 
|---|---|---|---|
expression | 
            
            string | the cron expression defining the triggering schedule  | 
        |
triggerName | 
            
            string | 
                
                    <optional> | 
            
            
            the optional name of the trigger to create  | 
        
(static) GenericEventTrigger(eventTopic, eventSource, eventTypes, triggerNameopt)
- Description:
 Creates a trigger that fires upon a matching event from the event bus.
Please have a look at the Event Bus docs to learn about events.
- Source:
 
Example
// Triggers when an Item is added or removed
GenericEventTrigger('openhab/items/**', '', ['ItemAddedEvent', 'ItemRemovedEvent'])
// Triggers when the Item "OutdoorLights" is commanded by expire
GenericEventTrigger('openhab/items/OutdoorLights/*', 'org.openhab.core.expire', 'ItemCommandEvent')
    Parameters:
(static) GroupCommandTrigger(groupOrName, commandopt, triggerNameopt)
- Description:
 Creates a trigger that fires upon a member of a group receiving a command. Note that the group Item does not need to change state.
- Source:
 
Example
GroupCommandTrigger('my_group', 'OFF');
    Parameters:
| Name | Type | Attributes | Description | 
|---|---|---|---|
groupOrName | 
            
            Item | string | the group   | 
        |
command | 
            
            string | 
                
                    <optional> | 
            
            
            the command received  | 
        
triggerName | 
            
            string | 
                
                    <optional> | 
            
            
            the optional name of the trigger to create  | 
        
(static) GroupStateChangeTrigger(groupOrName, oldStateopt, newStateopt, triggerNameopt)
- Description:
 Creates a trigger that fires upon a member of a group changing state. Note that group Item does not need to change state.
- Source:
 
Example
GroupStateChangeTrigger('my_group', 'OFF', 'ON');
    Parameters:
| Name | Type | Attributes | Description | 
|---|---|---|---|
groupOrName | 
            
            Item | string | the group   | 
        |
oldState | 
            
            string | 
                
                    <optional> | 
            
            
            the previous state of the group  | 
        
newState | 
            
            string | 
                
                    <optional> | 
            
            
            the new state of the group  | 
        
triggerName | 
            
            string | 
                
                    <optional> | 
            
            
            the optional name of the trigger to create  | 
        
(static) GroupStateUpdateTrigger(groupOrName, stateopt, triggerNameopt)
- Description:
 Creates a trigger that fires upon a member of a group receiving a state update. Note that group Item does not need to change state.
- Source:
 
Example
GroupStateUpdateTrigger('my_group', 'OFF');
    Parameters:
| Name | Type | Attributes | Description | 
|---|---|---|---|
groupOrName | 
            
            Item | string | the group   | 
        |
state | 
            
            string | 
                
                    <optional> | 
            
            
            the new state of the group  | 
        
triggerName | 
            
            string | 
                
                    <optional> | 
            
            
            the optional name of the trigger to create  | 
        
(static) ItemCommandTrigger(itemOrName, commandopt, triggerNameopt)
- Description:
 Creates a trigger that fires upon an Item receiving a command. Note that the Item does not need to change state.
- Source:
 
Example
ItemCommandTrigger('my_item'); // received command
ItemCommandTrigger('my_item', 'OFF'); // received command OFF
    Parameters:
| Name | Type | Attributes | Description | 
|---|---|---|---|
itemOrName | 
            
            Item | string | the   | 
        |
command | 
            
            string | 
                
                    <optional> | 
            
            
            the command received  | 
        
triggerName | 
            
            string | 
                
                    <optional> | 
            
            
            the optional name of the trigger to create  | 
        
(static) ItemStateChangeTrigger(itemOrName, oldStateopt, newStateopt, triggerNameopt)
- Description:
 Creates a trigger that fires upon an Item changing state.
- Source:
 
Example
ItemStateChangeTrigger('my_item'); // changed
ItemStateChangeTrigger('my_item', 'OFF', 'ON'); // changed from OFF to ON
ItemStateChangeTrigger('my_item', undefined, 'ON'); // changed to ON
ItemStateChangeTrigger('my_item', 'OFF', undefined); // changed from OFF
    Parameters:
| Name | Type | Attributes | Description | 
|---|---|---|---|
itemOrName | 
            
            Item | string | the   | 
        |
oldState | 
            
            string | 
                
                    <optional> | 
            
            
            the previous state of the Item  | 
        
newState | 
            
            string | 
                
                    <optional> | 
            
            
            the new state of the Item  | 
        
triggerName | 
            
            string | 
                
                    <optional> | 
            
            
            the optional name of the trigger to create  | 
        
(static) ItemStateUpdateTrigger(itemOrName, stateopt, triggerNameopt)
- Description:
 Creates a trigger that fires upon an Item receiving a state update. Note that the Item does not need to change state.
- Source:
 
Example
ItemStateUpdateTrigger('my_item'); // received update
ItemStateUpdateTrigger('my_item', 'OFF'); // received update OFF
    Parameters:
| Name | Type | Attributes | Description | 
|---|---|---|---|
itemOrName | 
            
            Item | string | the   | 
        |
state | 
            
            string | 
                
                    <optional> | 
            
            
            the new state of the Item  | 
        
triggerName | 
            
            string | 
                
                    <optional> | 
            
            
            the optional name of the trigger to create  | 
        
(static) PIDTrigger(inputItem, setpointItem, kp, ki, kd, kdTimeConstant, loopTime, commandItemopt, integralMinValueopt, integralMaxValueopt, pInspectorItemopt, iInspectorItemopt, dInspectorItemopt, errorInspectorItemopt, triggerNameopt)
- Description:
 Creates a trigger for the PID Controller Automation add-on.
- Source:
 
Example
rules.JSRule({
  name: 'PID rule',
  triggers: [
    triggers.PIDTrigger('currentTemperature', 'targetTemperature', 1, 1, 1, 1, 10000, undefined, 1, 100);
  ],
  execute: (event) => {
    // Look out what the max value for your Item is!
    const command = parseInt(event.receivedCommand) > 100 ? '100' : event.receivedCommand;
    items.getItem('thermostat').sendCommand(command);
  }
});
    Parameters:
| Name | Type | Attributes | Default | Description | 
|---|---|---|---|---|
inputItem | 
            
            string | name of the input Item (e.g. temperature sensor value)  | 
        ||
setpointItem | 
            
            string | name of the setpoint Item (e.g. desired room temperature)  | 
        ||
kp | 
            
            number | 
                
                    1
                
                 | 
            
            P: Proportional Gain parameter  | 
        |
ki | 
            
            number | 
                
                    1
                
                 | 
            
            I: Integral Gain parameter  | 
        |
kd | 
            
            number | 
                
                    1
                
                 | 
            
            D: Deritative Gain parameter  | 
        |
kdTimeConstant | 
            
            number | 
                
                    1
                
                 | 
            
            D-T1: Derivative Gain Time Constant in sec  | 
        |
loopTime | 
            
            number | 
                
                    1000
                
                 | 
            
            The interval the output value will be updated in milliseconds. Note: the output will also be updated when the input value or the setpoint changes.  | 
        |
commandItem | 
            
            string | 
                
                    <optional> | 
            
            
                Name of the item to send a String "RESET" to reset the I- and the D-part to 0.  | 
        |
integralMinValue | 
            
            number | 
                
                    <optional> | 
            
            
                The I-part will be limited (min) to this value.  | 
        |
integralMaxValue | 
            
            number | 
                
                    <optional> | 
            
            
                The I-part will be limited (max) to this value.  | 
        |
pInspectorItem | 
            
            string | 
                
                    <optional> | 
            
            
                name of the debug Item for the current P-part  | 
        |
iInspectorItem | 
            
            string | 
                
                    <optional> | 
            
            
                name of the debug Item for the current I-part  | 
        |
dInspectorItem | 
            
            string | 
                
                    <optional> | 
            
            
                name of the debug Item for the current D-part  | 
        |
errorInspectorItem | 
            
            string | 
                
                    <optional> | 
            
            
                name of the debug Item for the current regulation difference (error)  | 
        |
triggerName | 
            
            string | 
                
                    <optional> | 
            
            
                the optional name of the trigger to create  | 
        
(static) PWMTrigger(dutycycleItem, interval, minDutyCycleopt, maxDutyCycleopt, deadManSwitchopt, triggerNameopt)
- Description:
 Creates a trigger for the Pulse Width Modulation (PWM) Automation add-on.
- Source:
 
Example
rules.JSRule({
  name: 'PWM rule',
  triggers: [
    triggers.PWMTrigger('pwm_dimmer', 10);
  ],
  execute: (event) => {
    items.getItem('pwm_switch').sendCommand(event.receivedCommand);
  }
});
    Parameters:
| Name | Type | Attributes | Description | 
|---|---|---|---|
dutycycleItem | 
            
            string | Item (PercentType) to read the duty cycle from  | 
        |
interval | 
            
            number | constant interval in which the output is switch ON and OFF again (in sec)  | 
        |
minDutyCycle | 
            
            number | 
                
                    <optional> | 
            
            
            any duty cycle below this value will be increased to this value  | 
        
maxDutyCycle | 
            
            number | 
                
                    <optional> | 
            
            
            any duty cycle above this value will be decreased to this value  | 
        
deadManSwitch | 
            
            number | 
                
                    <optional> | 
            
            
            output will be switched off, when the duty cycle is not updated within this time (in ms)  | 
        
triggerName | 
            
            string | 
                
                    <optional> | 
            
            
            the optional name of the trigger to create  | 
        
(static) SystemStartlevelTrigger(startlevel, triggerNameopt)
- Description:
 Creates a trigger that fires if a given start level is reached by the system
- Source:
 
Example
SystemStartlevelTrigger(40)  // Rules loaded
SystemStartlevelTrigger(50)  // Rule engine started
SystemStartlevelTrigger(70)  // User interfaces started
SystemStartlevelTrigger(80)  // Things initialized
SystemStartlevelTrigger(100) // Startup Complete
    Parameters:
| Name | Type | Attributes | Description | 
|---|---|---|---|
startlevel | 
            
            string | number | the system start level to be triggered on  | 
        |
triggerName | 
            
            string | 
                
                    <optional> | 
            
            
            the optional name of the trigger to create  | 
        
(static) ThingStatusChangeTrigger(thingUID, statusopt, previousStatusopt, triggerNameopt)
- Description:
 Creates a trigger that fires upon a Thing status changing.
- Source:
 
Example
ThingStatusChangeTrigger('some:thing:uuid', 'ONLINE', 'OFFLINE');
    Parameters:
| Name | Type | Attributes | Description | 
|---|---|---|---|
thingUID | 
            
            string | the name of the thing to monitor for a status change  | 
        |
status | 
            
            string | 
                
                    <optional> | 
            
            
            the optional status to monitor for  | 
        
previousStatus | 
            
            string | 
                
                    <optional> | 
            
            
            the optional previous state to monitor from  | 
        
triggerName | 
            
            string | 
                
                    <optional> | 
            
            
            the optional name of the trigger to create  | 
        
(static) ThingStatusUpdateTrigger(thingUID, statusopt, triggerNameopt)
- Description:
 Creates a trigger that fires upon a Thing status updating.
- Source:
 
Example
ThingStatusUpdateTrigger('some:thing:uuid', 'OFFLINE');
    Parameters:
| Name | Type | Attributes | Description | 
|---|---|---|---|
thingUID | 
            
            string | the name of the thing to monitor for a status updating  | 
        |
status | 
            
            string | 
                
                    <optional> | 
            
            
            the optional status to monitor for  | 
        
triggerName | 
            
            string | 
                
                    <optional> | 
            
            
            the optional name of the trigger to create  | 
        
(static) TimeOfDayTrigger(time, triggerNameopt)
- Description:
 Creates a trigger that fires daily at a specific time. The supplied time defines when the trigger will fire.
- Source:
 
Example
TimeOfDayTrigger('19:00');
    Parameters:
| Name | Type | Attributes | Description | 
|---|---|---|---|
time | 
            
            string | the time expression (in   | 
        |
triggerName | 
            
            string | 
                
                    <optional> | 
            
            
            the optional name of the trigger to create  |