Repository: truenas/py-SMART

Issue:
NVME interface devices on Windows show is_ssd=False
Devices in Windows are always shown as /dev/sdaX. No matter if it is nvme or not.
As a result SSD devices with the nvme interface always have the attribute `is_ssd` set to `False`.
I could provide an example from my windows 11 system but the testcase `tests/dataset/singletests/nvme_win10_0_issue_64` is actually a perfect example of this behavior. 
Could you use the interface `nvme` reported in the `--scan-open` which is the same as the value of the `interface` in the result as an indicator for `is_ssd` ?

Discussion:

Solution patch:
diff --git a/pySMART/device.py b/pySMART/device.py
index 2359726..6b2af49 100644
--- a/pySMART/device.py
+++ b/pySMART/device.py
@@ -134,12 +134,12 @@ class Device(object):
         """**(str):** Device's user capacity (human readable) as reported directly by smartctl (RAW)."""
         self.firmware: Optional[str] = None
         """**(str):** Device's firmware version."""
-        self.smart_capable: bool = 'nvme' in self.name
+        self.smart_capable: bool = self._interface == 'nvme'
         """
         **(bool):** True if the device has SMART Support Available.
         False otherwise. This is useful for VMs amongst other things.
         """
-        self.smart_enabled: bool = 'nvme' in self.name
+        self.smart_enabled: bool = self._interface == 'nvme'
         """
         **(bool):** True if the device supports SMART (or SCSI equivalent) and
         has the feature set enabled. False otherwise.
@@ -153,7 +153,7 @@ class Device(object):
         **(list of str):** Contains any SMART warnings or other error messages
         reported by the device (ie: ascq codes).
         """
-        self.is_ssd: bool = True if 'nvme' in self.name else False
+        self.is_ssd: bool = self._interface == 'nvme'
         """
         **(bool):** True if this device is a Solid State Drive.
         False otherwise.
@@ -280,6 +280,7 @@ class Device(object):
                             if self._interface == "nvme":  # if nvme set SMART to true
                                 self.smart_capable = True
                                 self.smart_enabled = True
+                                self.is_ssd = True
 
                             break
                 except:


Test patch:
diff --git a/tests/dataset/singletests/nvme_10_issue_73/device.json b/tests/dataset/singletests/nvme_10_issue_73/device.json
index a5f6c66..c37b2af 100644
--- a/tests/dataset/singletests/nvme_10_issue_73/device.json
+++ b/tests/dataset/singletests/nvme_10_issue_73/device.json
@@ -298,7 +298,7 @@
             "warningTemperatureTime": null
         },
         "interface": "nvme",
-        "is_ssd": false,
+        "is_ssd": true,
         "logical_sector_size": 512,
         "messages": [],
         "model": "Netac NVMe SSD 2TB",
@@ -309,8 +309,8 @@
         "serial": "RN202303092TB677720",
         "size": 2000398934016,
         "size_raw": "2.00 TB",
-        "smart_capable": false,
-        "smart_enabled": false,
+        "smart_capable": true,
+        "smart_enabled": true,
         "smartctl_interface": "nvme",
         "temperature": 54,
         "temperatures": {
diff --git a/tests/dataset/singletests/nvme_11_issue_75/device.json b/tests/dataset/singletests/nvme_11_issue_75/device.json
index 7d7c559..d0b0479 100644
--- a/tests/dataset/singletests/nvme_11_issue_75/device.json
+++ b/tests/dataset/singletests/nvme_11_issue_75/device.json
@@ -347,7 +347,7 @@
             "warningTemperatureTime": null
         },
         "interface": "nvme",
-        "is_ssd": false,
+        "is_ssd": true,
         "logical_sector_size": 512,
         "messages": [],
         "model": "KBG30ZMV256G TOSHIBA",
@@ -358,8 +358,8 @@
         "serial": "68APC048P12P",
         "size": 256060514304,
         "size_raw": "256 GB",
-        "smart_capable": false,
-        "smart_enabled": false,
+        "smart_capable": true,
+        "smart_enabled": true,
         "smartctl_interface": "nvme",
         "temperature": 48,
         "temperatures": {
diff --git a/tests/dataset/singletests/nvme_9_issue_72/device.json b/tests/dataset/singletests/nvme_9_issue_72/device.json
index 3a1d847..af8cc62 100644
--- a/tests/dataset/singletests/nvme_9_issue_72/device.json
+++ b/tests/dataset/singletests/nvme_9_issue_72/device.json
@@ -298,7 +298,7 @@
             "warningTemperatureTime": null
         },
         "interface": "nvme",
-        "is_ssd": false,
+        "is_ssd": true,
         "logical_sector_size": 512,
         "messages": [],
         "model": "KINGSTON SA2000M8500G",
@@ -309,8 +309,8 @@
         "serial": "50026B72826F6BB1",
         "size": 500107862016,
         "size_raw": "500 GB",
-        "smart_capable": false,
-        "smart_enabled": false,
+        "smart_capable": true,
+        "smart_enabled": true,
         "smartctl_interface": "nvme",
         "temperature": 38,
         "temperatures": {},
diff --git a/tests/dataset/singletests/nvme_win10_0_issue_64/device.json b/tests/dataset/singletests/nvme_win10_0_issue_64/device.json
index 96a195d..cc1a6f1 100644
--- a/tests/dataset/singletests/nvme_win10_0_issue_64/device.json
+++ b/tests/dataset/singletests/nvme_win10_0_issue_64/device.json
@@ -383,7 +383,7 @@
             "warningTemperatureTime": null
         },
         "interface": "nvme",
-        "is_ssd": false,
+        "is_ssd": true,
         "logical_sector_size": 512,
         "messages": [],
         "model": "Samsung SSD 980 PRO 1TB",
@@ -394,8 +394,8 @@
         "serial": "S5P2NG0NB05964V",
         "size": 1000204886016,
         "size_raw": "1.00 TB",
-        "smart_capable": false,
-        "smart_enabled": false,
+        "smart_capable": true,
+        "smart_enabled": true,
         "smartctl_interface": "nvme",
         "temperature": 62,
         "temperatures": {
diff --git a/tests/dataset/singletests/nvme_win10_mingw32_0_issue_48/device.json b/tests/dataset/singletests/nvme_win10_mingw32_0_issue_48/device.json
index 413494b..8990faa 100644
--- a/tests/dataset/singletests/nvme_win10_mingw32_0_issue_48/device.json
+++ b/tests/dataset/singletests/nvme_win10_mingw32_0_issue_48/device.json
@@ -297,7 +297,7 @@
             "warningTemperatureTime": 2
         },
         "interface": "nvme",
-        "is_ssd": false,
+        "is_ssd": true,
         "logical_sector_size": 512,
         "messages": [],
         "model": "WDS100T3X0C-00SJG0",