项目作者: lost-carrier

项目描述 :
Netatmo Java API (unofficial)
高级语言: Java
项目地址: git://github.com/lost-carrier/netatmo-api.git
创建时间: 2015-09-10T21:25:00Z
项目社区:https://github.com/lost-carrier/netatmo-api

开源协议:Apache License 2.0

下载


:no_entry: [DEPRECATED] Due to Netatmo’s authentication procedure changes, this lib continued to operate unreliably. I threw my Netatmo in the trash and went for Ecowitt!

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.

  1. <dependencies>
  2. [...]
  3. <dependency>
  4. <groupId>org.losty.netatmo</groupId>
  5. <artifactId>netatmo-api</artifactId>
  6. <version>0.9.1</version>
  7. </dependency>
  8. [...]
  9. </dependencies>

Usage

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

  1. OAuthTokenStore tokenStore = new TransientOAuthTokenStore();
  2. tokenStore.setTokens(REFRESH_TOKEN, ACCESS_TOKEN, 0);
  3. NetatmoHttpClient client = new NetatmoHttpClient(CLIENT_ID, CLIENT_SECRET, tokenStore);
  4. List<String> types = Arrays.asList(Params.TYPE_TEMPERATURE, Params.TYPE_PRESSURE, Params.TYPE_HUMIDITY);
  5. ZonedDateTime dateBegin = ZonedDateTime.parse("2015-09-10T00:00Z");
  6. ZonedDateTime dateEnd = ZonedDateTime.parse("2015-09-11T00:00Z");
  7. Station station = client.getStationsData().get(0);
  8. List<Measures> measures = client.getMeasures(station, station.getModules().get(0), types, Params.SCALE_MAX, dateBegin, dateEnd, null, null);
  9. for (Measures measure : measures) {
  10. new DateTime(measure.getBeginTime()).withZone(DateTimeZone.UTC).toString();
  11. measure.getTemperature();
  12. measure.getPressure();
  13. measure.getHumidity();
  14. ...

What else?

Hmm… That’s about it!

Forks, PRs and stuff is always welcome!

License

  1. Copyright 2013 Netatmo
  2. Licensed under the Apache License, Version 2.0 (the "License");
  3. you may not use this file except in compliance with the License.
  4. You may obtain a copy of the License at
  5. http://www.apache.org/licenses/LICENSE-2.0
  6. Unless required by applicable law or agreed to in writing, software
  7. distributed under the License is distributed on an "AS IS" BASIS,
  8. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. See the License for the specific language governing permissions and
  10. limitations under the License.