No support for Netatmo Healthy Home Coach?

Before I dive into the architecture and code of HA to try and create support for the Healty Home Coach myself, I just want to be sure my assumption that it is currently not supported is correct.
Can anyone confirm or correct with certainty?

I tried adding it via de Netatmo Hub and use auto discovery to find the device, nothing is logged and nothing is found.

EDIT: The Healthy Home Coach is an odd device as the Netatmo application to setup the devices from your computer doesn’t detect it (only Weather Stations, Thermostats and Presence Cameras). But there is an API available that returns the information in JSON format, so should be possible to create a component similar to the Weather Station.

1 Like

Here is my config for Netatmo Home Coach

  - platform: rest
    resource: https://api.netatmo.com/api/gethomecoachsdata?access_token=<YOUR_TOKEN_HERE>
    name: NAME OF SENSOR
    method: GET
    value_template: "{{ value_json['body']['devices'][0]['dashboard_data']['Temperature'] }}"
    unit_of_measurement: "°C"

You can grab your TOKEN from https://dev.netatmo.com/resources/technical/reference/thermostat/getthermostatsdata

click the down arrow on the page

for your token

Here is sample data source to use as sensor:

				"AbsolutePressure":
				"time_utc":
				"health_idx":
				"Noise":
				"Temperature":
				"temp_trend": "
				"Humidity":
				"Pressure":
				"pressure_trend": 
				"CO2":
				"date_max_temp":
				"date_min_temp":
				"min_temp":
				"max_temp":
2 Likes

Sorry for the late reply! ;o|

It works as advertised… thanks!

You need refresh your token every 3h. :frowning:
I’m trying to create automation with python script. I will inform you, if I success :slight_smile:

Finally, here is my solution;

you need create two python files.

STEP 1
create new file like “netatmo_token_request.py” and run with “python3 netatmo_token_request.py”

import requests

payload = {'grant_type': 'password',
           'username': "YOUR_NETATMO_MAIL_ADDRESS",
           'password': "YOUR_NETATMO_PASSWORD",
           'client_id':"YOUR_NETATMO_CLIENT_ID",
           'client_secret': "YOUR_NETATMO_CLIENT_SECRET",
           'scope': 'read_homecoach'}
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"]
    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)

It will generate access token and refresh token.

STEP 2

create new file like “netatmo_refresh_token.py” and copy to /config/python_scripts/ folder. If folder not exist, create it.

import http.client

conn = http.client.HTTPSConnection("api.netatmo.com")

payload = "refresh_token=<COPY_YOUR_REFRESH_TOKEN_FROM_STEP1>&client_id=<YOUR_NETATMO_CLIENT_ID>&client_secret=<YOUR_NETATMO_CLIENT_SECRET>&grant_type=refresh_token"

headers = { 'content-type': "application/x-www-form-urlencoded;charset=UTF-8" }

conn.request("POST", "/oauth2/token", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))

STEP 3

Create an automation file like “netatmo_refresh_token.yaml”

- alias: Netatmo Refresh Token
  trigger:
   platform: time
    # Matches every 150 minutes, netatmo token expires every 3h.
   minutes: '/150'
   seconds: 00

  action:
   - service: python_script.netatmo_refresh_token

Don’t forget to change ACCESS TOKEN in your sensor file. (not refresh token)

I’m not developer. I created the codes by bringing the codes I found from Google. :slight_smile:

I hope it works out to you.

Hi guys, I did everything as you mentioned in your posts. Unfortunately it doesn’t work, the status is “unknown”. I was wondering how the access token is made, how many numbers etc.

Can you help me?

Marco

Hi,

I’ve been following your solution, and it’s really helpful.

However, I’m really confused about how you updated the ACCESS TOKEN in the sensor file to make it update every 3 hours.

I have created the python script for token refreshing, as well as the automation file. But in the sensor file, I still have the following line:

I tried changing the token to the automation file, and it just gives an error as “access token not found”

Could you please help me with this?

Thank you very much!

after trying this method I noticed that the tokens were not updated. Since I was not able to renew token with the script on HA, I created a small python code on my mac and run with a cron job. You can try to work on HA script or use a python script outside of HA.

Hi, I opened a PR here https://github.com/home-assistant/home-assistant/pull/18308 giving support for the Home Coach. Hopefully we will get it released soon! Cheers

1 Like

@lasote thank you for the PR that has been merged. I have both Netatmo Weatherstation and Homecoach under the same NetAtmo account. Your PR implemented however the logic that one can have either only WeatherStation in API or HomeCoach with the priority for WeatherStation. Once you have both, HomeCoach sensors will not be autodiscovered by HA. I noticed that I’m not alone with the problem in the PR discussion thread which was however closed. As a quick dirty hack, I made a custom component sensor/netatmo2.py from the sensor/netatmo.py which just modifies NetAtmoData._detect_platform_type method to tests the availability of pyatmo.HomeCoachData and not pyatmo.WeatherStationData. The custom component is loaded by adding in configuration.yaml section sensor

  • platform : netatmo2

Was this problem ever solved? I’m also a dual user …

Problem is fixed in 0.89

1 Like