call API via Python
Hello,
Im trying to ask my netatmo weatherstation for data using the API with a python script.
But it does not work.
Is someone using it the same way and can help me?
Thanks in advance for any help
Hello,
Im trying to ask my netatmo weatherstation for data using the API with a python script.
But it does not work.
Is someone using it the same way and can help me?
Thanks in advance for any help
<%= block.description %>
<% } %><%= block.description %>
<% } %>
Comments
8 comments
Hello,
How the implementation of token access and refresh is implemented?
May you share the python script?
Phil [ just a user ]
Hi,
I used this one, took the infos from dev.netatmo.com, but it doesnt work.
import requests
# Zugangsdaten
client_id = 'DEIN_CLIENT_ID'
client_secret = 'DEIN_CLIENT_SECRET'
username = 'DEINE_NETATMO_EMAIL'
password = 'DEIN_NETATMO_PASSWORT'
# Authentifizieren und Token holen
auth_url = 'https://api.netatmo.com/oauth2/token'
auth_payload = {
'grant_type': 'password',
'client_id': client_id,
'client_secret': client_secret,
'username': username,
'password': password,
'scope': 'read_station'
}
auth_response = requests.post(auth_url, data=auth_payload)
auth_data = auth_response.json()
access_token = auth_data['access_token']
# Wetterdaten abrufen
station_url = 'https://api.netatmo.com/api/getstationsdata'
headers = {'Authorization': f'Bearer {access_token}'}
station_response = requests.get(station_url, headers=headers)
station_data = station_response.json()
# Beispiel: Temperatur ausgeben
for device in station_data['body']['devices']:
print("Hauptstation:", device['station_name'])
dashboard_data = device['dashboard_data']
print("Innen-Temperatur:", dashboard_data['Temperature'], "°C")
for module in device['modules']:
print(f"Modul: {module['module_name']}")
mod_data = module['dashboard_data']
if 'Temperature' in mod_data:
if 'Temperature' in mod_data:
print("Außen-Temperatur:", mod_data['Temperature'], "°C")
Thanks for any help :-)
Claude
Hello Claude,
Thanks for sharing.
Since end of 2022, it it no more possible to obtain a token with a username and a password.
I shared via github, what I use every day.
- script in php to manage token (https://github.com/Phil353556/netatmo-manage-tokens)
- script in php to manage netatmo floodlight (https://github.com/Phil353556/netatmo-floodlight)
I hope it can help you
Phil
Dear Phil,
I'm sorry, but I can't figure it out. Unfortunately, I'm not a programmer and have only limited knowledge of it. I can handle Python a little, but PHP isn't my thing.
Thanks for trying, though.
:-)
Ok
I understand
What you can do is:
-take the php script (the manage token one)
-ask lumo.proton.me, or whatever the LLM you want;, to translate it into python
and you're done :-)
Phil
Hey,
i will try it, thanks for your idea
Take you informed if it works :-)
Claude
Get inspiration here. It works.
https://github.com/philippelt/netatmo-api-python
I tryied now several ways, but no one worked.
Anyway i put my netatmo to trash and buy another product, which is more communicativ.
Thanks for all your help.
Br
Please sign in to leave a comment.