From d08d00daa72d039545b46e739e686bdc41b55696 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Thu, 2 Jul 2020 02:39:53 -0700 Subject: [PATCH] Limit entity platform entity service to same integration (#37313) --- homeassistant/helpers/entity_platform.py | 6 +++++- tests/helpers/test_entity_platform.py | 9 +++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/homeassistant/helpers/entity_platform.py b/homeassistant/helpers/entity_platform.py index 0a7667e64d5..ee60563ba2a 100644 --- a/homeassistant/helpers/entity_platform.py +++ b/homeassistant/helpers/entity_platform.py @@ -517,7 +517,11 @@ class EntityPlatform: """Handle the service.""" await service.entity_service_call( self.hass, - self.hass.data[DATA_ENTITY_PLATFORM][self.platform_name], + [ + plf + for plf in self.hass.data[DATA_ENTITY_PLATFORM][self.platform_name] + if plf.domain == self.domain + ], func, call, required_features, diff --git a/tests/helpers/test_entity_platform.py b/tests/helpers/test_entity_platform.py index 8917e69e3ae..d5b817e0655 100644 --- a/tests/helpers/test_entity_platform.py +++ b/tests/helpers/test_entity_platform.py @@ -882,6 +882,15 @@ async def test_platforms_sharing_services(hass): entity2 = MockEntity(entity_id="mock_integration.entity_2") await entity_platform2.async_add_entities([entity2]) + entity_platform3 = MockEntityPlatform( + hass, + domain="different_integration", + platform_name="mock_platform", + platform=None, + ) + entity3 = MockEntity(entity_id="different_integration.entity_3") + await entity_platform3.async_add_entities([entity3]) + entities = [] @callback