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): New implementation (using an integer step):
```python ```python
vol.Schema( vol.Optional(CONF_ADDRESS): NumberSelector(
{
vol.Optional(CONF_ADDRESS): NumberSelector(
NumberSelectorConfig( NumberSelectorConfig(
min=1, max=255, mode=NumberSelectorMode.BOX, step=1 min=1, max=255, mode=NumberSelectorMode.BOX, step=1
) )
),
}
) )
``` ```
Previous implementation (with explicit integer conversion): Previous implementation (with explicit integer conversion):
```python ```python
vol.Schema( vol.Optional(CONF_ADDRESS): vol.All(
{
vol.Optional(CONF_ADDRESS): vol.All(
NumberSelector( NumberSelector(
NumberSelectorConfig( NumberSelectorConfig(
min=1, max=255, mode=NumberSelectorMode.BOX min=1, max=255, mode=NumberSelectorMode.BOX
) )
), ),
vol.Coerce(int), vol.Coerce(int),
),
}
) )
``` ```