def test_get_entity_ids_with_domain_filter(self): """Test if get_entity_ids works with a domain_filter.""" self.hass.states.set("switch.AC", STATE_OFF) mixed_group = group.Group.create_group(self.hass, "mixed_group", ["light.Bowl", "switch.AC"], False) self.assertEqual(["switch.ac"], group.get_entity_ids(self.hass, mixed_group.entity_id, domain_filter="switch"))
def test_get_entity_ids(self): """Test get_entity_ids method.""" self.hass.states.set("light.Bowl", STATE_ON) self.hass.states.set("light.Ceiling", STATE_OFF) test_group = group.Group.create_group(self.hass, "init_group", ["light.Bowl", "light.Ceiling"], False) self.assertEqual(["light.bowl", "light.ceiling"], sorted(group.get_entity_ids(self.hass, test_group.entity_id)))
def _resolve_group(self, group_entity_id) -> None: """Resolve a group. Will only be called if group is an entry point. """ for entity_id in group.get_entity_ids(self.hass, group_entity_id): self._add_or_resolve("entity", entity_id)
def test_get_entity_ids(self): """ Test get_entity_ids method. """ # Get entity IDs from our group self.assertEqual( sorted(['light.Ceiling', 'light.Bowl']), sorted(group.get_entity_ids(self.hass, self.group_name))) # Test domain_filter self.assertEqual(['switch.AC'], group.get_entity_ids(self.hass, self.mixed_group_name, domain_filter="switch")) # Test with non existing group name self.assertEqual([], group.get_entity_ids(self.hass, 'non_existing')) # Test with non-group state self.assertEqual([], group.get_entity_ids(self.hass, 'switch.AC'))
def test_get_entity_ids(self): """Test get_entity_ids method.""" self.hass.states.set('light.Bowl', STATE_ON) self.hass.states.set('light.Ceiling', STATE_OFF) test_group = group.Group.create_group( self.hass, 'init_group', ['light.Bowl', 'light.Ceiling'], False) assert ['light.bowl', 'light.ceiling'] == \ sorted(group.get_entity_ids(self.hass, test_group.entity_id))
def test_get_entity_ids(self): """ Test get_entity_ids method. """ # Get entity IDs from our group self.assertEqual( sorted(['light.Ceiling', 'light.Bowl']), sorted(group.get_entity_ids(self.hass, self.group_name))) # Test domain_filter self.assertEqual( ['switch.AC'], group.get_entity_ids( self.hass, self.mixed_group_name, domain_filter="switch")) # Test with non existing group name self.assertEqual([], group.get_entity_ids(self.hass, 'non_existing')) # Test with non-group state self.assertEqual([], group.get_entity_ids(self.hass, 'switch.AC'))
def test_get_entity_ids(self): """Test get_entity_ids method.""" self.hass.states.set("light.Bowl", STATE_ON) self.hass.states.set("light.Ceiling", STATE_OFF) test_group = group.Group.create_group(self.hass, "init_group", ["light.Bowl", "light.Ceiling"], False) assert ["light.bowl", "light.ceiling"] == sorted( group.get_entity_ids(self.hass, test_group.entity_id))
def test_get_entity_ids(self): """Test get_entity_ids method.""" self.hass.states.set('light.Bowl', STATE_ON) self.hass.states.set('light.Ceiling', STATE_OFF) test_group = group.Group.create_group( self.hass, 'init_group', ['light.Bowl', 'light.Ceiling'], False) self.assertEqual( ['light.bowl', 'light.ceiling'], sorted(group.get_entity_ids(self.hass, test_group.entity_id)))
def test_get_entity_ids_with_domain_filter(self): """Test if get_entity_ids works with a domain_filter.""" self.hass.states.set('switch.AC', STATE_OFF) mixed_group = group.Group.create_group( self.hass, 'mixed_group', ['light.Bowl', 'switch.AC'], False) assert ['switch.ac'] == \ group.get_entity_ids( self.hass, mixed_group.entity_id, domain_filter="switch")
def test_get_entity_ids_with_domain_filter(self): """Test if get_entity_ids works with a domain_filter.""" self.hass.states.set("switch.AC", STATE_OFF) mixed_group = group.Group.create_group(self.hass, "mixed_group", ["light.Bowl", "switch.AC"], False) assert ["switch.ac"] == group.get_entity_ids(self.hass, mixed_group.entity_id, domain_filter="switch")
def test_get_entity_ids_with_domain_filter(self): """Test if get_entity_ids works with a domain_filter.""" self.hass.states.set('switch.AC', STATE_OFF) mixed_group = group.Group(self.hass, 'mixed_group', ['light.Bowl', 'switch.AC'], False) self.assertEqual(['switch.ac'], group.get_entity_ids(self.hass, mixed_group.entity_id, domain_filter="switch"))
async def test_get_entity_ids_with_domain_filter(hass): """Test if get_entity_ids works with a domain_filter.""" hass.states.async_set("switch.AC", STATE_OFF) assert await async_setup_component(hass, "group", {}) mixed_group = await group.Group.async_create_group( hass, "mixed_group", ["light.Bowl", "switch.AC"], False) assert ["switch.ac"] == group.get_entity_ids(hass, mixed_group.entity_id, domain_filter="switch")
async def test_get_entity_ids(hass): """Test get_entity_ids method.""" hass.states.async_set("light.Bowl", STATE_ON) hass.states.async_set("light.Ceiling", STATE_OFF) assert await async_setup_component(hass, "group", {}) test_group = await group.Group.async_create_group( hass, "init_group", ["light.Bowl", "light.Ceiling"], False) assert ["light.bowl", "light.ceiling" ] == sorted(group.get_entity_ids(hass, test_group.entity_id))
def setup(hass, config): # state listener: pass in entity that changed def state_changed(entity_id, old_state, new_state): _LOGGER.debug(f"{dbg()}:{entity_id} changed state: {new_state}") hass.data[ENERGY_ASSET_DOMAIN].add_dirty_list(entity_id) hass.data[ENERGY_ASSET_DOMAIN].update_asset(entity_id, new_state.attributes) _LOGGER.debug(f"{dbg()}:Entities: {group.get_entity_ids(hass, 'group.all_switches')}") # register the state change listener: pass in the entities to observer and the callback listener # will listen on the event bus and filter for the entities we care about track_state_change(hass, group.get_entity_ids(hass, 'group.all_switches'), state_changed) return True # show that the component loaded successfully
def test_get_entity_ids_with_non_existing_group_name(self): """Test get_entity_ids with a non existing group.""" assert [] == group.get_entity_ids(self.hass, 'non_existing')
def test_get_entity_ids_with_non_group_state(self): """Test get_entity_ids with a non group state.""" self.assertEqual([], group.get_entity_ids(self.hass, 'switch.AC'))
def test_get_entity_ids_with_non_existing_group_name(self): """Test get_entity_ids with a non existing group.""" self.assertEqual([], group.get_entity_ids(self.hass, 'non_existing'))
def test_get_entity_ids_with_non_existing_group_name(self): """Test get_entity_ids with a non existing group.""" assert [] == group.get_entity_ids(self.hass, "non_existing")
def test_get_entity_ids_with_non_group_state(self): """Test get_entity_ids with a non group state.""" assert [] == group.get_entity_ids(self.hass, 'switch.AC')
def test_get_entity_ids_with_non_group_state(self): """Test get_entity_ids with a non group state.""" assert [] == group.get_entity_ids(self.hass, "switch.AC")
def test_get_entity_ids(self): """ Test get_entity_ids method. """ self.assertEqual( ['light.bowl', 'light.ceiling'], sorted(group.get_entity_ids(self.hass, self.group_entity_id)))