A possible solution to multiple variable length bed serving

The barcode thing could work, but it sounds like quite a lot of tech to throw at it.

What about just adding a magnet at 1m intervals and a hall effect sensor