diff --git a/LiquidctlDevice.cs b/LiquidctlDevice.cs index 7949d05..c4a1c04 100644 --- a/LiquidctlDevice.cs +++ b/LiquidctlDevice.cs @@ -16,7 +16,7 @@ public LiquidTemperature(LiquidctlStatusJSON output) } public void UpdateFromJSON(LiquidctlStatusJSON output) { - _value = output.status.Single(entry => entry.key == "Liquid temperature").value; + _value = (float)output.status.Single(entry => entry.key == "Liquid temperature").value; } public string Id => _id; string _id; @@ -40,7 +40,7 @@ public PumpSpeed(LiquidctlStatusJSON output) } public void UpdateFromJSON(LiquidctlStatusJSON output) { - _value = output.status.Single(entry => entry.key == "Pump speed").value; + _value = (float)output.status.Single(entry => entry.key == "Pump speed").value; } public string Id => _id; readonly string _id; @@ -65,7 +65,7 @@ public PumpDuty(LiquidctlStatusJSON output) } public void UpdateFromJSON(LiquidctlStatusJSON output) { - _value = output.status.Single(entry => entry.key == "Pump duty").value; + _value = (float)output.status.Single(entry => entry.key == "Pump duty").value; } public string Id => _id; string _id; @@ -95,15 +95,15 @@ public LiquidctlDevice(LiquidctlStatusJSON output) { address = output.address; - hasPumpSpeed = output.status.Exists(entry => entry.key == "Pump duty"); + hasPumpSpeed = output.status.Exists(entry => entry.key == "Pump duty" && !(entry.value is null)); if (hasPumpSpeed) pumpDuty = new PumpDuty(output); - hasPumpDuty = output.status.Exists(entry => entry.key == "Pump speed"); + hasPumpDuty = output.status.Exists(entry => entry.key == "Pump speed" && !(entry.value is null)); if (hasPumpDuty) pumpSpeed = new PumpSpeed(output); - hasLiquidTemperature = output.status.Exists(entry => entry.key == "Liquid temperature"); + hasLiquidTemperature = output.status.Exists(entry => entry.key == "Liquid temperature" && !(entry.value is null)); if (hasLiquidTemperature) liquidTemperature = new LiquidTemperature(output); } diff --git a/LiquidctlStatusJSON.cs b/LiquidctlStatusJSON.cs index b8a9e6d..3886c47 100644 --- a/LiquidctlStatusJSON.cs +++ b/LiquidctlStatusJSON.cs @@ -6,7 +6,7 @@ public class LiquidctlStatusJSON public class StatusRecord { public string key { get; set; } - public float value { get; set; } + public float? value { get; set; } public string unit { get; set; } } public string bus { get; set; }