Event Reference¶
Here’s a list of all available events that may be triggered. Please be aware that only some will trigger, depending on what settings you have selected, and what plugins you have active.
Internal (core) events¶
Event |
Example |
---|---|
|
on DHT11Outside#Temperature>20 do
GPIO,2,1
endon
|
|
on TaskInit#bme do
LogEntry,'TaskInit task: %eventvalue1% result: %eventvalue2%'
endon
The first event value is the task index, the second event value is the return value of the |
|
on TaskExit#bme do
LogEntry,'TaskExit task: %eventvalue1% result: %eventvalue2%'
endon
|
|
on TaskError#bme do
LogEntry,'TaskError task: %eventvalue1% result: %eventvalue2%'
endon
The first event value is the task index, the second event value is a plugin specific indicator of the error that occured. N.B. The second event value can be a string. |
|
on System#Wake do
GPIO,15,1
endon
|
On ESP32-series only. Event is sent right before network connection is attempted. On normal boots (GPIO-0 is high), the ESP32 can record the state of a number of pins and make these available after boot in the |
on System#BootMode do
LogEntry,'Boot pins: GPIO-5: %eventvalue1%, GPIO-15: %eventvalue2%, GPIO-4: %eventvalue3%, GPIO-2: %eventvalue4%'
endon
For the classic ESP32, the event values represent the state of these pins in the following order:
The standard BootMode event will be: N.B. When pulling down GPIO-15 during boot, the ROM bootloader messages will be silenced. N.B.2 Do not pull GPIO-2 high when GPIO-0 is low for programming mode. See ‘Boot Strapping Pins’ documentation for the boot strapping pins for all ESP32-series chips. |
|
on System#Boot do
GPIO,2,1
timerSet,1,30
endon
|
|
on System#Sleep do
GPIO,2,0
endon
|
|
on http#192.168.1.2 do
if %eventvalue1%!=200
// %eventvalue1% is HTTP Code
// %eventpar% is the part of the event after the #, thus here it is the hostname
LogEntry,'HTTP error: %eventvalue1% to: %eventpar%:'
endif
endon
|
|
on MQTT#Connected do
Publish,%sysname%/status,First message!
endon
|
|
on MQTT#Disconnected do
Reboot
endon
|
|
on MQTTimport#Connected do
Publish,%sysname%/status,MQTT Import is now operational
endon
|
|
on MQTTimport#Disconnected do
Reboot
endon
|
Added: 2024-05-01 Triggered when a new ESPEasy p2p node has been seen. N.B. Only for nodes with a valid unit ID (not 0) Eventvalues:
|
on p2pNode#Connected do
LogEntry,'ESPEasy p2p node %eventvalue1% added: %eventvalue2% with build %eventvalue3%'
endon
|
Added: 2024-05-01 Triggered when a ESPEasy p2p node has been removed from the nodes list. N.B. Only for nodes with a valid unit ID (not 0) Eventvalues:
|
on p2pNode#Disconnected do
LogEntry,`ESPEasy p2p node %eventvalue1% not seen for a while`
endon
|
|
on WiFi#Connected do
SendToHTTP,url.com,80,/report.php?hash=123abc456&t=[temp2#out]
endon
|
|
On WiFi#Disconnected Do
LongPulse,2,1,1,1,-1 // 0.5 Hz flashing of WiFi led
Endon
On WiFi#Connected Do
GPIO,2,1 // Turn off WiFi led
SendToHTTP,url.com,80,/report.php?hash=123abc456&t=[temp2#out]
Endon
|
|
on WiFi#ChangedAccesspoint do
Publish,%sysname%/status,AP changed
endon
|
|
on WiFi#ChangedWiFichannel do
Publish,%sysname%/status,channel changed
endon
|
|
on WiFi#APmodeEnabled do
... // Some command
endon
|
|
on WiFi#APmodeDisabled do
Publish,%sysname%/status,AP disabled
endon
|
|
on Login#Failed do
Publish,%sysname%/warning,Intruder alert!
endon
|
|
on Time#Initialized do
Publish,%sysname%/Time,%systime%
endon
|
|
on Time#Set do
Publish,%sysname%/Time,%systime%
Publish,%sysname%/NTP,Updated time at: %systime%
endon
|
|
on Rules#Timer=1 do
GPIO,2,1
endon
|
For handling events to only be executed on weekdays (Mon..Fri), the day indicator ‘Wrk’ (work) can be used, and for weekend days (Sat, Sun), the day indicator ‘Wkd’ is available. |
on Clock#Time=All,12:00 do //will run once a day at noon
GPIO,2,1
endon
on Clock#Time=All,**:30 do //will run half past every hour
GPIO,2,1
endon
on Clock#Time=All,%sunrise% do //will run at sunrise (%sunset% is also available)
GPIO,2,1
endon
|
|
on System#Boot do
Monitor GPIO,15
endon
on GPIO#15=0 do
if [Plugin#GPIO#Pinstate#13]=0
// do something
endif
endon
on GPIO#15=1 do
if [Plugin#GPIO#Pinstate#13]=1
// do something
endif
endon
|
Plugin based events¶
Besides the internal events there’s also plugin specific events. These are listed here below.
P000 (core) Buzzer (RTTTL)¶
Event |
Example |
---|---|
|
on RTTTL#Started do
GPIO,13,1 // Turn on LED while playing a song
endon
|
|
on RTTTL#Finished do
GPIO,13,0 // Turn off LED after playing a song
event,nextSong // Select the next song to play
endon
|
|
on RTTTL#Cancelled do
GPIO,13,0 // Turn off LED
endon
|
P036 Display - OLED SSD1306/SH1106 Framed¶
Event |
Example |
---|---|
|
|
|
|
|
|
|
|
|
P037 Generic - MQTT Import¶
Event |
Example |
---|---|
|
on MQTTimport#Value1 do
GPIO,2,%eventvalue% // Turn on based on an MQTT message
endon
When option Generate events for accepted topics is enabled: on MQTTimport#Value1=on do
event,switchToggle // See next example
endon
|
Should best be used combined with the Filtering option. |
on domoticz/in#svalue do
TaskValueSet,2,1,%eventvalue%
endon
on zigbee2mqtt/eria_dimswitch_1#action=on do
event,switchToggle
endon
on switchToggle do // Sonoff switch here
if [Relay#State]=1
gpio,12,0 // Relay off
else
gpio,12,1 // Relay on
endif
endon
|
P043 Output - Clock¶
Event |
Example |
---|---|
If no GPIO is configured and ‘Value input On/Off only’ is unchecked, the configured value is provided as Events are only generated if the value is not set to 0 or empty. |
P053 Dust - PMSx003 / PMSx003ST¶
Event |
Example |
---|---|
A task named |
on foo#Humi do
if %eventvalue1% > 90
GPIO,2,1 //LED on
else
GPIO,2,0 //LED off
endif
endon
|
A task named |
on foo#HCHO do
if %eventvalue1% > 0.1
GPIO,2,1 //LED on
else
GPIO,2,0 //LED off
endif
endon
|
A task named |
on foo#cnt1.0 do
if %eventvalue1% > 300
GPIO,2,1 //LED on
else
GPIO,2,0 //LED off
endif
endon
|
A task named |
on foo#pm1.0 do
if %eventvalue1% > 300
GPIO,2,1 //LED on
else
GPIO,2,0 //LED off
endif
endon
|
Note
PMxx
values relate to particles less than or equal to said size, while count/100ml relates to particles of at least said size.
Except when “Split count bins” is checked, then the “count/0.1L” values represent only a single bin.
P064 Gesture - APDS9960¶
Event |
Example |
---|---|
|
Will trigger when the configuration option Separate Gesture events is enabled. These values are the same for the |
P080 Switch input - iButton¶
Event |
Example |
---|---|
|
This event is generated when the Event with iButton address setting is enabled, and no Device Address is selected (None). As the iButton address is in fact a 64 bit value (though only 57 bits are used), this value is too large to be stored in a regular variable in the rules, so they are split into 2 parts, as often sets of iButtons are produced in the same batch, where the higher bits are the same, and only the lower bits vary. These numbers can be processed, f.e. in a lookup table, similar to the example Validate a RFID tag against a sorted list (though somewhat different…) Simply logging the data could look like this: On iButton#Address Do
Let,1,%eventvalue2%
Let,2,%eventvalue3%
LogEntry,'iButton %eventvalue2%_%eventvalue3% = %eventvalue1% (%v1% / %v2%)'
Endon
|
P081 Generic - CRON¶
Event |
Example |
---|---|
|
on Cron#foo do
GPIO,2,1 //LED on
endon
|
P082 Position - GPS¶
Event |
Example |
---|---|
|
on GPS#GotFix do
GPIO,2,1 //LED on
endon
|
|
on GPS#LostFix do
GPIO,2,0 //LED off
endon
|
|
on GPS#travelled do
LogEntry,'Travelled %eventvalue% meter'
endon
|
P097 Internal - Touch ESP32¶
Event |
Example |
---|---|
The regular events like in every other task. Only difference here is that you may have an event either when the touch pad is touched, released or both. |
on touch#Touch do
GPIO,2,1 //LED on
endon
|
When enabled, this event will be sent on release of the touch pad. The event variable is the time in msec the pad had been touched. |
on touch#Duration do
LogEntry,'Touch Duration %eventvalue% ms'
endon
Example in the log: 6553261 : Info : Touch : ADC2 ch5 (T5): 10
6553338 : Info : EVENT: touch#Touch=10.00
6553638 : Info : EVENT: touch#Duration=460
6553653 : Info : ACT : LogEntry,'Touch Duration 460 ms'
6553654 : Info : Command: LogEntry
6553655 : Info : Touch Duration 460 ms
|
P098 Motor - PWM Motor¶
Event |
Example |
---|---|
Limit switch A is reached |
If limit switch A is configured, then this event will be generated once the switch is reached. |
Limit switch B is reached |
If limit switch B is configured, then this event will be generated once the switch is reached. |
Requested position is reached |
After a command |
A time-out has occurred. |
The command took longer then the configured time-out duration, causing this event to be generated. |
P099 Touch - XPT2046 touchscreen on TFT display¶
Event |
Example |
---|---|
The regular events like in every other task. It is fired if the configuration is set to send events for objectnames. Has 3 eventvalues, the X, Y and Z values of the touch event. When the setting On/Off button is checked for a touchobject, then the new state (On or Off) will be sent as the only |
on System#Boot do
let,1,0
let,2,0
endon
// With debouncing in the script
on XPT2046#sun do
if %v2%=0
let,2,1
if %v1%=0
let,1,1
else
let,1,0
endif
timerSet_ms,1,300 // Debouncing timer
endif
endon
on Rules#Timer=1 do
if %v2%=1
if %v1%=1
GPIO,2,1 //LED on
else
GPIO,2,0 //LED off
endif
let,2,0
endif
endon
// Alternatively, using the On/Off button setting, the on/off state can also be inverted, if desired.
on XPT2046#sun do
GPIO,2,%eventvalue%
endon
|
When enabled, these events will be sent on touch of the touchscreen. The event variable is the current x/y/z value of the touched position. |
on XPT2046#X do
LogEntry,'Touch X position %eventvalue%'
endon
on XPT2046#Y do
LogEntry,'Touch Y position %eventvalue%'
endon
on XPT2046#Z do
LogEntry,'Touch Z pressure %eventvalue%'
endon
|
P115 Energy - MAX1704x¶
Event |
Description |
---|---|
|
Alert is triggered for a task running |
P123 Touch - I2C Touchscreens¶
P129 Input - Shift registers (74HC165)¶
Event |
Extra information |
---|---|
<taskname>=<state>,<chip>,<port>,<pin> state : 0 or 1 .chip : range 1..16, depending on the number of chips configured.port : range 1..8.pin : range 1..128, depending on the number of chips configured. |
Generic event for each activated input pin, that is enabled in the Event configuration matrix.
Generated if Separate events per pin is unchecked/disabled.
|
<taskname>#<pin>=<state>,<chip>,<port>,<pin> state : 0 or 1 .chip : range 1..16, depending on the number of chips configured.port : range 1..8.pin : range 1..128, depending on the number of chips configured. |
Generic event for each activated input pin, that is enabled in the Event configuration matrix.
Generated if Separate events per pin is enabled.
|
<taskname>#<valuename>=[<decimalvalue>][,][<hex/binvalue>] Values provided depend on the setting Output selection.
|
The generic event per Value
State_A .. State_D , that are available, depending on the number of chips configured.Only sent if Interval is greater than 0, or an explicit
TaskRun command for this task is executed. |
P138 Power mgt - IP5306 Power management¶
Event |
Extra information |
---|---|
<taskname>#PowerChanged=<source> source : 0 (Battery power) or 1 (External / USB power). |
Event generated when the Event on PowerSource change is enabled.
|
P143 Switch input - I2C Rotary encoders¶
Event |
Extra information |
---|---|
<taskname>#Counter=<counter>,<delta> counter : Current counter value.delta : Change of counter from previous position. |
This event is generated on every change of the rotary encoder. Because the encoder can be rotated rather quick, the delta since the previous reading is calculated. If the value is below 0 the encoder is turned counter-clockwise, and when delta is positive, the rotation is clockwise.
|
<taskname>#State=<state> state : Current state value. Possible values: 0, 1, 10, 11. 0 and 1 for regulat button states, 10 and 11 for longpress states. |
This event is generated on buttonpress action. Depending on the action defined, either the button-down and button-up cause this event (Pushbutton), or when the state is changed (Toggle switch).
|
P170 Input - I2C Liquid level sensor¶
Event |
Extra information |
---|---|
<taskname>#LowLevel=<level> <level> : Current level value. |
This event is generated if the level goes below the set Trigger on Low level value (5..100 mm), and is repeated every Interval seconds (or 1 sec. if Interval is 0). When Trigger only once is set, only a single event will be generated, until the measured level rises above the configured level and goes below that again.
|
<taskname>#HighLevel=<level> <level> : Current level value. |
This event is generated if the level rises above the set Trigger on High level value (5..100 mm), and is repeated every Interval seconds (or 1 sec. if Interval is 0). When Trigger only once is set, only a single event will be generated, until the measured level goes below the configured level and rises above that again.
|