Skip to content

lost-carrier/netatmo-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.