Skip to content

Commit

Permalink
- Check for unavailable and unknown state for PowerUsage
Browse files Browse the repository at this point in the history
  • Loading branch information
KoalaBear84 committed Apr 8, 2021
1 parent 20c8a63 commit f8ba061
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/HAClimateDeskband/HAClimateUserControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,10 @@ private void UpdateValues()
string json = HttpClient.GetStringAsync($"states/{HAClimateDeskBandSettings.PowerUsageEntityId}").GetAwaiter().GetResult();
JObject jObject = JObject.Parse(json);

powerUsageToday = jObject.SelectToken(".state").Value<decimal>();
if (jObject.Value<string>("state") != "unavailable" && jObject.Value<string>("state") != "unknown")
{
powerUsageToday = jObject.Value<decimal>("state");
}
powerUsageUOM = jObject.SelectToken(".attributes.unit_of_measurement").Value<string>();
}

Expand Down

0 comments on commit f8ba061

Please sign in to comment.