Euler's number: e

The e template constant provides the mathematical constant e (Euler’s number), approximately 2.71828. This is the base of the natural logarithm and appears throughout mathematics and science.

This is useful as the base for natural logarithm and exponential calculations in your templatesA template is an automation definition that can include variables for the action or data from the trigger values. This allows automations to generate dynamic actions. [Learn more]. For example, you might use it with the log function for natural logarithm calculations, or in exponential growth and decay formulas applied to sensorSensors return information about a thing, for instance the level of water in a tank. [Learn more] data.

Usage

Here’s how to use this template function. Copy any example and adjust it to your setup.

As a function
{{ e }}
Result (floatA number that can have decimal places, like 21.5 or 3.14. Used for temperatures, percentages, and other measurements that need precision.)
2.718281828459045

Good to know

  • This is a mathematical constant approximately equal to 2.71828.
  • Use it without parentheses. e is a value, not a function you call.

Try it yourself

Ready to test this? Open Developer tools > Template, paste the example into the Template editor, and watch the result update on the right. Edit the values to see how the function adapts to your own entitiesAn entity represents a sensor, actor, or function in Home Assistant. Entities are used to monitor physical properties or to control other entities. An entity is usually part of a device or a service. [Learn more].

More examples

Real scenarios where this function comes up in automations and templates. Copy any example and adapt it to your setup.

Natural logarithm verification

Verify that the natural logarithm of e is 1.

TemplateA template is an automation definition that can include variables for the action or data from the trigger values. This allows automations to generate dynamic actions. [Learn more]
{{ log(e) }}
Result (floatA number that can have decimal places, like 21.5 or 3.14. Used for temperatures, percentages, and other measurements that need precision.)
1.0

Still stuck?

The Home Assistant community is quick to help: join Discord for real-time chat, post on the community forum with your template and expected result, or share on our subreddit /r/homeassistant.

Tip

AI assistants like ChatGPT or Claude can also explain or fix templates when you describe what you want in plain language.

Related template functions

These functions work well alongside this one:

  • Pi: pi - The mathematical constant pi, approximately 3.14159.

  • Tau: tau - The mathematical constant tau (2 * pi), approximately 6.28318.

  • Logarithm: log - Returns the logarithm of a value with an optional base (default is natural logarithm).