hass-agent / HASS.Agent

Unofficial development project for the HASS.Agent platform.
https://hass-agent.io
MIT License
373 stars 9 forks source link

Bug: Storage sensor does not show mapped disk volumes to folder. #37

Open danishru opened 10 months ago

danishru commented 10 months ago

Describe the bug If you have volumes without a drive letter that are mounted in a folders, then sensors will not be created for such volumes..

To Reproduce Steps to reproduce the behavior:

  1. Create volume, without letter only mounted to folder.
  2. Create StorageSensors.
  3. Go to mqtt device.
  4. Storage sensor not show disk volumes without letter.

Expected behavior Should create storage sensors for volumes with and without letter. For example, as shown by the PowerShell command get-volume.

Screenshots Disk volumes for which I want to see sensors. image

What I see image

Misc info (please complete the following information):

Please check what's applicable (multiple answers possible):

Additional context Having studied the source code of the sensor, I came to I come to the conclusion that the DriveInfo.GetDrives method cannot show drives that do not have drive letters. In the PowerShell command, get-volume is apparently implemented through the Windows API, detailed in this forum post

amadeo-alex commented 9 months ago

Does the sensor of drive where the "other drive" is mounted as a folder include the size of the "other drive"?

amadeo-alex commented 8 months ago

The link to the forum post seems to return "404 - Page not found", could you elaborate on this? It may not be so straightforward to change the current storage sensor but it may be possible to create another one dedicated for the drives without letter.

danishru commented 8 months ago

Does the sensor of drive where the "other drive" is mounted as a folder include the size of the "other drive"?

No, it doesn't include.

The link to the forum post seems to return "404 - Page not found", could you elaborate on this?

Yes, the link to the discussion has been removed. As far as I remember, they recommended using this information. https://learn.microsoft.com/en-us/windows/win32/fileio/volume-mount-points

It may not be so straightforward to change the current storage sensor but it may be possible to create another one dedicated for the drives without letter.

This would be a good alternative, for example using the same Powershell, but it would be great to see any other option. I have already suggested in another Issue how this can be done universally.

amadeo-alex commented 5 months ago

So, I have some progress on this but I wouldn't call it a major one. I have a POC that is able to list mounted folders for specific volume but it requires admin rights to function: OArYeR

I can be switched around and such mounted folders would be treated "per device" (as the mounted folders come up in path names information) but I need to work around a few things.