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应该考虑使用DTO来代替Spring控制器层吗?   java为什么要将Maven与Git结合起来?   java试图将CSV转换为XLSX,但使用了错误的逗号拆分列   mysql Spring 3+Hibernate:java。sql。BatchUpdateException:无法添加或更新子行(ManyToMany)   java基本字符串反转器   java无法使用RestControllerAdvice为身份验证失败生成自定义错误消息   java当只允许SQLException时,如何抛出EOFEException?   java如何创建播放模块?   Android中匿名类的java实例化异常问题   java两个停靠组件,其中第二个组件填充剩余空间   java如何在按钮延迟时启用它   Java中正在运行的应用程序中的后台进程   java我正试图从一个字符串打印出这个字符输出   如何使用java socket通过两个不同的wifi连接两台电脑?   javaapachecamel:如何将分层数据从数据库转换为pojo   java Webrtc:OniconConnectionChange和onConnectionChange之间有什么区别   java如何重写已经创建的JTable方法   爪哇扫雷机堆垛机   雅加达ee Java ee EJB 3.0 Glassfish