Giter Club home page Giter Club logo

Comments (9)

lukaspustina avatar lukaspustina commented on September 25, 2024

Hi @theHausdorffMetric, thanks for using my create.

I haven't looked into it yet, before I do, just one questions: Do the other examples work for you? If not, it might be due to authorization. If yes, it might be that Netatmo changed the response or something else broke in my parser.

from netatmo-rs.

lukaspustina avatar lukaspustina commented on September 25, 2024

I've just added logging right before the location I suspect your panic to occur. Can please rerun your example from the current master and prepend RUST_LOG=netatmo_rs=trace to your command. This should show us the result that we receive from the API -- please be aware that the log output will contain sensitive authentication information; so make sure to omit that from sharing.

from netatmo-rs.

theHausdorffMetric avatar theHausdorffMetric commented on September 25, 2024

Hi @lukaspustina,
thx - I can auth ok and get some data but it panics on deserialisation where the pressureunit is missing. I will try to investigate the api response with the browser first.

Below is the current ouput (I DELETED some confidential stuff as you suggested)

Finished dev [unoptimized + debuginfo] target(s) in 0.07s
Running target/debug/examples/get_station_data
[2020-11-08T08:53:29Z TRACE netatmo_rs::client] Sucessful (200) repsone: '{"access_token":"DELETED":"DELETED","scope":["read_station"],"expires_in":10800,"expire_in":10800}'
[2020-11-08T08:53:29Z TRACE netatmo_rs::client] Sucessful (200) repsone: '{"body":{"devices":[{"_id":"DELETED","station_name":"FamilyProbst NetAtmo","date_setup":1359763200,"last_setup":1359763200,"type":"NAMain","last_status_store":1604825349,"module_name":"Indoor1","firmware":177,"last_upgrade":1439971768,"wifi_status":68,"reachable":true,"co2_calibrating":false,"data_type":["Temperature","CO2","Humidity","Noise","Pressure"],"place":{"altitude":803,"city":"Menzingen","country":"CH","timezone":"Europe/Zurich","location":[8.5909,47.17796]},"home_id":"DELETED","home_name":"FamilyProbst NetAtmo","dashboard_data":{"time_utc":1604825336,"Temperature":23.2,"CO2":1049,"Humidity":44,"Noise":44,"Pressure":1024.9,"AbsolutePressure":931,"min_temp":22.6,"max_temp":23.5,"date_max_temp":1604790274,"date_min_temp":1604804783,"temp_trend":"stable","pressure_trend":"stable"},"modules":[{"_id":"02:00:00:2e:ee:e0","type":"NAModule1","module_name":"Outdoor2017","last_setup":1513417244,"data_type":["Temperature","Humidity"],"battery_percent":80,"reachable":true,"firmware":50,"last_message":1604825342,"last_seen":1604825330,"rf_status":77,"battery_vp":5524,"dashboard_data":{"time_utc":1604825330,"Temperature":10,"Humidity":76,"min_temp":5.6,"max_temp":10,"date_max_temp":1604825330,"date_min_temp":1604799903,"temp_trend":"up"}}]}],"user":{"mail":"DELETED","administrative":{"country":"CH","feel_like_algo":0,"lang":"en","reg_locale":"en-GB","unit":0,"windunit":0}}},"status":"ok","time_exec":0.05339217185974121,"time_server":1604825609}'
thread 'main' panicked at 'Failed to get station data: Error { inner: Error("missing field pressureunit", line: 1, column: 1433)

failed to deserialize JSON }', examples/get_station_data.rs:38:10
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

from netatmo-rs.

lukaspustina avatar lukaspustina commented on September 25, 2024

So it seems your device is sending slightly different Administrative information compared to mine. The crate so far expects this:

#[derive(Debug, Serialize, Deserialize)]
pub struct Administrative {
    pub feel_like_algo: u64,
    pub lang: String,
    pub pressureunit: u64,
    pub reg_locale: String,
    pub unit: u64,
    pub windunit: u64,
}

I don't see a reason to force these information. I will make country (as in your response) and pressureunit (as in my response) optional. Let's see how far this will get us.

The only concern I have here is that this is going to break the API and other users might get affected. But I will need to push a new create version anyway, so I'll make a minor increment. Please give a few days to change the code.

from netatmo-rs.

lukaspustina avatar lukaspustina commented on September 25, 2024

@theHausdorffMetric Please check my changes on master. If it works, can you check all other examples too? Maybe we can surface other misplaced requirements, too.

from netatmo-rs.

theHausdorffMetric avatar theHausdorffMetric commented on September 25, 2024

can now confirm that get_measure and get_station_data work as intended.
Thx a lot
(now i'm just waiting for my new rapi 0 and e-ink hat to make a temperature display)

from netatmo-rs.

lukaspustina avatar lukaspustina commented on September 25, 2024

Great. I'll push a new crate version later.

from netatmo-rs.

lukaspustina avatar lukaspustina commented on September 25, 2024

Please see https://crates.io/crates/netatmo-rs/0.5.0.

If this works for you, please close the issue.

from netatmo-rs.

theHausdorffMetric avatar theHausdorffMetric commented on September 25, 2024

Thx for the support.

from netatmo-rs.

Related Issues (3)

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.