From 651ca3890e057b396f4744d6387159e2fbf4fecd Mon Sep 17 00:00:00 2001 From: Shulyaka Date: Wed, 2 Dec 2020 15:51:46 +0300 Subject: [PATCH] Add new number entity support (#712) --- docs/entity_number.md | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 docs/entity_number.md diff --git a/docs/entity_number.md b/docs/entity_number.md new file mode 100644 index 00000000..e2d681e1 --- /dev/null +++ b/docs/entity_number.md @@ -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.""" + +```