Found this when snorkling in Greece about 17 years ago when i was just a kid. Always wondered what it was... Anyone an idea? Almost certainly made of metal and i think it is hollow on the inside.
From a quick search, it is used to control the flow of refrigerant based on its temperature. The tube deforms based on how hot or cold the refrigerant is, and there are contacts on the tube to switches that permit or resrrict coolant flow
Just to add my 2 cents, it's more likely a filter/drier from a refrigerator. Those are much more common, even though a sensor/thermal bulb looks very similar.
Picking up trash under water is not the same as picking up trash on land. The small piece OP collected was probably ok, but the damage you can do to the ecosystem by removing a bottle or other big chunks that have been there for years can be really bad. I hope all divers have that in mind when they explore the underwater world.
Edit: I don't get the downvotes, I'm not making this up. It's one of the first things you learn as a CMAS diver.
Phew. The small size, combined with other people surmising it might be part of a refrigerator greatly alleviates my worries you might have picked up a piece of unexploded munitions from WW2. Which is an all too common thing over here in Germany.
There could be dangerous coolant in it. When scrapping devices using coolant, the workers used to make it pump it into this chamber, then squish the end tight, roll it a bit, then remove it.