Giter Site home page Giter Site logo

Comments (14)

mainstreetmark avatar mainstreetmark commented on September 18, 2024 1

Netatmo finally replied. the "device_id" is the base station's mac. I needed to pass each device'd mac via "module_id" to getMeasure.

from netatmo.

karbassi avatar karbassi commented on September 18, 2024

@mainstreetmark: Make sure your auth and options variables is filled in.

Using api.getStationsData(), you can get your device_id that is in options

var netatmo = require('netatmo');

// FILL THIS OUT
var auth = {
  "client_id": "",
  "client_secret": "",
  "username": "",
  "password": "",
};

var api = new netatmo(auth);

api.getStationsData(function(err, devices) {
  console.log(devices);
});

// FILL THIS OUT
var options = {
  device_id: '',
  scale: 'max',
  type: ['Temperature', 'CO2', 'Humidity', 'Pressure', 'Noise'],
};

api.getMeasure(options, function(err, measure) {
  console.log(measure.length);
  console.log(measure[0]);
});

from netatmo.

mainstreetmark avatar mainstreetmark commented on September 18, 2024

Yep. getStationData is working. I use it. Here's a section of getStationData's reply:

{
  _id: '03:00:00:01:cf:24',
  type: 'NAModule4',
  last_message: 1500993523,
  last_seen: 1500993497,
  dashboard_data: {
    time_utc: 1500993497,
    Temperature: 25.4,
    temp_trend: 'stable',
    Humidity: 57,
    CO2: 682,
    date_max_temp: 1500956588,
    date_min_temp: 1500978683,
    min_temp: 24.3,
    max_temp: 25.4
  },
  data_type: [
    'Temperature',
    'CO2',
    'Humidity'
  ],
  module_name: 'Office',
  last_setup: 1440081115,
  battery_vp: 4840,
  battery_percent: 36,
  rf_status: 69,
  firmware: 44
}

and then here's the code that 404's:

var options = {
  device_id: '03:00:00:01:cf:24', //<-- _id
  scale: 'max',
  type: ['Temperature'],
};

api.getMeasure(options, function(err, measure) {
        console.log(err);
  console.log(measure);
});

from netatmo.

karbassi avatar karbassi commented on September 18, 2024

@mainstreetmark check again, it may be that you hit an API rate limit or the service was down.

Also, could you print our what is in err and measure.

from netatmo.

mainstreetmark avatar mainstreetmark commented on September 18, 2024
Error: getMeasure error: Status code404
    at netatmo.handleRequestError (/Users/mark/Sites/tg4/node_modules/netatmo/netatmo.js:46:15)
    at netatmo.<anonymous> (/Users/mark/Sites/tg4/node_modules/netatmo/netatmo.js:383:24)
    at Request.self.callback (/Users/mark/Sites/tg4/node_modules/request/request.js:188:22)
    at emitTwo (events.js:106:13)
    at Request.emit (events.js:192:7)
    at Request.<anonymous> (/Users/mark/Sites/tg4/node_modules/request/request.js:1171:10)
    at emitOne (events.js:96:13)
    at Request.emit (events.js:189:7)
    at IncomingMessage.<anonymous> (/Users/mark/Sites/tg4/node_modules/request/request.js:1091:12)
    at Object.onceWrapper (events.js:291:19)
undefined

measure is "undefined".

getStationData appears to be working, sending back a list of devices[0].modules, so the Netatmo connection is working.

├── [email protected]

from netatmo.

mainstreetmark avatar mainstreetmark commented on September 18, 2024

Here's my form post, from line ~370 of netatmo.js (with my particular access token hash X'd out):

{ url: 'https://api.netatmo.net/api/getmeasure',
  method: 'POST',
  form: 
   { access_token: 'xxx|xxx',
     device_id: '03:00:00:01:cf:24',
     scale: 'max',
     type: 'temperature' } }

A valid URL, it seems.

Here's what was in body:

{"error":{"code":9,"message":"Device not found"}}

So, perhaps the error message handling could be improved?

from netatmo.

mainstreetmark avatar mainstreetmark commented on September 18, 2024

ok, ... another note.

I can't even get dev.netatmo.com to recognize the MAC it's giving me, and the MAC it does give me doesn't OUI to Netatmo. So the "404" in all of this has been that my MAC wasn't found. Netatmo thinks the devices should start with "70:ee:50:00:00"

So I'm going to spend some time with NMAP and maybe ask Netatmo themselves why my MACs are not lining up.

"Status code404" was misleading. :)

from netatmo.

karbassi avatar karbassi commented on September 18, 2024

@mainstreetmark thanks for updating this. 💯

On the server side, technically 404 status code is correct since your device couldn't be found in their DB.

On a service level, please do reach out to Netatmo. It's weird that the MAC addresses aren't synced correctly. Could be a number of reasons for that. My bet is that they'll just have you delete it from your account and re-add it.

Keep me updated. 👍

from netatmo.

mainstreetmark avatar mainstreetmark commented on September 18, 2024

Ok. Will let you know. Looks like my ecosystem needs a bunch of batteries anyways.

Meanwhile, maybe display the actual error from the body, rather than the status code. Thanks. :)

from netatmo.

karbassi avatar karbassi commented on September 18, 2024

@mainstreetmark It should already.

The code will display error.message from the body response. See line 37-40.

Line 382-388 is the logic.

Can you debug and tell me what is being sent to line 383?

For the function call this.handleRequestError(err, response, body, "getMeasure error"), can you debug and give me the values of err, response, and body?

response may be large, but I'll need to see the response.statusCode part as well.

from netatmo.

mainstreetmark avatar mainstreetmark commented on September 18, 2024

My content type is application/json; charset=utf-8 and failed the line 37 test.

from netatmo.

karbassi avatar karbassi commented on September 18, 2024

@mainstreetmark I'm not behind my workstation, but can you try changing line 37 from:

if (body && response.headers['content-type'] === 'application/json') {

to

if (body && response.headers['content-type'].trim().toLowerCase().indexOf('application/json') !== -1) {

I'm trimming and lowercasing it even though the content-type should be already in the correct pattern, but it's better to be safe than assume.

from netatmo.

mainstreetmark avatar mainstreetmark commented on September 18, 2024

Yep. That fixes it:

Error: getMeasure error: Status code404

... to ...

Error: getMeasure error: Device not found

No reply from Netatmo yet, but that's not a problem you need to worry about. Thanks for help.

from netatmo.

alcm-b avatar alcm-b commented on September 18, 2024

Kind of confirming the @karbassi 's solution: make sure you submit device MAC address in lowercase.

For example, 70:AB:CD:56:58:5C yields 404 error, while 70:ab:cd:56:58:5c is okay.

At least that was the problem in my case. No idea, why Netatmo devs are so picky when it comes to MAC addresses :)

from netatmo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.