How can I check which of my collections are hidden in viewport? Using this part of code...
for collection in bpy.data.collections:
    print(collection.name, ' - ', collection.hide_viewport)

...I am trying to check which of my collections are hidden in viewport. But the result I get in console, has to do with the collection where are disabled in viewport!!! Any idea what is the correct way?
Looping collections through bpy.data.collections gives you classes of type Collection:
https://docs.blender.org/api/current/bpy.types.Collection.html#bpy.types.Collection
Looping collections through bpy.context.view_layer.layer_collection.children gives you classes of type LayerCollection:
https://docs.blender.org/api/current/bpy.types.LayerCollection.html#bpy.types.LayerCollection
The meaning of the property hide_viewport seems to be slightly different in these two class types.

In type Collection it means: &quot;Globally disable in viewports&quot;
In type LayerCollection it means: &quot;Temporarily hide in viewport&quot;
Type LayerCollection additionally exposes the property is_visible, which is True, when the collection is both enabled and visible

I guess LayerCollection.hide_viewport is what you were looking for.
Code example to see the differences in action:
print('Looping type &quot;Collection&quot;, property &quot;hide_viewport&quot;:')
for collection in bpy.data.collections:
    print(collection.name, ' - Disabled in Viewport:', collection.hide_viewport)

print('Looping type &quot;LayerCollection&quot;, property &quot;hide_viewport&quot;:')
for layer_collection in bpy.context.view_layer.layer_collection.children:
    print(layer_collection.name, ' - Hidden in Viewport: ', layer_collection.hide_viewport)

print('Looping type &quot;LayerCollection&quot;, property &quot;is_visible&quot;:')
for layer_collection in bpy.context.view_layer.layer_collection.children:
    print(layer_collection.name, ' - Enabled and visible: ', layer_collection.is_visible)