Overkiz API and Somfy API

This API can also be used for the more affordable connexoon. It would be awesome if HA can use this API

2 Likes

This would allow me to finaly control my somfy sunscreens with the Connexxoon via Home assistant. Would love to see the API implemented!

1 Like

@nelbs @darkpainy don’t forget to vote :wink:

What are our chances to introduce this API in HomeAssistant? :slight_smile:

After some research, the Somfy API look like the Wink API. So inspired by the python-wink library, I’ve started to develop the Somfy one: https://github.com/tetienne/somfy-open-api/
I’ve 10 years of experience in Java, Python is kind of new for me. So I will use this project to learn the basics.

4 Likes

I’ve updated my python library to request successfully the Somfy API. An example in the README describe how list for instance all the covers.

For the moment, Somfy does not return the light like Hue, or the sensors like the Solar sensor. I’ve been able to test only with the covers.

1 Like

I’ve finished to developed the client to manipulate the covers from the Somfy API. The documentation does not provide enough information to implement other devices. I need some volunteers to discover what Somfy exposes. The list of available devices are here: https://developer.somfy.com/products-services-informations.

On my repository, I explain how to help me to enhance the client: https://github.com/tetienne/somfy-open-api. It’s really easy.

Meanwhile, I’ve contacted Somfy Support to have more details. They are also working on a fix about the GET /device/<device_id> not returning the correct state. That’s a bug I found during my tests.

Once the client mature enough, I will start to integrate it in Home Assistant. I’ve read the documentation, it seems not so obvious but will be feasible.

2 Likes

My somfy covers are categorized as interior_blind and support the following exec commans:

  • identify
  • open
  • close
  • stop

Created issue

Thank you for your issue. It should be quick to add support for this device. Monday I will have a look.
I’m curious, you cannot control the position of your blinds?

Well the blinds don’t support it. So that makes sense. However, the blinds do support a predefined position called the My Position. I raised the issue with somfy to support it in the API.

Tahoma component works with connexoon too.

@robertpe We never said the opposite. Currently the Tahoma component use the unofficial API, scraped from the Tahoma website.
Purpose here is to use the official API which has been created to be exposed to the world. Perhaps, the set of features is limited but it should evolve in the future if Somfy play well the game.

@pbavinck Indeed that makes sense. You are right, for the covers, I haven’t too the My position command. I’ve solved your issue on the repository. There is one question waiting for you :wink:
By the way, if you can only open and close your blinds, what’s the purpose of the stop command?

You can stop them mid-way. E.g.
Open: not covering the window
Closed: curtains/covers are all the way down
Stop: While the curtain/covers is going up or down, you can tell it to stop, only covering top part of the window.

@pbavinck So that’s weird Somfy does not return the position command like the roller shutter. That’s make no sense. By the way, can you have look on your issue please?

I’ve uploaded my library to pypi. It means now an home assistant component can use it.

@tetienne I do not seems to manage to install your pymfy module using PyPI…

I set up a python3 virtual environment using python3 -m venv . . Then I started python application with your example code. It gives me:

(test) Bert-MBP:test bertouttier$ python3 main.py
Traceback (most recent call last):
File "main.py", line 8, in &lt;module&gt;
from pymfy.api.somfy_api import SomfyApi
ModuleNotFoundError: No module named 'pymfy'

What am I doing wrong? Could you indicate how to install your module from source?

Can you show me your main.py file please ? Maybe I’ve badly upload my package.

it is just a copy/paste of your example code:

import json
import re

client_id = r'test'
redir_url = 'https://hassio.com'
secret = r'7test'

from pymfy.api.somfy_api import SomfyApi

api = SomfyApi(client_id, redir_url)
authorization_url, state = api.get_authorization_url()
print('Please go to {} and authorize access.'.format(authorization_url))
authorization_response = input('Enter the full callback URL')
api.request_token(authorization_response, secret)
api.automatic_refresh()

devices = api.get_devices()
# Remove personal information
dumps = json.dumps(devices, sort_keys=True, indent=4, separators=(',', ': '))
dumps = re.sub('".*id.*": ".*",\n', '', dumps)

print(dumps)

When I try to install pymfy

