Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Muller-Intuitiv by Netatmo support #157

Closed
cmucchietto opened this issue Nov 13, 2021 · 2 comments · Fixed by #253
Closed

Add Muller-Intuitiv by Netatmo support #157

cmucchietto opened this issue Nov 13, 2021 · 2 comments · Fixed by #253

Comments

@cmucchietto
Copy link

Muller-Intuitiv provides equipments that are label as 'by Netatmo'.

I'm reverse engineering their propiretary API, which is mostly compatbile with Netatmo, so I was thinking to use and modify pyatmo. My ultimate goal is to add support to home-assistant which uses this module

I think it might be good to add this support in your library as it might not be a lot of effort. To do so, I will need need some guidance to do it the right way (hint : I'm not a python developper)

Some hardcoded values have to be customized to work properly:

I have done a very ugly "patch" to test this approach:

helpers.py

_BASE_URL: str = "https://app.muller-intuitiv.net/"

oauth2_session.py : OAuth2Session::request

        data['user_prefix'] = 'muller'
        log.debug("Requesting url %s using method %s.", url, method)
        log.debug("Supplying headers %s and data %s", headers, data)
        log.debug("Passing through key word arguments %s.", kwargs)
        return super(OAuth2Session, self).request(
            method, url, headers=headers, data=data, **kwargs
        )

Currently the followin llittle script works fine: I'm able to retreive all informations needed. I will then need to adapt / add some custom class for parsing their JSON, but I think this part can be easier for me.

authorization = pyatmo.ClientAuth(
    client_id=CLIENT_ID,
    client_secret=CLIENT_SECRET,
    username=USERNAME,
    password=PASSWORD,
    scope="read_muller write_muller",
)
r = pyatmo.HomeData(authorization)
r.update()
r.process()
print(r.homes)
for home_id in r.homes.keys():
    r = pyatmo.HomeStatus(authorization, home_id)
    r.update()
    r.process()
    print(r.rooms)
@cgtobi
Copy link
Collaborator

cgtobi commented Nov 13, 2021

Hi @cmucchietto ,

is this product only available in France? I'd be happy to assist you with this and investigate how to implement this. Feed free to get in contact with me on Discord.

@outadoc
Copy link
Contributor

outadoc commented Jan 25, 2022

Hi!

I have the same request, to support the Saunier Duval Migo thermostat, which is not visibly branded as Netatmo but clearly uses their back-end.

@cmucchietto's research seems on point. I had to make a few changes to the code to make it work with my thermostat (haven't checked thoroughly, but at least HomeData completes successully):

  • Change _BASE_URL to https://app.migo-thermostat.com/;
  • In ClientAuth, pass user_prefix="sdbg" to the fetch_token function. Turns out it supports kwargs so this works well. Not specifying it yields oauthlib.oauth2.rfc6749.errors.InvalidGrantError: (invalid_grant).

It would be awesome if these two things could be made customizable. Refactoring _BASE_URL to be properly configurable seems a bit above my pythoning skills, but if you need help for testing I should be able to give some! It would a good step towards a Home Assistant integration 🙂

Fun fact: I'm guessing user_prefix is a sort of "customer ID" for Netatmo's backend. Calling an API like WeatherStationData with the sdbg prefix yields pyatmo.exceptions.ApiError: 403 - Forbidden - Method does not support this user prefix. (13) when accessing 'https://app.migo-thermostat.com/api/getstationsdata'. They must be whitelisting APIs per-user-prefix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants