Voltoplus Integration, parse JSON response

Hi,

I need some help on reading out/controlling my Voltoplus device. Everything can be done by GET and POST methods.

GET http://voltoplus.local/api/v1/values will return all values at once as JSON:

{
    "json_values": [
        {
            "id": "U1",
            "value": "0"
        },
        {
            "id": "U2",
            "value": "0"
        },
        {
            "id": "U3",
            "value": "0"
        },
        {
            "id": "I1",
            "value": "0"
        },
        {
            "id": "I2",
            "value": "0"
        },
        {
            "id": "I3",
            "value": "0"
        },
        {
            "id": "P1",
            "value": "0"
        },
        {
            "id": "P2",
            "value": "0"
        },
        {
            "id": "P3",
            "value": "0"
        },
        {
            "id": "P",
            "value": "0"
        },
        {
            "id": "fwdEn",
            "value": "62289"
        },
        {
            "id": "rvsEn",
            "value": "94225"
        },
        {
            "id": "AO1",
            "value": "43"
        },
        {
            "id": "AO2",
            "value": "56"
        },
        {
            "id": "my-PV1",
            "value": "0"
        },
        {
            "id": "abl1",
            "value": "0"
        },
        {
            "id": "DO1",
            "value": "0"
        },
        {
            "id": "DO2",
            "value": "0"
        },
        {
            "id": "LEDS",
            "value": "0"
        },
        {
            "id": "LEDP",
            "value": "0"
        },
        {
            "id": "date_time",
            "value": {
                "year": 2024,
                "month": 8,
                "day": 16,
                "hour": 13,
                "minute": 10,
                "second": 14
            }
        }
    ]
}

I tried different configuration like the following, but without success:

sensor:
  - platform: rest
    name: voltoplus_analog_out_1
    method: GET
    unit_of_measurement: "%"
    resource: http://voltoplus.local/api/v1/values
    value_template: "{{ value_json.json_values.id[AO1] }}"
    scan_interval: 30

And second:
what would be an easy solution to send POST’s like this:

{"json_config":[{"id":"210","value":"1"},{"id":"211","value":"50"},{"id":"212","value":"18:45"}]}

210: Activate manual mode
211: Set output to 50%
212: Go back to automatic mode at 18:45

thanks a lot in advance!

For the GET, I only know how to do this via command_line and a curl + jq
If the A01 is always at the same locaiton in the dict then you can use the dict posion between , e.g. json_values[12]
If not then … jq probably … Can help but maybe someone else has a better idea

Hello,

I don’t know if this topic is still up to date, but from my point of view the following code should work. Unfortunately, I don’t currently have a voltoplus to test. But if I use a mock service with your json, Homeassistant shows the data.

rest:
  - resource: "http://voltoplus.local/api/v1/values"
    scan_interval: 30
    sensor:
      - name: voltoplus_u1
        value_template: "{{ value_json.json_values | selectattr('id', 'eq', 'U1') | map(attribute='value') | first | default }}"
        unit_of_measurement: V
      - name: voltoplus_u2
        value_template: "{{ value_json.json_values | selectattr('id', 'eq', 'U2') | map(attribute='value') | first | default }}"
        unit_of_measurement: V
      - name: voltoplus_u3
        value_template: "{{ value_json.json_values | selectattr('id', 'eq', 'U3') | map(attribute='value') | first | default }}"
        unit_of_measurement: V
      - name: voltoplus_i1
        value_template: "{{ value_json.json_values | selectattr('id', 'eq', 'I1') | map(attribute='value') | first | default }}"
        unit_of_measurement: V
      - name: voltoplus_i2
        value_template: "{{ value_json.json_values | selectattr('id', 'eq', 'I2') | map(attribute='value') | first | default }}"
        unit_of_measurement: V
      - name: voltoplus_i3
        value_template: "{{ value_json.json_values | selectattr('id', 'eq', 'I3') | map(attribute='value') | first | default }}"
        unit_of_measurement: A
      - name: voltoplus_p
        value_template: "{{ value_json.json_values | selectattr('id', 'eq', 'P') | map(attribute='value') | first | default }}"
        unit_of_measurement: W
      - name: voltoplus_fwdEn
        value_template: "{{ value_json.json_values | selectattr('id', 'eq', 'fwdEn') | map(attribute='value') | first | default }}"
        unit_of_measurement: kWh
      - name: voltoplus_rvsEn
        value_template: "{{ value_json.json_values | selectattr('id', 'eq', 'rvsEn') | map(attribute='value') | first | default }}"
        unit_of_measurement: kWh

Hello helium,

thank you for your solution! I just tested it with the real Voltoplus and it works flawless!

The solution vingerha proposed also works very well for months:

I think I will keep it simple and go for the indexed version:

value_template: "{{ value_json.json_values[0].value|float/100 }}"

Hi, jahusi,

thank you for your feedback!
Here comes a bug fixed version - based on tests with a real Voltoplus.

rest:
  - resource: "http://192.168.178.10/api/v1/values"
    scan_interval: 10
    sensor:
      - name: voltoplus_u1
        value_template: "{{ value_json.json_values | selectattr('id', 'eq', 'U1') | map(attribute='value') | first | default |  float / 100 |round(1)}}"
        unit_of_measurement: V
      - name: voltoplus_u2
        value_template: "{{ value_json.json_values | selectattr('id', 'eq', 'U2') | map(attribute='value') | first | default |  float / 100 |round(1)}}"
        unit_of_measurement: V
      - name: voltoplus_u3
        value_template: "{{ value_json.json_values | selectattr('id', 'eq', 'U3') | map(attribute='value') | first | default |  float / 100 |round(1)}}"
        unit_of_measurement: V
      - name: voltoplus_i1
        value_template: "{{ value_json.json_values | selectattr('id', 'eq', 'I1') | map(attribute='value') | first | default |  float / 1000 |round(1)}}"
        unit_of_measurement: A
      - name: voltoplus_i2
        value_template: "{{ value_json.json_values | selectattr('id', 'eq', 'I2') | map(attribute='value') | first | default |  float / 1000 |round(1)}}"
        unit_of_measurement: A
      - name: voltoplus_i3
        value_template: "{{ value_json.json_values | selectattr('id', 'eq', 'I3') | map(attribute='value') | first | default |  float / 1000 |round(1)}}"
        unit_of_measurement: A
      - name: voltoplus_p
        value_template: "{{ value_json.json_values | selectattr('id', 'eq', 'P') | map(attribute='value') | first | default }}"
        unit_of_measurement: W
      - name: voltoplus_fwdEn
        value_template: "{{ value_json.json_values | selectattr('id', 'eq', 'fwdEn') | map(attribute='value') | first | default |  float / 100 |round(1)}}"
        unit_of_measurement: kWh
      - name: voltoplus_rvsEn
        value_template: "{{ value_json.json_values | selectattr('id', 'eq', 'rvsEn') | map(attribute='value') | first | default|  float / 100 |round(1) }}"
        unit_of_measurement: kWh