Skip to content

Dim (and brighten) lights via a remote #3319

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

Merged
merged 5 commits into from
Sep 7, 2017
Merged

Dim (and brighten) lights via a remote #3319

merged 5 commits into from
Sep 7, 2017

Conversation

DubhAd
Copy link
Contributor

@DubhAd DubhAd commented Sep 6, 2017

Hopefully this one won't break everything ;)

As per chat in the Discord, these are the scripts, automations, and input_sliders to allow a light to be dimmed and brightened by holding down the down or up button on an appropriate remote.

This has been extended to use input_sliders for the dim/brighten step, and for the minimum and maximum brightness levels. The defaults have been set based upon DariBer's experience, so they should be close to "right" for others.

Hopefully this one won't break everything ;)
Copy link
Member

@dale3h dale3h left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do apologize for the strict formatting change requests, but I just want to make sure that all docs moving forward do not require as many changes when standards are put into place.

ha_category: Automation Examples
---

This requires both a light on a dimmer, and a z-wave remote control that sends one scene when a button is held, and another when released. This ensures that the scripts (which follow) are stopped, avoiding the risks of a script that never ends.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am working on implementing a set of standards for our documentation as to provide consistency and reduce confusion, while also improving a professional appearance to our users. Part of this will include proper casing of brands, names, protocols, services, etc.

  • Change "z-wave" -> "Z-Wave"
  • Change "a light on a dimmer" -> "a dimmable light"


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, we'll use an input_slider for the step (at the time of writing this, it's not possible to template the delay when the delay uses milliseconds). We're also using a slider to set the minimum and maximum brightness, so that it's easy to tune that (or manage it through an automation).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • "we'll use an input_slider" -> "an [Input Slider](/components/input_slider/) is used"
  • "We're also using a slider" -> "Two additional [Input Sliders](/components/input_slider/) are used"

entity_id: light.YOURLIGHT
brightness: >-
{% raw %}{% set current = (states.light.YOURLIGHT.attributes|default).brightness|default(0)|int %}
{% set step = states.input_slider.light_step.states|int %}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

states.input_slider.light_step.states|int -> states('input_slider.light_step')|int

There are 5 more lines similar to this that need to be changed as well.

data_template:
entity_id: light.YOURLIGHT
brightness: >-
{% raw %}{% set current = (states.light.YOURLIGHT.attributes|default).brightness|default(0)|int %}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To help prevent confusion, please remove the default filter from attributes. Also, please update all occurrences of YOURLIGHT to YOUR_LIGHT. (May as well do this with YOURCONTROLLER -> YOUR_REMOTE as well)

(states.light.YOURLIGHT.attributes|default).brightness|default(0)|int -> states.light.YOUR_LIGHT.attributes.brightness|default(0)|int

sequence:
- service: light.turn_on
data_template:
entity_id: light.YOURLIGHT
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

YOURLIGHT -> YOUR_LIGHT

Copy link
Member

@frenck frenck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Minor spelling & grammar issues found.
@DubhAd Could you please correct those?

ha_category: Automation Examples
---

This requires both a a dimmable light, and a Z-Wave remote control that sends one scene when a button is held, and another when released. This ensures that the scripts (which follow) are stopped, avoiding the risks of a script that never ends.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling & Grammar:

  • both a a dimmable light -> both a dimmable light


This requires both a a dimmable light, and a Z-Wave remote control that sends one scene when a button is held, and another when released. This ensures that the scripts (which follow) are stopped, avoiding the risks of a script that never ends.

In the following automation, replace `zwave.YOUR_REMOTE` with the actual entity ID of your controller. For the controller this was written for scene ID 13 was sent when the up button was held, and 15 when released. Similarly scene 14 when the down button was held, and 16 when released. You'll need to use the scene IDs that are sent by your remote if different.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling & Grammar:

  • Missing comma after Similarly -> Similarly, scene 14

entity_id: script.light_dim_pause
```

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling & Grammar:

  • Two independent parts joined by a comma: The second is the delay, larger delays will create a slower transition. -> The second is the delay. Larger delays will create a slower transition.

step: 1
```

Now the scripts. There are 2 pairs of scripts. The first steps the light brighter to the maximum, and the second provides the delay. These call each other until both are stopped. The second pair do the same for dimming.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling & Grammar:

  • Unnecessary comma: maximum, and -> maximum and
  • do the same -> does the same

Other than the last point, done.

The last part I've left, as these aren't strictly independent parts - the section after the comma is the explanation for how the "lever" works.
You snuck those in while I was editing ;)
Copy link
Member

@frenck frenck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @DubhAd!
@dale3h, please check if changes match your expectations.

@dale3h dale3h merged commit d53a51f into home-assistant:current Sep 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants