Add options
This commit is contained in:
parent
46a2506278
commit
722c4a6b14
1 changed files with 14 additions and 0 deletions
|
@ -33,6 +33,8 @@ This section contains a couple of snippets for the validation we use.
|
|||
|
||||
### {% linkable_title Default name %}
|
||||
|
||||
It's common to set a default for a sensor if the user is not providing a name to use.
|
||||
|
||||
```python
|
||||
DEFAULT_NAME = 'Sensor name'
|
||||
|
||||
|
@ -41,6 +43,18 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
|||
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
|
||||
```
|
||||
|
||||
### {% linkable_title Limit the values %}
|
||||
|
||||
In certain cases you want to limit the user's input to a couple of options.
|
||||
|
||||
```python
|
||||
DEFAULT_METHOD = 'GET'
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
...
|
||||
vol.Optional(CONF_METHOD, default=DEFAULT_METHOD): vol.In(['POST', 'GET']),
|
||||
```
|
||||
|
||||
### {% linkable_title Port %}
|
||||
|
||||
As all port numbers are coming out of the range 1 till 65535 a range check should be performed.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue