API: "measured" part missing in response to /getthermstate

The Netatmo API is a set of webservices allowing developers and third parties to access Netatmo device's data.
Post Reply
nlohmann
Posts: 9
Joined: 22 Nov 2013, 23:57
Location: Rostock. Germany

API: "measured" part missing in response to /getthermstate

Post by nlohmann » 20 Aug 2014, 21:26

Hi there,

I tried using the /getthermstate endpoint (https://api.netatmo.net/api/getthermstate) and had some problems:

First, it seems that I can only get a result if I use the scope "read_station". If I use "read_thermostat", I get the response

Code: Select all

{
  "error": {
    "message": "Application does not have the good scope rights", 
    "code": 13
  }
}
The results for scope "read_thermostat read_station" and "read_station" do not differ.

Second, in the result JSON object, the entry "measured" is missing, though it is documented in https://dev.netatmo.com/doc/methods/getthermstate. Also other entries seem to be missing - here is my complete result:

Code: Select all

{
  "status": "ok", 
  "body": {
    "last_therm_seen": 1408562472, 
    "rf_status": 76, 
    "setpoint": {
      "setpoint_mode": "program"
    }, 
    "last_plug_seen": 1408562476, 
    "therm_program_order": {
      "timetable": [
        {
          "m_offset": 0, 
          "id": 1
        }, 
        {
          "m_offset": 420, 
          "id": 0
        }, 
        {
          "m_offset": 480, 
          "id": 4
        }, 
        {
          "m_offset": 1140, 
          "id": 0
        }, 
        {
          "m_offset": 1320, 
          "id": 1
        }, 
        {
          "m_offset": 1860, 
          "id": 0
        }, 
        {
          "m_offset": 1920, 
          "id": 4
        }, 
        {
          "m_offset": 2580, 
          "id": 0
        }, 
        {
          "m_offset": 2760, 
          "id": 1
        }, 
        {
          "m_offset": 3300, 
          "id": 0
        }, 
        {
          "m_offset": 3360, 
          "id": 4
        }, 
        {
          "m_offset": 4020, 
          "id": 0
        }, 
        {
          "m_offset": 4200, 
          "id": 1
        }, 
        {
          "m_offset": 4740, 
          "id": 0
        }, 
        {
          "m_offset": 4800, 
          "id": 4
        }, 
        {
          "m_offset": 5460, 
          "id": 0
        }, 
        {
          "m_offset": 5640, 
          "id": 1
        }, 
        {
          "m_offset": 6180, 
          "id": 0
        }, 
        {
          "m_offset": 6240, 
          "id": 4
        }, 
        {
          "m_offset": 6900, 
          "id": 0
        }, 
        {
          "m_offset": 7080, 
          "id": 1
        }, 
        {
          "m_offset": 7620, 
          "id": 0
        }, 
        {
          "m_offset": 8520, 
          "id": 1
        }, 
        {
          "m_offset": 9060, 
          "id": 0
        }, 
        {
          "m_offset": 9960, 
          "id": 1
        }
      ], 
      "zones": [
        {
          "type": 0, 
          "id": 0, 
          "temp": 19
        }, 
        {
          "type": 1, 
          "id": 1, 
          "temp": 17
        }, 
        {
          "type": 2, 
          "id": 2, 
          "temp": 12
        }, 
        {
          "type": 3, 
          "id": 3, 
          "temp": 7
        }, 
        {
          "type": 5, 
          "id": 4, 
          "temp": 16
        }
      ], 
      "default": true, 
      "program_id": "53f4f4071b775937e7a59407"
    }, 
    "wifi_status": 69, 
    "battery_vp": 5946
  }, 
  "time_exec": 0.0095820426940918, 
  "time_server": 1408562531
}
Can anyone help me?

All the best,
Niels.

fduval_netatmo
Posts: 160
Joined: 27 Nov 2013, 09:22

Re: API: "measured" part missing in response to /getthermsta

Post by fduval_netatmo » 21 Aug 2014, 08:34

Hi nlohmann

Can you provide your device's ID and your app client_id?

thanks
Fabien - Netatmo team

trosenblatt
Posts: 233
Joined: 18 Sep 2012, 12:18

Re: API: "measured" part missing in response to /getthermsta

Post by trosenblatt » 21 Aug 2014, 11:32

Hi,
Just a reminder in case you haven't provided the scope in the right method
The scope has to provided during the authentication phase (oauth) and for requests (getthermstate in your case)
Regards,

Thomas.
Thomas Rosenblatt, Netatmo Team.

nlohmann
Posts: 9
Joined: 22 Nov 2013, 23:57
Location: Rostock. Germany

Re: API: "measured" part missing in response to /getthermsta

Post by nlohmann » 21 Aug 2014, 19:44

Dear Thomas,

thanks for your quick response!
trosenblatt wrote: Just a reminder in case you haven't provided the scope in the right method
The scope has to provided during the authentication phase (oauth) and for requests (getthermstate in your case)
I did not find a hint in the documentation that I would need to pass the scope in the requests. Anyway, I tried it and it still did not work. As a reference, here is the code I use (the only thing I removed where my credentials.

Code: Select all

#!/usr/bin/env python

import json
import requests

token_url = "https://api.netatmo.net/oauth2/token"

post_data_dictionary = {
    "grant_type": "password",
    "client_id": "...",
    "client_secret": "...",
    "username": "...",
    "password": "...",
    "scope": "read_station read_thermostat write_thermostat"
}

token_response = requests.post(token_url, data=post_data_dictionary, verify=False)

token = json.loads(token_response.text)['access_token']


therm_url = "http://api.netatmo.net/api/getthermstate"

therm_response = requests.get(therm_url + "?access_token=%s&device_id=%s&module_id=%s&scope=%s" % (token, "70:ee:50:ff:fe:18", "05:00:00:00:1e:1a", "read_thermostat"))

therm = json.loads(therm_response.text)
print json.dumps(therm, indent=2)
Again, the output lacks information on the current and set temperature:

Code: Select all

{
  "status": "ok", 
  "body": {
    "last_therm_seen": 1408642239, 
    "rf_status": 78, 
    "setpoint": {
      "setpoint_mode": "program"
    }, 
    "last_plug_seen": 1408642245, 
    "therm_program_order": {
      "timetable": [
        {
          "m_offset": 0, 
          "id": 1
        }, 
        {
          "m_offset": 420, 
          "id": 0
        }, 
        {
          "m_offset": 480, 
          "id": 4
        }, 
        {
          "m_offset": 1140, 
          "id": 0
        }, 
        {
          "m_offset": 1320, 
          "id": 1
        }, 
        {
          "m_offset": 1860, 
          "id": 0
        }, 
        {
          "m_offset": 1920, 
          "id": 4
        }, 
        {
          "m_offset": 2580, 
          "id": 0
        }, 
        {
          "m_offset": 2760, 
          "id": 1
        }, 
        {
          "m_offset": 3300, 
          "id": 0
        }, 
        {
          "m_offset": 3360, 
          "id": 4
        }, 
        {
          "m_offset": 4020, 
          "id": 0
        }, 
        {
          "m_offset": 4200, 
          "id": 1
        }, 
        {
          "m_offset": 4740, 
          "id": 0
        }, 
        {
          "m_offset": 4800, 
          "id": 4
        }, 
        {
          "m_offset": 5460, 
          "id": 0
        }, 
        {
          "m_offset": 5640, 
          "id": 1
        }, 
        {
          "m_offset": 6180, 
          "id": 0
        }, 
        {
          "m_offset": 6240, 
          "id": 4
        }, 
        {
          "m_offset": 6900, 
          "id": 0
        }, 
        {
          "m_offset": 7080, 
          "id": 1
        }, 
        {
          "m_offset": 7620, 
          "id": 0
        }, 
        {
          "m_offset": 8520, 
          "id": 1
        }, 
        {
          "m_offset": 9060, 
          "id": 0
        }, 
        {
          "m_offset": 9960, 
          "id": 1
        }
      ], 
      "zones": [
        {
          "type": 0, 
          "id": 0, 
          "temp": 19
        }, 
        {
          "type": 1, 
          "id": 1, 
          "temp": 17
        }, 
        {
          "type": 2, 
          "id": 2, 
          "temp": 12
        }, 
        {
          "type": 3, 
          "id": 3, 
          "temp": 7
        }, 
        {
          "type": 5, 
          "id": 4, 
          "temp": 16
        }
      ], 
      "default": true, 
      "program_id": "53f62da41b775958b2a592f3"
    }, 
    "wifi_status": 68, 
    "battery_vp": 5942
  }, 
  "time_exec": 0.010221004486084, 
  "time_server": 1408642775
}
While I am at is: is there a possibility to get information about whether the boiler is switched on and how long it was switched on in, say, the past 24 hours?

All the best,
Niels.

fduval_netatmo
Posts: 160
Joined: 27 Nov 2013, 09:22

Re: API: "measured" part missing in response to /getthermsta

Post by fduval_netatmo » 22 Aug 2014, 09:25

Hi,

it seems you are doing a getthermstate with a weather station instead of a thermostat.

This methos is intended to work only with a thermostat.

best regards
Fabien - Netatmo team

nlohmann
Posts: 9
Joined: 22 Nov 2013, 23:57
Location: Rostock. Germany

Re: API: "measured" part missing in response to /getthermsta

Post by nlohmann » 23 Aug 2014, 13:22

Dear Fabien,
fduval wrote: it seems you are doing a getthermstate with a weather station instead of a thermostat.

This methos is intended to work only with a thermostat.
oh, this is embarrassing! I did not realize that there is a special method to list thermostats. Now, everything works. Thanks for the help!

All the best,
Niels

Post Reply

Return to “Netatmo API”