Unable to get a value in a RESTful sensor

I’m fighting with HA since yesterday trying to get an entity populated by an external API source.
I admit that I’m not a good friend of templates, so there might be the problem.
Starting from the beginning.
Here is a working CURL command and the response received from the external source

What I’m trying to do is to define a sensor entity in HA using the RESTful integration
Here is the my current best attempt:

Best attempt because I can see the entity in HA but its valuer remains “Unknown”
I’m sure I’m doing something wrong, but after two days of tests I think I really need your help to understand what is it…
No need to say that I tried to apply all the suggestion and tried to copy all the available examples… stil I must be missing something
Thanks for your help

Giacomo

Please do not use images for showing your code: this is making it harder to respond with some modified code. It is better to post your code in correctly formatted form, like is shown here: Format it properly

Since you want to fetch the data from the source, you need to use the GET method instead of the POST method.
And then you have to define a list of the required json attributes.
See this example:

Try this:

sensor:
  - platform: rest
    name: Airzone Guestroom status
    resource: http://192.168.1.242:3000/api/v1/hvac
    method: GET
    json_attributes:
      - systemID
      - zoneID
      - name
      - on
      - maxTemp
      - minTemp
      - setpoint
      - roomTemp
      - mode
      - coldStages
      - coldStage
      - heatStages
      - heatStage
      - humidity
      - units
      - errors
      - air_demand
      - floor_demand

This should provide you with a sensor delivering all the required data as attributes.
You can get specific attributes from that sensor with template sensors like this:

sensor:
  - platform: template
    sensors:
      airzone_systemid:
        friendly_name: "Airzone Guestroom System ID"
        value_template: "{{ state_attr('sensor.airzone_guestroom_status', 'systemID') }}"
      airzone_zoneid:
        friendly_name: "Airzone Guestroom Zone ID"
        value_template: "{{ state_attr('sensor.airzone_guestroom_status', 'zoneID') }}"

Sorry for using pictures instead of the proper function, but today is not my day, so I couldn’t find the proper way to format.
I’ll try to do it now to see if I learned :grinning:
The following sensor definition allows me to have the desired result:

- platform: rest
    name: "Airzone Guestroom status"
    resource: http://192.168.1.242:3000/api/v1/hvac
    method: POST
    payload: '{"systemID":1,"zoneID":3}'  
    headers:
      Content-Type: application/json    
    value_template: "{{ value_json.data[0].on }}"

I’m not sure why, but this API demands for a POST command when you want to read and a PUT when you want to change a value.
So, as I imagined, the real change in the above code is the value_template line provided by my son who finally emerged from a busy day of work.

Thanks anyway to have used your time to show me another way to reach the result and that I will certainly use when my query will need to have back more than a single value

Giacomo

Interesting!
Rethinking it, I would not be surprised now when my proposal does not work in this case.
As I understand it now, you have to use POST to first tell the API from which systemID and zoneID you want to fetch the data (via the payload), and then ask for the specific “on” data (via the value_template)?

I think you are absolutely right.
As per their API documentation you have to send a POST command with system and zone in the payload.
As you see in my original CURL picture, the system responds with the infos of that specific identity.
If you want to change on of the setting the API asks for a PUT command with, again, system, zone, plus the name of the setting and its new value.
To tell you the truth, I have hard time to match this with the POST/GET alternative if the RESTful sensor.
Tomorrow I’ll try to change the value of the entity in HA and see if it affect in some way the value in the target.
I’ll keep you updated