postmannest-api

How to I get just the temperature from the new google SDM for nest thermostat


Using : Get

https://smartdevicemanagement.googleapis.com/v1/enterprises/project-id/devices/device-id/

It returns all the info below. i just want the temperature. I am using postnam with: Content-Type and Authorization.

{
    "name": "enterprises/c7ad210f-e05d-418c-a52a-1efc0891b3cf/devices/AVPHwEu-AUnrc2QEy_wmf7_u1hXWh_fH2V4q_DA5S1C3_bnLc2H-IxPEsNKtbc5NJZGCXFNAgK9HyZ96slFUQuyShlqauw",
    "type": "sdm.devices.types.THERMOSTAT",
    "assignee": "enterprises/c7ad210f-e05d-418c-a52a-1efc0891b3cf/structures/AVPHwEsL0trQSBq4GoBJFNrt_eBujz2A9uQvOxg112ZkvUSGMw3A2l3BBFGrLQ-Q8nyc-Mvvqb-Dy6YabT4625fGH1fcIg/rooms/AVPHwEuauRh8KXX1R_kRoTnxKUXRomQ_u80JOyjhfVKKCbn-OPPPigjoAOIJ7kFFwy1-PEs9z6BIP4DugImZLQ2bL59Uv0nZuHLjVsb0If9q0-pGQZcFgY5dxx7iIX63GuIezOW4paE8NNE",
    "traits": {
        "sdm.devices.traits.Info": {
            "customName": ""
        },
        "sdm.devices.traits.Humidity": {
            "ambientHumidityPercent": 63
        },
        "sdm.devices.traits.Connectivity": {
            "status": "ONLINE"
        },
        "sdm.devices.traits.Fan": {},
        "sdm.devices.traits.ThermostatMode": {
            "mode": "HEAT",
            "availableModes": [
                "HEAT",
                "OFF"
            ]
        },
        "sdm.devices.traits.ThermostatEco": {
            "availableModes": [
                "OFF",
                "MANUAL_ECO"
            ],
            "mode": "OFF",
            "heatCelsius": 8.82,
            "coolCelsius": 24.44443
        },
        "sdm.devices.traits.ThermostatHvac": {
            "status": "OFF"
        },
        "sdm.devices.traits.Settings": {
            "temperatureScale": "CELSIUS"
        },
        "sdm.devices.traits.ThermostatTemperatureSetpoint": {
            "heatCelsius": 16
        },
        "sdm.devices.traits.Temperature": {
            "ambientTemperatureCelsius": 20.23
        }
    },
    "parentRelations": [
        {
            "parent": "enterprises/c7ad210f-e05d-418c-a52a-1efc0891b3cf/structures/AVPHwEsL0trQSBq4GoBJFNrt_eBujz2A9uQvOxg112ZkvUSGMw3A2l3BBFGrLQ-Q8nyc-Mvvqb-Dy6YabT4625fGH1fcIg/rooms/AVPHwEuauRh8KXX1R_kRoTnxKUXRomQ_u80JOyjhfVKKCbn-OPPPigjoAOIJ7kFFwy1-PEs9z6BIP4DugImZLQ2bL59Uv0nZuHLjVsb0If9q0-pGQZcFgY5dxx7iIX63GuIezOW4paE8NNE",
            "displayName": "Hallway"
        }
    ]
}

Solution

  • According to the API documentation, it's not possible to only get the temperature.

    But you can get it from the response body you posted, in Postman's test tab:

    const resBody = pm.response.json();
    
    temperature = resBody.traits['sdm.devices.traits.Temperature'].ambientTemperatureCelsius;
    
    console.log(temperature);