Overkiz API and Somfy API

Totally random :slight_smile: but then I guess it is up to Somfy to make more robustness. Do you know, do they aware of this non-deterministic behave?

Regarding the version I do not see it under the integration menu. I used your github repository (https://github.com/tetienne/home-assistant/tree/somfy-open-api) to get the latest and greatest version of somfy component.

hi that don’t work for me :
INFO:homeassistant.util.package:Attempting install of colorlog==4.0.2
Testing configuration at /config
Failed config
General Errors:
- Component not found: somfy
Successful config (partial)

however when I test config that’s ok !?!
i’ve copied all the files!

thanks for your help

Hi, can you please explain what you did exactly?

Can anybody try to explain, in simple way, how to instal Somfy custom components, please?

@tetienne, that is my question in fact… a simple way to install

@robertpe and @5chacha5
first, you need to create an App and get credentials on the Somfy site
Get developer credentials

  • Vist https://developer.somfy.com
  • Create an account
  • Open the My Apps menu
  • Add a new App (for testing, redirect url should be your local subnet HA url like http://xxx.xxx.xxx.xxx:yyyy/auth/somfy/callback and don’t forget port number )
  • Keep info for next.

Then, you need to go to you HA “/config” directory and create a folder named “custom_components” and then a “somfy” subfolder.
You should now have “/config/custom_components/somfy”
In this path, download every file from https://github.com/tetienne/home-assistant/tree/somfy-open-api/homeassistant/components/somfy (verify that you download the “Raw” version of each files)
Now you need to edit 2 files :
in
__init__.py :
change
from homeassistant.components.somfy import config_flow
to
from custom_components.somfy import config_flow
and in
cover.py :
change
from homeassistant.components.somfy import DOMAIN, SomfyEntity, DEVICES, API
to
from custom_components.somfy import DOMAIN, SomfyEntity, DEVICES, API

Then, in your configuration.yaml you need to add

somfy:
client_id: your_somfy_Consumer_Key
client_secret: your_somfy_Consumer_Secret

Restart your HA

On the first start, you’ll have a “Somfy Card” with a “Link” where you’ll be redirected to somfy, to make the OAuth2 process (you’ll need to login to make the link approved from HA to Somfy API)

Now you should have every known components in your UI.

Hope that everything is understandable, and that will work for you.

Important notice, you need to have a recent HA, i’ve just tested this procedure on my fresh new 0.87.1

Hi, Thanks very good instruction.
All is OK till the last auth when I receive:
{“error”:“redirect_uri_mismatch”,“error_description”:“The redirect URI provided does not match registered URI(s).”}

Many thanks @koomik for this explanation. It’s almost perfect, except for the redirect part. I guess i’s why @robertpe got his error.

@robertpe, Somfy returns this message when the redirect uri you set does not match your home assistant uri. The redirect uri must be <your hass uri>/auth/somfy/callback.
Keep in mind this component is not yet perfect, I got several remarks on my pull request.

But what <your hass url? - local? with http://xxx.xxx.xxx.xxx/auth/somfy/callback -?

@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 ?