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

<taskname>#<valuename> As described already, each task can produced one or more events, one for each measured value. You should not name your devices and value names so that the combination equals to any of the below listed system events!

on DHT11Outside#Temperature>20 do
 GPIO,2,1
endon

TaskInit#<taskname> Triggered when a tasks PLUGIN_INIT was called. This can happen at boot, when a task is enabled, or TaskEnable command is used.

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 PLUGIN_INIT call. The task index can be useful to store in a variable so the task index of a specific plugin like the dummy plugin can be stored to keep rules exchangeble among nodes regardless the order of tasks.

TaskExit#<taskname> Triggered when a tasks PLUGIN_EXIT was called. This can happen when entering deep sleep, when a task is disabled, or TaskDisable command is used.

on TaskExit#bme do
  LogEntry,'TaskExit task: %eventvalue1% result: %eventvalue2%'
endon

System#Wake Triggered after power on.

on System#Wake do
  GPIO,15,1
endon

System#Boot Triggered at boot time.

on System#Boot do
  GPIO,2,1
  timerSet,1,30
endon

System#Sleep Triggered just before the ESP goes to deep sleep.

on System#Sleep do
 GPIO,2,0
endon

MQTT#Connected Triggered when the ESP has connected to broker.

on MQTT#Connected do
 Publish,%sysname%/status,First message!
endon

MQTT#Disconnected Triggered when the ESP has disconnected from the broker.

on MQTT#Disconnected do
 Reboot
endon

MQTTimport#Connected Triggered when the ESP has connected to broker (the MQTT Import plugin uses a separate connection than the generic one).

on MQTTimport#Connected do
 Publish,%sysname%/status,MQTT Import is now operational
endon

MQTTimport#Disconnected Triggered when the ESP has disconnected from the broker (the MQTT Import plugin uses a separate connection than the generic one).

on MQTTimport#Disconnected do
 Reboot
endon

WiFi#Connected Triggered when the ESP has connected to Wi-Fi.

on WiFi#Connected do
 SendToHTTP,url.com,80,/report.php?hash=123abc456&t=[temp2#out]
endon

WiFi#ChangedAccesspoint Triggered when the ESP has changed to access point, will also trigger first time the unit connects to the Wi-Fi.

on WiFi#ChangedAccesspoint do
 Publish,%sysname%/status,AP changed
endon

WiFi#ChangedWiFichannel Triggered when the ESP is connected to the AP on a different channel, will also trigger first time the unit connects to the Wi-Fi. This has been added in build mega-20190910

on WiFi#ChangedWiFichannel do
 Publish,%sysname%/status,channel changed
endon

WiFi#APmodeEnabled Triggered when the ESP has set the AP mode (access point) active. This may happen when no valid WiFi settings are found or the ESP cannot connect to the set AP, but it can also be enabled via some command. N.B. Sending a publish command may not be very useful on this event, since this will mainly happen when there is no WiFi connection.

on WiFi#APmodeEnabled do
 ... // Some command
endon

WiFi#APmodeDisabled Triggered when the ESP has disabled the AP mode (access point). This can happen some time (default 60 seconds) after a WiFi connection has been made. Or disabled using some command.

on WiFi#APmodeDisabled do
 Publish,%sysname%/status,AP disabled
endon

Login#Failed Triggered when (someone) has tried to login to a ESP unit with admin password enabled, but have failed to enter correct password.

on Login#Failed do
 Publish,%sysname%/warning,Intruder alert!
endon

Time#Initialized Triggered the first time (after boot) NTP is updating the unit.

on Time#Initialized do
 Publish,%sysname%/Time,%systime%
endon

Time#Set Triggered when the time is set by an update from NTP.

on Time#Set do
 Publish,%sysname%/Time,%systime%
 Publish,%sysname%/NTP,Updated time at: %systime%
endon

Rules#Timer= As described already, triggered when a rules timer ends (setting a timer to 0 will disable the timer).

on Rules#Timer=1 do
 GPIO,2,1
endon

Clock#Time= Triggered every minute with day and time like: Mon,12:30 or Tue,14:45. You can define triggers on specific days or all days using ‘All’ for days indicator. You can also use wildcards in the time setting like All,**:00 to run every hour.

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

GPIO#N If the command ‘Monitor’ is used to monitor a given pin you will receive an event for that GPIO as soon as it’s state changes. As seen in the example you can always use the square brackets together with the task/value name of Plugin#GPIO#Pinstate#N to get the state, but to trigger events you need to add the monitor command (preferably at boot).

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.

P081 Generic - CRON

Event

Example

Cron#foo Will trigger when the cron expression of task named foo matches the current time.

on Cron#foo do
 GPIO,2,1 //LED on
endon

P082 Position - GPS

Event

Example

GPS#GotFix Will trigger when the GPS unit got a good position from the satellites.

on GPS#GotFix do
 GPIO,2,1 //LED on
endon

GPS#LostFix Will trigger when the GPS unit is not having a good position from the satellites.

on GPS#LostFix do
  GPIO,2,0 //LED off
endon

GPS#travelled When configured to update every N meters travelled, this event will be triggered if the GPS moved more than N meters away from the last position this trigger was given. This means the total travel distance can be more if the GPS does not move in a straight line.

on GPS#travelled do
  LogEntry,'Travelled %eventvalue% meter'
endon