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

Adds light switch platform #18562

Merged
merged 4 commits into from Nov 20, 2018

Conversation

Projects
None yet
4 participants
@frenck
Member

frenck commented Nov 18, 2018

Description:

This PR adds the Light Switch Platform.

This platform can create a light based on a switch. We've seen a lot of PR in that past to modify the domain a switch is in. This is mainly because people want to have a switch acting as a light. Many components have limited their use to entities in the light domains only (e.g. Light Group), which makes it impossible to use a switch entity in those cases. Another example, having switches showing up as a light in Google Assistant/HomeKit.

The main reason for this, is that wall plugs are often used for controlling lights (e.g., your Christmas tree). The current workaround is using a rather nasty light template.

This component provides a more elegant way of doing this and behaves / is similar to the Light Group platform (as in acting on an existing entity). It remains user-friendly and doesn't "fool around" with entity domains.

Notes

I'm unsure if a discussion/issue in the architecture repository was needed for this. If so, please let me know.

Python is not my daily used language, and this is my first PR against the Home Assistant repository as well. I'm willing to learn, so if you encounter issues and/or have comments, please consider a little more extensive explanation.

Related issue (if applicable): n/a

Pull request in home-assistant.io with documentation (if applicable): home-assistant/home-assistant.io#7577

Example entry for configuration.yaml (if applicable):

light:
  - platform: switch
    name: "Christmas Tree Lights"
    entity_id: switch.christmas_tree

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.

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

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

  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New or updated dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • New files were added to .coveragerc.

If the code does not interact with devices:

  • Tests have been added to verify that the new code works.
Show resolved Hide resolved tests/components/light/test_switch.py
Show resolved Hide resolved tests/components/light/test_switch.py
Show resolved Hide resolved homeassistant/components/light/switch.py Outdated
Show resolved Hide resolved homeassistant/components/light/switch.py Outdated
Show resolved Hide resolved homeassistant/components/light/switch.py Outdated
Show resolved Hide resolved homeassistant/components/light/switch.py Outdated
Show resolved Hide resolved homeassistant/components/light/switch.py

frenck added some commits Nov 18, 2018

@frenck frenck referenced this pull request Nov 18, 2018

Merged

Adds light switch platform documentation #7577

2 of 2 tasks complete

@frenck frenck removed the docs-missing label Nov 18, 2018

@pvizeli pvizeli merged commit 80cd8b1 into dev Nov 20, 2018

6 checks passed

Hound No violations found. Woof!
WIP ready for review
Details
cla-bot Everyone involved has signed the CLA
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
coverage/coveralls Coverage increased (+0.01%) to 93.048%
Details

@wafflebot wafflebot bot removed the in progress label Nov 20, 2018

@pvizeli pvizeli deleted the platform-light-switch branch Nov 20, 2018

mxworm added a commit to mxworm/home-assistant that referenced this pull request Nov 20, 2018

Merge branch 'dev' of https://github.com/home-assistant/home-assistant
…into dev

* 'dev' of https://github.com/home-assistant/home-assistant:
  Improve available for Mill heater (home-assistant#18597)
  Z-Wave Lock Config Entry Support (home-assistant#18209)
  Add support for Daikin BRP069B41 (home-assistant#18564)
  Hass.io config check (home-assistant#18576)
  Revert changes that broke UI (home-assistant#18495)
  Add websocket calls to shopping-list (home-assistant#18392)
  Bump Python-Nest to 4.0.5 (home-assistant#18580)
  Adds light switch platform (home-assistant#18562)
  Added unique id to all Wink devices. (home-assistant#18589)

@balloob balloob referenced this pull request Nov 29, 2018

Merged

0.83 #18776

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment