Lambda for loop id(variable).state

You’ll anyway have to expose a fixed list of available sensors in your code.

To dynamically access one of the sensors based on an ID of your choice, can have a look at this solution (the lambda part). In this example it’s using a numeric number as key and a LightState pointer as value.

In your case I have no idea what class this “cell_voltage_1” component is. You’ll need to post some more yaml for that.