I wanted to say the examples:
- https://home-assistant.io/developers/platform_example_sensor/
- https://home-assistant.io/developers/platform_example_light/
are great I’ve more questions but it gives me a good starting point.
I’ve implemented a FakeAwesomelights object set so that the awesomelights demo can run (NOTE remove/comment-out the REQUIREMENTS
line and the import line). Is there any value in this? Posting here in the off chance there is:
class FakeAwesomelights(object):
pass
class FakeLight(object):
name = 'Fake Light'
brightness = 1
def update(self):
_LOGGER.info('update() called')
# Not really sure when/why this is called
# seen it called once, is_on() called often
def is_on(self):
_LOGGER.info('is_on() called')
return True
def turn_on(self):
_LOGGER.info('turn_on() called FakeLight ON')
def turn_off(self):
_LOGGER.info('turn_off() called FakeLight OFF')
class FakeHub(object):
def __init__(self, host, username, password):
_LOGGER.info('FakeHub() init')
def is_valid_login(self):
return True
def lights(self):
# Fake discovery
return [FakeLight()]
awesomelights = FakeAwesomelights()
awesomelights.Hub = FakeHub
The FakeAwesomelights class could be removed if this was placed into an awesomelights.py file