Skip to content

Add Elk light platform#17222

Merged
MartinHjelmare merged 6 commits intohome-assistant:devfrom
gwww:elkm1-light
Oct 8, 2018
Merged

Add Elk light platform#17222
MartinHjelmare merged 6 commits intohome-assistant:devfrom
gwww:elkm1-light

Conversation

@gwww
Copy link
Copy Markdown
Contributor

@gwww gwww commented Oct 7, 2018

Description:

Related issue (if applicable): fixes #

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

Example entry for configuration.yaml (if applicable):

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass

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.

@ghost ghost added the in progress label Oct 7, 2018
@gwww
Copy link
Copy Markdown
Contributor Author

gwww commented Oct 7, 2018

@MartinHjelmare
Copy link
Copy Markdown
Member

The light platform module is missing.

@gwww
Copy link
Copy Markdown
Contributor Author

gwww commented Oct 7, 2018

Whadda mean you need to do a git add :)

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.

Please add a guard clause to the alarm_control_panel platform too. See below.

elk = hass.data[ELK_DOMAIN]['elk']
async_add_entities(
create_elk_entities(hass, elk.lights, 'plc', ElkLight, []), True)
return True
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nothing is checking this return value. Please remove the statement.


@property
def is_on(self) -> bool:
"""Is there light?"""
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please write the docstring in imperative mood and end with period.

return self._brightness != 0

def _element_changed(self, element, changeset):
"""Callback handler from the Elk."""
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

See above.

self._brightness = round(status * 2.55)

async def async_turn_on(self, **kwargs):
"""Let there be light!"""
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please keep docstrings formal.

self._element.level(round(kwargs.get(ATTR_BRIGHTNESS, 255) / 2.55))

async def async_turn_off(self, **kwargs):
"""In the darkness..."""
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

See above.



async def async_setup_platform(
hass, config, async_add_entities, discovery_info=None):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

continuation line with same indent as next logical line

async def async_setup_platform(hass, config, async_add_entities,
discovery_info):
async def async_setup_platform(
hass, config, async_add_entities, discovery_info=None):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

continuation line with same indent as next logical line

for component in SUPPORTED_DOMAINS:
hass.async_create_task(
discovery.async_load_platform(hass, component, DOMAIN))
discovery.async_load_platform(hass, component, DOMAIN, []))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We usually put an empty dict for discovery_info.

@MartinHjelmare MartinHjelmare changed the title Add Elk light platform. Add Elk light platform Oct 8, 2018
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 great!

@MartinHjelmare MartinHjelmare merged commit 9380fca into home-assistant:dev Oct 8, 2018
@ghost ghost removed the in progress label Oct 8, 2018
@gwww
Copy link
Copy Markdown
Contributor Author

gwww commented Oct 8, 2018

Thank you.

@gwww gwww deleted the elkm1-light branch October 8, 2018 15:55
@balloob balloob mentioned this pull request Oct 26, 2018
@home-assistant home-assistant locked and limited conversation to collaborators Feb 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants