Package: sensemapi
SenseMAPI - Pythonic access to the OpenSenseMap APIsensemapiis a Python package to access theOpenSenseMap
API.DisclaimerThis software was developed within the context of aCO2 monitoring projectof the University of Tübingen, Germany. The developer is not in any
way affiliated with thesenseBox project.What cansensemapido?Withsensemapi, you can do the most important things that you can also do via
theOpenSenseMap user interface.See some examples:Access an OpenSenseMap accountaccount=sensemapi.account.SenseMapAccount(email="SENSEMAP_EMAIL",password=os.environ.get("SENSEMAP_PASSWORD"))Create new senseBoxes# 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)Modify senseBoxes and sensors# 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()Upload measurements# 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 a senseBox# delete the account's first senseBoxaccount.delete_box(account.boxes[0].id,really=True)Retreive any senseBox by its ID# with an accountaccount.get_box(id="57000b8745fd40c8196ad04c")# without an accountsensemapi.client.SenseMapClient().get_box(id="57000b8745fd40c8196ad04c")Retreive measurements of a senseBox sensor# 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# Or download CSV data from the command-line:sensemapidownload--sensebox5d35d315953683001a2b877a--from2022-02--to2022-03-odata.csvInstallationThesensemapipackage is best installed viapip3. Run from anywhere:pip3install--usersensemapi
pip3install--userpandas# if you want pandas supportThis downloads and installs the package from thePython Package
Index.You may also installsensemapiviapip3from the repository root:pip3install--user.DocumentationDocumentation of thesensemapipackage can be foundhere on
GitLab.DevelopmentThe following might only be interesting for developersTestsFor running the full test suite, a registered and activated account at theTesting Stage of the OpenSenseMapis
required. Details of this account must then be passed as environment
variables, for example:exportSENSEMAP_EMAIL="user@email.com"# specify either the email...exportSENSEMAP_USER="username"# or the usernameexportSENSEMAP_PASSWORD="5uP3rP45sW0Rd"You may also specifiy this sensitive data in a file which can then besourced.For running the tests,SENSEMAP_EMAILandSENSEMAP_PASSWORDare required,
else some tests might be skipped.To run the test suite, run from the repository root./setup.pytestTo get a test coverage, runmakecoverageVersioningThis project usesbumpversionto
increase version numbers.