Skip to content
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

switchbot #16396

Merged
merged 7 commits into from
Sep 6, 2018
Merged

switchbot #16396

merged 7 commits into from
Sep 6, 2018

Conversation

Danielhiversen
Copy link
Member

Description:

Adds support for https://www.switch-bot.com/

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

Example entry for configuration.yaml (if applicable):

- platform: switchbot
  mac: 'ea:c6.....'

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][ex-requir]).
  • New dependencies are only imported inside functions that use them ([example][ex-import]).
  • New or updated dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • New files were added to .coveragerc.

Daniel Iversen and others added 2 commits September 3, 2018 20:34
self._mac = mac
self._device = None

def _sendpacket(self, key, retry=2) -> bool:
Copy link
Member

Choose a reason for hiding this comment

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

This belongs in a standalone library.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, I thought it might be ok since it so few lines.
But I will make a standalone library.

For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/switch.switchbot
"""
import binascii

Choose a reason for hiding this comment

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

'binascii' imported but unused

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

Nice! Two small comments.

})


def setup_platform(hass, config, add_devices, discovery_info=None):
Copy link
Member

Choose a reason for hiding this comment

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

Rename add_devices to add_entities.

def setup_platform(hass, config, add_devices, discovery_info=None):
"""Perform the setup for Switchbot devices."""
name = config.get(CONF_NAME)
mac_addr = config.get(CONF_MAC)
Copy link
Member

Choose a reason for hiding this comment

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

Use dict[key] for required config keys.

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

@Danielhiversen Danielhiversen merged commit 5bd9be6 into dev Sep 6, 2018
@ghost ghost removed the in progress label Sep 6, 2018
@Danielhiversen Danielhiversen deleted the switchbot branch September 6, 2018 08:02
@balloob balloob mentioned this pull request Sep 17, 2018
@home-assistant home-assistant locked and limited conversation to collaborators Dec 10, 2018
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.

None yet

4 participants