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

Add support for Tikteck Bluetooth bulbs #4843

Merged
merged 2 commits into from
Jan 4, 2017
Merged

Conversation

mjg59
Copy link
Contributor

@mjg59 mjg59 commented Dec 11, 2016

Description:

Add support for Tikteck Smart Bluetooth Bulbs. These are RGBW bulbs available for $9.99 from the manufacturer, communicating over BTLE. Each bulb needs a key which can be extracted from the Android app.

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

Example entry for configuration.yaml (if applicable):

light:
  - platform: tikteck
    devices:
      00:21:4D:00:00:01:
        name: Tikteck bulb 1
        password: 285614125
      00:21:4D:00:00:02:
        name: Tikteck bulb 2
        password: 365115194
    

Checklist:

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

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

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New 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:

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • Tests have been added to verify that the new code works.

@mention-bot
Copy link

@mjg59, thanks for your PR! By analyzing the history of the files in this pull request, we identified @balloob, @fabaff and @robbiet480 to be potential reviewers.

self._bulb = tikteck.tikteck(self._address, "Smart Light",
self._password)
self._bulb.connect()
except Exception as e:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

lint is unhappy with this, but I'm not sure what the best thing to do here is. The protocol code will raise a BTException, and handling that would mean pulling in the underlying Bluetooth implementation which really ought to be abstracted (I've already changed implementation in this code). The alternative would be to push the retry code down to the protocol implementation? In this case I'm upstream so can do that, but there may be other Bluetooth backed devices that don't handle reconnect.

Copy link
Member

Choose a reason for hiding this comment

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

You are correct that we don't want to get caught dealing with the implementation details of the lib. The cleanest approach would be to have the lib wrap the exception with it's own error type.

self._bulb = tikteck.tikteck(self._address, "Smart Light",
self._password)
self._bulb.connect()
except Exception as e:
Copy link
Member

Choose a reason for hiding this comment

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

You are correct that we don't want to get caught dealing with the implementation details of the lib. The cleanest approach would be to have the lib wrap the exception with it's own error type.

self._state = False
self.set_state(0, 0, 0, 0)

def update(self):
Copy link
Member

Choose a reason for hiding this comment

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

If there is no update method, you can remove it. It will default to be a no-op. In that case you also should also:

  • Add property should_poll that returns False
  • Add property assumed_state that returns True
  • Add self.schedule_update_ha_state() at the end of turn_on and turn_off

self.is_valid = True
self._bulb = tikteck.tikteck(self._address, "Smart Light",
self._password)
if self._bulb.connect() == False:

Choose a reason for hiding this comment

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

comparison to False should be 'if cond is False:' or 'if not cond:'

https://home-assistant.io/components/light.tikteck/
"""
import logging
import time

Choose a reason for hiding this comment

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

'time' imported but unused

@mjg59 mjg59 force-pushed the tikteck branch 2 times, most recently from 853a89a to c584f56 Compare December 29, 2016 21:35
Adds support for the Tikteck RGBW BLE bulbs. These don't provide "true" RGBW
support - at a certain point in RGB space, the white LEDs turn on. Each bulb
has a specific key that needs to be extracted from the Android app.
@balloob
Copy link
Member

balloob commented Jan 4, 2017

Awesome! 🐬

@balloob balloob merged commit ff07883 into home-assistant:dev Jan 4, 2017
@mjg59 mjg59 deleted the tikteck branch January 4, 2017 23:26
@home-assistant home-assistant locked and limited conversation to collaborators Apr 30, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants