【问题标题】:How to I get just the temperature from the new google SDM for nest thermostat如何从新的谷歌 SDM 获取巢恒温器的温度
【发布时间】:2020-09-30 20:43:51
【问题描述】:

使用:获取

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

它返回以下所有信息。我只想要温度。我正在使用 postnam:Content-TypeAuthorization

{
    "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"
        }
    ]
}

【问题讨论】:

  • 您可以简单地从返回的 JSON 中解析它。
  • @nicholas 好吧,这个问题被标记为postman,他还说Using : GetI am using postnam with

标签: postman nest-api


【解决方案1】:

根据API documentation,不可能只得到温度。

但您可以从 Postman 的测试选项卡中发布的响应正文中获取它:

const resBody = pm.response.json();

temperature = resBody.traits['sdm.devices.traits.Temperature'].ambientTemperatureCelsius;

console.log(temperature);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-05-07
    • 1970-01-01
    • 1970-01-01
    • 2014-08-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多