Skip to main content

A Python SDK for the SmartCoop API

Project description

Omlet Python SDK

This SDK is designed to facilitate seamless authentication with Omlet and provide interaction with devices. With our SDK, developers can easily retrieve device information, and execute actions tailored to their devices and groups.

Introduction

Getting Started

Overview

To use this SDK the user will already be registered with omlet as you will use the same email and password credentials to authenticate. We will go through the steps for including this SDK in your application and how to interact with your devices.

Installation

To install the SmartCoop SDK, ensure you have pip installed on your system. Then, create or navigate to your project directory and execute the following command:

pip install smartcoop-python-sdk

Authentication

Create API Key

To generate an API key you'll need to login to the developer console with the email and password that use for the App. Once logged in navigate to "API Keys" and click "Generate Key". Take note of this key.

Omlet

Overview

The Omlet object offers the ability to interact with your devices, groups and user actions.

Creating an Instance

Use the apiKey you've created to start omlet.

from smartcoop.client import SmartCoopClient
from smartcoop.api.omlet import Omlet

client = SmartCoopClient(client_secret='Xwa661NcAF__secret')
omlet = Omlet(client)

Retrieving Devices

devices = omlet.get_devices()

Device Actions

Devices have a list of actions that can be executed against them. They're represented by the action class.

Using an Action

open_action = next((action for action in device.actions if action.name == 'open'), None)

if open_action:
    omlet.perform_action(open_action)

Updating Device Configuration

config = device.configuration

configuration = device.configuration
configuration.general.language = 'US'

omlet.update_configuration(device.deviceId, configuration)

A full list of the available actions for omlet can be found here:

  • get_devices()

    • Description: Retrieves a list of all devices.
    • Returns: List[Device]
  • get_device_by_id(id: str)

    • Description: Retrieves a specific device by its ID.
    • Parameters:
      • id: The ID of the device.
    • Returns: Device
  • perform_action(action: Action)

    • Description: Performs a specified action.
    • Parameters:
      • action: The Action object to be performed.
  • update_configuration(device_id: str, configuration: Configuration)

    • Description: Updates the configuration of a specific device.
    • Parameters:
      • device_id: The ID of the device.
      • configuration: The new Configuration object.
  • get_groups()

    • Description: Retrieves a list of all groups.
    • Returns: List[Group]
  • get_group_by_id(id: str)

    • Description: Retrieves a specific group by its ID.
    • Parameters:
      • id: The ID of the group.
    • Returns: Group
  • create_group(name: str)

    • Description: Creates a new group with the specified name.
    • Parameters:
      • name: The name of the new group.
    • Returns: Group
  • get_user()

    • Description: Retrieves the current user information.
    • Returns: User
  • accept_invite(group: GroupSubset)

    • Description: Accepts an invite to join a group.
    • Parameters:
      • group: The GroupSubset object representing the group invitation.
  • reject_invite(group: GroupSubset)

    • Description: Rejects an invite to join a group.
    • Parameters:
      • group: The GroupSubset object representing the group invitation.
  • update_group(group_id: str, group_name: str)

    • Description: Updates the name of a specific group.
    • Parameters:
      • group_id: The ID of the group.
      • group_name: The new name for the group.
  • delete_group(group_id: str)

    • Description: Deletes a specific group.
    • Parameters:
      • group_id: The ID of the group.
  • invite_user(group_id: str, email_address: str, access: str)

    • Description: Invites a user to a group.
    • Parameters:
      • group_id: The ID of the group.
      • email_address: The email address of the user to invite.
      • access: The access level to grant to the user.
  • remove_user(group_id: str, email_address: str)

    • Description: Removes a user from a group.
    • Parameters:
      • group_id: The ID of the group.
      • email_address: The email address of the user to remove.
  • update_user_access(group_id: str, email_address: str, access: str)

    • Description: Updates a user's access level in a group.
    • Parameters:
      • group_id: The ID of the group.
      • email_address: The email address of the user.
      • access: The new access level for the user.

