Netatmo Weather Station is an IoT terminal that can be installed indoors and outdoors to measure indoor and outdoor weather information [API](https: //) dev.netatmo.com/dev/resources/technical/introduction) is also available. I would like to hit this API with Python.
We don't officially publish the Python library, so we'll use a third-party library. For the library, lnetatmo created by philippelt is convenient.
lnetatmo After cloning the project from here, use `` `setup.py``` to install the library.
Terminal
$python setup.py install
It can also be installed with pip.
Terminal
$pip install lnetatmo
Prepare the user information. You can check your CLIENT_ID and CLIENT_SECRET after logging in to here.
"CLIENT_ID" : "",
"CLIENT_SECRET" : "",
"USERNAME" : "mail address",
"PASSWORD" : "password"
Try to get the latest weather information using lnetatmo.
sample.py
#!/usr/bin/python3
# encoding=utf-8
import lnetatmo
#Get token
authorization = lnetatmo.ClientAuth(
clientId = "",
clientSecret = "",
username = "",
password = "",
scope = ""
)
#Get weather information
weather_station = lnetatmo.WeatherStationData(authorization)
#Display of weather information
print(weather_station.lastData())
If you can get it like this, you are successful.
Recommended Posts