Fix Piko MP Plus template

The source XML has no `value` attribute when PV has no power. This adds a check for that
This commit is contained in:
Andreas Linde 2021-12-30 10:00:28 +01:00
parent 07c559b4c7
commit e017ce0586
No known key found for this signature in database
GPG key ID: 96178502495847D9

View file

@ -21,5 +21,5 @@ render: |
# PV
source: http
uri: http://{{ .host }}/measurements.xml
jq: .root.Device.Measurements.Measurement[] | select(.attrType == "AC_Power") | .attrValue | tonumber
jq: .root.Device.Measurements.Measurement[] | select(.attrType == "AC_Power") | if has ("attrValue") then .attrValue else "0" end | tonumber
{{- end -}}