Update 2024-11-08-number_selector.md

This commit is contained in:
epenet 2024-11-12 09:53:29 +01:00 committed by GitHub
parent 9fda1b71a8
commit 0796e9e441
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -12,31 +12,23 @@ Set this parameter in [config flows](/docs/data_entry_flow_index#show-form) to e
New implementation (using an integer step):
```python
vol.Schema(
{
vol.Optional(CONF_ADDRESS): NumberSelector(
NumberSelectorConfig(
min=1, max=255, mode=NumberSelectorMode.BOX, step=1
)
),
}
vol.Optional(CONF_ADDRESS): NumberSelector(
NumberSelectorConfig(
min=1, max=255, mode=NumberSelectorMode.BOX, step=1
)
)
```
Previous implementation (with explicit integer conversion):
```python
vol.Schema(
{
vol.Optional(CONF_ADDRESS): vol.All(
NumberSelector(
NumberSelectorConfig(
min=1, max=255, mode=NumberSelectorMode.BOX
)
),
vol.Coerce(int),
),
}
vol.Optional(CONF_ADDRESS): vol.All(
NumberSelector(
NumberSelectorConfig(
min=1, max=255, mode=NumberSelectorMode.BOX
)
),
vol.Coerce(int),
)
```