mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Fix for deviceless entities in Hue integration (#59820)
This commit is contained in:
parent
902da4daf8
commit
4820acb897
@ -36,9 +36,7 @@ class HueBaseEntity(Entity):
|
|||||||
self.bridge = bridge
|
self.bridge = bridge
|
||||||
self.controller = controller
|
self.controller = controller
|
||||||
self.resource = resource
|
self.resource = resource
|
||||||
self.device = (
|
self.device = controller.get_device(resource.id)
|
||||||
controller.get_device(resource.id) or bridge.api.config.bridge_device
|
|
||||||
)
|
|
||||||
self.logger = bridge.logger.getChild(resource.type.value)
|
self.logger = bridge.logger.getChild(resource.type.value)
|
||||||
|
|
||||||
# Entity class attributes
|
# Entity class attributes
|
||||||
|
@ -240,6 +240,8 @@ async def test_grouped_lights(hass, mock_bridge_v2, v2_resources_test_data):
|
|||||||
assert entity_entry
|
assert entity_entry
|
||||||
assert entity_entry.disabled
|
assert entity_entry.disabled
|
||||||
assert entity_entry.disabled_by == er.DISABLED_INTEGRATION
|
assert entity_entry.disabled_by == er.DISABLED_INTEGRATION
|
||||||
|
# entity should not have a device assigned
|
||||||
|
assert entity_entry.device_id is None
|
||||||
|
|
||||||
# enable the entity
|
# enable the entity
|
||||||
updated_entry = ent_reg.async_update_entity(
|
updated_entry = ent_reg.async_update_entity(
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
"""Philips Hue scene platform tests for V2 bridge/api."""
|
"""Philips Hue scene platform tests for V2 bridge/api."""
|
||||||
|
|
||||||
|
|
||||||
|
from homeassistant.helpers import entity_registry as er
|
||||||
|
|
||||||
from .conftest import setup_platform
|
from .conftest import setup_platform
|
||||||
from .const import FAKE_SCENE
|
from .const import FAKE_SCENE
|
||||||
|
|
||||||
@ -39,6 +41,16 @@ async def test_scene(hass, mock_bridge_v2, v2_resources_test_data):
|
|||||||
assert test_entity.attributes["brightness"] == 100.0
|
assert test_entity.attributes["brightness"] == 100.0
|
||||||
assert test_entity.attributes["is_dynamic"] is False
|
assert test_entity.attributes["is_dynamic"] is False
|
||||||
|
|
||||||
|
# scene entities should not have a device assigned
|
||||||
|
ent_reg = er.async_get(hass)
|
||||||
|
for entity_id in (
|
||||||
|
"scene.test_zone_dynamic_test_scene",
|
||||||
|
"scene.test_room_regular_test_scene",
|
||||||
|
):
|
||||||
|
entity_entry = ent_reg.async_get(entity_id)
|
||||||
|
assert entity_entry
|
||||||
|
assert entity_entry.device_id is None
|
||||||
|
|
||||||
|
|
||||||
async def test_scene_turn_on_service(hass, mock_bridge_v2, v2_resources_test_data):
|
async def test_scene_turn_on_service(hass, mock_bridge_v2, v2_resources_test_data):
|
||||||
"""Test calling the turn on service on a scene."""
|
"""Test calling the turn on service on a scene."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user