Skip to content

Commit

Permalink
Emulated Hue + Alexa: Fix devices not discovered and error response (h…
Browse files Browse the repository at this point in the history
…ome-assistant#30013 & home-assistant#29899) (home-assistant#31413)

* Revert "Emulated Hue: changed the reported fallback device-type to fix Alexa compatibility issues (home-assistant#30013)"

This reverts commit ddc8d9e.

* Revert "Emulated Hue: updated tests (home-assistant#30013)"

This reverts commit 90df461.

* Emulated Hue + Alexa: changed the fallback device-type again to "Dimmable Light" (home-assistant#30013) after collective debugging; fixed brightness for on/off-devices and scripts to prevent "device malfunction" response from Alexa (home-assistant#29899)

* Emulated Hue + Alexa: lint (home-assistant#30013, home-assistant#29899)
  • Loading branch information
xtools-at authored Feb 2, 2020
1 parent 96ede54 commit af105d2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
28 changes: 13 additions & 15 deletions homeassistant/components/emulated_hue/hue_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -688,27 +688,25 @@ def entity_to_json(config, entity):
retval["state"].update(
{HUE_API_STATE_COLORMODE: "ct", HUE_API_STATE_CT: state[STATE_COLOR_TEMP]}
)
elif (
entity_features
& (
SUPPORT_BRIGHTNESS
| SUPPORT_SET_POSITION
| SUPPORT_SET_SPEED
| SUPPORT_VOLUME_SET
| SUPPORT_TARGET_TEMPERATURE
)
) or entity.domain == script.DOMAIN:
elif entity_features & (
SUPPORT_BRIGHTNESS
| SUPPORT_SET_POSITION
| SUPPORT_SET_SPEED
| SUPPORT_VOLUME_SET
| SUPPORT_TARGET_TEMPERATURE
):
# Dimmable light (Zigbee Device ID: 0x0100)
# Supports groups, scenes, on/off and dimming
retval["type"] = "Dimmable light"
retval["modelid"] = "HASS123"
retval["state"].update({HUE_API_STATE_BRI: state[STATE_BRIGHTNESS]})
else:
# On/off plug-in unit (Zigbee Device ID: 0x0000)
# Supports groups and on/off control
# Used for compatibility purposes with Alexa instead of "On/off light"
retval["type"] = "On/off plug-in unit"
retval["modelid"] = "HASS321"
# Dimmable light (Zigbee Device ID: 0x0100)
# Supports groups, scenes, on/off and dimming
# Reports fixed brightness for compatibility with Alexa.
retval["type"] = "Dimmable light"
retval["modelid"] = "HASS123"
retval["state"].update({HUE_API_STATE_BRI: HUE_API_STATE_BRI_MAX})

return retval

Expand Down
2 changes: 1 addition & 1 deletion tests/components/emulated_hue/test_hue_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ async def test_light_without_brightness_supported(hass_hue, hue_client):
)

assert light_without_brightness_json["state"][HUE_API_STATE_ON] is True
assert light_without_brightness_json["type"] == "On/off plug-in unit"
assert light_without_brightness_json["type"] == "Dimmable light"


async def test_light_without_brightness_can_be_turned_off(hass_hue, hue_client):
Expand Down

0 comments on commit af105d2

Please sign in to comment.