diff --git a/homeassistant/components/emulated_hue/hue_api.py b/homeassistant/components/emulated_hue/hue_api.py index 1b08b43c9af..fc00746fc7f 100644 --- a/homeassistant/components/emulated_hue/hue_api.py +++ b/homeassistant/components/emulated_hue/hue_api.py @@ -562,17 +562,27 @@ def get_entity_state(config, entity): def entity_to_json(config, entity, state): """Convert an entity to its Hue bridge JSON representation.""" + entity_features = entity.attributes.get(ATTR_SUPPORTED_FEATURES, 0) + if (entity_features & SUPPORT_BRIGHTNESS) or entity.domain != light.DOMAIN: + return { + "state": { + HUE_API_STATE_ON: state[STATE_ON], + HUE_API_STATE_BRI: state[STATE_BRIGHTNESS], + HUE_API_STATE_HUE: state[STATE_HUE], + HUE_API_STATE_SAT: state[STATE_SATURATION], + "reachable": True, + }, + "type": "Dimmable light", + "name": config.get_entity_name(entity), + "modelid": "HASS123", + "uniqueid": entity.entity_id, + "swversion": "123", + } return { - "state": { - HUE_API_STATE_ON: state[STATE_ON], - HUE_API_STATE_BRI: state[STATE_BRIGHTNESS], - HUE_API_STATE_HUE: state[STATE_HUE], - HUE_API_STATE_SAT: state[STATE_SATURATION], - "reachable": True, - }, - "type": "Dimmable light", + "state": {HUE_API_STATE_ON: state[STATE_ON], "reachable": True}, + "type": "On/off light", "name": config.get_entity_name(entity), - "modelid": "HASS123", + "modelid": "HASS321", "uniqueid": entity.entity_id, "swversion": "123", } diff --git a/tests/components/emulated_hue/test_hue_api.py b/tests/components/emulated_hue/test_hue_api.py index 57f29a4ef61..02f24f5afba 100644 --- a/tests/components/emulated_hue/test_hue_api.py +++ b/tests/components/emulated_hue/test_hue_api.py @@ -128,6 +128,9 @@ def hass_hue(loop, hass): kitchen_light_entity.entity_id, kitchen_light_entity.state, attributes=attrs ) + # create a lamp without brightness support + hass.states.async_set("light.no_brightness", "on", {}) + # Ceiling Fan is explicitly excluded from being exposed ceiling_fan_entity = hass.states.get("fan.ceiling_fan") attrs = dict(ceiling_fan_entity.attributes) @@ -218,6 +221,17 @@ def test_discover_lights(hue_client): assert "climate.ecobee" not in devices +@asyncio.coroutine +def test_light_without_brightness_supported(hass_hue, hue_client): + """Test that light without brightness is supported.""" + light_without_brightness_json = yield from perform_get_light_state( + hue_client, "light.no_brightness", 200 + ) + + assert light_without_brightness_json["state"][HUE_API_STATE_ON] is True + assert light_without_brightness_json["type"] == "On/off light" + + @asyncio.coroutine def test_get_light_state(hass_hue, hue_client): """Test the getting of light state."""