Okay, first off, it's important to say what no one here seems willing to say: no one knows squat about this. Everything anyone says or has said is the subject of intense debate and inflammatory argumentation.
What this means to a worldbuilder is simple: you don't have to explain it.
Any organism at all can have sentience, and no one on Earth can say anything about it. As far as planets with sentient life go, we have a sample size of one. There is simply zero sound science on the matter.
Expect argument on this!
Second, I'm looking around and I'm seeing a huge amount of poor, poor analysis of evolution, the kind of talk that leaves space for creationists to argue. If you see the words "evolutionary purpose" run screaming. The phrase is meaningless at best and harmfully misleading at worst.
Holy effing JC, I lose patience with this. Evolution has no purpose. Evolution's primary engine is randomness. Natural selection can narrow down the amount of successful organisms, but it doesn't create them or direct them.
I've got to say this again: evolution has no purpose. To say that this or that feature of an organism is constrained by "evolutionary purpose" is putting the cart before the horse, or if you will, the arthropod before the ganglia. The mechanism is simple: evolution happens by accident, natural selection narrows it down.
Look, here's a simple example: say there's a lush field full of life and flying creatures with all sorts of flowery ornamental plumage, as tends to happen when there aren't lots of predators around that can manage to catch birds. Then suddenly the field is buried in lava. What species of bird will survive?
Some subset of the birds that happened to be in the air at the time. None of those birds developed with the "evolutionary purpose" of surviving sudden outpourings of lava. Even more relevant, the color and structure of the plumage of the birds that survived had nothing to do with whether or not they survived the lava.
Those colors and plumage happened because the environment allowed the randomness of evolution to travel down all sorts of useless byways, because there was nothing around to stop it. Then, through nobody's virtue or intention, a bunch of them died off. Fast forward to today, and some people on various websites argue about the "evolutionary purpose" of this or that frilly crest on this or that bird. It's nonsense! It's pure folderol.
So these people talking about this or that environmental stimuli leading to the development of consciousness are talking out their bazoo. The rule is: evolution happens randomly to the degree an environment permits it.
So yes, a sedentary organism could develop sentience. It could be in the face of environmental pressures, or it could be just because it did, that's why, and there's nothing more to it.
Nobody likes this, because we don't like uncertainty, which is why you get a lot of authoritative-sounding talk like you'll see around. But the most irritating fact is that evolution seems like a system almost entirely designed to foil the kind of answers people like to give.
This isn't my thinking, by the way, I got all this from Stephen Jay Gould.
Expect argument on this!
P.S.: people should be cautious about using plants as an example of lack of sentience. It's not broadly known, but there is in fact a growing field called "plant neurobiology". It's highly controversial, but it's far from a settled argument, partly because certain plants have been shown to pass tests of sentience that it was previously assumed only animals could pass.
P.P.S: the other thing people who like to sound authoritative always leave out is sexual selection, a mechanism described by Darwin and almost entirely ignored in layman's arguments. Simply put, a hyperintelligent mollusk could evolve just because the female mollusks thought they were cute.