Overkiz API and Somfy API

@tetienne Can you show how your uri looks like written in Somfy callback URL?

Sorry for my mystake.
This is what i used on the Somfy Dev App
http://192.168.98.20:8123/auth/somfy/callback
This is the internal IP of the Docker instance hosting HA, with the TCP port 8123

Now it works, but only one cover is visible in HA. I have got 2 identical covers and the gate. Any ideas how to add the second cover?

Hi @robertpe , have you tried the test platform
https://developer.somfy.com/somfy-open-api/apis
You first need to use the “GET /site” to obtain your “Site ID” (you’ll have to click at least one time on the “OAuth2” button and then “Try it out”. The response is in JSON format
With your SiteID, go back and use the “GET /site/{siteid}/device”
Put your Site_ID in the “Ressource URL” and Click on “Try it out”
The JSON result will give you every device recognized by the Somfy Open API.
You should have your hub and your 2 devices.
If not, maybe the “type” of the second cover is not yet included in the API (but it’s weird if they are strictly the same)

Oh, and does the HA gives you error or warning in the log ? (maybe i should have give you that clue first :laughing: )

thanks a lot !

that don’t work for me and I have this error :

Log Details (ERROR)
Mon Feb 18 2019 09:34:10 GMT+0100 (CET)

Unexpected error generating auth url
Traceback (most recent call last):
File “/config/custom_components/somfy/config_flow.py”, line 99, in async_step_auth
url = await self._get_authorization_url()
File “/config/custom_components/somfy/config_flow.py”, line 114, in _get_authorization_url
from pymfy.api.somfy_api import SomfyApi
ModuleNotFoundError: No module named ‘pymfy’

Could you reboot your HA ? Which version of HA do you have ?
I thought that the pymfi component was downloaded because of the requirements.
If reboot doesn’t help, you will need to run this in your HA :
pip install https://github.com/tetienne/somfy-open-api/archive/0.5.1.tar.gz

yes I reboot 2 times… and now I haven’t any error but no devices and no Somfy card

I’m HA 0.87.1

how I run the pip… in HA ?

Do you have a “Bell” icon at (top right) ? Maybe the configuration card is there
To run pip, you need to have access to a command line (via ssh, or terminal in docker)

yes I have a bell but no Somfy card only “integrations”

Thanks for your help!

I don’t use SSH … other idea ?

Continuing in PM until solving :wink:

@koomik, thanks you very much !!

I forgot the folder .translations so I cannot see Somfy card…

that’s work perfectly now… thanks you again.

PS : is there a update later to have my garage door in HA with Somfy API ?

1 Like

or is the photoelectric cells are need to control garage door with HA ?

No, for the moment garage doors are not in the scope of the API. Hope it will be soon…

Glad to see it works for you too. About the supported devices, you can see them here https://developer.somfy.com/products-services-informations

I’ve implemented all of them in my library. But for the moment, only the cover are integrated in home assistant.

By the way once my components approved, I will need some help to translate the text in different languages.

1 Like

Hello, i have problem with Somfy after migrate from RPi 1 to 3 B+. All data is ok, but doesnt work. :frowning: I think is authorise problem, but i cannot do it again. :frowning: Any help?

Log Details (ERROR)
Mon Feb 18 2019 23:13:17 GMT+0100 (Středoevropský standardní čas)
Error during setup of component somfy
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/requests_oauthlib/oauth2_session.py", line 395, in request
    http_method=method, body=data, headers=headers)
  File "/usr/local/lib/python3.6/site-packages/oauthlib/oauth2/rfc6749/clients/base.py", line 198, in add_token
    raise TokenExpiredError()
oauthlib.oauth2.rfc6749.errors.TokenExpiredError: (token_expired) 

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/setup.py", line 148, in _async_setup_component
    component.setup, hass, processed_config)  # type: ignore
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/somfy/__init__.py", line 86, in setup
    if update_all_devices(hass):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/util/__init__.py", line 315, in wrapper
    result = method(*args, **kwargs)
  File "/config/custom_components/somfy/__init__.py", line 173, in update_all_devices
    data[DEVICES] = data[API].get_devices()
  File "/config/deps/lib/python3.6/site-packages/pymfy/api/somfy_api.py", line 98, in get_devices
    site_ids = [s.id for s in self.get_sites()] if site_id is None else [
  File "/config/deps/lib/python3.6/site-packages/pymfy/api/somfy_api.py", line 78, in get_sites
    r = self._oauth.get(BASE_URL + '/site')
  File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 546, in get
    return self.request('GET', url, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/requests_oauthlib/oauth2_session.py", line 408, in request
    self.auto_refresh_url, auth=auth, **kwargs
  File "/usr/local/lib/python3.6/site-packages/requests_oauthlib/oauth2_session.py", line 374, in refresh_token
    self.token = self._client.parse_request_body_response(r.text, scope=self.scope)
  File "/usr/local/lib/python3.6/site-packages/oauthlib/oauth2/rfc6749/clients/base.py", line 415, in parse_request_body_response
    self.token = parse_token_response(body, scope=scope)
  File "/usr/local/lib/python3.6/site-packages/oauthlib/oauth2/rfc6749/parameters.py", line 425, in parse_token_response
    validate_token_parameters(params)
  File "/usr/local/lib/python3.6/site-packages/oauthlib/oauth2/rfc6749/parameters.py", line 435, in validate_token_parameters
    raise MissingTokenError(description="Missing access token parameter.")
oauthlib.oauth2.rfc6749.errors.MissingTokenError: (missing_token) Missing access token parameter.

Ok, I did the exact instructions @koomik and allowed authentication. Now I have another problem.

Error while setting up platform somfy
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 124, in _async_setup_platform
    task = async_create_setup_task()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 103, in async_create_setup_task
    return platform.async_setup_entry(
AttributeError: module 'custom_components.cover.somfy' has no attribute 'async_setup_entry'

You have to remove the old Somfy.py file within the cover folder. Now all the files related to a component have to be within the same folder.