smartthings

class platypush.plugins.smartthings.SmartthingsPlugin(access_token: str, **kwargs)[source]

Plugin to interact with devices and locations registered to a Samsung SmartThings account.

Requires:

  • pysmartthings (pip install pysmartthings)

__init__(access_token: str, **kwargs)[source]
Parameters

access_token – SmartThings API access token - you can get one at https://account.smartthings.com/tokens.

execute(device: str, capability: str, command, component_id: str = 'main', args: Optional[list] = None)[source]

Execute a command on a device.

Example request to turn on a device with switch capability:

{
  "type": "request",
  "action": "smartthings.execute",
  "args": {
    "device": "My Switch",
    "capability": "switch",
    "command": "on"
  }
}
Parameters
get_device(device: str) dict[source]

Get a device info by ID or name.

Parameters

device – Device ID or name.

Returns

"tv-switch-id": {
    "capabilities": [
        "switch",
        "refresh",
        "healthCheck"
    ],
    "device_id": "tv-switch-id",
    "device_type_id": null,
    "device_type_name": null,
    "device_type_network": null,
    "location_id": "location-id",
    "name": "TV Smart Switch",
    "room_id": "room-1"
}

get_location(location_id: Optional[str] = None, name: Optional[str] = None) dict[source]

Get the info of a location by ID or name.

{
    "name": "My home",
    "location_id": "location-id",
    "country_code": "us",
    "locale": "en-US",
    "latitude": "latitude",
    "longitude": "longitude",
    "temperature_scale": null,
    "region_radius": null,
    "timezone_id": null,
    "rooms": {
        "room-1": {
            "background_image": null,
            "location_id": "location-1",
            "name": "Living Room",
            "room_id": "room-1"
        },
        "room-2": {
            "background_image": null,
            "location_id": "location-1",
            "name": "Bedroom",
            "room_id": "room-2"
        }
    }
}
info() Dict[str, Dict[str, dict]][source]

Return the objects registered to the account, including locations and devices.

{
    "devices": {
        "smart-tv-id": {
            "capabilities": [
                "ocf",
                "switch",
                "audioVolume",
                "audioMute",
                "tvChannel",
                "mediaInputSource",
                "mediaPlayback",
                "mediaTrackControl",
                "custom.error",
                "custom.picturemode",
                "custom.soundmode",
                "custom.accessibility",
                "custom.launchapp",
                "custom.recording",
                "custom.tvsearch",
                "custom.disabledCapabilities",
                "samsungvd.ambient",
                "samsungvd.ambientContent",
                "samsungvd.ambient18",
                "samsungvd.mediaInputSource",
                "refresh",
                "execute",
                "samsungvd.firmwareVersion",
                "samsungvd.supportsPowerOnByOcf"
            ],
            "device_id": "smart-tv-id",
            "device_type_id": null,
            "device_type_name": null,
            "device_type_network": null,
            "location_id": "location-id",
            "name": "Samsung Smart TV",
            "room_id": "room-1"
        },
        "tv-switch-id": {
            "capabilities": [
                "switch",
                "refresh",
                "healthCheck"
            ],
            "device_id": "tv-switch-id",
            "device_type_id": null,
            "device_type_name": null,
            "device_type_network": null,
            "location_id": "location-id",
            "name": "TV Smart Switch",
            "room_id": "room-1"
        },
        "lights-switch-id": {
            "capabilities": [
                "switch",
                "refresh",
                "healthCheck"
            ],
            "device_id": "lights-switch-id",
            "device_type_id": null,
            "device_type_name": null,
            "device_type_network": null,
            "location_id": "location-id",
            "name": "Lights Switch",
            "room_id": "room-2"
        }
    },
    "locations": {
        "location-id": {
            "name": "My home",
            "location_id": "location-id",
            "country_code": "us",
            "locale": "en-US",
            "latitude": "latitude",
            "longitude": "longitude",
            "temperature_scale": null,
            "region_radius": null,
            "timezone_id": null,
            "rooms": {
                "room-1": {
                    "background_image": null,
                    "location_id": "location-1",
                    "name": "Living Room",
                    "room_id": "room-1"
                },
                "room-2": {
                    "background_image": null,
                    "location_id": "location-1",
                    "name": "Bedroom",
                    "room_id": "room-2"
                }
            }
        }
    }
}
off(device: str, *args, **kwargs) dict[source]

Turn off a device with switch capability.

Parameters

device – Device name or ID.

Returns

Device status

on(device: str, *args, **kwargs) dict[source]

Turn on a device with switch capability.

Parameters

device – Device name or ID.

Returns

Device status

status(device: Optional[Union[str, List[str]]] = None) List[dict][source]

Refresh and return the status of one or more devices.

Parameters

device – Device or list of devices to refresh (default: all)

Returns

A list containing on entry per device, and each entry containing the current device state. Example:

[
  {
    "device_id": "switch-1",
    "name": "Fan",
    "switch": false
  },
  {
    "device_id": "tv-1",
    "name": "Samsung Smart TV",
    "switch": true
  }
]

property switches: List[dict]
Returns

List of switch devices statuses in platypush.plugins.switch.SwitchPlugin compatible format.

Example:

[
  {
    "id": "switch-1",
    "name": "Fan",
    "on": false
  },
  {
    "id": "tv-1",
    "name": "Samsung Smart TV",
    "on": true
  }
]

toggle(device: str, *args, **kwargs) dict[source]

Toggle a device with switch capability.

Parameters

device – Device name or ID.

Returns

Device status