Number - documentation is unclear how to use

I wanted to create a number in my esphome - which can be adjusted from the HA interface - but doesn’t have to be
a numbers seem to be what I want as it says “A number entity is like a sensor that can read a value from a device, but is useful when that value can be set by the user/frontend.”
But when I try and use this

number: 
  - platform: template
    name: "${solenoidname} Seconds Increment"
    icon: "mdi:water-plus"
    id: watering_${solenoidname}_Increment
    min_value: 0
    max_value: 9999999
    step: 1
    unit_of_measurement: seconds
    device_class: duration

I just keep getting errors which don’t seem to match the documentation
First it says must have min_value, max_value, step , none of which are on the documentation page - but clear enough to configure - although not documented that they are required
The last one though is

Either optimistic mode must be enabled, or set_action must be set, to handle the number being set.

I can’t find either optimistic or set_action on the documentation page - so I’m not sure what these are for - Is there different documentation that I should be using ?

Marvellous

and

I’m not sure what the difference is -

the one example in Number Component - ESPHome - Smart Home Made Simple is

number:
  - platform: template
    # ...

so it seems to be it is really a Template Number - ESPHome - Smart Home Made Simple

Number is the base component. Template number is a type of number component.

Just like sensor is the base component and an ADC sensor is a type of sensor component.

Individual component types have all the respective base options. It saves a lot of repetition.

They are all in the template number component configuration options. Right here: https://esphome.io/components/number/template/#configuration-variables

Note what the very last line says.

1 Like

So how to I create a number component - not a number template?
Or more likely how do I know I cannot create a number component ?

You don’t. As I said that is the base component. You need to create a “type” of number component. In this case a template number.

That is what all the configuration options you are missing are listed under as in the image I shared and linked to above.

I think you are getting hung up on the fact that the example shown in the documentation for this component does not have all the options in the example yaml. It is a simple example. You can still add more options to it from the list of valid ones.

Notice the difference in phrasing:

Number:

ESPHome has support for components to create a number entity.

Template number:

The template number platform allows you to create a number

Template number is a component.

set_action and optimistic_mode are the 2 mode options that establish how your number entity will function/behave whenever a number is set from the frontend so, without you instructing it by setting one of the two options then it doesnt know how its supposed to handle a number when someone sets a number.