Package: iotery-embedded-python-sdk
iotery.io Embedded Python SDKThe python iotery.io SDK is intended to be used on your embedded device to interact with the itoery.io IoT Platform. The SDK is a fully featured wrapper for theREST API.Getting StartedSetup your free account oniotery.ioand go to yourdashboardget started with creating device types and devices.After you get your key, install the SDK:pipinstalliotery-embedded-python-sdkNote: Make sure you are using Python 3.5+!And finally, some simple example usage:fromiotery_embedded_python_sdkimportIoteryTEAM_ID="265fcb74-8889-11f9-8452-d283610663ec"# team ID found on the dashboard: https://iotery.io/systemiotery=Iotery()d=iotery.getDeviceTokenBasic(data={"key":"thermal_sensor_001","serial":"THERMAL_SENSOR_001","secret":"thermal_sensor_001_secret","teamUuid":TEAM_ID})iotery.set_token(d["token"])me=iotery.getMe()print(me["name"])APIThis SDK simply wraps theREST API, so more information and specifics can be found there. Since the API is a wrapper around the REST API, the syntax is standard for each of the Create, Read, Update, and Delete operations on iotery.io resources. All methods return a dictonary containing the API response. If there is an error, the method willraisean expection.Creating ResourcesThe generalized syntax for creating resources in iotery.io python sdk looks like:iotery.methodName(inputParameter="parameter",data={"data":"variables"})For example, to create a device, the python would look likecreateDeviceCommandInstanceEmbedded(deviceUuid="a-valid-device-type-uuid",commandTypeUuid="a-valid-command-type-uuid",data={})wherecreateDeviceCommandInstanceEmbeddedmaps tomethodName,deviceUuidmaps toinputParameter, anddata={}and maps to the dictonary{data : "variables"}in the generalized form given above.The available resource creation (POST) methods aremethodNameinputlinkdescriptiongetDeviceTokenBasiclinkGet token for device via key, serial, and secret.reportAlreadyExecutedCommandslinkReport an already executed set of commands to the server.createDevicelinkCreate a device.createDeviceCommandInstancedeviceUuid,commandTypeUuidlinkCreate a command instance via a device.postDatadeviceUuidlinkPost data to the cloud.upsertDeviceSettingsdeviceUuidlinkUpsert settings for a device.uploadDeviceLogsdeviceUuidlinkUpload zip file of device logs.provisionNetworklinkProvision a network.getDeviceTokenAsymmetriclinkGet device token based on encrypted credentials.Reading ResourcesThe generalized syntax for reading (getting) resources in iotery.io python sdk looks like:iotery.methodName(inputParameter="parameter",opts={"query":"parameter"})For example, to get a device by it's unique identifieruuid, the python would look likegetDeviceTypeFirmwareRecord(deviceUuid="a-valid-device-uuid",version="valid version",opts={"limit":1})wheregetDeviceTypeFirmwareRecordmaps tomethodName,deviceUuidmaps toinputParameter, and{ "limit": 1 }maps to the dictonary{"query" : "parameters"}in the generalized form given above.Thelimitoption is for instructive purposes only. By definition, auuidis unique and so there will never be more than one device for a givenuuid.The available resource creation methods aremethodNameinputlinkdescriptiongetBrokerAddresslinkGet the MQTT broker address.getCommandTypeListlinkGet a list of available command types.getCurrentTimestamplinkGet the current server time in epoch (unix) time.getDataTypeListlinkGet a list of available data types.getDeviceSettingListdeviceUuidlinkGet a list of settings for a device.getDeviceUnexecutedCommandInstanceListdeviceUuidlinkGet a list of unexecuted command instances for a device.getDeviceTypeFirmwareRecorddeviceTypeUuid,versionlinkGet a desired version of a firmware record for a given device type.getPublicCloudKeylinkGet base64 encoded public key from the server for use in RSA scheme.getMelinkGet information about the device.getNotificationTypeListlinkGet a list of available notifications.getSettingTypeListlinkGet a list of available setting types.getTeamlinkGet the team information for a device.Updating ResourcesThe generalized syntax for updating resources in iotery.io python sdk looks like:iotery.methodName(inputParameter="parameter",data={"data":"variables"})For example, to update a device type, the code would look likeupdateDeviceChannel(deviceUuid="a-valid-device-type-uuid",channelId="1",data={})whereupdateDeviceChannelmaps tomethodName,deviceUuidmaps toinputParameter, and{}maps to the dictonary{data : "variables"}in the generalized form given above (if there was a body).The available resource creation methods aremethodNameinputlinkdescriptionsetNotificationInstanceListInactivelinkSet notification instance list inactive.setBatchedCommandInstancesAsExecutedbatchReferenceUuidlinkSet a collection of batched command instances as executed.setCommandInstanceAsExecutedcommandInstanceUuidlinkReport that a command has been executed to the server.updateDeviceChanneldeviceUuid,channelIdlinkUpdate device channel.setNotificationInstanceInactivenotificationInstanceUuidlinkSet notification instance inactive.Deleting ResourcesThe generalized syntax for reading (getting) resources in iotery.io python sdk looks like:iotery.methodName(inputParameter="parameter",opts={"query":"parameter"})For example, to get a device by it's unique identifieruuid, the python would look likedeleteDevice(deviceUuid="a-valid-device-uuid",opts={"some":"option"})wheredeleteDevicemaps tomethodName,deviceUuidmaps toinputParameter, and{ "some": "option" }maps to the dictonary{"query" : "parameters"}in the generalized form given above.The available resource creation methods aremethodNameinputlinkdescriptionContributingWe welcome contributors and PRs! Let us know if you are interested.