Somfy Tahoma Official API


#63

@tetienne to answer your previous questions, when i check the Somfy API, it shows me

  • 8 roller_shutter_positionable_stateful_generic
  • 2 exterior_blind_discrete_generic
    But my TaHoma hub is also controlling
  • 2 Garage doors
  • 1 Sliding portal
  • 4 RTS cover (pergola top cover)
  • 1 Alarm (Protexial IO)
  • 2 smoke detector
  • 1 Motion detector
  • 2 opening sensor
    I hope that Somfy will include most of this features :wink:

#64

Step forward, another error. How can i install pymfy to hassio?

2018-12-27 08:58:11 WARNING (MainThread) [homeassistant.loader] You are using a custom component for somfy which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.
2018-12-27 09:05:34 ERROR (MainThread) [homeassistant.setup] Error during setup of component somfy
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 60, in setup
    from pymfy.api.somfy_api import SomfyApi
ModuleNotFoundError: No module named 'pymfy'

#65

I think that you need this
pip install https://github.com/tetienne/somfy-open-api/archive/0.4.3.tar.gz


#67

Try to reboot a second time hassio.


#68

Can you see your 10 devices in hass? According to their support they plan to expose first only actuator and perhaps later for the sensor. I can try to see with them if they have a roadmap.


#69

Reboot help. Thank you!
I see all covers, but here is one problem with tilt. I cannot set tilt if are cover fully closed, but if full open (doesnt make sense), i can tilt cover.


#70

Great!

For your issue, can you replace in the somfy.py file, can you replace:

@property
def current_cover_tilt_position(self):
    """Return current position of cover tilt.

    None is unknown, 0 is closed, 100 is fully open.
    """
    orientation = None
    try:
        from pymfy.api.devices.blind import Blind
        orientation = Blind(self.device, self.api).orientation
    except StopIteration:
        pass
    return orientation

def set_cover_tilt_position(self, **kwargs):
    """Move the cover tilt to a specific position."""
    orientation = kwargs.get(ATTR_TILT_POSITION)
    from pymfy.api.devices.blind import Blind
    Blind(self.device, self.api).orientation = orientation

by

@property
def current_cover_tilt_position(self):
    """Return current position of cover tilt.

    None is unknown, 0 is closed, 100 is fully open.
    """
    orientation = None
    try:
        from pymfy.api.devices.blind import Blind
        orientation = Blind(self.device, self.api).orientation
    except StopIteration:
        pass
    return 100 - orientation

def set_cover_tilt_position(self, **kwargs):
    """Move the cover tilt to a specific position."""
    orientation = kwargs.get(ATTR_TILT_POSITION)
    from pymfy.api.devices.blind import Blind
    Blind(self.device, self.api).orientation = 100 - orientation

You will have perhaps to change

def open_cover_tilt(self, **kwargs):
    """Open the cover tilt."""
    from pymfy.api.devices.blind import Blind
    Blind(self.device, self.api).orientation = 0

def close_cover_tilt(self, **kwargs):
    """Close the cover tilt."""
    from pymfy.api.devices.blind import Blind
    Blind(self.device, self.api).orientation = 100

#71

That is amazing! It works perfectly. So, if anybody have Somfy Connexon with outside cover, work great!

Thank you very much tetienne.

Now i can create automation by the sun azimuth, elevation and inside temperature. :slight_smile:


#72

Nice, glad to see it works with your blind. Can you confirm all work as expected : tilt position, open tilt, and close tilt? If OK can you share the somfy.py you have? I will push the modifications in the pull request.


#73

Yes, i can see and control all 10 devices.
(but it’s annoying because of duality with the old TaHoma api … which annoyingly, for the moment, have more features than the new Somfy Open API)
I should remove “discovery” on Tahoma API and manually declare only what i want (that is missing)


#75

After two reboot i cannot see any blinds. :frowning:

2018-12-27 13:20:00 WARNING (SyncWorker_2) [custom_components.somfy] Cannot update devices.
Traceback (most recent call last):
  File "/config/custom_components/somfy/__init__.py", line 165, in update_all_devices
    data[DEVICES] = data[API].get_devices()
  File "/config/deps/lib/python3.6/site-packages/pymfy/api/somfy_api.py", line 103, in get_devices
    r.raise_for_status()
  File "/usr/local/lib/python3.6/site-packages/requests/models.py", line 940, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: https://api.somfy.com/api/v1/site/**DELETED-TOKEN-byME**/device
2018-12-27 13:20:00 ERROR (MainThread) [homeassistant.components.sensor.yr] Retrying in 16 minutes: 
2018-12-27 13:20:21 WARNING (MainThread) [homeassistant.setup] Setup of script is taking over 10 seconds.
2018-12-27 13:20:21 WARNING (MainThread) [homeassistant.components.vacuum] Setup of platform xiaomi_miio is taking over 10 seconds.
2018-12-27 13:20:22 WARNING (MainThread) [homeassistant.loader] You are using a custom component for cover.somfy which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.
2018-12-27 13:20:23 ERROR (MainThread) [homeassistant.components.cover] 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 128, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=hass.loop)
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 358, in wait_for
    return fut.result()
  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/cover/somfy.py", line 22, in setup_platform
    devices = hass.data[DOMAIN][DEVICES]
KeyError: 'devices'

#76

I was able to reproduce. Let me find what’s the issue.

Edit: it seems it was a temporary issue on Somfy side. So when you reboot your instance, it was not possible to retrieve your covers. Try to reboot again, it seems ok now.


#78

Ok, mám vrácené žaluzie, kromě jednoho v ložnici. :otevři pusu: V protokolu je mnoho řádků s “somfy”


#79

Sorry, in English please.


#80

Sorry, i use Google translator And copyed Wrong Windows. :smiley:
I have blinds Back, but only one in bedroom doesnt show. I try move with HW button and look that helps.


#81

@tetienne i am trying to give you some input for the Somfy switches i have and i have made an issue here https://github.com/tetienne/somfy-open-api/issues/14 with few questions which i hope you can help with.


#82

tetienne: i back numbers of tilt. Before has been correct, 100 is full open tilt. But funcionality is bad. If I put a closed position (dark), I can not select the tilt. It should be the opposite when the blinds are up.


#83

Sadly Somfy does not yet expose their switches. I have updated the readme file to explain what’s currently supported and where to find the information. I’ve contacted their support to know if they have a roadmap.


#84

Hmm, ahh that explains. I can however do a MITM attack and sniff the traffic the iOS app does with the somfy api while using the switch if that has any interest.


#85

So just to clarify, can you show me the somfy.py file you have and tell me what happen when you set the tilt position to 90%? Cover is almost closed or opened?