[SOLVED] Parsing a json value from an existing entity in a template sensor

Thanks @sti0, but I get a

ERROR (MainThread) [homeassistant.components.sensor.template] Could not render template grid_status: UndefinedError: 'homeassistant.core.State object' has no attribute 'siteCurrentPowerFlow'

EDIT: here’s working, really thanks for the hint!! (you just missed attributes)

- platform: jsonrest
  resource: [redacted]
  method: GET
  name: SolarEdge jsonrest
  scan_interval: 400

- platform: template
  sensors:
    grid_consumo:
      value_template: '{{ states.sensor.solaredge_jsonrest.attributes.siteCurrentPowerFlow["LOAD"].currentPower}}'
    grid_produzione:
      value_template: '{{ states.sensor.solaredge_jsonrest.attributes.siteCurrentPowerFlow["PV"].currentPower}}'

For anybody interested in SolarEdge, I’ll write a little tutorial and will try to keep it up to date with the mainstream edition of this great piece of code. You can find relevant post here

Thanks so much guys, you rock!

1 Like