add empy all groups view. Makes Brilliant Lightpad work (#20564)
This commit is contained in:
parent
e0e5b860e4
commit
48f0e8311b
3 changed files with 40 additions and 2 deletions
|
@ -22,7 +22,7 @@ from homeassistant.components.http import real_ip
|
|||
|
||||
from .hue_api import (
|
||||
HueUsernameView, HueAllLightsStateView, HueOneLightStateView,
|
||||
HueOneLightChangeView, HueGroupView)
|
||||
HueOneLightChangeView, HueGroupView, HueAllGroupsStateView)
|
||||
from .upnp import DescriptionXmlView, UPNPResponderThread
|
||||
|
||||
DOMAIN = 'emulated_hue'
|
||||
|
@ -105,6 +105,7 @@ async def async_setup(hass, yaml_config):
|
|||
HueAllLightsStateView(config).register(app, app.router)
|
||||
HueOneLightStateView(config).register(app, app.router)
|
||||
HueOneLightChangeView(config).register(app, app.router)
|
||||
HueAllGroupsStateView(config).register(app, app.router)
|
||||
HueGroupView(config).register(app, app.router)
|
||||
|
||||
upnp_listener = UPNPResponderThread(
|
||||
|
|
|
@ -56,6 +56,28 @@ class HueUsernameView(HomeAssistantView):
|
|||
return self.json([{'success': {'username': '12345678901234567890'}}])
|
||||
|
||||
|
||||
class HueAllGroupsStateView(HomeAssistantView):
|
||||
"""Group handler."""
|
||||
|
||||
url = '/api/{username}/groups'
|
||||
name = 'emulated_hue:all_groups:state'
|
||||
requires_auth = False
|
||||
|
||||
def __init__(self, config):
|
||||
"""Initialize the instance of the view."""
|
||||
self.config = config
|
||||
|
||||
@core.callback
|
||||
def get(self, request, username):
|
||||
"""Process a request to make the Brilliant Lightpad work."""
|
||||
if not is_local(request[KEY_REAL_IP]):
|
||||
return self.json_message('only local IPs allowed',
|
||||
HTTP_BAD_REQUEST)
|
||||
|
||||
return self.json({
|
||||
})
|
||||
|
||||
|
||||
class HueGroupView(HomeAssistantView):
|
||||
"""Group handler to get Logitech Pop working."""
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ from homeassistant.components import (
|
|||
from homeassistant.components.emulated_hue import Config
|
||||
from homeassistant.components.emulated_hue.hue_api import (
|
||||
HUE_API_STATE_ON, HUE_API_STATE_BRI, HueUsernameView, HueOneLightStateView,
|
||||
HueAllLightsStateView, HueOneLightChangeView)
|
||||
HueAllLightsStateView, HueOneLightChangeView, HueAllGroupsStateView)
|
||||
from homeassistant.const import STATE_ON, STATE_OFF
|
||||
|
||||
HTTP_SERVER_PORT = get_test_instance_port()
|
||||
|
@ -135,6 +135,7 @@ def hue_client(loop, hass_hue, aiohttp_client):
|
|||
HueAllLightsStateView(config).register(web_app, web_app.router)
|
||||
HueOneLightStateView(config).register(web_app, web_app.router)
|
||||
HueOneLightChangeView(config).register(web_app, web_app.router)
|
||||
HueAllGroupsStateView(config).register(web_app, web_app.router)
|
||||
|
||||
return loop.run_until_complete(aiohttp_client(web_app))
|
||||
|
||||
|
@ -420,6 +421,20 @@ def test_proper_put_state_request(hue_client):
|
|||
assert result.status == 400
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def test_get_empty_groups_state(hue_client):
|
||||
"""Test the request to get groups endpoint."""
|
||||
# Test proper on value parsing
|
||||
result = yield from hue_client.get(
|
||||
'/api/username/groups')
|
||||
|
||||
assert result.status == 200
|
||||
|
||||
result_json = yield from result.json()
|
||||
|
||||
assert result_json == {}
|
||||
|
||||
|
||||
# pylint: disable=invalid-name
|
||||
async def perform_put_test_on_ceiling_lights(hass_hue, hue_client,
|
||||
content_type='application/json'):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue