pythonic访问opensensemap api

sensemapi的Python项目详细描述


sensemapi-pythonic访问opensensemap api

pipeline statuscoverage reportdocumentationPyPI

sensemapi是访问OpenSenseMap API的python包。

Disclaimer

This software was developed within the context of a CO2 monitoring project of the University of Tübingen, Germany. The developer is not in any way affiliated with the senseBox project.

sensemapi能做什么?

使用sensemapi,您可以通过 这是OpenSenseMap user interface

请参阅一些示例:

访问opensensemap帐户

account=sensemapi.account.SenseMapAccount(email="SENSEMAP_EMAIL",password=os.environ.get("SENSEMAP_PASSWORD"))

创建新的感光盒

# set up a senseBox (offline)box=sensemapi.senseBox.senseBox(exposure="outdoor",name="My senseBox",current_lat=50.5,current_lon=10.1)# add a temperature sensor to the box (offline)box.new_sensor(title="temperature",unit="°C",type="SHT31",icon="osem-temperature-celsius")# create the senseBox (online)account.new_box(box)

修改传感器盒和传感器

# retreive the account's boxesaccount.get_own_boxes()# choose the first boxbox=account.boxes[0]# change the boxbox.name="My supercool senseBox"# ... do anything with the box object ...# upload the changesbox.upload_metadata()

上传测量值

# select the box's first sensorsensor=box.sensors[0]# reset the time to use the current timesensor.last_time=None# specify measurement valuesensor.last_value=25.2# upload the measurementsensor.upload_measurement()

删除感光盒

# delete the account's first senseBoxaccount.delete_box(account.boxes[0].id,really=True)

按id

检索任何感光盒
# with an accountaccount.get_box(id="57000b8745fd40c8196ad04c")# without an accountsensemapi.client.SenseMapClient().get_box(id="57000b8745fd40c8196ad04c")

传感器盒传感器的检索测量

# get a boxbox=sensemapi.client.SenseMapClient().get_box(id="57000b8745fd40c8196ad04c")# the box' first sensorsensor=box.sensors[0]# get the sensor's latest measurements as pandas.Seriesseries=sensor.get_measurements().series

更多的功能可能会跟随…

安装

最好通过pip3安装sensemapi包。从任何地方运行:

pip3 install --user sensemapi
pip3 install --user pandas # if you want pandas support

这将从Python Package Index下载并安装包。

您也可以通过pip3从存储库根目录安装sensemapi

pip3 install --user .

文档

可以找到sensemapi包的文档here on GitLab

开发

以下内容可能只对开发人员感兴趣

测试

由于这是一个api库,您需要指定一个帐户来运行测试:

exportSENSEMAP_EMAIL="user@email.com"# specify either the email...exportSENSEMAP_USER="username"# or the usernameexportSENSEMAP_PASSWORD="5uP3rP45sW0Rd"

您还可以在一个文件中指定此敏感数据,然后可以 source直径。

要运行测试套件,请从存储库根目录运行

./setup.py test

要获得测试覆盖率,请运行

make coverage

版本控制

此项目使用bumpversion来 增加版本号。

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

推荐PyPI第三方库


热门话题
java打印出JScience中所有定义的单元   swing如何停止在java中重叠两个JPanel   java Eclipse表示无法执行操作,因为连接池已关闭   java应用。亚马尔对阿彭吉纽布。xml使用哪一种?   java迭代HashMap的两种方法有什么不同   java在数组/集合的每个索引上调用不同对象的构造函数   java选项菜单不使用主题ThemeOverlay。AppCompat。黑暗的操作栏   java不能打印来自另一个类的变量吗?   基于JEE规范的java,在一场势均力敌的战争中,SAR是否可以对类进行类可见性?   java Kafka的序列化程序<T>接口中的'configs'参数是什么?   java使用ApachePOI更新MSWord文档   Android中无循环的java获取jsonArray   java将BigDecimal转换为双值   java如何获取所有短暂的节点,以及它们在Zookeeper服务器中存在了多长时间?