pi@raspberry:~ $ pip install pymfy
Collecting pymfy
  Could not find a version that satisfies the requirement pymfy (from versions: )
No matching distribution found for pymfy
pi@raspberry:~ $ wget https://github.com/tetienne/somfy-open-api/archive/master.zip
--2018-11-18 13:02:19--  https://github.com/tetienne/somfy-open-api/archive/master.zip
Herleiden van github.com (github.com)... 140.82.118.4, 140.82.118.3
Verbinding maken met github.com (github.com)|140.82.118.4|:443... verbonden.
HTTP-verzoek is verzonden; wachten op antwoord... 302 Found
Locatie: https://codeload.github.com/tetienne/somfy-open-api/zip/master [volgen...]
--2018-11-18 13:02:19--  https://codeload.github.com/tetienne/somfy-open-api/zip/master
Herleiden van codeload.github.com (codeload.github.com)... 192.30.253.120, 192.30.253.121
Verbinding maken met codeload.github.com (codeload.github.com)|192.30.253.120|:443... verbonden.
HTTP-verzoek is verzonden; wachten op antwoord... 200 OK
Lengte: niet-opgegeven [application/zip]
Wordt opgeslagen als: ‘master.zip’

master.zip                                     [ <=>                                                                                    ]  26,07K  --.-KB/s    in 0,1s

2018-11-18 13:02:20 (227 KB/s) - '‘master.zip’' opgeslagen [26696]
pi@raspberry:~ $ unzip master.zip
Archive:  master.zip
d6bf3e9a01a7a7281914b0f9415a81375c8d74b5
   creating: somfy-open-api-master/
  inflating: somfy-open-api-master/.gitignore
  inflating: somfy-open-api-master/.travis.yml
 extracting: somfy-open-api-master/CHANGELOG.md
  inflating: somfy-open-api-master/LICENSE
 extracting: somfy-open-api-master/MANIFEST.in
  inflating: somfy-open-api-master/README.md
   creating: somfy-open-api-master/pymfy/
 extracting: somfy-open-api-master/pymfy/__init__.py
  inflating: somfy-open-api-master/pymfy/__version__.py
   creating: somfy-open-api-master/pymfy/api/
 extracting: somfy-open-api-master/pymfy/api/__init__.py
   creating: somfy-open-api-master/pymfy/api/devices/
 extracting: somfy-open-api-master/pymfy/api/devices/__init__.py
  inflating: somfy-open-api-master/pymfy/api/devices/base.py
  inflating: somfy-open-api-master/pymfy/api/devices/blind.py
  inflating: somfy-open-api-master/pymfy/api/devices/category.py
  inflating: somfy-open-api-master/pymfy/api/devices/roller_shutter.py
  inflating: somfy-open-api-master/pymfy/api/model.py
  inflating: somfy-open-api-master/pymfy/api/somfy_api.py
  inflating: somfy-open-api-master/requirements.txt
  inflating: somfy-open-api-master/setup.py
   creating: somfy-open-api-master/tests/
 extracting: somfy-open-api-master/tests/__init__.py
  inflating: somfy-open-api-master/tests/get_device.json
  inflating: somfy-open-api-master/tests/get_devices_1.json
  inflating: somfy-open-api-master/tests/get_devices_2.json
  inflating: somfy-open-api-master/tests/get_site.json
  inflating: somfy-open-api-master/tests/get_sites.json
  inflating: somfy-open-api-master/tests/test_command.py
  inflating: somfy-open-api-master/tests/test_somfy_api.py
  inflating: somfy-open-api-master/tests/test_somfy_device.py
  inflating: somfy-open-api-master/tox.ini
pi@raspberry:~ $ cd somfy-open-api-master
pi@raspberry:~/somfy-open-api-master $ sudo python setup.py install
/usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'long_description_content_type'
  warnings.warn(msg)
running install
running bdist_egg
running egg_info
creating pymfy.egg-info
writing requirements to pymfy.egg-info/requires.txt
writing pymfy.egg-info/PKG-INFO
writing top-level names to pymfy.egg-info/top_level.txt
writing dependency_links to pymfy.egg-info/dependency_links.txt
writing manifest file 'pymfy.egg-info/SOURCES.txt'
file src/api.py (for module src/api) not found
reading manifest file 'pymfy.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'pymfy.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
file src/api.py (for module src/api) not found
file src/api.py (for module src/api) not found
warning: install_lib: 'build/lib.linux-x86_64-2.7' does not exist -- no Python modules to install

