pythonic访问opensensemap api
sensemapi的Python项目详细描述
sensemapi-pythonic访问opensensemap api
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来 增加版本号。