Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions docs/entity_number.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
title: Number Entity
sidebar_label: Number
---

A `number` is an entity that allows the user to input an arbitrary value to an integration. Derive entity platforms from [`homeassistant.components.number.NumberEntity`](https://github.com/home-assistant/home-assistant/blob/master/homeassistant/components/number/__init__.py)

## Properties

> Properties should always only return information from memory and not do I/O (like network requests). Implement `update()` or `async_update()` to fetch data.

| Name | Type | Default | Description
| ---- | ---- | ------- | -----------
| state | float | **Required** | Current value of the entity
| min_value | float | 0 | The minimum accepted value (inclusive)
| max_value | float | 100 | The maximum accepted value (inclusive)
| step | float | **See below** | Defines the resolution of the values, i.e. the smallest increment or decrement

Other properties that are common to all entities such as `icon`, `unit_of_measurement`, `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 devided by 10 until it becomes lower than the range.

## Methods

### Set value

Called when the user or automation wants to update the value.

```python
class MyNumber(NumberEntity):
# Implement one of these methods.

def set_value(self, value: float) -> None:
"""Update the current value."""

async def async_set_value(self, value: float) -> None:
"""Update the current value."""

```