* Initial Harmony device support, working current activity sensor and switch for each activity TODO: add new device per hub to send device specific activity Changes to be committed: new file: homeassistant/components/harmony.py new file: homeassistant/components/sensor/harmony.py new file: homeassistant/components/switch/harmony.py * ready for beta, I think Changes to be committed: modified: homeassistant/components/harmony.py modified: homeassistant/components/sensor/harmony.py modified: homeassistant/components/switch/harmony.py * Changes to be committed: modified: homeassistant/components/harmony.py new file: homeassistant/components/remote/__init__.py new file: homeassistant/components/remote/harmony.py new file: homeassistant/components/remote/services.yaml modified: homeassistant/components/sensor/harmony.py modified: homeassistant/components/switch/harmony.py Implemented remote component and harmony platform * streamlined harmony support * typo * Initial Harmony device support, working current activity sensor and switch for each activity TODO: add new device per hub to send device specific activity Changes to be committed: new file: homeassistant/components/harmony.py new file: homeassistant/components/sensor/harmony.py new file: homeassistant/components/switch/harmony.py * ready for beta, I think Changes to be committed: modified: homeassistant/components/harmony.py modified: homeassistant/components/sensor/harmony.py modified: homeassistant/components/switch/harmony.py * Changes to be committed: modified: homeassistant/components/harmony.py new file: homeassistant/components/remote/__init__.py new file: homeassistant/components/remote/harmony.py new file: homeassistant/components/remote/services.yaml modified: homeassistant/components/sensor/harmony.py modified: homeassistant/components/switch/harmony.py Implemented remote component and harmony platform * streamlined harmony support * typo * reworked token generation * delete * Initial Harmony device support, working current activity sensor and switch for each activity TODO: add new device per hub to send device specific activity Changes to be committed: new file: homeassistant/components/harmony.py new file: homeassistant/components/sensor/harmony.py new file: homeassistant/components/switch/harmony.py * Initial Harmony device support, working current activity sensor and switch for each activity TODO: add new device per hub to send device specific activity Changes to be committed: new file: homeassistant/components/harmony.py new file: homeassistant/components/sensor/harmony.py new file: homeassistant/components/switch/harmony.py * ready for beta, I think Changes to be committed: modified: homeassistant/components/harmony.py modified: homeassistant/components/sensor/harmony.py modified: homeassistant/components/switch/harmony.py * ready for beta, I think Changes to be committed: modified: homeassistant/components/harmony.py modified: homeassistant/components/sensor/harmony.py modified: homeassistant/components/switch/harmony.py * Changes to be committed: modified: homeassistant/components/harmony.py new file: homeassistant/components/remote/__init__.py new file: homeassistant/components/remote/harmony.py new file: homeassistant/components/remote/services.yaml modified: homeassistant/components/sensor/harmony.py modified: homeassistant/components/switch/harmony.py Implemented remote component and harmony platform * streamlined harmony support * typo * reworked token generation * delete * readded after rebase * cleaning up style errors * modified .coveragerc * moved import statements * added more debug logging * Added URL encoding of token received from Logitech * Corrected import for python 3 * new pyharmony version * new pyharmony version * remote tests * only write config file if not present or sync service is called * more tests * more tests * bumped pyharmony version to work with new auth * bumped pyharmony version to work with new auth * style corrections * harmony local auth and remote demo platform * style fix * PR refinements and permission issues * forgot a blank line * removed sync test from test_init * removed sync test from test_init * visual indent * send_command test in demo platform
57 lines
1.5 KiB
Python
57 lines
1.5 KiB
Python
"""
|
|
Demo platform that has two fake remotes.
|
|
|
|
For more details about this platform, please refer to the documentation
|
|
https://home-assistant.io/components/demo/
|
|
"""
|
|
from homeassistant.components.remote import RemoteDevice
|
|
from homeassistant.const import DEVICE_DEFAULT_NAME
|
|
|
|
|
|
# pylint: disable=unused-argument
|
|
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
|
"""Setup the demo remotes."""
|
|
add_devices_callback([
|
|
DemoRemote('Remote One', False, None),
|
|
DemoRemote('Remote Two', True, 'mdi:remote'),
|
|
])
|
|
|
|
|
|
class DemoRemote(RemoteDevice):
|
|
"""Representation of a demo remote."""
|
|
|
|
def __init__(self, name, state, icon):
|
|
"""Initialize the Demo Remote."""
|
|
self._name = name or DEVICE_DEFAULT_NAME
|
|
self._state = state
|
|
self._icon = icon
|
|
|
|
@property
|
|
def should_poll(self):
|
|
"""No polling needed for a demo remote."""
|
|
return False
|
|
|
|
@property
|
|
def name(self):
|
|
"""Return the name of the device if any."""
|
|
return self._name
|
|
|
|
@property
|
|
def icon(self):
|
|
"""Return the icon to use for device if any."""
|
|
return self._icon
|
|
|
|
@property
|
|
def is_on(self):
|
|
"""Return true if remote is on."""
|
|
return self._state
|
|
|
|
def turn_on(self, **kwargs):
|
|
"""Turn the remote on."""
|
|
self._state = True
|
|
self.schedule_update_ha_state()
|
|
|
|
def turn_off(self, **kwargs):
|
|
"""Turn the remote off."""
|
|
self._state = False
|
|
self.schedule_update_ha_state()
|