Skip to content

Commit

Permalink
Enphase: support for sparse production.json
Browse files Browse the repository at this point in the history
In some cases production.json does not list CT meters, not even as a disabled resource. To support that use case, we need to check the length of array before iterating on, potentially non-existing, keys.
  • Loading branch information
ivoks authored Dec 26, 2024
1 parent 7866f36 commit 25d3889
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions templates/definition/meter/enphase.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ render: |
password: {{ .token }}
insecure: true
{{- end }}
jq: if .production[] | select(.measurementType == "production").activeCount >= 1 then .production[] | select(.measurementType == "production").wNow else .production[] | select(.type == "inverters").wNow end
jq: if (.production | length) > 1 and (.production[] | select(.measurementType == "production").activeCount >= 1) then .production[] | select(.measurementType == "production").wNow else .production[] | select(.type == "inverters").wNow end
energy:
source: http
uri: http://{{ .host }}/production.json
Expand All @@ -51,7 +51,7 @@ render: |
password: {{ .token }}
insecure: true
{{- end }}
jq: if .production[] | select(.measurementType == "production").activeCount >= 1 then .production[] | select(.measurementType == "production").whLifetime else .production[] | select(.type == "inverters").whLifetime end
jq: if (.production | length) > 1 and (.production[] | select(.measurementType == "production").activeCount >= 1) then .production[] | select(.measurementType == "production").whLifetime else .production[] | select(.type == "inverters").whLifetime end
scale: 0.001
{{- end }}
{{- if eq .usage "battery" }}
Expand Down

0 comments on commit 25d3889

Please sign in to comment.