Powerfox Rest-Call for Daily consumption

Hello,
I want to read the daily consumption from the Powerfox-API. The result of the REST-Call is:
{"Consumption":{"StartTime":1673082000,"StartTimeCurrency":1673082000,"Sum":17.970000000000002,"Max":2.404,"MaxCurrency":0.9706322580645163,"ReportValues":[{"DeviceId":"9c9c1f14ac90","Timestamp":1673164800,"Complete":true,"Delta":0.7550000000000001,"DeltaCurrency":0.30877419354838714,"ValuesType":1},{"DeviceId":"9c9c1f14ac90","Timestamp":1673161200,"Complete":true,"Delta":0.36800000000000005,"DeltaCurrency":0.15623225806451613,"ValuesType":1},

How can I access the “Sum” value in the Rest answer? The Value is in the JSON-Value for Consumption:, so I can’t access it with json-attributes:

Greetings
Harry

Don’t understand why this would not work

  - platform: rest
    name: whatever
    resource: "whateverurl"
    value_template: "OK"
    json_attributes_path: $.Consumption
    json_attributes:
        - Sum

Thank you vingerha. But the API answers with to many requests. I think there is something wrong with the URL. But the json_attributes_path looks fine

Any chance you can share the full response or URL (noting that I will not engage on key/user/pwd)

The Api-Call is https://backend.powerfox.energy/api/2.0/my/all/report?year=XXXX&month=YY&day=ZZ. Without correct date it will answer with the values for the last 24 hours.

The answer in Browser after Login is:

{"Consumption":{"StartTime":1673201700,"StartTimeCurrency":1673201700,"Sum":10.560999999999998,"Max":1.2229999999999999,"MaxCurrency":0.49823225806451615,"ReportValues":[{"DeviceId":"9c9c1f14ac90","Timestamp":1673287200,"Complete":true,"Delta":0.022,"DeltaCurrency":0.011058064516129033,"ValuesType":1},{"DeviceId":"9c9c1f14ac90","Timestamp":1673283600,"Complete":true,"Delta":0.484,"DeltaCurrency":0.20263225806451615,"ValuesType":1},{"DeviceId":"9c9c1f14ac90","Timestamp":1673280000,"Complete":true,"Delta":0.581,"DeltaCurrency":0.24143225806451613,"ValuesType":1},{"DeviceId":"9c9c1f14ac90","Timestamp":1673276400,"Complete":true,"Delta":0.612,"DeltaCurrency":0.25383225806451615,"ValuesType":1},{"DeviceId":"9c9c1f14ac90","Timestamp":1673272800,"Complete":true,"Delta":1.2229999999999999,"DeltaCurrency":0.49823225806451615,"ValuesType":1},{"DeviceId":"9c9c1f14ac90","Timestamp":1673269200,"Complete":true,"Delta":0.543,"DeltaCurrency":0.22623225806451613,"ValuesType":1},{"DeviceId":"9c9c1f14ac90","Timestamp":1673265600,"Complete":true,"Delta":0.402,"DeltaCurrency":0.16983225806451613,"ValuesType":1},{"DeviceId":"9c9c1f14ac90","Timestamp":1673262000,"Complete":true,"Delta":0.26199999999999996,"DeltaCurrency":0.11383225806451612,"ValuesType":1},{"DeviceId":"9c9c1f14ac90","Timestamp":1673258400,"Complete":true,"Delta":0.30100000000000005,"DeltaCurrency":0.12943225806451614,"ValuesType":1},{"DeviceId":"9c9c1f14ac90","Timestamp":1673254800,"Complete":true,"Delta":0.362,"DeltaCurrency":0.15383225806451614,"ValuesType":1},{"DeviceId":"9c9c1f14ac90","Timestamp":1673251200,"Complete":true,"Delta":0.733,"DeltaCurrency":0.30223225806451615,"ValuesType":1},{"DeviceId":"9c9c1f14ac90","Timestamp":1673247600,"Complete":true,"Delta":0.45199999999999996,"DeltaCurrency":0.18983225806451615,"ValuesType":1},{"DeviceId":"9c9c1f14ac90","Timestamp":1673244000,"Complete":true,"Delta":0.708,"DeltaCurrency":0.29223225806451614,"ValuesType":1},{"DeviceId":"9c9c1f14ac90","Timestamp":1673240400,"Complete":true,"Delta":0.553,"DeltaCurrency":0.23023225806451614,"ValuesType":1},{"DeviceId":"9c9c1f14ac90","Timestamp":1673236800,"Complete":true,"Delta":0.303,"DeltaCurrency":0.13023225806451613,"ValuesType":1},{"DeviceId":"9c9c1f14ac90","Timestamp":1673233200,"Complete":true,"Delta":0.208,"DeltaCurrency":0.09223225806451614,"ValuesType":1},{"DeviceId":"9c9c1f14ac90","Timestamp":1673229600,"Complete":true,"Delta":0.162,"DeltaCurrency":0.07383225806451613,"ValuesType":1},{"DeviceId":"9c9c1f14ac90","Timestamp":1673226000,"Complete":true,"Delta":0.2,"DeltaCurrency":0.08903225806451615,"ValuesType":1},{"DeviceId":"9c9c1f14ac90","Timestamp":1673222400,"Complete":true,"Delta":0.19899999999999998,"DeltaCurrency":0.08863225806451613,"ValuesType":1},{"DeviceId":"9c9c1f14ac90","Timestamp":1673218800,"Complete":true,"Delta":0.181,"DeltaCurrency":0.08143225806451614,"ValuesType":1},{"DeviceId":"9c9c1f14ac90","Timestamp":1673215200,"Complete":true,"Delta":0.28400000000000003,"DeltaCurrency":0.12263225806451614,"ValuesType":1},{"DeviceId":"9c9c1f14ac90","Timestamp":1673211600,"Complete":true,"Delta":0.30400000000000005,"DeltaCurrency":0.13063225806451614,"ValuesType":1},{"DeviceId":"9c9c1f14ac90","Timestamp":1673208000,"Complete":true,"Delta":0.48,"DeltaCurrency":0.20103225806451613,"ValuesType":1},{"DeviceId":"9c9c1f14ac90","Timestamp":1673204400,"Complete":true,"Delta":0.527,"DeltaCurrency":0.21983225806451615,"ValuesType":1},{"DeviceId":"9c9c1f14ac90","Timestamp":1673200800,"Complete":true,"Delta":0.475,"DeltaCurrency":0.1967741935483871,"ValuesType":1}],"SumCurrency":4.441174193548386},"FeedIn":{"StartTime":1673201700,"StartTimeCurrency":9223372036854775807,"Sum":0,"Max":0,"MaxCurrency":0,"ReportValues":[{"DeviceId":"9c9c1f14ac90","Timestamp":1673287200,"Complete":true,"Delta":0,"DeltaCurrency":0,"ValuesType":2},{"DeviceId":"9c9c1f14ac90","Timestamp":1673283600,"Complete":true,"Delta":0,"DeltaCurrency":0,"ValuesType":2},{"DeviceId":"9c9c1f14ac90","Timestamp":1673280000,"Complete":true,"Delta":0,"DeltaCurrency":0,"ValuesType":2},{"DeviceId":"9c9c1f14ac90","Timestamp":1673276400,"Complete":true,"Delta":0,"DeltaCurrency":0,"ValuesType":2},{"DeviceId":"9c9c1f14ac90","Timestamp":1673272800,"Complete":true,"Delta":0,"DeltaCurrency":0,"ValuesType":2},{"DeviceId":"9c9c1f14ac90","Timestamp":1673269200,"Complete":true,"Delta":0,"DeltaCurrency":0,"ValuesType":2},{"DeviceId":"9c9c1f14ac90","Timestamp":1673265600,"Complete":true,"Delta":0,"DeltaCurrency":0,"ValuesType":2},{"DeviceId":"9c9c1f14ac90","Timestamp":1673262000,"Complete":true,"Delta":0,"DeltaCurrency":0,"ValuesType":2},{"DeviceId":"9c9c1f14ac90","Timestamp":1673258400,"Complete":true,"Delta":0,"DeltaCurrency":0,"ValuesType":2},{"DeviceId":"9c9c1f14ac90","Timestamp":1673254800,"Complete":true,"Delta":0,"DeltaCurrency":0,"ValuesType":2},{"DeviceId":"9c9c1f14ac90","Timestamp":1673251200,"Complete":true,"Delta":0,"DeltaCurrency":0,"ValuesType":2},{"DeviceId":"9c9c1f14ac90","Timestamp":1673247600,"Complete":true,"Delta":0,"DeltaCurrency":0,"ValuesType":2},{"DeviceId":"9c9c1f14ac90","Timestamp":1673244000,"Complete":true,"Delta":0,"DeltaCurrency":0,"ValuesType":2},{"DeviceId":"9c9c1f14ac90","Timestamp":1673240400,"Complete":true,"Delta":0,"DeltaCurrency":0,"ValuesType":2},{"DeviceId":"9c9c1f14ac90","Timestamp":1673236800,"Complete":true,"Delta":0,"DeltaCurrency":0,"ValuesType":2},{"DeviceId":"9c9c1f14ac90","Timestamp":1673233200,"Complete":true,"Delta":0,"DeltaCurrency":0,"ValuesType":2},{"DeviceId":"9c9c1f14ac90","Timestamp":1673229600,"Complete":true,"Delta":0,"DeltaCurrency":0,"ValuesType":2},{"DeviceId":"9c9c1f14ac90","Timestamp":1673226000,"Complete":true,"Delta":0,"DeltaCurrency":0,"ValuesType":2},{"DeviceId":"9c9c1f14ac90","Timestamp":1673222400,"Complete":true,"Delta":0,"DeltaCurrency":0,"ValuesType":2},{"DeviceId":"9c9c1f14ac90","Timestamp":1673218800,"Complete":true,"Delta":0,"DeltaCurrency":0,"ValuesType":2},{"DeviceId":"9c9c1f14ac90","Timestamp":1673215200,"Complete":true,"Delta":0,"DeltaCurrency":0,"ValuesType":2},{"DeviceId":"9c9c1f14ac90","Timestamp":1673211600,"Complete":true,"Delta":0,"DeltaCurrency":0,"ValuesType":2},{"DeviceId":"9c9c1f14ac90","Timestamp":1673208000,"Complete":true,"Delta":0,"DeltaCurrency":0,"ValuesType":2},{"DeviceId":"9c9c1f14ac90","Timestamp":1673204400,"Complete":true,"Delta":0,"DeltaCurrency":0,"ValuesType":2},{"DeviceId":"9c9c1f14ac90","Timestamp":1673200800,"Complete":true,"Delta":0,"DeltaCurrency":0,"ValuesType":2}],"SumCurrency":0}}

`For the current power it is
https://backend.powerfox.energy/api/2.0/my/main/current?unit=kwh
Answer:

{"Outdated":false,"Watt":421,"Timestamp":1673287737,"A_Plus":10893.792,"A_Minus":84.163}

This I can show on HA. The configuration.yaml is:

sensor:
  - platform: rest
    authentication: basic
    username: username
    password: PW
    scan_interval: 30
    resource: https://backend.powerfox.energy/api/2.0/my/main/current?unit=kwh
    name: "poweropti"
    json_attributes:
      - "Watt"
      - "Timestamp"
      - "A_Plus"
      - "A_Minus"
      - "Outdated"

template:
  - sensor:
      - name: "Strom-aktuell"
        unique_id: strom_aktuell
        unit_of_measurement: "W"
        device_class: "power"
        state_class: "measurement"
        state: >
            {{ state_attr('sensor.poweropti', 'Watt') }}
      - name: "Strom-Bezug"
        unique_id: strom_bezug
        unit_of_measurement: "kWh"
        device_class: "energy"
        state_class: "total_increasing"
        state: >
           {{ state_attr('sensor.poweropti', 'A_Plus') }}
      - name: "Strom_Einspeisung"
        unique_id: Einspeisung
        unit_of_measurement: "kWh"
        device_class: "energy"
        state_class: "total_increasing"
        state: >
           {{ state_attr('sensor.poweropti', 'A_Minus') }}

So, I cannot use the url as it asks for a pwd but the full response was OK
Your rest sensor lacks the value_template (setting the state, this can be as simple as “OK”) and the json_attributes_path
Suggest to not add / look at other sensors until you have the rest part as you like it
Copy/paste your json output in a json viewer, this may help, e.g. Online JSON Viewer (stack.hu)

Thank you @vingerha
Now the response with the value_template is good and I can see the daily consumption.