Since NetAtmo Home Coach seems to be the "so new product" that even NetAtmo is NOT supporting it it its online dashboard... it looks that even the NetAtmo connector in Domoticz Hardware does not support or include such device either
the only way to access datas is to subscribe the NetATMO Connect program (for free) and trigger some script to grab info and update several custom sensors.
WORKFLOW
As I understood NetAtmo Connect works whis way:
- You post you request using: UserID, Password, ClientId, ClientSecret, MethodRequest (scope)
- The site replies with an AuthorizationToken
- Use this Token to inquiry the DeviceID
- Get your data back
REQUIREMENTS:
- Subscribe NetAtmo Connect (http://dev.netatmo.com ) and create a new app and keep the Client_ID and Client_Secret.
- HomeCoach DeviceID (Mac Address)
- UserId, Password for NetAtmo connect
- Several Virtual Sensors:
HomeCoach returns all these info:
Code: Select all
AbsolutePressure: 1002.4
time_utc: 1480697811
health_idx: 0
Noise: 60
Temperature: 24.7
Humidity: 40
Pressure: 1028.4
pressure_trend: "up"
CO2: 433
date_max_temp: 1480688755
date_min_temp: 1480684710
min_temp: 15.4
max_temp: 25.3
I grab the code from Netatmo tutorial and then I adapt it to my needs...
it is not yet finish (the Domoticz Update portion is missing because I have an error in updating the device) but here it is... if someone wish to integrate and optimize...
I'm not a programmer, so please be kind with my code


Code: Select all
#This code sample uses requests (HTTP library)
import requests
# import json ---- Not really needed anymore
# Local Variable and settings
DEBUG = True
# NetATMO Connect Related
NA_GRANT_TYPE = 'password' #DO NOT CHANGE THIS... it is realy 'password' ;)
NA_USERNAME = 'NetATMO DEV UserID'
NA_PASSWORD = NetATMO DEV Password'
NA_CLIENT_ID = 'App ClientId'
NA_CLIENT_SECRET = 'App ClientSecret'
NA_SCOPE = 'read_homecoach'
NA_DEVICE_ID = 'HomeCoach ID - MAC ADDRESS'
# Domoticz Related
DZ_HOST = 'http://127.0.0.1:8080/json.htm'
DZ_IDX_CO2 = 999
DZ_IDX_HUM = 999
DZ_IDX_DBM = 999
DZ_IDX_MBAR = 999
DZ_IDX_TEMP = 999
DZ_IDX_TREND = 999
payload = {'grant_type': NA_GRANT_TYPE,
'username': NA_USERNAME,
'password': NA_PASSWORD,
'client_id': NA_CLIENT_ID,
'client_secret': NA_CLIENT_SECRET,
'scope': NA_SCOPE}
try:
response = requests.post("https://api.netatmo.com/oauth2/token", data=payload)
response.raise_for_status()
access_token=response.json()["access_token"]
refresh_token=response.json()["refresh_token"]
scope=response.json()["scope"]
if DEBUG == True:
print("Your access token is:", access_token)
print("Your refresh token is:", refresh_token)
print("Your scopes are:", scope)
except requests.exceptions.HTTPError as error:
print(error.response.status_code, error.response.text)
params = {
'access_token': access_token,
'device_id': NA_DEVICE_ID
}
try:
response = requests.post("https://api.netatmo.com/api/gethomecoachsdata", params=params)
response.raise_for_status()
data = response.json()["body"]
if DEBUG == True:
print (
'CO2 Rilevata: ', data['devices'][0]['dashboard_data']['CO2'], '\n'
'Umidità: ', data['devices'][0]['dashboard_data']['Humidity'], '\n'
'Rumore: ', data['devices'][0]['dashboard_data']['Noise'], '\n'
'Pressione: ', data['devices'][0]['dashboard_data']['Pressure'], '\n'
'Temperatura: ', data['devices'][0]['dashboard_data']['CO2'], '\n'
)
params = {
'type': 'command',
'command': 'udevice',
'idx': DZ_IDX_CO2,
'nvalue': data['devices'][0]['dashboard_data']['CO2'],
'svalue': data['devices'][0]['dashboard_data']['CO2']
}
dz_co2_post = requests.post(DZ_HOST , data=params)
dz_co2_post.raise_for_status()
print (dz_co2_post)
except requests.exceptions.HTTPError as error:
print(error.response.status_code, error.response.text)
Code: Select all
dz_co2_post = requests.post(DZ_HOST , data=params)

if anyone have and idea why it does not work

Hope this would help!
ciao
M