Types

Action

@dataclass
class Action:
    name: str
    description: str
    value: str
    url: str
    pending: Optional[str] = None

Configuration Connectivity

@dataclass
class ConfigurationConnectivity:
    wifiState: str

Configuration Door

@dataclass
class ConfigurationDoor:
    doorType: str
    openMode: str
    openDelay: int
    openLightLevel: int
    openTime: str
    closeMode: str
    closeDelay: int
    closeLightLevel: int
    closeTime: str
    colour: str

Configuration General

@dataclass
class ConfigurationGeneral:
    datetime: str
    timezone: str
    updateFrequency: int
    language: str
    overnightSleepEnable: bool
    overnightSleepStart: str
    overnightSleepEnd: str
    pollFreq: int
    stayAliveTime: int
    statusUpdatePeriod: int
    useDst: Optional[bool] = None

Configuration Light

@dataclass
class ConfigurationLight:
    mode: str
    minutesBeforeClose: int
    maxOnTime: int
    equipped: int

Configuration

@dataclass
class Configuration:
    general: ConfigurationGeneral
    connectivity: ConfigurationConnectivity
    door: Optional[ConfigurationDoor] = None
    light: Optional[ConfigurationLight] = None

Device

@dataclass
class Device:
    deviceId: str
    name: str
    deviceType: str
    state: State
    configuration: Configuration
    actions: List[Action]

Group Subset

@dataclass
class GroupSubset:
    groupId: str
    groupName: str
    access: str

Group

@dataclass
class Group:
    groupId: str
    groupName: str
    devices: List[Device]
    admins: List[User]
    users: List[User]
    access: Optional[str] = None

State Connectivity

@dataclass
class StateConnectivity:
    ssid: str
    wifiStrength: str

State Door

@dataclass
class StateDoor:
    state: str
    lastOpenTime: str
    lastCloseTime: str
    fault: str
    lightLevel: int

State General

@dataclass
class StateGeneral:
    firmwareVersionCurrent: str
    firmwareVersionPrevious: str
    firmwareLastCheck: str
    batteryLevel: int
    powerSource: str
    uptime: int
    displayLine1: str
    displayLine2: str

State Light

@dataclass
class StateLight:
    state: str

State

@dataclass
class State:
    general: StateGeneral
    connectivity: StateConnectivity
    door: Optional[StateDoor] = None
    light: Optional[StateLight] = None

User

@dataclass
class User:
    firstName: str
    lastName: str
    userId: Optional[str] = None
    emailAddress: Optional[str] = None
    siteLink: Optional[str] = None
    invites: Optional[List[GroupSubset]] = None

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

smartcoop-python-sdk-0.1.2.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

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

smartcoop_python_sdk-0.1.2-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

File details

Details for the file smartcoop-python-sdk-0.1.2.tar.gz.

File metadata

  • Download URL: smartcoop-python-sdk-0.1.2.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.8.10

File hashes

Hashes for smartcoop-python-sdk-0.1.2.tar.gz
Algorithm Hash digest
SHA256 b52ff71add28f2ef23fd7c666a77a320f973c79cfb51d6f45106aad77154e309
MD5 b2854df78f5bde5accf1d2c3c2ff5ea0
BLAKE2b-256 511a58f7082a5ff45f1bccc874e07ad5d3e7e1547a30781b9d2b15cc711a7291

See more details on using hashes here.

File details

Details for the file smartcoop_python_sdk-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for smartcoop_python_sdk-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7568e5e2f1d09fbc68bafac6a660957d80306cf82a2ec898614545244e8a1175
MD5 4f6a4c9e62fbfc64f62a981aa5af7be0
BLAKE2b-256 c38755f2ad243637d9bb7e887a86ed4437f4511f7f9b4925772d2463f7eeffd3

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