Skip to content

Commit

Permalink
Merge pull request #981 from pkuehnel/fix/interpretPvNullValuesAs0
Browse files Browse the repository at this point in the history
Fix/interpret pv null values as0
  • Loading branch information
pkuehnel authored Nov 16, 2023
2 parents d957991 + 7816337 commit 067b642
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion TeslaSolarCharger/Server/Services/PvValueService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -394,10 +394,11 @@ internal double GetValueFromResult(string? pattern, string result, NodePatternTy
{
switch (patternType)
{
//allow JSON values to be null, as this is needed by SMA inverters: https://tff-forum.de/t/teslasolarcharger-laden-nach-pv-ueberschuss-mit-beliebiger-wallbox/170369/2728?u=mane123
case NodePatternType.Json:
_logger.LogTrace("Extract overage value from json {result} with {pattern}", result, pattern);
result = (JObject.Parse(result).SelectToken(pattern ?? throw new ArgumentNullException(nameof(pattern))) ??
throw new InvalidOperationException("Could not find token by pattern")).Value<string>() ?? throw new InvalidOperationException("Extracted Json Value is null");
throw new InvalidOperationException("Could not find token by pattern")).Value<string>() ?? "0";
break;
case NodePatternType.Xml:
_logger.LogTrace("Extract overage value from xml {result} with {pattern}", result, pattern);
Expand Down

0 comments on commit 067b642

Please sign in to comment.