Bump aiohue library to 4.6.1 (#85504)

* Bump aiohue to 4.6.0

* fix device name for lights

* fix name for groups too

* ignore smart scenes

* bump to 4.6.1 instead

* fix test fixture

* update tests

* fix scene test
This commit is contained in:
Marcel van der Veldt 2023-01-09 16:37:03 +01:00 committed by GitHub
parent 86ab5f76e0
commit c181fb6de0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 27 additions and 40 deletions

View file

@ -3,7 +3,7 @@
"name": "Philips Hue",
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/hue",
"requirements": ["aiohue==4.5.0"],
"requirements": ["aiohue==4.6.1"],
"ssdp": [
{
"manufacturer": "Royal Philips Electronics",

View file

@ -47,10 +47,10 @@ async def async_setup_entry(
@callback
def async_add_entity(event_type: EventType, resource: HueScene) -> None:
"""Add entity from Hue resource."""
async_add_entities([HueSceneEntity(bridge, api.scenes, resource)])
async_add_entities([HueSceneEntity(bridge, api.scenes.scene, resource)])
# add all current items in controller
for item in api.scenes:
for item in api.scenes.scene:
async_add_entity(EventType.RESOURCE_ADDED, item)
# register listener for new items only

View file

@ -71,11 +71,11 @@ class HueBaseEntity(Entity):
# creating a pretty name for device-less entities (e.g. groups/scenes)
# should be handled in the platform instead
return self.resource.type.value
# if resource is a light, use the name from metadata
if self.resource.type == ResourceTypes.LIGHT:
return self.resource.name
# for sensors etc, use devicename + pretty name of type
dev_name = self.device.metadata.name
# if resource is a light, use the device name itself
if self.resource.type == ResourceTypes.LIGHT:
return dev_name
# for sensors etc, use devicename + pretty name of type
type_title = RESOURCE_TYPE_NAMES.get(
self.resource.type, self.resource.type.value.replace("_", " ").title()
)

View file

@ -120,7 +120,10 @@ class GroupedHueLight(HueBaseEntity, LightEntity):
scenes = {
x.metadata.name for x in self.api.scenes if x.group.rid == self.group.id
}
lights = {x.metadata.name for x in self.controller.get_lights(self.resource.id)}
lights = {
self.controller.get_device(x.id).metadata.name
for x in self.controller.get_lights(self.resource.id)
}
return {
"is_hue_group": True,
"hue_scenes": scenes,

View file

@ -184,7 +184,7 @@ aiohomekit==2.4.3
aiohttp_cors==0.7.0
# homeassistant.components.hue
aiohue==4.5.0
aiohue==4.6.1
# homeassistant.components.imap
aioimaplib==1.0.1

View file

@ -168,7 +168,7 @@ aiohomekit==2.4.3
aiohttp_cors==0.7.0
# homeassistant.components.hue
aiohue==4.5.0
aiohue==4.6.1
# homeassistant.components.imap
aioimaplib==1.0.1

View file

@ -32,7 +32,6 @@ FAKE_LIGHT = {
},
"id": "fake_light_id_1",
"id_v1": "/lights/1",
"metadata": {"archetype": "unknown", "name": "Hue fake light"},
"mode": "normal",
"on": {"on": False},
"owner": {"rid": "fake_device_id_1", "rtype": "device"},
@ -93,5 +92,6 @@ FAKE_SCENE = {
},
"palette": {"color": [], "color_temperature": [], "dimming": []},
"speed": 0.5,
"auto_dynamic": False,
"type": "scene",
}

View file

@ -168,6 +168,7 @@
"dimming": []
},
"speed": 0.6269841194152832,
"auto_dynamic": false,
"type": "scene"
},
{
@ -220,6 +221,7 @@
"dimming": []
},
"speed": 0.5,
"auto_dynamic": false,
"type": "scene"
},
{
@ -624,14 +626,12 @@
},
"effects": {
"status_values": ["no_effect", "candle", "fire"],
"status": "no_effect"
"status": "no_effect",
"effect_values": ["no_effect", "candle", "fire"],
"effect": "no_effect"
},
"id": "02cba059-9c2c-4d45-97e4-4f79b1bfbaa1",
"id_v1": "/lights/29",
"metadata": {
"archetype": "floor_shade",
"name": "Hue light with color and color temperature 1"
},
"mode": "normal",
"on": {
"on": true
@ -666,18 +666,18 @@
},
"effects": {
"status_values": ["no_effect", "candle"],
"status": "no_effect"
"status": "no_effect",
"effect_values": ["no_effect", "candle", "fire"],
"effect": "no_effect"
},
"timed_effects": {
"status_values": ["no_effect", "sunrise"],
"status": "no_effect"
"status": "no_effect",
"effect_values": ["no_effect", "sunrise"],
"effect": "no_effect"
},
"id": "3a6710fa-4474-4eba-b533-5e6e72968feb",
"id_v1": "/lights/4",
"metadata": {
"archetype": "ceiling_round",
"name": "Hue light with color temperature only"
},
"mode": "normal",
"on": {
"on": false
@ -733,10 +733,6 @@
},
"id": "b3fe71ef-d0ef-48de-9355-d9e604377df0",
"id_v1": "/lights/16",
"metadata": {
"archetype": "hue_lightstrip",
"name": "Hue light with color and color temperature 2"
},
"mode": "normal",
"on": {
"on": true
@ -759,10 +755,6 @@
},
"id": "7697ac8a-25aa-4576-bb40-0036c0db15b9",
"id_v1": "/lights/23",
"metadata": {
"archetype": "classic_bulb",
"name": "Hue on/off light"
},
"mode": "normal",
"on": {
"on": false
@ -810,10 +802,6 @@
},
"id": "74a45fee-1b3d-4553-b5ab-040da8a10cfd",
"id_v1": "/lights/11",
"metadata": {
"archetype": "hue_bloom",
"name": "Hue light with color only"
},
"mode": "normal",
"on": {
"on": true
@ -914,10 +902,6 @@
},
"id": "8015b17f-8336-415b-966a-b364bd082397",
"id_v1": "/lights/24",
"metadata": {
"archetype": "hue_lightstrip_tv",
"name": "Hue light with color and color temperature gradient"
},
"mode": "normal",
"on": {
"on": true

View file

@ -277,7 +277,7 @@ async def test_light_added(hass, mock_bridge_v2):
await setup_platform(hass, mock_bridge_v2, "light")
test_entity_id = "light.hue_fake_light"
test_entity_id = "light.hue_mocked_device"
# verify entity does not exist before we start
assert hass.states.get(test_entity_id) is None
@ -290,7 +290,7 @@ async def test_light_added(hass, mock_bridge_v2):
test_entity = hass.states.get(test_entity_id)
assert test_entity is not None
assert test_entity.state == "off"
assert test_entity.attributes["friendly_name"] == FAKE_LIGHT["metadata"]["name"]
assert test_entity.attributes["friendly_name"] == FAKE_DEVICE["metadata"]["name"]
async def test_light_availability(hass, mock_bridge_v2, v2_resources_test_data):