Difference between revisions of "ESPEasy System Variables"

From Let's Control It
Jump to navigation Jump to search
m (Added "leading zero" time/date system vars.)
 
(10 intermediate revisions by 2 users not shown)
Line 1: Line 1:
= system variables available =
+
To use other values than those created by sensors you need to go to system variables enclosed with "%". Not all of these can be used in rules tests (i.e. "=, >, <" etc.) since some of them output a string value and not a float. Which ones that are float are marked below.
 +
 
 +
= System variables available =
  
 
These can be used in templates for HTTP, MQTT, OLED and LCD displays and within rules. More uses of these system variables can be seen in the [[Tutorial_Rules|'''rules section''']] and [[EasyFormula|'''formula section''']].
 
These can be used in templates for HTTP, MQTT, OLED and LCD displays and within rules. More uses of these system variables can be seen in the [[Tutorial_Rules|'''rules section''']] and [[EasyFormula|'''formula section''']].
Line 7: Line 9:
 
! Example output
 
! Example output
 
! Extra information
 
! Extra information
 +
! Float output
 
|-
 
|-
  
Line 12: Line 15:
 
| ESP_Easy
 
| ESP_Easy
 
| Name as configured through the webgui.
 
| Name as configured through the webgui.
 +
|
 
|-
 
|-
  
Line 17: Line 21:
 
| 01:23:54
 
| 01:23:54
 
| Current time if NTP is enabled (hh:mm:ss, hh:mm prior to v2.0).
 
| Current time if NTP is enabled (hh:mm:ss, hh:mm prior to v2.0).
 +
|
 
|-
 
|-
  
Line 22: Line 27:
 
| 01:23
 
| 01:23
 
| Current time if NTP is enabled (hh:mm "old behavior").
 
| Current time if NTP is enabled (hh:mm "old behavior").
 +
|
 
|-
 
|-
  
Line 27: Line 33:
 
| 1:23:54 AM
 
| 1:23:54 AM
 
| Current AM/PM time if NTP is enabled (hh:mm:ss xM).
 
| Current AM/PM time if NTP is enabled (hh:mm:ss xM).
 +
|
 
|-
 
|-
  
Line 32: Line 39:
 
| 1:23 AM
 
| 1:23 AM
 
| Current AM/PM time if NTP is enabled (hh:mm:ss xM).
 
| Current AM/PM time if NTP is enabled (hh:mm:ss xM).
 +
|
 
|-
 
|-
  
 
| %lcltime%
 
| %lcltime%
| 2018-03-16 01:23:54
+
| 2020-03-16 01:23:54
 
| Current date/time if NTP is enabled (YYYY-MM-DD hh:mm:ss).
 
| Current date/time if NTP is enabled (YYYY-MM-DD hh:mm:ss).
 +
|
 +
|-
 +
 +
| %sunrise%
 +
| 5:04
 +
| Time of sunrise on current day, when NTP is active and coordinates set. If you want to postpone or trigger something earlier but still using the sunset/sunrise time as reference you can use this syntax: '''%sunrise+10m%''' or '''%sunset-1h%'''. Where the offset must be a integer with the prefix "m" for minutes or "h" for hours. Minus or plus is used to tell if the offset is prior or later than the sunset/sunrise. Any other letter positioned between the number and '%' is regarded as "seconds" notation.
 +
|
 +
|-
 +
 +
| %sunset%
 +
| 22:03
 +
| Time of sunset on current day, when NTP is active and coordinates set. For example on how to offset this time see the information for %sunrise%.
 +
|
 
|-
 
|-
  
 
| %lcltime_am%
 
| %lcltime_am%
| 2018-03-16 1:23:54 AM
+
| 2020-03-16 1:23:54 AM
 
| Current date/time (AM/PM) if NTP is enabled (YYYY-MM-DD hh:mm:ss xM).
 
| Current date/time (AM/PM) if NTP is enabled (YYYY-MM-DD hh:mm:ss xM).
 +
|
 
|-
 
|-
  
 
| %syshour%
 
| %syshour%
| 11
+
%syshour_0%
| Current hour (hh).
+
| 6
 +
