]> git.basschouten.com Git - openhab-addons.git/commitdiff
[systeminfo] QuantityTypes and state descriptions cleanup (#13804)
authorMark Herwege <mherwege@users.noreply.github.com>
Sat, 10 Dec 2022 22:32:25 +0000 (23:32 +0100)
committerGitHub <noreply@github.com>
Sat, 10 Dec 2022 22:32:25 +0000 (23:32 +0100)
* State descriptions cleanup
* Converted channels to QuantityType, adjusted default translations
* Channel definitions and percent to QuanityType
* Changed default state descriptions from MB to MiB

Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
bundles/org.openhab.binding.systeminfo/README.md
bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/handler/SysteminfoHandler.java
bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/OSHISysteminfo.java
bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/SysteminfoInterface.java
bundles/org.openhab.binding.systeminfo/src/main/resources/OH-INF/i18n/systeminfo.properties
bundles/org.openhab.binding.systeminfo/src/main/resources/OH-INF/thing/channels.xml
itests/org.openhab.binding.systeminfo.tests/src/main/java/org/openhab/binding/systeminfo/test/SysteminfoOSGiTest.java

index bc3abf59fe1299051ebf1b862626fa527ec5638d..1d01a923ab3223a93e4f202cc9694dc6ff4d1af5 100644 (file)
@@ -118,22 +118,22 @@ The binding introduces the following channels:
 | load15             | Load for the last 15 minutes                                     | Number              | Medium           | True     |
 | threads            | Number of threads currently running or for the process           | Number              | Medium           | True     |
 | path               | The full path of the process                                     | String              | Low              | False    |
-| uptime             | System uptime (time after start) in minutes                      | Number              | Medium           | True     |
+| uptime             | System uptime (time after start) in minutes                      | Number:Time         | Medium           | True     |
 | name               | Name of the device or process                                    | String              | Low              | False    |
-| available          | Available size in MB                                             | Number              | High             | False    |
-| used               | Used size in MB                                                  | Number              | High             | False    |
-| total              | Total size in MB                                                 | Number              | Low              | False    |
-| availablePercent   | Available size in %                                              | Number              | High             | False    |
-| usedPercent        | Used size in %                                                   | Number              | High             | False    |
+| available          | Available size                                                   | Number:DataAmount   | High             | False    |
+| used               | Used size                                                        | Number:DataAmount   | High             | False    |
+| total              | Total size                                                       | Number:DataAmount   | Low              | False    |
+| availablePercent   | Available size in %                                              | Number:Dimensionless| High             | False    |
+| usedPercent        | Used size in %                                                   | Number:Dimensionless| High             | False    |
 | model              | The model of the device                                          | String              | Low              | True     |
 | serial             | The serial number of the device                                  | String              | Low              | True     |
 | description        | Description of the device                                        | String              | Low              | True     |
 | type               | Storage type                                                     | String              | Low              | True     |
-| cpuTemp            | CPU Temperature in degrees Celsius                               | Number              | High             | True     |
-| cpuVoltage         | CPU Voltage in V                                                 | Number              | Medium           | True     |
+| cpuTemp            | CPU Temperature in degrees Celsius                               | Number:Temperature  | High             | True     |
+| cpuVoltage         | CPU Voltage                                                      | Number:ElectricPotential| Medium       | True     |
 | fanSpeed           | Fan speed in rpm                                                 | Number              | Medium           | True     |
-| remainingTime      | Remaining time in minutes                                        | Number              | Medium           | False    |
-| remainingCapacity  | Remaining capacity in %                                          | Number              | Medium           | False    |
+| remainingTime      | Remaining time in minutes                                        | Number:Time         | Medium           | False    |
+| remainingCapacity  | Remaining capacity in %                                          | Number:Dimensionless| Medium           | False    |
 | information        | Product, manufacturer, SN, width and height of the display in cm | String              | Low              | True     |
 | ip                 | Host IP address of the network                                   | String              | Low              | False    |
 | mac                | MAC address                                                      | String              | Low              | True     |
@@ -141,9 +141,9 @@ The binding introduces the following channels:
 | networkDisplayName | The display name of the network                                  | String              | Low              | False    |
 | packetsSent        | Number of packets sent                                           | Number              | Medium           | True     |
 | packetsReceived    | Number of packets received                                       | Number              | Medium           | True     |
-| dataSent           | Data sent in MB                                                  | Number              | Medium           | True     |
-| dataReceived       | Data received in MB                                              | Number              | Medium           | True     |
-| availableHeap      | How many bytes are free out of the currently committed heap      | Number:DataAmount   | Medium           | True     |
+| dataSent           | Volume of data sent                                              | Number:DataAmount   | Medium           | True     |
+| dataReceived       | Volume of data received                                          | Number:DataAmount   | Medium           | True     |
+| availableHeap      | How much space is available in the currently committed heap      | Number:DataAmount   | Medium           | True     |
 | usedHeapPercent    | How much of the MAX heap size is actually used in %              | Number:Dimensionless| Medium           | False    |
 
 ## Channel configuration
@@ -195,80 +195,80 @@ Items:
 
 ```
 /* Network information*/
-String Network_AdapterName        "Adapter name"        <network>        { channel="systeminfo:computer:work:network#networkDisplayName" }
-String Network_Name               "Name"                <network>        { channel="systeminfo:computer:work:network#networkName" }
-String Network_IP                 "IP address"          <network>        { channel="systeminfo:computer:work:network#ip" }
-String Network_Mac                "Mac address"         <network>        { channel="systeminfo:computer:work:network#mac" }
-Number Network_DataSent           "Data sent"           <flowpipe>       { channel="systeminfo:computer:work:network#dataSent" }
-Number Network_DataReceived       "Data received"       <returnpipe>     { channel="systeminfo:computer:work:network#dataReceived" }
-Number Network_PacketsSent        "Packets sent"        <flowpipe>       { channel="systeminfo:computer:work:network#packetsSent" }
-Number Network_PacketsReceived    "Packets received"    <returnpipe>     { channel="systeminfo:computer:work:network#packetsReceived" }
+String Network_AdapterName         "Adapter name"        <network>       { channel="systeminfo:computer:work:network#networkDisplayName" }
+String Network_Name                "Name"                <network>       { channel="systeminfo:computer:work:network#networkName" }
+String Network_IP                  "IP address"          <network>       { channel="systeminfo:computer:work:network#ip" }
+String Network_Mac                 "Mac address"         <network>       { channel="systeminfo:computer:work:network#mac" }
+Number Network_DataSent            "Data sent"           <flowpipe>      { channel="systeminfo:computer:work:network#dataSent" }
+Number Network_DataReceived        "Data received"       <returnpipe>    { channel="systeminfo:computer:work:network#dataReceived" }
+Number Network_PacketsSent         "Packets sent"        <flowpipe>      { channel="systeminfo:computer:work:network#packetsSent" }
+Number Network_PacketsReceived     "Packets received"    <returnpipe>    { channel="systeminfo:computer:work:network#packetsReceived" }
 
 /* CPU information*/
-String CPU_Name                   "Name"                <none>           { channel="systeminfo:computer:work:cpu#name" }
-String CPU_Description            "Description"         <none>           { channel="systeminfo:computer:work:cpu#description" }
-Number CPU_Load                   "CPU Load"            <none>           { channel="systeminfo:computer:work:cpu#load" }
-Number CPU_Load1                  "Load (1 min)"        <none>           { channel="systeminfo:computer:work:cpu#load1" }
-Number CPU_Load5                  "Load (5 min)"        <none>           { channel="systeminfo:computer:work:cpu#load5" }
-Number CPU_Load15                 "Load (15 min)"       <none>           { channel="systeminfo:computer:work:cpu#load15" }
-Number CPU_Threads                "Threads"             <none>           { channel="systeminfo:computer:work:cpu#threads" }
-Number CPU_Uptime                 "Uptime"              <time>           { channel="systeminfo:computer:work:cpu#uptime" }
+String CPU_Name                    "Name"                <none>          { channel="systeminfo:computer:work:cpu#name" }
+String CPU_Description             "Description"         <none>          { channel="systeminfo:computer:work:cpu#description" }
+Number:Dimensionless CPU_Load      "CPU Load"            <none>          { channel="systeminfo:computer:work:cpu#load" }
+Number CPU_Load1                   "Load (1 min)"        <none>          { channel="systeminfo:computer:work:cpu#load1" }
+Number CPU_Load5                   "Load (5 min)"        <none>          { channel="systeminfo:computer:work:cpu#load5" }
+Number CPU_Load15                  "Load (15 min)"       <none>          { channel="systeminfo:computer:work:cpu#load15" }
+Number CPU_Threads                 "Threads"             <none>          { channel="systeminfo:computer:work:cpu#threads" }
+Number:Time CPU_Uptime             "Uptime"              <time>          { channel="systeminfo:computer:work:cpu#uptime" }
 
 /* Drive information*/
-String Drive_Name                 "Name"                <none>           { channel="systeminfo:computer:work:drive#name" }
-String Drive_Model                "Model"               <none>           { channel="systeminfo:computer:work:drive#model" }
-String Drive_Serial               "Serial"              <none>           { channel="systeminfo:computer:work:drive#serial" }
+String Drive_Name                  "Name"                <none>          { channel="systeminfo:computer:work:drive#name" }
+String Drive_Model                 "Model"               <none>          { channel="systeminfo:computer:work:drive#model" }
+String Drive_Serial                "Serial"              <none>          { channel="systeminfo:computer:work:drive#serial" }
 
 /* Storage information*/
-String Storage_Name               "Name"                <none>           { channel="systeminfo:computer:work:storage#name" }
-String Storage_Type               "Type"                <none>           { channel="systeminfo:computer:work:storage#type" }
-String Storage_Description        "Description"         <none>           { channel="systeminfo:computer:work:storage#description" }
-Number Storage_Available          "Available"           <none>           { channel="systeminfo:computer:work:storage#available" }
-Number Storage_Used               "Used"                <none>           { channel="systeminfo:computer:work:storage#used" }
-Number Storage_Total              "Total"               <none>           { channel="systeminfo:computer:work:storage#total" }
-Number Storage_Available_Percent  "Available (%)"       <none>           { channel="systeminfo:computer:work:storage#availablePercent" }
-Number Storage_Used_Percent       "Used (%)"            <none>           { channel="systeminfo:computer:work:storage#usedPercent" }
+String Storage_Name                "Name"                <none>          { channel="systeminfo:computer:work:storage#name" }
+String Storage_Type                "Type"                <none>          { channel="systeminfo:computer:work:storage#type" }
+String Storage_Description         "Description"         <none>          { channel="systeminfo:computer:work:storage#description" }
+Number:DataAmount Storage_Available "Available"          <none>          { channel="systeminfo:computer:work:storage#available" }
+Number:DataAmount Storage_Used     "Used"                <none>          { channel="systeminfo:computer:work:storage#used" }
+Number:DataAmount Storage_Total    "Total"               <none>          { channel="systeminfo:computer:work:storage#total" }
+Number:Dimensionless Storage_Available_Percent "Available (%)" <none>    { channel="systeminfo:computer:work:storage#availablePercent" }
+Number:Dimensionless Storage_Used_Percent "Used (%)"     <none>          { channel="systeminfo:computer:work:storage#usedPercent" }
 
 /* Memory information*/
-Number Memory_Available           "Available"           <none>           { channel="systeminfo:computer:work:memory#available" }
-Number Memory_Used                "Used"                <none>           { channel="systeminfo:computer:work:memory#used" }
-Number Memory_Total               "Total"               <none>           { channel="systeminfo:computer:work:memory#total" }
-Number Memory_Available_Percent   "Available (%)"       <none>           { channel="systeminfo:computer:work:memory#availablePercent" }
-Number Memory_Used_Percent        "Used (%)"            <none>           { channel="systeminfo:computer:work:memory#usedPercent" }
+Number Memory_Available            "Available"           <none>          { channel="systeminfo:computer:work:memory#available" }
+Number:DataAmount Memory_Used      "Used"                <none>          { channel="systeminfo:computer:work:memory#used" }
+Number:DataAmount Memory_Total     "Total"               <none>          { channel="systeminfo:computer:work:memory#total" }
+Number:Dimensionless Memory_Available_Percent "Available (%)" <none>     { channel="systeminfo:computer:work:memory#availablePercent" }
+Number:Dimensionless Memory_Used_Percent "Used (%)"      <none>          { channel="systeminfo:computer:work:memory#usedPercent" }
 
 /* Swap memory information*/
-Number Swap_Available             "Available"           <none>           { channel="systeminfo:computer:work:swap#available" }
-Number Swap_Used                  "Used"                <none>           { channel="systeminfo:computer:work:swap#used" }
-Number Swap_Total                 "Total"               <none>           { channel="systeminfo:computer:work:swap#total" }
-Number Swap_Available_Percent     "Available (%)"       <none>           { channel="systeminfo:computer:work:swap#availablePercent" }
-Number Swap_Used_Percent          "Used (%)"            <none>           { channel="systeminfo:computer:work:swap#usedPercent" }
+Number:DataAmount Swap_Available   "Available"           <none>          { channel="systeminfo:computer:work:swap#available" }
+Number:DataAmount Swap_Used        "Used"                <none>          { channel="systeminfo:computer:work:swap#used" }
+Number:DataAmount Swap_Total       "Total"               <none>          { channel="systeminfo:computer:work:swap#total" }
+Number:Dimensionless Swap_Available_Percent "Available (%)" <none>       { channel="systeminfo:computer:work:swap#availablePercent" }
+Number:Dimensionless Swap_Used_Percent "Used (%)"        <none>          { channel="systeminfo:computer:work:swap#usedPercent" }
 
 /* Battery information*/
-String Battery_Name               "Name"                <batterylevel>   { channel="systeminfo:computer:work:battery#name" }
-Number Battery_RemainingCapacity  "Remaining Capacity"  <batterylevel>   { channel="systeminfo:computer:work:battery#remainingCapacity" }
-Number Battery_RemainingTime      "Remaining Time"      <batterylevel>   { channel="systeminfo:computer:work:battery#remainingTime" }
+String Battery_Name                "Name"                <batterylevel>  { channel="systeminfo:computer:work:battery#name" }
+Number:Dimensionless Battery_RemainingCapacity "Remaining Capacity" <batterylevel> { channel="systeminfo:computer:work:battery#remainingCapacity" }
+Number:Time Battery_RemainingTime  "Remaining Time"      <batterylevel>  { channel="systeminfo:computer:work:battery#remainingTime" }
 
 /* Display information*/
-String Display_Description        "Display description" <screen>         { channel="systeminfo:computer:work:display#information" }
+String Display_Description         "Display description" <screen>        { channel="systeminfo:computer:work:display#information" }
 
 /* Sensors information*/
-Number Sensor_CPUTemp             "CPU Temperature"     <temperature>    { channel="systeminfo:computer:work:sensors#cpuTemp" }
-Number Sensor_CPUVoltage          "CPU Voltage"         <energy>         { channel="systeminfo:computer:work:sensors#cpuVoltage" }
-Number Sensor_FanSpeed            "Fan speed"           <fan>            { channel="systeminfo:computer:work:sensors#fanSpeed" }
+Number:Temperature Sensor_CPUTemp  "CPU Temperature"     <temperature>   { channel="systeminfo:computer:work:sensors#cpuTemp" }
+Number:ElectricPotential Sensor_CPUVoltage "CPU Voltage" <energy>        { channel="systeminfo:computer:work:sensors#cpuVoltage" }
+Number Sensor_FanSpeed             "Fan speed"           <fan>           { channel="systeminfo:computer:work:sensors#fanSpeed" }
 
 /* Current process information*/
-Number Current_process_load       "Load"                <none>           { channel="systeminfo:computer:work:currentProcess#load" }
-Number Current_process_used       "Used"                <none>           { channel="systeminfo:computer:work:currentProcess#used" }
-String Current_process_name       "Name"                <none>           { channel="systeminfo:computer:work:currentProcess#name" }
-Number Current_process_threads    "Threads"             <none>           { channel="systeminfo:computer:work:currentProcess#threads" }
-String Current_process_path       "Path"                <none>           { channel="systeminfo:computer:work:currentProcess#path" }
+Number:Dimensionless Current_process_load "Load"         <none>          { channel="systeminfo:computer:work:currentProcess#load" }
+Number:Dimensionless Current_process_used "Used"         <none>          { channel="systeminfo:computer:work:currentProcess#used" }
+String Current_process_name        "Name"                <none>          { channel="systeminfo:computer:work:currentProcess#name" }
+Number Current_process_threads     "Threads"             <none>          { channel="systeminfo:computer:work:currentProcess#threads" }
+String Current_process_path        "Path"                <none>          { channel="systeminfo:computer:work:currentProcess#path" }
 
 /* Process information*/
-Number Process_load               "Load"                <none>           { channel="systeminfo:computer:work:process#load" }
-Number Process_used               "Used"                <none>           { channel="systeminfo:computer:work:process#used" }
-String Process_name               "Name"                <none>           { channel="systeminfo:computer:work:process#name" }
-Number Process_threads            "Threads"             <none>           { channel="systeminfo:computer:work:process#threads" }
-String Process_path               "Path"                <none>           { channel="systeminfo:computer:work:process#path" }
+Number:Dimensionless Process_load  "Load"                <none>          { channel="systeminfo:computer:work:process#load" }
+Number:Dimensionless Process_used  "Used"                <none>          { channel="systeminfo:computer:work:process#used" }
+String Process_name                "Name"                <none>          { channel="systeminfo:computer:work:process#name" }
+Number Process_threads             "Threads"             <none>          { channel="systeminfo:computer:work:process#threads" }
+String Process_path                "Path"                <none>          { channel="systeminfo:computer:work:process#path" }
 ```
 
 Sitemap:
index 3b8efb316e6e2506c2e26cd2daa755ef586cb372..76a92016f561857c2bfe4f1358a19712e695aea9 100644 (file)
@@ -462,7 +462,7 @@ public class SysteminfoHandler extends BaseThingHandler {
                     state = systeminfo.getBatteryName(deviceIndex);
                     break;
                 case CHANNEL_BATTERY_REMAINING_CAPACITY:
-                    state = systeminfo.getBatteryRemainingCapacity(deviceIndex);
+                    state = new QuantityType<>(systeminfo.getBatteryRemainingCapacity(deviceIndex), Units.PERCENT);
                     break;
                 case CHANNEL_BATTERY_REMAINING_TIME:
                     state = systeminfo.getBatteryRemainingTime(deviceIndex);
@@ -511,10 +511,13 @@ public class SysteminfoHandler extends BaseThingHandler {
                     state = systeminfo.getMemoryTotal();
                     break;
                 case CHANNEL_MEMORY_AVAILABLE_PERCENT:
-                    state = systeminfo.getMemoryAvailablePercent();
+                    PercentType memoryAvailablePercent = systeminfo.getMemoryAvailablePercent();
+                    state = (memoryAvailablePercent != null) ? new QuantityType<>(memoryAvailablePercent, Units.PERCENT)
+                            : null;
                     break;
                 case CHANNEL_MEMORY_USED_PERCENT:
-                    state = systeminfo.getMemoryUsedPercent();
+                    PercentType memoryUsedPercent = systeminfo.getMemoryUsedPercent();
+                    state = (memoryUsedPercent != null) ? new QuantityType<>(memoryUsedPercent, Units.PERCENT) : null;
                     break;
                 case CHANNEL_SWAP_AVAILABLE:
                     state = systeminfo.getSwapAvailable();
@@ -526,10 +529,13 @@ public class SysteminfoHandler extends BaseThingHandler {
                     state = systeminfo.getSwapTotal();
                     break;
                 case CHANNEL_SWAP_AVAILABLE_PERCENT:
-                    state = systeminfo.getSwapAvailablePercent();
+                    PercentType swapAvailablePercent = systeminfo.getSwapAvailablePercent();
+                    state = (swapAvailablePercent != null) ? new QuantityType<>(swapAvailablePercent, Units.PERCENT)
+                            : null;
                     break;
                 case CHANNEL_SWAP_USED_PERCENT:
-                    state = systeminfo.getSwapUsedPercent();
+                    PercentType swapUsedPercent = systeminfo.getSwapUsedPercent();
+                    state = (swapUsedPercent != null) ? new QuantityType<>(swapUsedPercent, Units.PERCENT) : null;
                     break;
                 case CHANNEL_DRIVE_MODEL:
                     state = systeminfo.getDriveModel(deviceIndex);
@@ -559,10 +565,14 @@ public class SysteminfoHandler extends BaseThingHandler {
                     state = systeminfo.getStorageType(deviceIndex);
                     break;
                 case CHANNEL_STORAGE_AVAILABLE_PERCENT:
-                    state = systeminfo.getStorageAvailablePercent(deviceIndex);
+                    PercentType storageAvailablePercent = systeminfo.getStorageAvailablePercent(deviceIndex);
+                    state = (storageAvailablePercent != null)
+                            ? new QuantityType<>(storageAvailablePercent, Units.PERCENT)
+                            : null;
                     break;
                 case CHANNEL_STORAGE_USED_PERCENT:
-                    state = systeminfo.getStorageUsedPercent(deviceIndex);
+                    PercentType storageUsedPercent = systeminfo.getStorageUsedPercent(deviceIndex);
+                    state = (storageUsedPercent != null) ? new QuantityType<>(storageUsedPercent, Units.PERCENT) : null;
                     break;
                 case CHANNEL_NETWORK_IP:
                     state = systeminfo.getNetworkIp(deviceIndex);
index 4c4b3903c7ad8887aed3399d997ad29b52422189..9350755f3d3e295a58339f4983486f103022acbf 100644 (file)
@@ -18,11 +18,19 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import javax.measure.quantity.ElectricPotential;
+import javax.measure.quantity.Temperature;
+import javax.measure.quantity.Time;
+
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
+import org.openhab.core.library.dimension.DataAmount;
 import org.openhab.core.library.types.DecimalType;
 import org.openhab.core.library.types.PercentType;
+import org.openhab.core.library.types.QuantityType;
 import org.openhab.core.library.types.StringType;
+import org.openhab.core.library.unit.SIUnits;
+import org.openhab.core.library.unit.Units;
 import org.osgi.service.component.annotations.Component;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -53,6 +61,7 @@ import oshi.util.EdidUtil;
  *         CentralProcessor#getSystemSerialNumber()
  * @author Wouter Born - Update to OSHI 4.0.0 and add null annotations
  * @author Mark Herwege - Add dynamic creation of extra channels
+ * @author Mark Herwege - Use units of measure
  *
  * @see <a href="https://github.com/oshi/oshi">OSHI GitHub repository</a>
  */
@@ -189,59 +198,59 @@ public class OSHISysteminfo implements SysteminfoInterface {
     }
 
     @Override
-    public DecimalType getMemoryTotal() {
+    public QuantityType<DataAmount> getMemoryTotal() {
         long totalMemory = memory.getTotal();
         totalMemory = getSizeInMB(totalMemory);
-        return new DecimalType(totalMemory);
+        return new QuantityType<>(totalMemory, Units.MEBIBYTE);
     }
 
     @Override
-    public DecimalType getMemoryAvailable() {
+    public QuantityType<DataAmount> getMemoryAvailable() {
         long availableMemory = memory.getAvailable();
         availableMemory = getSizeInMB(availableMemory);
-        return new DecimalType(availableMemory);
+        return new QuantityType<>(availableMemory, Units.MEBIBYTE);
     }
 
     @Override
-    public DecimalType getMemoryUsed() {
+    public QuantityType<DataAmount> getMemoryUsed() {
         long totalMemory = memory.getTotal();
         long availableMemory = memory.getAvailable();
         long usedMemory = totalMemory - availableMemory;
         usedMemory = getSizeInMB(usedMemory);
-        return new DecimalType(usedMemory);
+        return new QuantityType<>(usedMemory, Units.MEBIBYTE);
     }
 
     @Override
-    public DecimalType getStorageTotal(int index) throws DeviceNotFoundException {
+    public QuantityType<DataAmount> getStorageTotal(int index) throws DeviceNotFoundException {
         OSFileStore fileStore = getDevice(fileStores, index);
         fileStore.updateAttributes();
         long totalSpace = fileStore.getTotalSpace();
         totalSpace = getSizeInMB(totalSpace);
-        return new DecimalType(totalSpace);
+        return new QuantityType<>(totalSpace, Units.MEBIBYTE);
     }
 
     @Override
-    public DecimalType getStorageAvailable(int index) throws DeviceNotFoundException {
+    public QuantityType<DataAmount> getStorageAvailable(int index) throws DeviceNotFoundException {
         OSFileStore fileStore = getDevice(fileStores, index);
         fileStore.updateAttributes();
         long freeSpace = fileStore.getUsableSpace();
         freeSpace = getSizeInMB(freeSpace);
-        return new DecimalType(freeSpace);
+        return new QuantityType<>(freeSpace, Units.MEBIBYTE);
     }
 
     @Override
-    public DecimalType getStorageUsed(int index) throws DeviceNotFoundException {
+    public QuantityType<DataAmount> getStorageUsed(int index) throws DeviceNotFoundException {
         OSFileStore fileStore = getDevice(fileStores, index);
         fileStore.updateAttributes();
         long totalSpace = fileStore.getTotalSpace();
         long freeSpace = fileStore.getUsableSpace();
         long usedSpace = totalSpace - freeSpace;
         usedSpace = getSizeInMB(usedSpace);
-        return new DecimalType(usedSpace);
+        return new QuantityType<>(usedSpace, Units.MEBIBYTE);
     }
 
     @Override
-    public @Nullable DecimalType getStorageAvailablePercent(int deviceIndex) throws DeviceNotFoundException {
+    public @Nullable PercentType getStorageAvailablePercent(int deviceIndex) throws DeviceNotFoundException {
         OSFileStore fileStore = getDevice(fileStores, deviceIndex);
         fileStore.updateAttributes();
         long totalSpace = fileStore.getTotalSpace();
@@ -249,14 +258,14 @@ public class OSHISysteminfo implements SysteminfoInterface {
         if (totalSpace > 0) {
             double freePercentDecimal = (double) freeSpace / (double) totalSpace;
             BigDecimal freePercent = getPercentsValue(freePercentDecimal);
-            return new DecimalType(freePercent);
+            return new PercentType(freePercent);
         } else {
             return null;
         }
     }
 
     @Override
-    public @Nullable DecimalType getStorageUsedPercent(int deviceIndex) throws DeviceNotFoundException {
+    public @Nullable PercentType getStorageUsedPercent(int deviceIndex) throws DeviceNotFoundException {
         OSFileStore fileStore = getDevice(fileStores, deviceIndex);
         fileStore.updateAttributes();
         long totalSpace = fileStore.getTotalSpace();
@@ -265,7 +274,7 @@ public class OSHISysteminfo implements SysteminfoInterface {
         if (totalSpace > 0) {
             double usedPercentDecimal = (double) usedSpace / (double) totalSpace;
             BigDecimal usedPercent = getPercentsValue(usedPercentDecimal);
-            return new DecimalType(usedPercent);
+            return new PercentType(usedPercent);
         } else {
             return null;
         }
@@ -332,17 +341,17 @@ public class OSHISysteminfo implements SysteminfoInterface {
     }
 
     @Override
-    public @Nullable DecimalType getSensorsCpuTemperature() {
+    public @Nullable QuantityType<Temperature> getSensorsCpuTemperature() {
         BigDecimal cpuTemp = new BigDecimal(sensors.getCpuTemperature());
         cpuTemp = cpuTemp.setScale(PRECISION_AFTER_DECIMAL_SIGN, RoundingMode.HALF_UP);
-        return cpuTemp.signum() == 1 ? new DecimalType(cpuTemp) : null;
+        return cpuTemp.signum() == 1 ? new QuantityType<>(cpuTemp, SIUnits.CELSIUS) : null;
     }
 
     @Override
-    public @Nullable DecimalType getSensorsCpuVoltage() {
+    public @Nullable QuantityType<ElectricPotential> getSensorsCpuVoltage() {
         BigDecimal cpuVoltage = new BigDecimal(sensors.getCpuVoltage());
         cpuVoltage = cpuVoltage.setScale(PRECISION_AFTER_DECIMAL_SIGN, RoundingMode.HALF_UP);
-        return cpuVoltage.signum() == 1 ? new DecimalType(cpuVoltage) : null;
+        return cpuVoltage.signum() == 1 ? new QuantityType<>(cpuVoltage, Units.VOLT) : null;
     }
 
     @Override
@@ -358,22 +367,22 @@ public class OSHISysteminfo implements SysteminfoInterface {
     }
 
     @Override
-    public @Nullable DecimalType getBatteryRemainingTime(int index) throws DeviceNotFoundException {
+    public @Nullable QuantityType<Time> getBatteryRemainingTime(int index) throws DeviceNotFoundException {
         PowerSource powerSource = getDevice(powerSources, index);
         powerSource.updateAttributes();
         double remainingTimeInSeconds = powerSource.getTimeRemainingEstimated();
         // The getTimeRemaining() method returns (-1.0) if is calculating or (-2.0) if the time is unlimited.
         BigDecimal remainingTime = getTimeInMinutes(remainingTimeInSeconds);
-        return remainingTime.signum() == 1 ? new DecimalType(remainingTime) : null;
+        return remainingTime.signum() == 1 ? new QuantityType<>(remainingTime, Units.MINUTE) : null;
     }
 
     @Override
-    public DecimalType getBatteryRemainingCapacity(int index) throws DeviceNotFoundException {
+    public PercentType getBatteryRemainingCapacity(int index) throws DeviceNotFoundException {
         PowerSource powerSource = getDevice(powerSources, index);
         powerSource.updateAttributes();
         double remainingCapacity = powerSource.getRemainingCapacityPercent();
         BigDecimal remainingCapacityPercents = getPercentsValue(remainingCapacity);
-        return new DecimalType(remainingCapacityPercents);
+        return new PercentType(remainingCapacityPercents);
     }
 
     @Override
@@ -384,27 +393,27 @@ public class OSHISysteminfo implements SysteminfoInterface {
     }
 
     @Override
-    public @Nullable DecimalType getMemoryAvailablePercent() {
+    public @Nullable PercentType getMemoryAvailablePercent() {
         long availableMemory = memory.getAvailable();
         long totalMemory = memory.getTotal();
         if (totalMemory > 0) {
             double freePercentDecimal = (double) availableMemory / (double) totalMemory;
             BigDecimal freePercent = getPercentsValue(freePercentDecimal);
-            return new DecimalType(freePercent);
+            return new PercentType(freePercent);
         } else {
             return null;
         }
     }
 
     @Override
-    public @Nullable DecimalType getMemoryUsedPercent() {
+    public @Nullable PercentType getMemoryUsedPercent() {
         long availableMemory = memory.getAvailable();
         long totalMemory = memory.getTotal();
         long usedMemory = totalMemory - availableMemory;
         if (totalMemory > 0) {
             double usedPercentDecimal = (double) usedMemory / (double) totalMemory;
             BigDecimal usedPercent = getPercentsValue(usedPercentDecimal);
-            return new DecimalType(usedPercent);
+            return new PercentType(usedPercent);
         } else {
             return null;
         }
@@ -432,50 +441,50 @@ public class OSHISysteminfo implements SysteminfoInterface {
     }
 
     @Override
-    public @Nullable DecimalType getSwapTotal() {
+    public QuantityType<DataAmount> getSwapTotal() {
         long swapTotal = memory.getVirtualMemory().getSwapTotal();
         swapTotal = getSizeInMB(swapTotal);
-        return new DecimalType(swapTotal);
+        return new QuantityType<>(swapTotal, Units.MEBIBYTE);
     }
 
     @Override
-    public @Nullable DecimalType getSwapAvailable() {
+    public QuantityType<DataAmount> getSwapAvailable() {
         long swapTotal = memory.getVirtualMemory().getSwapTotal();
         long swapUsed = memory.getVirtualMemory().getSwapUsed();
         long swapAvailable = swapTotal - swapUsed;
         swapAvailable = getSizeInMB(swapAvailable);
-        return new DecimalType(swapAvailable);
+        return new QuantityType<>(swapAvailable, Units.MEBIBYTE);
     }
 
     @Override
-    public @Nullable DecimalType getSwapUsed() {
+    public QuantityType<DataAmount> getSwapUsed() {
         long swapUsed = memory.getVirtualMemory().getSwapUsed();
         swapUsed = getSizeInMB(swapUsed);
-        return new DecimalType(swapUsed);
+        return new QuantityType<>(swapUsed, Units.MEBIBYTE);
     }
 
     @Override
-    public @Nullable DecimalType getSwapAvailablePercent() {
+    public @Nullable PercentType getSwapAvailablePercent() {
         long swapTotal = memory.getVirtualMemory().getSwapTotal();
         long swapUsed = memory.getVirtualMemory().getSwapUsed();
         long swapAvailable = swapTotal - swapUsed;
         if (swapTotal > 0) {
             double swapAvailablePercentDecimal = (double) swapAvailable / (double) swapTotal;
             BigDecimal swapAvailablePercent = getPercentsValue(swapAvailablePercentDecimal);
-            return new DecimalType(swapAvailablePercent);
+            return new PercentType(swapAvailablePercent);
         } else {
             return null;
         }
     }
 
     @Override
-    public @Nullable DecimalType getSwapUsedPercent() {
+    public @Nullable PercentType getSwapUsedPercent() {
         long swapTotal = memory.getVirtualMemory().getSwapTotal();
         long swapUsed = memory.getVirtualMemory().getSwapUsed();
         if (swapTotal > 0) {
             double swapUsedPercentDecimal = (double) swapUsed / (double) swapTotal;
             BigDecimal swapUsedPercent = getPercentsValue(swapUsedPercentDecimal);
-            return new DecimalType(swapUsedPercent);
+            return new PercentType(swapUsedPercent);
         } else {
             return null;
         }
@@ -561,9 +570,9 @@ public class OSHISysteminfo implements SysteminfoInterface {
     }
 
     @Override
-    public DecimalType getCpuUptime() {
+    public QuantityType<Time> getCpuUptime() {
         long seconds = operatingSystem.getSystemUptime();
-        return new DecimalType(getTimeInMinutes(seconds));
+        return new QuantityType<>(getTimeInMinutes(seconds), Units.MINUTE);
     }
 
     @Override
@@ -596,19 +605,19 @@ public class OSHISysteminfo implements SysteminfoInterface {
     }
 
     @Override
-    public DecimalType getNetworkDataSent(int networkIndex) throws DeviceNotFoundException {
+    public QuantityType<DataAmount> getNetworkDataSent(int networkIndex) throws DeviceNotFoundException {
         NetworkIF network = getDevice(networks, networkIndex);
         network.updateAttributes();
         long bytesSent = network.getBytesSent();
-        return new DecimalType(getSizeInMB(bytesSent));
+        return new QuantityType<>(getSizeInMB(bytesSent), Units.MEBIBYTE);
     }
 
     @Override
-    public DecimalType getNetworkDataReceived(int networkIndex) throws DeviceNotFoundException {
+    public QuantityType<DataAmount> getNetworkDataReceived(int networkIndex) throws DeviceNotFoundException {
         NetworkIF network = getDevice(networks, networkIndex);
         network.updateAttributes();
         long bytesRecv = network.getBytesRecv();
-        return new DecimalType(getSizeInMB(bytesRecv));
+        return new QuantityType<>(getSizeInMB(bytesRecv), Units.MEBIBYTE);
     }
 
     @Override
@@ -642,12 +651,12 @@ public class OSHISysteminfo implements SysteminfoInterface {
     }
 
     @Override
-    public @Nullable DecimalType getProcessMemoryUsage(int pid) throws DeviceNotFoundException {
+    public @Nullable QuantityType<DataAmount> getProcessMemoryUsage(int pid) throws DeviceNotFoundException {
         if (pid > 0) {
             OSProcess process = getProcess(pid);
             long memortInBytes = process.getResidentSetSize();
             long memoryInMB = getSizeInMB(memortInBytes);
-            return new DecimalType(memoryInMB);
+            return new QuantityType<>(memoryInMB, Units.MEBIBYTE);
         } else {
             return null;
         }
index 87a7c97610ac65d740fa89b54deddb157b1d2563..a76ff564fb5dc6c6baf42b92649e41e831de2e0b 100644 (file)
  */
 package org.openhab.binding.systeminfo.internal.model;
 
+import javax.measure.quantity.ElectricPotential;
+import javax.measure.quantity.Temperature;
+import javax.measure.quantity.Time;
+
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
+import org.openhab.core.library.dimension.DataAmount;
 import org.openhab.core.library.types.DecimalType;
 import org.openhab.core.library.types.PercentType;
+import org.openhab.core.library.types.QuantityType;
 import org.openhab.core.library.types.StringType;
 
 /**
@@ -24,6 +30,7 @@ import org.openhab.core.library.types.StringType;
  * @author Svilen Valkanov - Initial contribution
  * @author Wouter Born - Add null annotations
  * @author Mark Herwege - Add dynamic creation of extra channels
+ * @author Mark Herwege - Use units of measure
  */
 @NonNullByDefault
 public interface SysteminfoInterface {
@@ -76,7 +83,7 @@ public interface SysteminfoInterface {
     /**
      * Returns the system cpu load.
      *
-     * @return the system cpu load between 0 and 1 or null, if no information is available
+     * @return the system cpu load between 0 and 100% or null, if no information is available
      */
     public @Nullable PercentType getSystemCpuLoad();
 
@@ -104,9 +111,9 @@ public interface SysteminfoInterface {
     /**
      * Get the System uptime (time since boot).
      *
-     * @return time in minutes since boot
+     * @return time since boot
      */
-    public DecimalType getCpuUptime();
+    public QuantityType<Time> getCpuUptime();
 
     /**
      * Get the number of threads currently running
@@ -119,101 +126,101 @@ public interface SysteminfoInterface {
     /**
      * Returns total size of memory
      *
-     * @return memory size in MB
+     * @return memory size
      */
-    public DecimalType getMemoryTotal();
+    public QuantityType<DataAmount> getMemoryTotal();
 
     /**
      * Returns available size of memory
      *
-     * @return memory size in MB
+     * @return memory size
      */
-    public DecimalType getMemoryAvailable();
+    public QuantityType<DataAmount> getMemoryAvailable();
 
     /**
      * Returns used size of memory
      *
-     * @return memory size in MB
+     * @return memory size
      */
-    public DecimalType getMemoryUsed();
+    public QuantityType<DataAmount> getMemoryUsed();
 
     /**
      * Percents of available memory on the machine
      *
      * @return percent of available memory or null, if no information is available
      */
-    public @Nullable DecimalType getMemoryAvailablePercent();
+    public @Nullable PercentType getMemoryAvailablePercent();
 
     /**
      * Percents of used memory on the machine
      *
      * @return percent of used memory or null, if no information is available
      */
-    public @Nullable DecimalType getMemoryUsedPercent();
+    public @Nullable PercentType getMemoryUsedPercent();
 
     // Swap memory info
     /**
      * Returns total size of swap memory
      *
-     * @return memory size in MB or 0, if no there is no swap memory
+     * @return memory size or 0, if there is no swap memory
      */
-    public @Nullable DecimalType getSwapTotal();
+    public QuantityType<DataAmount> getSwapTotal();
 
     /**
      * Returns available size swap of memory
      *
-     * @return memory size in MB or 0, if no there is no swap memory
+     * @return memory size or 0, if no there is no swap memory
      */
-    public @Nullable DecimalType getSwapAvailable();
+    public QuantityType<DataAmount> getSwapAvailable();
 
     /**
      * Returns used size of swap memory
      *
-     * @return memory size in MB or 0, if no there is no swap memory
+     * @return memory size or 0, if no there is no swap memory
      */
-    public @Nullable DecimalType getSwapUsed();
+    public QuantityType<DataAmount> getSwapUsed();
 
     /**
      * Percents of available swap memory on the machine
      *
      * @return percent of available memory or null, if no there is no swap memory
      */
-    public @Nullable DecimalType getSwapAvailablePercent();
+    public @Nullable PercentType getSwapAvailablePercent();
 
     /**
      * Percents of used swap memory on the machine
      *
      * @return percent of used memory or null, if no there is no swap memory
      */
-    public @Nullable DecimalType getSwapUsedPercent();
+    public @Nullable PercentType getSwapUsedPercent();
 
     // Storage info
     /**
      * Returns the total space of the logical storage volume.
      *
      * @param deviceIndex - the index of the logical volume
-     * @return storage size in MB
+     * @return storage size
      * @throws DeviceNotFoundException
      */
-    public DecimalType getStorageTotal(int deviceIndex) throws DeviceNotFoundException;
+    public QuantityType<DataAmount> getStorageTotal(int deviceIndex) throws DeviceNotFoundException;
 
     /**
      * Returns the available storage space on the logical storage volume
      *
      * @param deviceIndex - the index of the logical volume
-     * @return storage size in MB
+     * @return storage size
      * @throws DeviceNotFoundException
      */
-    public DecimalType getStorageAvailable(int deviceIndex) throws DeviceNotFoundException;
+    public QuantityType<DataAmount> getStorageAvailable(int deviceIndex) throws DeviceNotFoundException;
 
     /**
      * Gets the used storage space on the logical storage volume
      *
      * @param deviceIndex - the index of the logical volume
-     * @return storage size in MB
+     * @return storage size
      * @throws DeviceNotFoundException
      */
-    public DecimalType getStorageUsed(int deviceIndex) throws DeviceNotFoundException;
+    public QuantityType<DataAmount> getStorageUsed(int deviceIndex) throws DeviceNotFoundException;
 
     /**
      * Gets the percent of available storage on the logical volume
@@ -222,7 +229,7 @@ public interface SysteminfoInterface {
      * @return percent of available storage or null
      * @throws DeviceNotFoundException
      */
-    public @Nullable DecimalType getStorageAvailablePercent(int deviceIndex) throws DeviceNotFoundException;
+    public @Nullable PercentType getStorageAvailablePercent(int deviceIndex) throws DeviceNotFoundException;
 
     /**
      * Gets the percent of used storage on the logical volume
@@ -231,7 +238,7 @@ public interface SysteminfoInterface {
      * @return percent of used storage or null
      * @throws DeviceNotFoundException
      */
-    public @Nullable DecimalType getStorageUsedPercent(int deviceIndex) throws DeviceNotFoundException;
+    public @Nullable PercentType getStorageUsedPercent(int deviceIndex) throws DeviceNotFoundException;
 
     /**
      * Gets the name of the logical storage volume
@@ -330,20 +337,20 @@ public interface SysteminfoInterface {
     public DecimalType getNetworkPacketsSent(int networkIndex) throws DeviceNotFoundException;
 
     /**
-     * Get data sent in MB for this network
+     * Get data sent for this network
      *
      * @param networkIndex - the index of the network
      * @throws DeviceNotFoundException
      */
-    public DecimalType getNetworkDataSent(int networkIndex) throws DeviceNotFoundException;
+    public QuantityType<DataAmount> getNetworkDataSent(int networkIndex) throws DeviceNotFoundException;
 
     /**
-     * Get data received in MB for this network
+     * Get data received for this network
      *
      * @param networkIndex - the index of the network
      * @throws DeviceNotFoundException
      */
-    public DecimalType getNetworkDataReceived(int networkIndex) throws DeviceNotFoundException;
+    public QuantityType<DataAmount> getNetworkDataReceived(int networkIndex) throws DeviceNotFoundException;
 
     // Display info
     /**
@@ -358,16 +365,16 @@ public interface SysteminfoInterface {
     /**
      * Get the information from the CPU temperature sensors.
      *
-     * @return Temperature in degrees Celsius if available, null otherwise.
+     * @return Temperature if available, null otherwise.
      */
-    public @Nullable DecimalType getSensorsCpuTemperature();
+    public @Nullable QuantityType<Temperature> getSensorsCpuTemperature();
 
     /**
      * Get the information for the CPU voltage.
      *
-     * @return Voltage in Volts if available, null otherwise.
+     * @return Voltage if available, null otherwise.
      */
-    public @Nullable DecimalType getSensorsCpuVoltage();
+    public @Nullable QuantityType<ElectricPotential> getSensorsCpuVoltage();
 
     /**
      * Get fan speed
@@ -383,19 +390,19 @@ public interface SysteminfoInterface {
      * Get estimated time remaining for the power source.
      *
      * @param deviceIndex
-     * @return minutes remaining charge or null, if the time is estimated as unlimited
+     * @return duration remaining charge or null, if the time is estimated as unlimited
      * @throws DeviceNotFoundException
      */
-    public @Nullable DecimalType getBatteryRemainingTime(int deviceIndex) throws DeviceNotFoundException;
+    public @Nullable QuantityType<Time> getBatteryRemainingTime(int deviceIndex) throws DeviceNotFoundException;
 
     /**
      * Battery remaining capacity.
      *
      * @param deviceIndex
-     * @return percentage value /0-100/
+     * @return percentage value
      * @throws DeviceNotFoundException
      */
-    public DecimalType getBatteryRemainingCapacity(int deviceIndex) throws DeviceNotFoundException;
+    public PercentType getBatteryRemainingCapacity(int deviceIndex) throws DeviceNotFoundException;
 
     /**
      * Get battery name
@@ -433,10 +440,10 @@ public interface SysteminfoInterface {
      * Returns the size of RAM memory only usage of the process
      *
      * @param pid - the PID of the process
-     * @return memory size in MB
+     * @return memory size
      * @throws DeviceNotFoundException- thrown if process with this PID can not be found
      */
-    public @Nullable DecimalType getProcessMemoryUsage(int pid) throws DeviceNotFoundException;
+    public @Nullable QuantityType<DataAmount> getProcessMemoryUsage(int pid) throws DeviceNotFoundException;
 
     /**
      * Returns the full path of the executing process.
index 289ef8f0d6e70935e64c0552febe1e3771eaa65a..dc184f6a5e340a4f0b734aaf6f3597e9b18d5b58 100644 (file)
@@ -43,23 +43,23 @@ channel-group-type.systeminfo.swapGroup.description = Swap memory information
 # channel types
 
 channel-type.systeminfo.available.label = Available
-channel-type.systeminfo.available.description = Available size in MB
+channel-type.systeminfo.available.description = Available size
 channel-type.systeminfo.availableHeap.label = Available Heap
 channel-type.systeminfo.availableHeap.description = How much data is available in the Java heap.
 channel-type.systeminfo.availablePercent.label = Available (%)
 channel-type.systeminfo.availablePercent.description = Available size in percent
 channel-type.systeminfo.cpuTemp.label = CPU Temperature
-channel-type.systeminfo.cpuTemp.description = CPU Temperature in Celsius degrees
+channel-type.systeminfo.cpuTemp.description = CPU Temperature
 channel-type.systeminfo.cpuVoltage.label = CPU Voltage
-channel-type.systeminfo.cpuVoltage.description = CPU Voltage in V
+channel-type.systeminfo.cpuVoltage.description = CPU Voltage
 channel-type.systeminfo.dataReceived.label = Data Received
-channel-type.systeminfo.dataReceived.description = Data received in MB
+channel-type.systeminfo.dataReceived.description = Volume of data received
 channel-type.systeminfo.dataSent.label = Data Sent
-channel-type.systeminfo.dataSent.description = Data sent in MB
+channel-type.systeminfo.dataSent.description = Volume of data sent
 channel-type.systeminfo.description.label = Description
 channel-type.systeminfo.description.description = Description of the device
 channel-type.systeminfo.fanSpeed.label = Fan Speed
-channel-type.systeminfo.fanSpeed.description = Fan speed in rpm
+channel-type.systeminfo.fanSpeed.description = Fan speed in rotations per minute
 channel-type.systeminfo.information.label = Display Information
 channel-type.systeminfo.information.description = Product, manufacturer, SN, width and height of the display in cm
 channel-type.systeminfo.ip.label = IP Address
@@ -93,27 +93,27 @@ channel-type.systeminfo.path_process.description = The full path
 channel-type.systeminfo.remainingCapacity.label = Remaining Capacity
 channel-type.systeminfo.remainingCapacity.description = Remaining capacity in percent
 channel-type.systeminfo.remainingTime.label = Remaining Time
-channel-type.systeminfo.remainingTime.description = Remaining time in minutes
+channel-type.systeminfo.remainingTime.description = Remaining time
 channel-type.systeminfo.serial.label = Serial Number
 channel-type.systeminfo.serial.description = The serial number of the device
 channel-type.systeminfo.threads.label = Number of Threads
-channel-type.systeminfo.threads.description = Number of threads currently running
+channel-type.systeminfo.threads.description = Total number of threads currently running
 channel-type.systeminfo.threads_process.label = Number of Threads
-channel-type.systeminfo.threads_process.description = Number of threads currently running
+channel-type.systeminfo.threads_process.description = Number of threads for process currently running
 channel-type.systeminfo.total.label = Total
-channel-type.systeminfo.total.description = Total size in MB
+channel-type.systeminfo.total.description = Total size
 channel-type.systeminfo.type.label = Type
 channel-type.systeminfo.type.description = Storage type
 channel-type.systeminfo.uptime.label = System Uptime
-channel-type.systeminfo.uptime.description = System uptime (time after start) in minutes
+channel-type.systeminfo.uptime.description = System uptime (time after start)
 channel-type.systeminfo.used.label = Used
-channel-type.systeminfo.used.description = Used size in MB
+channel-type.systeminfo.used.description = Used size
 channel-type.systeminfo.usedHeapPercent.label = Used Heap Percent
 channel-type.systeminfo.usedHeapPercent.description = How much data in percent has been used from the max size the Java heap can grow to.
 channel-type.systeminfo.usedPercent.label = Used (%)
 channel-type.systeminfo.usedPercent.description = Used size in percent
 channel-type.systeminfo.used_process.label = Used
-channel-type.systeminfo.used_process.description = Used size in MB
+channel-type.systeminfo.used_process.description = Used size
 
 # channel types config
 
index 5add605847cf067b129f0739c904bf63473b249c..150075edc5682272b1cc0f8c00831c819fdf643e 100644 (file)
                <item-type>Number:DataAmount</item-type>
                <label>Available Heap</label>
                <description>How much data is available in the Java heap.</description>
-               <state pattern="%.1f %unit%" readOnly="true"/>
+               <state pattern="%.0f MiB" readOnly="true"/>
                <config-description-ref uri="channel-type:systeminfo:mediumpriority"/>
        </channel-type>
 
        </channel-type>
 
        <channel-type id="available">
-               <item-type>Number</item-type>
+               <item-type>Number:DataAmount</item-type>
                <label>Available</label>
-               <description>Available size in MB</description>
-               <state readOnly="true" pattern="%d MB"/>
+               <description>Available size</description>
+               <state readOnly="true" pattern="%.0f MiB"/>
                <config-description-ref uri="channel-type:systeminfo:highpriority"/>
        </channel-type>
 
        <channel-type id="used">
-               <item-type>Number</item-type>
+               <item-type>Number:DataAmount</item-type>
                <label>Used</label>
-               <description>Used size in MB</description>
-               <state readOnly="true" pattern="%d MB"/>
+               <description>Used size</description>
+               <state readOnly="true" pattern="%.0f MiB"/>
                <config-description-ref uri="channel-type:systeminfo:highpriority"/>
        </channel-type>
 
        <channel-type id="used_process">
-               <item-type>Number</item-type>
+               <item-type>Number:DataAmount</item-type>
                <label>Used</label>
-               <description>Used size in MB</description>
-               <state readOnly="true" pattern="%d MB"/>
+               <description>Used size</description>
+               <state readOnly="true" pattern="%.0f MiB"/>
                <config-description-ref uri="channel-type:systeminfo:highpriority_process"/>
        </channel-type>
 
        <channel-type id="total">
-               <item-type>Number</item-type>
+               <item-type>Number:DataAmount</item-type>
                <label>Total</label>
-               <description>Total size in MB</description>
-               <state readOnly="true" pattern="%d MB"/>
+               <description>Total size</description>
+               <state readOnly="true" pattern="%.0f MiB"/>
                <config-description-ref uri="channel-type:systeminfo:lowpriority"/>
        </channel-type>
 
        <channel-type id="availablePercent">
-               <item-type>Number</item-type>
+               <item-type>Number:Dimensionless</item-type>
                <label>Available (%)</label>
                <description>Available size in percent</description>
                <state readOnly="true" pattern="%.1f %%"/>
        </channel-type>
 
        <channel-type id="usedPercent">
-               <item-type>Number</item-type>
+               <item-type>Number:Dimensionless</item-type>
                <label>Used (%)</label>
                <description>Used size in percent</description>
                <state readOnly="true" pattern="%.1f %%"/>
                <item-type>String</item-type>
                <label>Description</label>
                <description>Description of the device</description>
-               <state readOnly="true" pattern="%s "/>
+               <state readOnly="true" pattern="%s"/>
                <config-description-ref uri="channel-type:systeminfo:lowpriority"/>
        </channel-type>
 
                <item-type>String</item-type>
                <label>Type</label>
                <description>Storage type</description>
-               <state readOnly="true" pattern="%s "/>
+               <state readOnly="true" pattern="%s"/>
                <config-description-ref uri="channel-type:systeminfo:lowpriority"/>
        </channel-type>
 
        <channel-type id="cpuTemp" advanced="true">
-               <item-type>Number</item-type>
+               <item-type>Number:Temperature</item-type>
                <label>CPU Temperature</label>
-               <description>CPU Temperature in Celsius degrees</description>
-               <state readOnly="true" pattern="%.1f Â°"/>
+               <description>CPU temperature</description>
+               <state readOnly="true" pattern="%.1f Â°C"/>
                <config-description-ref uri="channel-type:systeminfo:highpriority"/>
        </channel-type>
 
        <channel-type id="cpuVoltage" advanced="true">
-               <item-type>Number</item-type>
+               <item-type>Number:ElectricPotential</item-type>
                <label>CPU Voltage</label>
-               <description>CPU Voltage in V</description>
+               <description>CPU voltage</description>
                <state readOnly="true" pattern="%.1f V"/>
                <config-description-ref uri="channel-type:systeminfo:mediumpriority"/>
        </channel-type>
        <channel-type id="fanSpeed" advanced="true">
                <item-type>Number</item-type>
                <label>Fan Speed</label>
-               <description>Fan speed in rpm</description>
+               <description>Fan speed in rotations per minute</description>
                <state readOnly="true" pattern="%d rpm"/>
                <config-description-ref uri="channel-type:systeminfo:mediumpriority"/>
        </channel-type>
 
        <channel-type id="remainingTime">
-               <item-type>Number</item-type>
+               <item-type>Number:Time</item-type>
                <label>Remaining Time</label>
-               <description>Remaining time in minutes</description>
-               <state readOnly="true" pattern="%.1f Minutes"/>
+               <description>Remaining time</description>
+               <state readOnly="true" pattern="%.1f min"/>
                <config-description-ref uri="channel-type:systeminfo:mediumpriority"/>
        </channel-type>
 
        <channel-type id="remainingCapacity">
-               <item-type>Number</item-type>
+               <item-type>Number:Dimensionless</item-type>
                <label>Remaining Capacity</label>
                <description>Remaining capacity in percent</description>
                <state readOnly="true" pattern="%.1f %%"/>
        </channel-type>
 
        <channel-type id="uptime" advanced="true">
-               <item-type>Number</item-type>
+               <item-type>Number:Time</item-type>
                <label>System Uptime</label>
-               <description>System uptime (time after start) in minutes</description>
-               <state readOnly="true" pattern="%.1f Minutes"/>
+               <description>System uptime (time after start)</description>
+               <state readOnly="true" pattern="%.1f min"/>
                <config-description-ref uri="channel-type:systeminfo:mediumpriority"/>
        </channel-type>
 
        <channel-type id="threads" advanced="true">
                <item-type>Number</item-type>
                <label>Number of Threads</label>
-               <description>Number of threads currently running</description>
+               <description>Total number of threads currently running</description>
                <state readOnly="true" pattern="%d"/>
                <config-description-ref uri="channel-type:systeminfo:mediumpriority"/>
        </channel-type>
        <channel-type id="threads_process" advanced="true">
                <item-type>Number</item-type>
                <label>Number of Threads</label>
-               <description>Number of threads currently running</description>
+               <description>Number of threads for process currently running</description>
                <state readOnly="true" pattern="%d"/>
                <config-description-ref uri="channel-type:systeminfo:mediumpriority_process"/>
        </channel-type>
                <item-type>String</item-type>
                <label>Display Information</label>
                <description>Product, manufacturer, SN, width and height of the display in cm</description>
-               <state readOnly="true" pattern="%s "/>
+               <state readOnly="true" pattern="%s"/>
                <config-description-ref uri="channel-type:systeminfo:lowpriority"/>
        </channel-type>
 
                <item-type>String</item-type>
                <label>IP Address</label>
                <description>Host IP address of the network</description>
-               <state readOnly="true" pattern="%s "/>
+               <state readOnly="true" pattern="%s"/>
                <config-description-ref uri="channel-type:systeminfo:lowpriority"/>
        </channel-type>
 
                <item-type>String</item-type>
                <label>Mac Address</label>
                <description>Mac address of the network</description>
-               <state readOnly="true" pattern="%s "/>
+               <state readOnly="true" pattern="%s"/>
                <config-description-ref uri="channel-type:systeminfo:lowpriority"/>
        </channel-type>
 
                <item-type>String</item-type>
                <label>Network Name</label>
                <description>The name of the network.</description>
-               <state readOnly="true" pattern="%s "/>
+               <state readOnly="true" pattern="%s"/>
                <config-description-ref uri="channel-type:systeminfo:lowpriority"/>
        </channel-type>
 
                <item-type>String</item-type>
                <label>Network Display Name</label>
                <description>The display name of the network</description>
-               <state readOnly="true" pattern="%s "/>
+               <state readOnly="true" pattern="%s"/>
                <config-description-ref uri="channel-type:systeminfo:lowpriority"/>
        </channel-type>
 
                <item-type>Number</item-type>
                <label>Packets Sent</label>
                <description>Number of packets sent</description>
-               <state readOnly="true" pattern="%d "/>
+               <state readOnly="true" pattern="%d"/>
                <config-description-ref uri="channel-type:systeminfo:mediumpriority"/>
        </channel-type>
 
                <item-type>Number</item-type>
                <label>Packets Received</label>
                <description>Number of packets received</description>
-               <state readOnly="true" pattern="%d "/>
+               <state readOnly="true" pattern="%d"/>
                <config-description-ref uri="channel-type:systeminfo:mediumpriority"/>
        </channel-type>
 
        <channel-type id="dataSent" advanced="true">
-               <item-type>Number</item-type>
+               <item-type>Number:DataAmount</item-type>
                <label>Data Sent</label>
-               <description>Data sent in MB</description>
-               <state readOnly="true" pattern="%d MB"/>
+               <description>Volume of data sent</description>
+               <state readOnly="true" pattern="%.0f MiB"/>
                <config-description-ref uri="channel-type:systeminfo:mediumpriority"/>
        </channel-type>
 
        <channel-type id="dataReceived" advanced="true">
-               <item-type>Number</item-type>
+               <item-type>Number:DataAmount</item-type>
                <label>Data Received</label>
-               <description>Data received in MB</description>
-               <state readOnly="true" pattern="%d MB"/>
+               <description>Volume of data received</description>
+               <state readOnly="true" pattern="%.0f MiB"/>
                <config-description-ref uri="channel-type:systeminfo:mediumpriority"/>
        </channel-type>
 
index 57b78ead6e22d95bc4f982fcb01aa2fa33550c6e..89824b373986cffabc3a1cf09bd33e3955d5427f 100644 (file)
@@ -24,6 +24,10 @@ import java.net.UnknownHostException;
 import java.util.Hashtable;
 import java.util.List;
 
+import javax.measure.quantity.ElectricPotential;
+import javax.measure.quantity.Temperature;
+import javax.measure.quantity.Time;
+
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.junit.jupiter.api.AfterEach;
@@ -48,11 +52,15 @@ import org.openhab.core.config.discovery.inbox.InboxPredicates;
 import org.openhab.core.items.GenericItem;
 import org.openhab.core.items.ItemNotFoundException;
 import org.openhab.core.items.ItemRegistry;
+import org.openhab.core.library.dimension.DataAmount;
 import org.openhab.core.library.items.NumberItem;
 import org.openhab.core.library.items.StringItem;
 import org.openhab.core.library.types.DecimalType;
 import org.openhab.core.library.types.PercentType;
+import org.openhab.core.library.types.QuantityType;
 import org.openhab.core.library.types.StringType;
+import org.openhab.core.library.unit.SIUnits;
+import org.openhab.core.library.unit.Units;
 import org.openhab.core.test.java.JavaOSGiTest;
 import org.openhab.core.test.storage.VolatileStorageService;
 import org.openhab.core.thing.Channel;
@@ -314,8 +322,8 @@ public class SysteminfoOSGiTest extends JavaOSGiTest {
 
     private void intializeItem(ChannelUID channelUID, String itemName, String acceptedItemType) {
         GenericItem item = null;
-        if ("Number".equals(acceptedItemType)) {
-            item = new NumberItem(itemName);
+        if (acceptedItemType.startsWith("Number")) {
+            item = new NumberItem(acceptedItemType, itemName);
         } else if ("String".equals(acceptedItemType)) {
             item = new StringItem(itemName);
         }
@@ -447,9 +455,9 @@ public class SysteminfoOSGiTest extends JavaOSGiTest {
     @Test
     public void assertChannelCpuUptimeIsUpdated() {
         String channnelID = SysteminfoBindingConstants.CHANNEL_CPU_UPTIME;
-        String acceptedItemType = "Number";
+        String acceptedItemType = "Number:Time";
 
-        DecimalType mockedCpuUptimeValue = new DecimalType(100);
+        QuantityType<Time> mockedCpuUptimeValue = new QuantityType<>(100, Units.MINUTE);
         when(mockedSystemInfo.getCpuUptime()).thenReturn(mockedCpuUptimeValue);
 
         initializeThingWithChannel(channnelID, acceptedItemType);
@@ -484,9 +492,9 @@ public class SysteminfoOSGiTest extends JavaOSGiTest {
     @Test
     public void assertChannelMemoryAvailableIsUpdated() {
         String channnelID = SysteminfoBindingConstants.CHANNEL_MEMORY_AVAILABLE;
-        String acceptedItemType = "Number";
+        String acceptedItemType = "Number:DataAmount";
 
-        DecimalType mockedMemoryAvailableValue = new DecimalType(1000);
+        QuantityType<DataAmount> mockedMemoryAvailableValue = new QuantityType<>(1000, Units.MEBIBYTE);
         when(mockedSystemInfo.getMemoryAvailable()).thenReturn(mockedMemoryAvailableValue);
 
         initializeThingWithChannel(channnelID, acceptedItemType);
@@ -497,9 +505,9 @@ public class SysteminfoOSGiTest extends JavaOSGiTest {
     @Test
     public void assertChannelMemoryUsedIsUpdated() {
         String channnelID = SysteminfoBindingConstants.CHANNEL_MEMORY_USED;
-        String acceptedItemType = "Number";
+        String acceptedItemType = "Number:DataAmount";
 
-        DecimalType mockedMemoryUsedValue = new DecimalType(24);
+        QuantityType<DataAmount> mockedMemoryUsedValue = new QuantityType<>(24, Units.MEBIBYTE);
         when(mockedSystemInfo.getMemoryUsed()).thenReturn(mockedMemoryUsedValue);
 
         initializeThingWithChannel(channnelID, acceptedItemType);
@@ -509,9 +517,9 @@ public class SysteminfoOSGiTest extends JavaOSGiTest {
     @Test
     public void assertChannelMemoryTotalIsUpdated() {
         String channnelID = SysteminfoBindingConstants.CHANNEL_MEMORY_TOTAL;
-        String acceptedItemType = "Number";
+        String acceptedItemType = "Number:DataAmount";
 
-        DecimalType mockedMemoryTotalValue = new DecimalType(1024);
+        QuantityType<DataAmount> mockedMemoryTotalValue = new QuantityType<>(1024, Units.MEBIBYTE);
         when(mockedSystemInfo.getMemoryTotal()).thenReturn(mockedMemoryTotalValue);
 
         initializeThingWithChannel(channnelID, acceptedItemType);
@@ -524,7 +532,7 @@ public class SysteminfoOSGiTest extends JavaOSGiTest {
         String channnelID = SysteminfoBindingConstants.CHANNEL_MEMORY_AVAILABLE_PERCENT;
         String acceptedItemType = "Number";
 
-        DecimalType mockedMemoryAvailablePercentValue = new DecimalType(97);
+        PercentType mockedMemoryAvailablePercentValue = new PercentType(97);
         when(mockedSystemInfo.getMemoryAvailablePercent()).thenReturn(mockedMemoryAvailablePercentValue);
 
         initializeThingWithChannel(channnelID, acceptedItemType);
@@ -535,9 +543,9 @@ public class SysteminfoOSGiTest extends JavaOSGiTest {
     @Test
     public void assertChannelSwapAvailableIsUpdated() {
         String channnelID = SysteminfoBindingConstants.CHANNEL_SWAP_AVAILABLE;
-        String acceptedItemType = "Number";
+        String acceptedItemType = "Number:DataAmount";
 
-        DecimalType mockedSwapAvailableValue = new DecimalType(482);
+        QuantityType<DataAmount> mockedSwapAvailableValue = new QuantityType<>(482, Units.MEBIBYTE);
         when(mockedSystemInfo.getSwapAvailable()).thenReturn(mockedSwapAvailableValue);
 
         initializeThingWithChannel(channnelID, acceptedItemType);
@@ -548,9 +556,9 @@ public class SysteminfoOSGiTest extends JavaOSGiTest {
     @Test
     public void assertChannelSwapUsedIsUpdated() {
         String channnelID = SysteminfoBindingConstants.CHANNEL_SWAP_USED;
-        String acceptedItemType = "Number";
+        String acceptedItemType = "Number:DataAmount";
 
-        DecimalType mockedSwapUsedValue = new DecimalType(30);
+        QuantityType<DataAmount> mockedSwapUsedValue = new QuantityType<>(30, Units.MEBIBYTE);
         when(mockedSystemInfo.getSwapUsed()).thenReturn(mockedSwapUsedValue);
 
         initializeThingWithChannel(channnelID, acceptedItemType);
@@ -560,9 +568,9 @@ public class SysteminfoOSGiTest extends JavaOSGiTest {
     @Test
     public void assertChannelSwapTotalIsUpdated() {
         String channnelID = SysteminfoBindingConstants.CHANNEL_SWAP_TOTAL;
-        String acceptedItemType = "Number";
+        String acceptedItemType = "Number:DataAmount";
 
-        DecimalType mockedSwapTotalValue = new DecimalType(512);
+        QuantityType<DataAmount> mockedSwapTotalValue = new QuantityType<>(512, Units.MEBIBYTE);
         when(mockedSystemInfo.getSwapTotal()).thenReturn(mockedSwapTotalValue);
 
         initializeThingWithChannel(channnelID, acceptedItemType);
@@ -574,7 +582,7 @@ public class SysteminfoOSGiTest extends JavaOSGiTest {
         String channnelID = SysteminfoBindingConstants.CHANNEL_SWAP_AVAILABLE_PERCENT;
         String acceptedItemType = "Number";
 
-        DecimalType mockedSwapAvailablePercentValue = new DecimalType(94);
+        PercentType mockedSwapAvailablePercentValue = new PercentType(94);
         when(mockedSystemInfo.getSwapAvailablePercent()).thenReturn(mockedSwapAvailablePercentValue);
 
         initializeThingWithChannel(channnelID, acceptedItemType);
@@ -622,9 +630,9 @@ public class SysteminfoOSGiTest extends JavaOSGiTest {
     @Test
     public void assertChannelStorageAvailableIsUpdated() throws DeviceNotFoundException {
         String channnelID = SysteminfoBindingConstants.CHANNEL_STORAGE_AVAILABLE;
-        String acceptedItemType = "Number";
+        String acceptedItemType = "Number:DataAmount";
 
-        DecimalType mockedStorageAvailableValue = new DecimalType(2000);
+        QuantityType<DataAmount> mockedStorageAvailableValue = new QuantityType<>(2000, Units.MEBIBYTE);
         when(mockedSystemInfo.getStorageAvailable(DEFAULT_DEVICE_INDEX)).thenReturn(mockedStorageAvailableValue);
 
         initializeThingWithChannel(channnelID, acceptedItemType);
@@ -635,9 +643,9 @@ public class SysteminfoOSGiTest extends JavaOSGiTest {
     @Test
     public void assertChannelStorageUsedIsUpdated() throws DeviceNotFoundException {
         String channnelID = SysteminfoBindingConstants.CHANNEL_STORAGE_USED;
-        String acceptedItemType = "Number";
+        String acceptedItemType = "Number:DataAmount";
 
-        DecimalType mockedStorageUsedValue = new DecimalType(500);
+        QuantityType<DataAmount> mockedStorageUsedValue = new QuantityType<>(500, Units.MEBIBYTE);
         when(mockedSystemInfo.getStorageUsed(DEFAULT_DEVICE_INDEX)).thenReturn(mockedStorageUsedValue);
 
         initializeThingWithChannel(channnelID, acceptedItemType);
@@ -648,9 +656,9 @@ public class SysteminfoOSGiTest extends JavaOSGiTest {
     @Test
     public void assertChannelStorageTotalIsUpdated() throws DeviceNotFoundException {
         String channnelID = SysteminfoBindingConstants.CHANNEL_STORAGE_TOTAL;
-        String acceptedItemType = "Number";
+        String acceptedItemType = "Number:DataAmount";
 
-        DecimalType mockedStorageTotalValue = new DecimalType(2500);
+        QuantityType<DataAmount> mockedStorageTotalValue = new QuantityType<>(2500, Units.MEBIBYTE);
         when(mockedSystemInfo.getStorageTotal(DEFAULT_DEVICE_INDEX)).thenReturn(mockedStorageTotalValue);
 
         initializeThingWithChannel(channnelID, acceptedItemType);
@@ -663,7 +671,7 @@ public class SysteminfoOSGiTest extends JavaOSGiTest {
         String channnelID = SysteminfoBindingConstants.CHANNEL_STORAGE_AVAILABLE_PERCENT;
         String acceptedItemType = "Number";
 
-        DecimalType mockedStorageAvailablePercent = new DecimalType(20);
+        PercentType mockedStorageAvailablePercent = new PercentType(20);
         when(mockedSystemInfo.getStorageAvailablePercent(DEFAULT_DEVICE_INDEX))
                 .thenReturn(mockedStorageAvailablePercent);
 
@@ -714,9 +722,9 @@ public class SysteminfoOSGiTest extends JavaOSGiTest {
     @Test
     public void assertChannelSensorsCpuTempIsUpdated() {
         String channnelID = SysteminfoBindingConstants.CHANNEL_SENSORS_CPU_TEMPERATURE;
-        String acceptedItemType = "Number";
+        String acceptedItemType = "Number:Temperature";
 
-        DecimalType mockedSensorsCpuTemperatureValue = new DecimalType(60);
+        QuantityType<Temperature> mockedSensorsCpuTemperatureValue = new QuantityType<>(60, SIUnits.CELSIUS);
         when(mockedSystemInfo.getSensorsCpuTemperature()).thenReturn(mockedSensorsCpuTemperatureValue);
 
         initializeThingWithChannel(channnelID, acceptedItemType);
@@ -727,9 +735,9 @@ public class SysteminfoOSGiTest extends JavaOSGiTest {
     @Test
     public void assertChannelSensorsCpuVoltageIsUpdated() {
         String channnelID = SysteminfoBindingConstants.CHANNEL_SENOSRS_CPU_VOLTAGE;
-        String acceptedItemType = "Number";
+        String acceptedItemType = "Number:ElectricPotential";
 
-        DecimalType mockedSensorsCpuVoltageValue = new DecimalType(1000);
+        QuantityType<ElectricPotential> mockedSensorsCpuVoltageValue = new QuantityType<>(1000, Units.VOLT);
         when(mockedSystemInfo.getSensorsCpuVoltage()).thenReturn(mockedSensorsCpuVoltageValue);
 
         initializeThingWithChannel(channnelID, acceptedItemType);
@@ -767,7 +775,7 @@ public class SysteminfoOSGiTest extends JavaOSGiTest {
         String channnelID = SysteminfoBindingConstants.CHANNEL_BATTERY_REMAINING_CAPACITY;
         String acceptedItemType = "Number";
 
-        DecimalType mockedBatteryRemainingCapacity = new DecimalType(200);
+        PercentType mockedBatteryRemainingCapacity = new PercentType(20);
         when(mockedSystemInfo.getBatteryRemainingCapacity(DEFAULT_DEVICE_INDEX))
                 .thenReturn(mockedBatteryRemainingCapacity);
 
@@ -779,9 +787,9 @@ public class SysteminfoOSGiTest extends JavaOSGiTest {
     @Test
     public void assertChannelBatteryRemainingTimeIsUpdated() throws DeviceNotFoundException {
         String channnelID = SysteminfoBindingConstants.CHANNEL_BATTERY_REMAINING_TIME;
-        String acceptedItemType = "Number";
+        String acceptedItemType = "Number:Time";
 
-        DecimalType mockedBatteryRemainingTime = new DecimalType(3600);
+        QuantityType<Time> mockedBatteryRemainingTime = new QuantityType<>(3600, Units.MINUTE);
         when(mockedSystemInfo.getBatteryRemainingTime(DEFAULT_DEVICE_INDEX)).thenReturn(mockedBatteryRemainingTime);
 
         initializeThingWithChannel(channnelID, acceptedItemType);
@@ -828,9 +836,9 @@ public class SysteminfoOSGiTest extends JavaOSGiTest {
     @Test
     public void assertChannelNetworkDataSentIsUpdated() throws DeviceNotFoundException {
         String channnelID = SysteminfoBindingConstants.CHANNEL_NETWORK_DATA_SENT;
-        String acceptedItemType = "Number";
+        String acceptedItemType = "Number:DataAmount";
 
-        DecimalType mockedNetworkDataSent = new DecimalType(1000);
+        QuantityType<DataAmount> mockedNetworkDataSent = new QuantityType<>(1000, Units.MEBIBYTE);
         when(mockedSystemInfo.getNetworkDataSent(DEFAULT_DEVICE_INDEX)).thenReturn(mockedNetworkDataSent);
 
         initializeThingWithChannel(channnelID, acceptedItemType);
@@ -840,9 +848,9 @@ public class SysteminfoOSGiTest extends JavaOSGiTest {
     @Test
     public void assertChannelNetworkDataReceivedIsUpdated() throws DeviceNotFoundException {
         String channnelID = SysteminfoBindingConstants.CHANNEL_NETWORK_DATA_RECEIVED;
-        String acceptedItemType = "Number";
+        String acceptedItemType = "Number:DataAmount";
 
-        DecimalType mockedNetworkDataReceiveed = new DecimalType(800);
+        QuantityType<DataAmount> mockedNetworkDataReceiveed = new QuantityType<>(800, Units.MEBIBYTE);
         when(mockedSystemInfo.getNetworkDataReceived(DEFAULT_DEVICE_INDEX)).thenReturn(mockedNetworkDataReceiveed);
 
         initializeThingWithChannel(channnelID, acceptedItemType);
@@ -1048,11 +1056,11 @@ public class SysteminfoOSGiTest extends JavaOSGiTest {
     @Test
     public void assertChannelProcessMemoryIsUpdatedWithPIDset() throws DeviceNotFoundException {
         String channnelID = SysteminfoBindingConstants.CHANNEL_PROCESS_MEMORY;
-        String acceptedItemType = "Number";
+        String acceptedItemType = "Number:DataAmount";
         // The pid of the System idle process in Windows
         int pid = 0;
 
-        DecimalType mockedProcessMemory = new DecimalType(450);
+        QuantityType<DataAmount> mockedProcessMemory = new QuantityType<>(450, Units.MEBIBYTE);
         when(mockedSystemInfo.getProcessMemoryUsage(pid)).thenReturn(mockedProcessMemory);
 
         initializeThingWithChannelAndPID(channnelID, acceptedItemType, pid);