Overkiz API and Somfy API

At least for me it is still not working … :confused: I am just wondering that can I use ‘official’ tahoma component as a fallback mechanism. Like I would place both component configuration in to the configuration.yaml and use the same entity names.

What’s your opinion about it?

You can use both Tahoma component and this one at the same time. Entities will have different id, so you will have no conflict. The only side effect is that you will see twice the same covers. Later, once Somfy server will be really stable, you can still use the Tahoma component for sensors for instance and exclude the covers that will be controlled by the Somfy component.

Thanks @tetienne make some sense. Meanwhile I believe I will handle it with a conditional card entity :slight_smile:

I use both, I use the Tahoma component for the “scenes” but not for individual covers (because the open option is greyed out), and I use @tetienne’s Somfy component for individual covers because the open option is available (but the scenes are not supported). It all works very well.

I have a question to the API: as far as I understand the code, the home assistant tahoma component polls the api for sensor / cover values every 60 seconds. This is ok most of the time, but if I open a window, I don’t like the delay before a cover reacts to the change.
How does the open somfy API get the updated sensor values? Ideally, a changed entity (a cover or a sensor) would report its new state to the tahoma box. The tahoma box sends an update to the somfy server and immediately sends the new state to the home assistant instance. When opening a window, the sensor state is forwarded to home assistant within a second.
The tahoma polling is ok for temperature and sunlight sensor but to slow for a window opening sensor.
How does the Somfy API work?

Hi @sdekker I have the same issue. Did you manage to get this resolved?

For the moment, the Somfy component polls also the Somfy server every 15 sec. So you will have the same behavior than Tahoma.
But if we trust their dev website, one day they will implement hook. It means we will be able to register action on specific event. And so we will have instant update in HA.

I don’t know if this related to your issue, but I found a mistake in the code. I will try to push the modification this weekend.

Can you please try to update the component with this small modification?

Thanks @tetienne I updated the code and recreated the somfy app. I have successfully linked somfy to home assistant now.

Tetienne, is it possible to intentionally trigger a poll of the somfy interface? I have the following use case in my mind: HA detects an open window / patio / balcony door via the sensors. I want to save the current position of the window covers and move them up (i. e. 100%); and later, when the window / patio / balcony door is closed have it moved back to the original position. But in order to save the current position of the cover, I would like to have the latest information possible (trigger update and save). Consequently, does it make sense to provide the cover/current_position attribute as a sensor (just a thought)?
Thanks for your help!

Such a service, already exist: homeassistant.update_entity. You can give the entity id of one cover or group.all_covers.
By the way, the component update its state every 15 sec. Do you manipulate so many time your covers?

Hi @tetienne,

I am very interested in the development of this component that brings improvements over the Tahoma component.
But I encounter with your component the same problem: when I activate the wall switch, the status of the shutter in Home-Assistant is never updated (Tahoma’s opened bug: https://github.com/home-assistant/home-assistant/issues/20188).
You explain that the component update its state every 15sec, but in this case, only a call on command stop/up/down update its real state (a call on service homeassistant.update_entity doesn’t refresh its real state). Another solution is to open Android Tahoma app, and wait 15 seconds.

Have you more informations on this issue?

I use:

  • Tahoma box (with up to date firmware)
  • Somfy IO covers
  • Wall switches SMOOVE RS100 IO

Regards,

Romain.

Thanks for the hint, @Tetienne. I will give it a try.

I’ve been trying for a few hours to get this working.

I’ve done the following:
Created an app on developer.somfy.com with redirect url as <local_ha_ip>/auth/comfy/callback
Created custom_components/somfy directories under /config
Copied the contents of linked github page to this directory. Incl the .translations directory and contents
Installed
Updated init.py and cover.py
Added the following to configuration.yaml
somfy:

client_id: your_somfy_Consumer_Key
client_secret: your_somfy_Consumer_Secret
Downloaded pymfy with pip and link provded (v 0.5.1)

Restarted HA and under notifications I see that a notification appears. Opening the notifications I get: Authenticate Somfy

Clicking on the link, I get the following message:

An error has occurred
Please try again. If the problem persists, please contact our technical support team.

I’ve double checked the URL and it’s correct. I’ve also checked the breakdown of the link and everything seems correct when compared to https://developer.somfy.com/apis-docs. I do see here that there is “&grant_type=authorization_code” that’s not included in the generated link. Is this correct? I’ve tried manually adding this, but also not working.

I’ve tried recreated the app multiple times and redoing the configuration in HA. But the results are the same every time:

An error has occurred
Please try again. If the problem persists, please contact our technical support team.

Any advice? What am I missing here?

Thanks

Solved, connexon box was need update.

Hi, the blinds have stopped working this morning. Do you know if something’s wrong? I didn’t change anything.

Log Details (ERROR)
Fri Mar 22 2019 12:11:44 GMT+0100 (Středoevropský standardní čas)
Error setting up entry  for 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/config_entries.py", line 258, in async_setup
    result = await component.async_setup_entry(hass, self)
  File "/config/custom_components/somfy/__init__.py", line 85, in async_setup_entry
    await update_all_devices(hass)
  File "/config/custom_components/somfy/__init__.py", line 158, in update_all_devices
    data[DEVICES] = data[API].get_devices()
  File "/config/deps/lib/python3.6/site-packages/pymfy/api/somfy_api.py", line 77, 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 57, 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.

@Bojkas @jakezp It seems your error come from Somfy server (again). I’ve restarted the integration process, and it was OK today. Can you please retry?

I have the same for a few days.

I’m getting the same error. I don’t think its the integration that @tetienne has provided…seems like an issue with the Somfy OAuth. I have sent them an email as per their instructions: please contact our technical support team … I will post back if I get a response.

Did they reply?