Giter VIP home page Giter VIP logo

netatmo-api's Introduction

Netatmo Java API (unofficial)

Small adaption of the original Netatmo Android API that can be used with plain Java (>=v8) instead of Android. Nothing special, but might help you getting started as some parsing and the OAuth2 stuff is already handled (many thanks to those folks at Apache Oltu!).

Documentation of their API is available at https://dev.netatmo.com/apidocumentation/general.

Installation

Now available at Maven Central, so just add the dependency to your pom.xml.

<dependencies>
    [...]
    <dependency>
        <groupId>org.losty.netatmo</groupId>
        <artifactId>netatmo-api</artifactId>
        <version>0.9.1</version>
    </dependency>
    [...]
</dependencies>

Usage

You'll get CLIENT_ID, CLIENT_SECRET, REFRESH_TOKEN and ACCESS_TOKEN at https://dev.netatmo.com/apps/.

OAuthTokenStore tokenStore = new TransientOAuthTokenStore();
tokenStore.setTokens(REFRESH_TOKEN, ACCESS_TOKEN, 0);
NetatmoHttpClient client = new NetatmoHttpClient(CLIENT_ID, CLIENT_SECRET, tokenStore);

List<String> types = Arrays.asList(Params.TYPE_TEMPERATURE, Params.TYPE_PRESSURE, Params.TYPE_HUMIDITY);
ZonedDateTime dateBegin = ZonedDateTime.parse("2015-09-10T00:00Z");
ZonedDateTime dateEnd = ZonedDateTime.parse("2015-09-11T00:00Z");
Station station = client.getStationsData().get(0);

List<Measures> measures = client.getMeasures(station, station.getModules().get(0), types, Params.SCALE_MAX, dateBegin, dateEnd, null, null);
for (Measures measure : measures) {
	new DateTime(measure.getBeginTime()).withZone(DateTimeZone.UTC).toString();
	measure.getTemperature();
	measure.getPressure();
	measure.getHumidity();
	...

What else?

Hmm... That's about it!

Forks, PRs and stuff is always welcome!

License

Copyright 2013 Netatmo

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

netatmo-api's People

Contributors

bernardoscaetano avatar crea-doo avatar dependabot[bot] avatar jtorresmadiva avatar kaiwinter avatar lost-carrier avatar robmelfi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

netatmo-api's Issues

Reuse OAuth token

I'm working on my own netatmo client in which I'm using your library. Thank you for your effort, the library is perfectly simple I could get it running immediately.
The only thing I'm missing is the possibility to reuse the acquired OAuth token. I don't want to store the username/password in my client so I really want to use that token once I have it. I implemented this in my fork inspired by the official netatmo sample.
A new constructor of NetatmoHttpClient can take a TokenStore (interface) which can implement the persistence of the token. My fork contains a PreferenceTokenStore which saves the token by using the Java Preferences API. In my (android) client I'm using a SharedPreferencesTokenStore for example.
This solution is fully backwards compatible. If no TokenStore is passed a TransientTokenStore is used which doesn't persist the token.

Oh and there was a method for refreshing the token in your code already. This is called now if the existing token is expired. Works as expected.

Please let me know what you think. In case you think this is useful I could open a pull request.

client.getStationsData() missing?

Hi everyone,
I just tried to use the client like described in the readme. But the method client.getStationsData() (without parameters) is missing. I also cannot find another means to list Stations - only homes and their rooms.
Any pointers?

Regards,
Christian

Client credentials grant type no longer supported

Netatmo has now finally disabled the client credentials grant type meaning login with username and password is no longer possible. https://dev.netatmo.com/apidocumentation/oauth#client-credential
However using their web form to login is not possible having a backend application fetching the data. It looks like that the refresh token never expires. So the approach would be to get the refresh token from e.g. https://dev.netatmo.com/apps/ and use it for "login" instead of username/password. Are you planning to fix your netatmo-api in this way?

BR
Dirk

Maven support

Hello,
is there a way to provide this library as maven dependency?
I would really love it.

Thank you && greetings
Rouven

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.