iotery.io嵌入式python sdk
iotery-embedded-python-sdk的Python项目详细描述
iotery.io嵌入式python sdk
python iotery.io sdk将用于您的嵌入式设备,以与itoery.io iot平台交互。sdk是REST API的功能齐全的包装器。
开始
在iotery.io上设置免费帐户,然后转到dashboard开始创建设备类型和设备。
获取密钥后,安装sdk:
pip install iotery-embedded-python-sdk
Note: Make sure you are using Python 3.5+!
最后,一些简单的示例用法:
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"])
API
这个sdk仅仅包装了REST API,因此可以在那里找到更多的信息和细节。由于api是restapi的包装器,因此语法是iotery.io资源上每个创建、读取、更新和删除操作的标准。所有方法都返回一个包含api响应的dictional。如果有错误,方法将raise
一个期望值。
创建资源
在iotery.io python sdk中创建资源的通用语法如下:
iotery.methodName(inputParameter="parameter",data={"data":"variables"})
例如,要创建设备,python看起来像
createDeviceCommandInstanceEmbedded(deviceUuid="a-valid-device-type-uuid",commandTypeUuid="a-valid-command-type-uuid",data={})
其中createDeviceCommandInstanceEmbedded
映射到methodName
,deviceUuid
映射到inputParameter
,data={}
,并映射到上述广义形式的指令{data : "variables"}
。
可用的资源创建(post)方法是
^{ | ^{ | link | ^{ |
---|---|---|---|
getDeviceTokenBasic | link | Get token for device via key, serial, and secret. | |
reportAlreadyExecutedCommands | link | Report an already executed set of commands to the server. | |
createDeviceCommandInstance | deviceUuid,commandTypeUuid | link | Create a command instance via a device. |
postData | deviceUuid | link | Post data to the cloud. |
upsertDeviceSettings | deviceUuid | link | Upsert settings for a device. |
uploadDeviceLogs | deviceUuid | link | Upload zip file of device logs. |
getDeviceTokenAsymmetric | link | Get device token based on encrypted credentials. |
阅读资源
iotery.io python sdk中用于读取(获取)资源的通用语法如下:
iotery.methodName(inputParameter="parameter",opts={"query":"parameter"})
例如,要通过设备的唯一标识符uuid
获取设备,python看起来像
getDeviceTypeFirmwareRecord(deviceUuid="a-valid-device-uuid",version="valid version",opts={"limit":1})
其中getDeviceTypeFirmwareRecord
映射到methodName
,deviceUuid
映射到inputParameter
,{ "limit": 1 }
映射到上述广义形式的指令{"query" : "parameters"}
The
limit
option is for instructive purposes only. By definition, auuid
is unique and so there will never be more than one device for a givenuuid
.
可用的资源创建方法有
^{ | ^{ | link | ^{ |
---|---|---|---|
getBrokerAddress | link | Get the MQTT broker address. | |
getCommandTypeList | link | Get a list of available command types. | |
getCurrentTimestamp | link | Get the current server time in epoch (unix) time. | |
getDataTypeList | link | Get a list of available data types. | |
getDeviceSettingList | deviceUuid | link | Get a list of settings for a device. |
getDeviceUnexecutedCommandInstanceList | deviceUuid | link | Get a list of unexecuted command instances for a device. |
getDeviceTypeFirmwareRecord | deviceTypeUuid,version | link | Get a desired version of a firmware record for a given device type. |
getPublicCloudKey | link | Get base64 encoded public key from the server for use in RSA scheme. | |
getMe | link | Get information about the device. | |
getNotificationTypeList | link | Get a list of available notifications. | |
getSettingTypeList | link | Get a list of available setting types. |
更新资源
iotery.io python sdk中更新资源的通用语法如下:
iotery.methodName(inputParameter="parameter",data={"data":"variables"})
例如,要更新设备类型,代码将类似于
updateDeviceChannel(deviceUuid="a-valid-device-type-uuid",channelId="1",data={})
其中updateDeviceChannel
映射到methodName
,deviceUuid
映射到inputParameter
,{}
映射到上面给出的广义形式的指令{data : "variables"}
(如果有实体)。
可用的资源创建方法是
^{ | ^{ | link | ^{ |
---|---|---|---|
setBatchedCommandInstancesAsExecuted | batchReferenceUuid | link | Set a collection of batched command instances as executed. |
setCommandInstanceAsExecuted | commandInstanceUuid | link | Report that a command has been executed to the server. |
updateDeviceChannel | deviceUuid,channelId | link | Update device channel. |
setNotificationInstanceInactive | notificationInstanceUuid | link | Set notification instance inactive. |
删除资源
iotery.io python sdk中用于读取(获取)资源的通用语法如下:
iotery.methodName(inputParameter="parameter",opts={"query":"parameter"})
例如,要通过设备的唯一标识符uuid
获取设备,python看起来像
deleteDevice(deviceUuid="a-valid-device-uuid",opts={"some":"option"})
其中deleteDevice
映射到methodName
,deviceUuid
映射到inputParameter
,{ "some": "option" }
映射到上述广义形式的指令{"query" : "parameters"}
。
可用的资源创建方法有
^{ | ^{ | link | ^{ |
---|
贡献
我们欢迎投稿人和公关!如果你感兴趣,请告诉我们。