Cemm, how to retrieve json information

Hi, I tried to retrieve the information from my Cemm. When I read I get the next: (example)
{
“data”: {
“t1”:[1670866095000,1089.21],
“t2”:[1670866095000,854.79],
“t3”:[1670866095000,1219.97],
“t4”:[1670866095000,2697.32],
“electric_power”:[1670866095000,1076],
“rate”:[1670866095000,2],
“gas”:[0,0]
},
“totals”:{
“electric_energy”:[1670866106000,-130.76],
“electric_energy_high”:[1670866106000,-1842.53],
“t1”:[1670866106000,1089.21],
“t2”:[1670866106000,854.79],
“t3”:[1670866106000,1219.97],
“t4”:[1670866106000,2697.32],
“gas”:[1670866106000,0]
}
}

I try to make graphs from this information

My configuration file currently is:

rest:

  • authentication: basic
    resource: “http://x.x.x.x/open-api/v1/p1/realtime/
    sensor:
    • name: “t1”
      json_attributes_path: $.data.t1[1]
    • name: “t2”
      json_attributes_path: $.data.t2.[1]
    • name: “t3”
      json_attributes_path: $.data.t3.[1]
    • name: “t4”
      json_attributes_path: $.data.t4.[1]

Then I have an entity with the next attributes
t1: 1670878578000, 1090.47
t2: 1670878578000, 858.08
t3: 1670878578000, 1219.97
t4: 1670878578000, 2697.32
friendly_name: cemm

I am not succesfull in selecting de second value only in the list.
The list attribus list must be:
t1: 1090.47
t2: 858.08
t3: 1219.97
t4: 2697.32
friendly_name: cemm

After then I hope I can see the graphs.
Does anybody know how to do?

Hi there, can you check the sample json uploaded. It has some formatting issues. Also please paste the json between ``` to show it as code.

Hi this is the string I received from a http:
{“data”:{“t1”:[1670868410000,1089.21],“t2”:[1670868400000,855.51],“t3”:[1670868410000,1219.97],“t4”:[1670868400000,2697.32],“electric_power”:[1670868400000,1044],“rate”:[1670868400000,2],“gas”:[0,0]},“totals”:{“electric_energy”:[1670868412000,-130.76],“electric_energy_high”:[1670868412000,-1841.83],“t1”:[1670868412000,1089.21],“t2”:[1670868412000,855.49],“t3”:[1670868412000,1219.97],“t4”:[1670868412000,2697.32],“gas”:[1670868412000,0]}}

The code I am currente use is:

sensor:
  - platform: rest
    name: cemm
    resource: "http://x.x.x.x/open-api/v1/p1/realtime/"
    value_template: "{{ value_json.data }}"
    json_attributes_path: $.data
    json_attributes:
      - t1
      - t2
      - t3
      - t4

As i check the shared json is not formatted correct.

Hi, I cannot do something the device give me… So, if I understand you, I cannot retrieve the information with json. Correct?

since this is not a json, it wont be possible to use value_json in value_template.
If you are using node red, it would be easy for you to extract data than using various templates in HA.

Hi,
I take a look at node-red, but I also did not come further.

But I think I am successfull with the next code, because it is running now and I can create a graph.
The fact that I can create a graph is because of the “device_classs: energy”

- platform: rest
  name: cemm_huidige_energie_afname
  device_class: energy
  unit_of_measurement: W
  resource: "http://x.x.x.x/open-api/v1/p1/realtime/"
  value_template: "{{states.sensor.cemm_huidige_energie_afname.attributes.electric_power[1]}}"
  json_attributes_path: $.data
  json_attributes:
    - electric_power

Now I will find out if I can update the polling time.