Only construct enum __or__ once in emulated_hue (#97114)

pull/97119/head^2
J. Nick Koston 2023-07-23 18:17:46 -05:00 committed by GitHub
parent 2618bfc073
commit 34dcd98440
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 6 deletions

View File

@ -110,6 +110,13 @@ UNAUTHORIZED_USER = [
{"error": {"address": "/", "description": "unauthorized user", "type": "1"}} {"error": {"address": "/", "description": "unauthorized user", "type": "1"}}
] ]
DIMMABLE_SUPPORT_FEATURES = (
CoverEntityFeature.SET_POSITION
| FanEntityFeature.SET_SPEED
| MediaPlayerEntityFeature.VOLUME_SET
| ClimateEntityFeature.TARGET_TEMPERATURE
)
class HueUnauthorizedUser(HomeAssistantView): class HueUnauthorizedUser(HomeAssistantView):
"""Handle requests to find the emulated hue bridge.""" """Handle requests to find the emulated hue bridge."""
@ -801,12 +808,9 @@ def state_to_json(config: Config, state: State) -> dict[str, Any]:
HUE_API_STATE_BRI: state_dict[STATE_BRIGHTNESS], HUE_API_STATE_BRI: state_dict[STATE_BRIGHTNESS],
} }
) )
elif entity_features & ( elif entity_features & DIMMABLE_SUPPORT_FEATURES or light.brightness_supported(
CoverEntityFeature.SET_POSITION color_modes
| FanEntityFeature.SET_SPEED ):
| MediaPlayerEntityFeature.VOLUME_SET
| ClimateEntityFeature.TARGET_TEMPERATURE
) or light.brightness_supported(color_modes):
# Dimmable light (Zigbee Device ID: 0x0100) # Dimmable light (Zigbee Device ID: 0x0100)
# Supports groups, scenes, on/off and dimming # Supports groups, scenes, on/off and dimming
retval["type"] = "Dimmable light" retval["type"] = "Dimmable light"