06
 +
| Current hour (hh). %syshour% omits leading zeros.
 +
| Yes
 
|-
 
|-
  
 
| %sysmin%
 
| %sysmin%
| 22
+
%sysmin_0%
| Current minute (mm).
+
| 9
 +
09
 +
| Current minute (mm). %sysmin% omits leading zeros.
 +
| Yes
 
|-
 
|-
  
 
| %syssec%
 
| %syssec%
| 33
+
%syssec_0%
| Current second (ss).
+
| 5
 +
05
 +
| Current second (ss). %syssec% omits leading zeros.
 +
| Yes
 
|-
 
|-
  
 
| %sysday%
 
| %sysday%
| 16
+
%sysday_0%
| Current day of month (DD).
+
| 7
 +
07
 +
| Current day of month (DD). %sysday% omits leading zeros.
 +
| Yes
 
|-
 
|-
  
 
| %sysmonth%
 
| %sysmonth%
 +
%sysmonth_0%
 
| 3
 
| 3
 +
03
 
| Current month (MM).
 
| Current month (MM).
 +
| Yes
 
|-
 
|-
  
 
| %sysyear%
 
| %sysyear%
| 2018
+
%sysyear_0%
 +
| 2020
 +
2020
 
| 4 digits (YYYY).
 
| 4 digits (YYYY).
 +
| Yes
 
|-
 
|-
  
Line 77: Line 117:
 
| 18
 
| 18
 
| 2 digits (YY).
 
| 2 digits (YY).
 +
| Yes
 
|-
 
|-
  
Line 82: Line 123:
 
| 5
 
| 5
 
| Weekday (integer) - 1, 2, 3... (1=Sunday, 2=Monday etc.).
 
| Weekday (integer) - 1, 2, 3... (1=Sunday, 2=Monday etc.).
 +
| Yes
 
|-
 
|-
  
Line 87: Line 129:
 
| Fri
 
| Fri
 
| Weekday (verbose) - Sun, Mon, Tue...
 
| Weekday (verbose) - Sun, Mon, Tue...
 +
|
 +
|-
 +
 +
| %unixtime%
 +
| 1521731277
 +
| Unix time (seconds since epoch, 1970-01-01 00:00:00)<br>Example: 1521731277 = 2018-03-22 15:07:57
 +
| Yes
 
|-
 
|-
  
Line 92: Line 141:
 
| 3244
 
| 3244
 
| Uptime in minutes.
 
| Uptime in minutes.
 +
| Yes
 
|-
 
|-
  
Line 97: Line 147:
 
| -45
 
| -45
 
| WiFi signal strength (dBm).
 
| WiFi signal strength (dBm).
 +
| Yes
 
|-
 
|-
  
Line 102: Line 153:
 
| 192.168.0.123
 
| 192.168.0.123
 
| Current IP address.
 
| Current IP address.
 +
|
 
|-
 
|-
  
Line 107: Line 159:
 
| 32
 
| 32
 
| Unit number.
 
| Unit number.
 +
| Yes
 
|-
 
|-
  
Line 112: Line 165:
 
| H4XX0R njietwork!
 
| H4XX0R njietwork!
 
| Name of current WiFi.
 
| Name of current WiFi.
 +
|
 +
|-
 +
 +
| %bssid%
 +
| 00:15:E9:2B:99:3C
 +
| MAC of current AP.
 +
|
 +
|-
 +
 +
| %wi_ch%
 +
| 11
 +
| WiFi channel of current AP.
 +
| Yes
 
|-
 
|-
  
 
| %vcc%
 
| %vcc%
 
| 5.2
 
| 5.2
| VCC value, this is only available in the VCC versions of FW.
+
| VCC value, this is only available in the VCC versions of FW. If the variable output is "-1.0" it means that the VCC is not activated or that a reading has not been completed (could be due to incorrect cabling, interval set to "0", etc. etc.).
 +
| Yes
 
|-
 
|-
  
Line 122: Line 189:
 
| 00:14:22:01:23:45
 
| 00:14:22:01:23:45
 
