Template Number

The template number platform allows you to create a number with templated values using lambdas.

# Example configuration entry
number:
  - platform: template
    name: "Template number"
    update_interval: never
    min_value: 0
    max_value: 100
    step: 1

Configuration variables:

  • name (Required, string): The name of the number.

  • min_value (Required, float): The minimum value this number can be.

  • max_value (Required, float): The maximum value this number can be.

  • step (Required, float): The granularity with which the number can be set.

  • lambda (Optional, lambda): Lambda to be evaluated every update interval to get the new value of the number.

  • set_action (Optional, Action): The action that should be performed when the remote (like Home Assistant’s frontend) requests to set the number value.

  • update_interval (Optional, Time): The interval to check the number. Defaults to 60s.

  • optimistic (Optional, boolean): Whether to operate in optimistic mode - when in this mode, any command sent to the template number will immediately update the reported state. Cannot be used with lambda. Defaults to false.

  • restore_value (Optional, boolean): Saves and loads the state to RTC/Flash. Cannot be used with lambda. Defaults to false.

  • initial_value (Optional, float): The value to set the state to on setup if not restored with restore_value. Cannot be used with lambda. Defaults to min_value.

  • id (Optional, ID): Manually specify the ID used for code generation.

  • All other options from Number.

number.set Action

You can also publish a state to a template number from elsewhere in your YAML file with the number.set Action.

See Also