Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust step documentation for NumberSelector #2442

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
40 changes: 40 additions & 0 deletions blog/2024-11-08-number_selector.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
author: epenet
authorURL: https://github.com/epenet
title: "Return an integer in number selector"
---

The [Number selector](https://www.home-assistant.io/docs/blueprint/selectors/#number-selector) has been expanded and now also includes an `as_int` parameter.

Using this in [config flows](/docs/data_entry_flow_index#show-form) will remove the need to add an extra validation to the schema.

Example:

```python
vol.Schema(
{
vol.Optional(CONF_ADDRESS): NumberSelector(
NumberSelectorConfig(
as_int=True, min=1, max=255, mode=NumberSelectorMode.BOX
)
),
}
)
```

Old code:

```python
vol.Schema(
{
vol.Optional(CONF_ADDRESS): vol.All(
NumberSelector(
NumberSelectorConfig(
min=1, max=255, mode=NumberSelectorMode.BOX
)
),
vol.Coerce(int),
),
}
)
```