Merge pull request #3403 from BioSehnsucht/rename-input-slider

Rename input_slider to input_number and add numeric text box option
This commit is contained in:
Fabian Affolter 2017-10-07 21:44:23 +02:00 committed by Fabian Affolter
parent 48d1b3347f
commit 7076f2006d
No known key found for this signature in database
GPG key ID: DDF3D6F44AAB1336
7 changed files with 59 additions and 51 deletions

View file

@ -78,10 +78,10 @@ automation:
There are 2 variables that control the speed of the change for the scripts below. The first is the `step`, small steps create a smooth transition. The second is the delay, larger delays will create a slower transition.
To allow flexibility, an [Input Slider](/components/input_slider/) is used for the step (at the time of writing this, it's not possible to template the delay when the delay uses milliseconds). Two additional [Input Sliders](/components/input_slider/) are used to set the minimum and maximum brightness, so that it's easy to tune that (or manage it through an automation).
To allow flexibility, an [Input Number](/components/input_number/) is used for the step (at the time of writing this, it's not possible to template the delay when the delay uses milliseconds). Two additional [Input Numbers](/components/input_number/) are used to set the minimum and maximum brightness, so that it's easy to tune that (or manage it through an automation).
```yaml
input_slider:
input_number:
light_step:
name: 'Step the lights this much'
initial: 20
@ -116,10 +116,10 @@ script:
entity_id: light.YOUR_LIGHT
brightness: >-
{% raw %}{% set current = states.light.YOUR_LIGHT.attributes.brightness|default(0)|int %}
{% set step = states('input_slider.light_step')|int %}
{% set step = states('input_number.light_step')|int %}
{% set next = current + step %}
{% if next > states('input_slider.light_maximum')|int %}
{% set next = states('input_slider.light_maximum')|int %}
{% if next > states('input_number.light_maximum')|int %}
{% set next = states('input_number.light_maximum')|int %}
{% endif %}
{{ next }}{% endraw %}
@ -142,10 +142,10 @@ script:
entity_id: light.YOUR_LIGHT
brightness: >-
{% raw %}{% set current = states.light.YOUR_LIGHT.attributes.brightness|default(0)|int %}
{% set step = states('input_slider.light_step')|int %}
{% set step = states('input_number.light_step')|int %}
{% set next = current - step %}
{% if next < states('input_slider.light_minimum')|int %}
{% set next = states('input_slider.light_minimum')|int %}
{% if next < states('input_number.light_minimum')|int %}
{% set next = states('input_number.light_minimum')|int %}
{% endif %}
{{ next }}{% endraw %}