triggers

triggers

Source:

Triggers namespace. This namespace allows creation of openHAB rule triggers.

It is possible to skip parameter configuration in triggers by using null.

Methods

(static) ChannelEventTrigger(channel, event, triggerNameopt)

Source:

Creates a trigger that fires upon specific events in a channel.

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) ItemStateChangeTrigger(itemName, oldStateopt, newStateopt, triggerNameopt)

Source:

Creates a trigger that fires upon an Item changing state.

Example
ItemStateChangeTrigger('my_item'); // changed
ItemStateChangeTrigger('my_item', 'OFF', 'ON'); // changed from OFF to ON
ItemStateChangeTrigger('my_item', null, 'ON'); // changed to ON
ItemStateChangeTrigger('my_item', 'OFF', null); // changed from OFF
Parameters:
Name Type Attributes Description
itemName string

the name of the Item to monitor for change

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(itemName, stateopt, triggerNameopt)

Source:

Creates a trigger that fires upon an Item receiving a state update. Note that the Item does not need to change state.

Example
ItemStateUpdateTrigger('my_item'); // received update
ItemStateUpdateTrigger('my_item', 'OFF'); // received update OFF
Parameters:
Name Type Attributes Description
itemName string

the name of the Item to monitor for change

state string <optional>

the new state of the Item

triggerName string <optional>

the optional name of the trigger to create

(static) ItemCommandTrigger(itemName, commandopt, triggerNameopt)

Source:

Creates a trigger that fires upon an Item receiving a command. Note that the Item does not need to change state.

Example
ItemCommandTrigger('my_item'); // received command
ItemCommandTrigger('my_item', 'OFF'); // received command OFF
Parameters:
Name Type Attributes Description
itemName string

the name of the Item to monitor for change

command string <optional>

the command received

triggerName string <optional>

the optional name of the trigger to create

(static) GroupStateChangeTrigger(groupName, oldStateopt, newStateopt, triggerNameopt)

Source:

Creates a trigger that fires upon a member of a group changing state.

Example
GroupStateChangeTrigger('my_group', 'OFF', 'ON');
Parameters:
Name Type Attributes Description
groupName string

the name of the group to monitor for change

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(groupName, stateopt, triggerNameopt)

Source:

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.

Example
GroupStateUpdateTrigger('my_group', 'OFF');
Parameters:
Name Type Attributes Description
groupName string

the name of the group to monitor for change

state string <optional>

the new state of the group

triggerName string <optional>

the optional name of the trigger to create

(static) GroupCommandTrigger(groupName, commandopt, triggerNameopt)

Source:

Creates a trigger that fires upon a member of a group receiving a command. Note that the group does not need to change state.

Example
GroupCommandTrigger('my_group', 'OFF');
Parameters:
Name Type Attributes Description
groupName string

the name of the group to monitor for change

command string <optional>

the command received

triggerName string <optional>

the optional name of the trigger to create

(static) ThingStatusUpdateTrigger(thingUID, statusopt, triggerNameopt)

Source:

Creates a trigger that fires upon an Thing status updating

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) ThingStatusChangeTrigger(thingUID, statusopt, previousStatusopt, triggerNameopt)

Source:

Creates a trigger that fires upon an Thing status changing

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) SystemStartlevelTrigger(startlevel, triggerNameopt)

Source:

Creates a trigger that fires if a given start level is reached by the system

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

the system start level to be triggered on

triggerName string <optional>

the optional name of the trigger to create

(static) GenericCronTrigger(expression, triggerNameopt)

Source:

Creates a trigger that fires on a cron schedule. The supplied cron expression defines when the trigger will fire.

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) TimeOfDayTrigger(time, triggerNameopt)

Source:

Creates a trigger that fires daily at a specific time. The supplied time defines when the trigger will fire.

Example
TimeOfDayTrigger('19:00');
Parameters:
Name Type Attributes Description
time string

the time expression defining the triggering schedule

triggerName string <optional>

the optional name of the trigger to create

(static) PWMTrigger(dutycycleItem, interval, minDutyCycleopt, maxDutyCycleopt, deadManSwitchopt, triggerNameopt)

Source:

Creates a trigger for the Pulse Width Modulation (PWM) Automation add-on.

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) PIDTrigger(inputItem, setpointItem, kp, ki, kd, kdTimeConstant, loopTime, commandItemopt, integralMinValueopt, integralMaxValueopt, pInspectorItemopt, iInspectorItemopt, dInspectorItemopt, errorInspectorItemopt, triggerNameopt)

Source:

Creates a trigger for the PID Controller Automation add-on.

Example
rules.JSRule({
  name: 'PID rule',
  triggers: [
    triggers.PIDTrigger('currentTemperature', 'targetTemperature', 1, 1, 1, 1, 10000, null, 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