Skip to main content

A Somfy Open API library

Project description

This library is an attempt to implement the entire Somfy API in Python 3. Documentation for the Somfy API can be found here.

Get developer credentials

  1. Vist https://developer.somfy.com
  2. Create an account
  3. Open the My Apps menu
  4. Add a new App (for testing, redirect url can be anything in https)
  5. Plug in your details into the test script below.

Example usage

Print all covers name.

from pymfy.api.devices.roller_shutter import RollerShutter
from pymfy.api.somfy_api import SomfyApi
from pymfy.api.devices.types import Category

client_id = r'<CLIENT_ID>'
redir_url = '<REDIR_URL>'
secret = r'<secret>'

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(category=Category.ROLLER_SHUTTER)

covers = [RollerShutter(d, api) for d in devices]

for cover in covers:
    print("Cover {} has the following position: {}".format(cover.device.name, cover.position))

Contribute

The current documentation does not give enough information to implement all the devices. If you want to contribute to this repository adding new devices, you can create an issue with the output of this script:

import json
import re

client_id = r'<CLIENT_ID>'
redir_url = '<REDIR_URL>'
secret = r'<secret>'

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)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pymfy-0.2.1.tar.gz (18.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pymfy-0.2.1-py3-none-any.whl (18.6 kB view details)

Uploaded Python 3

File details

Details for the file pymfy-0.2.1.tar.gz.

File metadata

  • Download URL: pymfy-0.2.1.tar.gz
  • Upload date:
  • Size: 18.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.3

File hashes

Hashes for pymfy-0.2.1.tar.gz
Algorithm Hash digest
SHA256 1115380bcc99840f9d32417c0d22d5bb7c8efe4af5511f5ef15f108139504daa
MD5 df027d481f5e5139962cb24572872179
BLAKE2b-256 275fcd17574a03793850f5b0101983a60db13ddd2e59071d9250c2f278cd6bc7

See more details on using hashes here.

File details

Details for the file pymfy-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: pymfy-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 18.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.3

File hashes

Hashes for pymfy-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 14eace542153d40a0413b23237ac7c908adb39a1141d78aabaf35af2266ef988
MD5 05562b4483f2e0c5f28facad2eccc5d5
BLAKE2b-256 aecc2a685d12ddf5e21f3f9f7d6452abbd95fee7a5b821db38385d7fc014c846

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page