[systeminfo] QuantityTypes and state descriptions cleanup (#13804)

* 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>
This commit is contained in:
Mark Herwege
2022-12-10 23:32:25 +01:00
committed by GitHub
parent c09be1bfbe
commit d0681251cb
7 changed files with 291 additions and 257 deletions

View 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);

View 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;
}

View File

@@ -12,10 +12,16 @@
*/
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.

View 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

View File

@@ -144,7 +144,7 @@
<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>
@@ -173,39 +173,39 @@
</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 %%"/>
@@ -213,7 +213,7 @@
</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 %%"/>
@@ -256,7 +256,7 @@
<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>
@@ -264,22 +264,22 @@
<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>
@@ -287,21 +287,21 @@
<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 %%"/>
@@ -333,17 +333,17 @@
</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>
@@ -351,7 +351,7 @@
<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>
@@ -360,7 +360,7 @@
<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>
@@ -368,7 +368,7 @@
<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>
@@ -376,7 +376,7 @@
<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>
@@ -384,7 +384,7 @@
<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>
@@ -392,7 +392,7 @@
<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>
@@ -400,7 +400,7 @@
<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>
@@ -408,23 +408,23 @@
<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>