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映射到methodNamedeviceUuid映射到inputParameterdata={},并映射到上述广义形式的指令{data : "variables"}

可用的资源创建(post)方法是

^{}^{}link^{}
getDeviceTokenBasiclinkGet token for device via key, serial, and secret.
reportAlreadyExecutedCommandslinkReport an already executed set of commands to the server.
createDeviceCommandInstancedeviceUuid,commandTypeUuidlinkCreate a command instance via a device.
postDatadeviceUuidlinkPost data to the cloud.
upsertDeviceSettingsdeviceUuidlinkUpsert settings for a device.
uploadDeviceLogsdeviceUuidlinkUpload zip file of device logs.
getDeviceTokenAsymmetriclinkGet 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映射到methodNamedeviceUuid映射到inputParameter{ "limit": 1 }映射到上述广义形式的指令{"query" : "parameters"}

The limit option is for instructive purposes only. By definition, a uuid is unique and so there will never be more than one device for a given uuid.

可用的资源创建方法有

^{}^{}link^{}
getBrokerAddresslinkGet 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.

更新资源

iotery.io python sdk中更新资源的通用语法如下:

iotery.methodName(inputParameter="parameter",data={"data":"variables"})

例如,要更新设备类型,代码将类似于

updateDeviceChannel(deviceUuid="a-valid-device-type-uuid",channelId="1",data={})

其中updateDeviceChannel映射到methodNamedeviceUuid映射到inputParameter{}映射到上面给出的广义形式的指令{data : "variables"}(如果有实体)。

可用的资源创建方法是

^{}^{}link^{}
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.

删除资源

iotery.io python sdk中用于读取(获取)资源的通用语法如下:

iotery.methodName(inputParameter="parameter",opts={"query":"parameter"})

例如,要通过设备的唯一标识符uuid获取设备,python看起来像

deleteDevice(deviceUuid="a-valid-device-uuid",opts={"some":"option"})

其中deleteDevice映射到methodNamedeviceUuid映射到inputParameter{ "some": "option" }映射到上述广义形式的指令{"query" : "parameters"}

可用的资源创建方法有

^{}^{}link^{}

贡献

我们欢迎投稿人和公关!如果你感兴趣,请告诉我们。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java将spring j_spring_安全检查迁移到登录   log4j2中自定义appender中AppConfig的java问题   在将java转换为Json时是否可以忽略内部类名和变量   用java将PDF文件转换为十六进制格式   java将值从AsyncTask返回到主类   java如何导入带有部署变量类名的静态函数?   java Spring Boot@ConfigurationProperties未从环境检索属性   java为什么API调用需要80毫秒的延迟才能到达控制器(在Google应用程序引擎中)?   XML配置中MarshallingMessageConverter中的java设置MarshallTo获取无效属性“MarshallTo”   java从群中获取facebook帖子   @ComponentScan的java excludeFilters不起作用   java将单选按钮值从一个类传递到另一个类   java使JTextArea在Swing中可滚动   java Android增强现实应用程序:将球坐标旋转到设备坐标系