Skip to content

Add white value in light template platform#32481

Merged
MartinHjelmare merged 4 commits intohome-assistant:devfrom
elahd:template-light-add-white-value
Apr 20, 2020
Merged

Add white value in light template platform#32481
MartinHjelmare merged 4 commits intohome-assistant:devfrom
elahd:template-light-add-white-value

Conversation

@elahd
Copy link
Copy Markdown
Contributor

@elahd elahd commented Mar 4, 2020

Proposed change

This change adds support for "white value" in the Template Light integration. White value is defined in the top level Light integration and is typically used by RGBW devices. These devices allow for independent dimming of the white and RGBW channels. This change allows template lights to take on their own while value and control the while value of other lights in accordance with the HA standard.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example entry for configuration.yaml:

# Example configuration.yaml
light:
  - platform: template
    lights:
      theater_lights:
        friendly_name: "Theater Lights"
        level_template: "{{ state_attr('sensor.theater_brightness', 'lux')|int }}"
        white_value_template: "{{ state_attr('sensor.theater_white_value, 'value')|int }}"
        value_template: "{{ state_attr('sensor.theater_brightness', 'lux')|int > 0 }}"
        temperature_template: "{{states('input_number.temperature_input') | int}}"
        color_template: "({{states('input_number.h_input') | int}}, {{states('input_number.s_input') | int}})"
        turn_on:
          service: script.theater_lights_on
        turn_off:
          service: script.theater_lights_off
        set_level:
          service: script.theater_lights_level
          data_template:
            brightness: "{{ brightness }}"
        set_white_value:
          service: script.theater_lights_white_value
          data_template:
            white_value: "{{ white_value }}"
        set_temperature:
          service: input_number.set_value
          data_template:
            value: "{{ color_temp }}"
            entity_id: input_number.temperature_input
        set_color:
          - service: input_number.set_value
            data_template:
              value: "{{ h }}"
              entity_id: input_number.h_input
          - service: input_number.set_value
            data_template:
              value: "{{ s }}"
              entity_id: input_number.s_input

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

@probot-home-assistant
Copy link
Copy Markdown

Hey there @PhracturedBlue, @tetienne, mind taking a look at this pull request as its been labeled with a integration (template) you are listed as a codeowner for? Thanks!

@MartinHjelmare MartinHjelmare changed the title Added support for white value in Template Light integration. Add white value in light template platform Mar 5, 2020
@frenck
Copy link
Copy Markdown
Member

frenck commented Mar 5, 2020

Hi there @elahd 👋

Could you please make sure the build passes?
And please add some tests to verify the working of this new feature.

Thanks! 👍

@springstan
Copy link
Copy Markdown
Member

Please update the documentation as well to include this change :)

@elahd
Copy link
Copy Markdown
Contributor Author

elahd commented Mar 6, 2020

@springstan @frenck Will do. This will take a few days. I'm still getting oriented with the home assistant dev framework.

Comment thread homeassistant/components/template/light.py Outdated
@tetienne
Copy link
Copy Markdown
Contributor

tetienne commented Mar 6, 2020

Except for the missing tests and the copy/paste, it looks good to me.

@elahd
Copy link
Copy Markdown
Contributor Author

elahd commented Mar 25, 2020

@springstan Documentation is updated.
@tetienne Tests created.
@frenck Build is passing.

@tetienne
Copy link
Copy Markdown
Contributor

2712 files changed. I think you made a mistake.

@tetienne
Copy link
Copy Markdown
Contributor

Look good to me.

Copy link
Copy Markdown
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

Looks good! Just a clean up.

Comment thread tests/components/template/test_light.py Outdated
Copy link
Copy Markdown
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

Can be merged when build passes.

@tetienne
Copy link
Copy Markdown
Contributor

There was recently an issue with the light template : #33469
Can you check, it's OK with this feature?
(currently on my phone sorry)

Copy link
Copy Markdown
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

This should address the comment above.

Comment thread homeassistant/components/template/light.py
Comment thread homeassistant/components/template/light.py
Comment thread tests/components/template/test_light.py Outdated
Copy link
Copy Markdown
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

Can be merged when build passes.

@MartinHjelmare MartinHjelmare merged commit c5d2e44 into home-assistant:dev Apr 20, 2020
@lock lock Bot locked and limited conversation to collaborators Apr 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants