Provide fixed unit for sensors in data.json (#1876)
* Remove redundant second null check for sensor value * Add base formatted raw values to data.json for consistent units * Update HttpServer.cs --------- Co-authored-by: PhyxionNL <7643972+PhyxionNL@users.noreply.github.com>
This commit is contained in:
@@ -243,7 +243,7 @@ public class SensorNode : Node
|
||||
}
|
||||
case SensorType.TimeSpan:
|
||||
{
|
||||
return value.HasValue ? string.Format(Format, TimeSpan.FromSeconds(value.Value)) : "-";
|
||||
return string.Format(Format, TimeSpan.FromSeconds(value.Value));
|
||||
}
|
||||
default:
|
||||
{
|
||||
|
||||
@@ -627,9 +627,17 @@ public class HttpServer
|
||||
case SensorNode sensorNode:
|
||||
jsonNode["SensorId"] = sensorNode.Sensor.Identifier.ToString();
|
||||
jsonNode["Type"] = sensorNode.Sensor.SensorType.ToString();
|
||||
|
||||
// Formatted values, e.g. Throughput will be measured in KB/s or MB/s depending on the value
|
||||
jsonNode["Min"] = sensorNode.Min;
|
||||
jsonNode["Value"] = sensorNode.Value;
|
||||
jsonNode["Max"] = sensorNode.Max;
|
||||
|
||||
// Unformatted values for external systems to have consistent readings, e.g. Throughput will always be measured in B/s
|
||||
jsonNode["RawMin"] = string.Format(sensorNode.Format, sensorNode.Sensor.Min);
|
||||
jsonNode["RawValue"] = string.Format(sensorNode.Format, sensorNode.Sensor.Value);
|
||||
jsonNode["RawMax"] = string.Format(sensorNode.Format, sensorNode.Sensor.Max);
|
||||
|
||||
jsonNode["ImageURL"] = "images/transparent.png";
|
||||
break;
|
||||
case HardwareNode hardwareNode:
|
||||
|
||||
Reference in New Issue
Block a user