| MAC address.
 
| MAC address.
 +
|
 
|-
 
|-
  
Line 127: Line 195:
 
| 2212667
 
| 2212667
 
| MAC address in integer to be used in rules (only the last 24 bit).
 
| MAC address in integer to be used in rules (only the last 24 bit).
 +
| Yes
 
|-
 
|-
  
 
|}
 
|}

Latest revision as of 17:57, 8 April 2020

To use other values than those created by sensors you need to go to system variables enclosed with "%". Not all of these can be used in rules tests (i.e. "=, >, <" etc.) since some of them output a string value and not a float. Which ones that are float are marked below.

System variables available

These can be used in templates for HTTP, MQTT, OLED and LCD displays and within rules. More uses of these system variables can be seen in the rules section and formula section.

Syntax Example output Extra information Float output
%sysname% ESP_Easy Name as configured through the webgui.
%systime% 01:23:54 Current time if NTP is enabled (hh:mm:ss, hh:mm prior to v2.0).
%systm_hm% 01:23 Current time if NTP is enabled (hh:mm "old behavior").
%systime_am% 1:23:54 AM Current AM/PM time if NTP is enabled (hh:mm:ss xM).
%systm_hm_am% 1:23 AM Current AM/PM time if NTP is enabled (hh:mm:ss xM).
%lcltime% 2020-03-16 01:23:54 Current date/time if NTP is enabled (YYYY-MM-DD hh:mm:ss).
%sunrise% 5:04 Time of sunrise on current day, when NTP is active and coordinates set. If you want to postpone or trigger something earlier but still using the sunset/sunrise time as reference you can use this syntax: %sunrise+10m% or %sunset-1h%. Where the offset must be a integer with the prefix "m" for minutes or "h" for hours. Minus or plus is used to tell if the offset is prior or later than the sunset/sunrise. Any other letter positioned between the number and '%' is regarded as "seconds" notation.
%sunset% 22:03 Time of sunset on current day, when NTP is active and coordinates set. For example on how to offset this time see the information for %sunrise%.
%lcltime_am% 2020-03-16 1:23:54 AM Current date/time (AM/PM) if NTP is enabled (YYYY-MM-DD hh:mm:ss xM).
%syshour%

%syshour_0%

6

06

Current hour (hh). %syshour% omits leading zeros. Yes
%sysmin%

%sysmin_0%

9

09

Current minute (mm). %sysmin% omits leading zeros. Yes
%syssec%

%syssec_0%

5

05

Current second (ss). %syssec% omits leading zeros. Yes
%sysday%

%sysday_0%

7

07

Current day of month (DD). %sysday% omits leading zeros. Yes
%sysmonth%

%sysmonth_0%

3

03

Current month (MM). Yes
%sysyear%

%sysyear_0%

2020

2020

4 digits (YYYY). Yes
%sysyears% 18 2 digits (YY). Yes
%sysweekday% 5 Weekday (integer) - 1, 2, 3... (1=Sunday, 2=Monday etc.). Yes
%sysweekday_s% Fri Weekday (verbose) - Sun, Mon, Tue...
%unixtime% 1521731277 Unix time (seconds since epoch, 1970-01-01 00:00:00)
Example: 1521731277 = 2018-03-22 15:07:57
Yes
%uptime% 3244 Uptime in minutes. Yes
%rssi% -45 WiFi signal strength (dBm). Yes
%ip% 192.168.0.123 Current IP address.
%unit% 32 Unit number. Yes
%ssid% H4XX0R njietwork! Name of current WiFi.
%bssid% 00:15:E9:2B:99:3C MAC of current AP.
%wi_ch% 11 WiFi channel of current AP. Yes
%vcc% 5.2 VCC value, this is only available in the VCC versions of FW. If the variable output is "-1.0" it means that the VCC is not activated or that a reading has not been completed (could be due to incorrect cabling, interval set to "0", etc. etc.). Yes
%mac% 00:14:22:01:23:45 MAC address.
%mac_int% 2212667 MAC address in integer to be used in rules (only the last 24 bit). Yes