creating build
creating build/bdist.linux-x86_64
creating build/bdist.linux-x86_64/egg
creating build/bdist.linux-x86_64/egg/EGG-INFO
copying pymfy.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying pymfy.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying pymfy.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying pymfy.egg-info/requires.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying pymfy.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
zip_safe flag not set; analyzing archive contents...
creating dist
creating 'dist/pymfy-0.1.0-py2.7.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing pymfy-0.1.0-py2.7.egg
Copying pymfy-0.1.0-py2.7.egg to /usr/local/lib/python2.7/dist-packages
Adding pymfy 0.1.0 to easy-install.pth file

Installed /usr/local/lib/python2.7/dist-packages/pymfy-0.1.0-py2.7.egg
Processing dependencies for pymfy==0.1.0
Searching for typing
Reading https://pypi.python.org/simple/typing/
^Cinterrupted
pi@raspberry:~/somfy-open-api-master $ sudo python3 setup.py install
/usr/lib/python3.5/distutils/dist.py:261: UserWarning: Unknown distribution option: 'long_description_content_type'
  warnings.warn(msg)
running install
running bdist_egg
running egg_info
writing requirements to pymfy.egg-info/requires.txt
writing dependency_links to pymfy.egg-info/dependency_links.txt
writing pymfy.egg-info/PKG-INFO
writing top-level names to pymfy.egg-info/top_level.txt
file src/api.py (for module src/api) not found
reading manifest file 'pymfy.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'pymfy.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
file src/api.py (for module src/api) not found
file src/api.py (for module src/api) not found
warning: install_lib: 'build/lib' does not exist -- no Python modules to install

creating build/bdist.linux-x86_64/egg
creating build/bdist.linux-x86_64/egg/EGG-INFO
copying pymfy.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying pymfy.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying pymfy.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying pymfy.egg-info/requires.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying pymfy.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
zip_safe flag not set; analyzing archive contents...
creating 'dist/pymfy-0.1.0-py3.5.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing pymfy-0.1.0-py3.5.egg
Copying pymfy-0.1.0-py3.5.egg to /usr/local/lib/python3.5/dist-packages
Adding pymfy 0.1.0 to easy-install.pth file

Installed /usr/local/lib/python3.5/dist-packages/pymfy-0.1.0-py3.5.egg
Processing dependencies for pymfy==0.1.0
Searching for typing
Reading https://pypi.python.org/simple/typing/
Downloading https://files.pythonhosted.org/packages/bf/9b/2bf84e841575b633d8d91ad923e198a415e3901f228715524689495b4317/typing-3.6.6.tar.gz#sha256=4027c5f6127a6267a435201981ba156de91ad0d1d98e9ddc2aa173453453492d
Best match: typing 3.6.6
Processing typing-3.6.6.tar.gz
Writing /tmp/easy_install-9ixm8e3a/typing-3.6.6/setup.cfg
Running typing-3.6.6/setup.py -q bdist_egg --dist-dir /tmp/easy_install-9ixm8e3a/typing-3.6.6/egg-dist-tmp-pc_9csg9
zip_safe flag not set; analyzing archive contents...
Moving typing-3.6.6-py3.5.egg to /usr/local/lib/python3.5/dist-packages
Adding typing 3.6.6 to easy-install.pth file

Installed /usr/local/lib/python3.5/dist-packages/typing-3.6.6-py3.5.egg
Searching for requests-oauthlib==0.7.0
Best match: requests-oauthlib 0.7.0
Adding requests-oauthlib 0.7.0 to easy-install.pth file

Using /usr/lib/python3/dist-packages
Finished processing dependencies for pymfy==0.1.0
pi@raspberry:~/somfy-open-api-master $ cd ..
pi@raspberry:~ $ cd Downloads
pi@raspberry:~/Downloads $ python3 contribution.py
Traceback (most recent call last):
  File "contribution.py", line 1, in <module>
    from pymfy.api.somfy_api import SomfyApi
ImportError: No module named 'pymfy'