This works fine when the panels are generating power, but the system stops presenting the data once the sun goes away.
Is there a way, using templating, that I can use the value of the field when it is present, and return zero for the sensor value when the object returns unknown?
So - checking “Value” returns an error, you need to check the level up in the tree exists - this would probably have been obvious if I supplied examples of the Json, when the panels are off the object PAC is not supplied, not just the value. The final template looks like:
- platform: rest
resource: http://192.168.0.115/solar_api/v1/GetInverterRealtimeData.cgi?Scope=Device&DeviceId=1&DataCollection=CommonInverterData
name: "Current Power"
value_template: >
{% if value_json.Body.Data.PAC is defined %}
{{ value_json.Body.Data.PAC.Value }}
{% else %}
0
{% endif %}
unit_of_measurement: 'W'
force_update: true