number is an entity that allows the user to input an arbitrary value to an integration. Derive entity platforms from
Properties should always only return information from memory and not do I/O (like network requests). Implement
async_update() to fetch data.
|device_class||string||Type of number.|
|mode||string||Defines how the number should be displayed in the UI. It's recommended to use the default |
|native_max_value||float||100||The maximum accepted value in the number's |
|native_min_value||float||0||The minimum accepted value in the number's |
|native_step||float||See below||Defines the resolution of the values, i.e. the smallest increment or decrement in the number's|
|native_value||float||Required||The value of the number in the number's |
|native_unit_of_measurement||string||None||The unit of measurement that the sensor's value is expressed in. If the |
Other properties that are common to all entities such as
name etc are also applicable.
The default step value is dynamically chosen based on the range (max - min) values. If the difference between max_value and min_value is greater than 1.0, then the default step is 1.0. If, however, the range is smaller, then the step is iteratively divided by 10 until it becomes lower than the range.
Available device classes
If specifying a device class, your number entity will need to also return the correct unit of measurement.
|None||Air Quality Index|
|cbar, bar, hPa, inHg, kPa, mbar, Pa, psi||Atmospheric pressure, statistics will be stored in Pa.|
|%||Percentage of battery that is left|
|ppm||Concentration of carbon dioxide.|
|ppm||Concentration of carbon monoxide.|
|bit/s, kbit/s, Mbit/s, Gbit/s, B/s, kB/s, MB/s, GB/s, KiB/s, MiB/s, GiB/s||Data rate|
|bit, kbit, Mbit, Gbit, B, kB, MB, GB, TB, PB, EB, ZB, YB, KiB, MiB, GiB, TiB, PiB, EiB, ZiB, YiB||Data size|
|km, m, cm, mm, mi, yd, in||Generic distance|
|Wh, kWh, MWh, MJ, GJ||Energy, this device class should used to represent energy consumption, for example an electricity meter. Represents power over time. Not to be confused with |
|Wh, kWh, MWh, MJ, GJ||Stored energy, this device class should be used to represent stored energy, for example the amount of electric energy currently stored in a battery or the capacity of a battery. Represents power over time. Not to be confused with |
|Hz, kHz, MHz, GHz||Frequency|
|m³, ft³, CCF||Volume of gas. Gas consumption measured as energy in kWh instead of a volume should be classified as energy.|
|ISO 4217||Monetary value with a currency.|
|µg/m³||Concentration of nitrogen dioxide|
|µg/m³||Concentration of nitrogen monoxide|
|µg/m³||Concentration of nitrous oxide|
|µg/m³||Concentration of ozone|
|None||Potential hydrogen (pH) of a aqueous solution|
|µg/m³||Concentration of particulate matter less than 1 micrometer|
|µg/m³||Concentration of particulate matter less than 2.5 micrometers|
|µg/m³||Concentration of particulate matter less than 10 micrometers|
|%, None||Power Factor|
|cm, in, mm||Precipitation|
|in/d, in/h, mm/d, mm/h||Precipitation intensity|
|cbar, bar, hPa, inHg, kPa, mbar, Pa, psi||Pressure.|
|dB, dBm||Signal strength|
|dB, dBA||Sound pressure|
|ft/s, in/d, in/h, km/h, kn, m/s, mph, mm/d||Generic speed|
|µg/m³||Concentration of sulphure dioxide|
|°C, °F, K||Temperature.|
|µg/m³||Concentration of volatile organic compounds|
|L, mL, gal, fl. oz., m³, ft³, CCF||Generic volume, this device class should be used to represent a consumption, for example the amount of fuel consumed by a vehicle.|
|L, mL, gal, fl. oz., m³, ft³, CCF||Generic stored volume, this device class should be used to represent a stored volume, for example the amount of fuel in a fuel tank.|
|L, gal, m³, ft³, CCF||Water consumption|
|kg, g, mg, µg, oz, lb, st||Generic mass; |
|ft/s, km/h, kn, m/s, mph||Wind speed|
Restoring number states
Numbers which restore the state after restart or reload should not extend
RestoreEntity because that does not store the
native_value, but instead the
state which may have been modifed by the number base entity. Numbers which restore the state should extend
RestoreNumber and call
await self.async_get_last_number_data from
async_added_to_hass to get access to the stored
Called when the user or an automation wants to update the value.
# Implement one of these methods.
def set_native_value(self, value: float) -> None:
"""Update the current value."""
async def async_set_native_value(self, value: float) -> None:
"""Update the current value."""