Fetch Cavelink data by parsing the webpage of sensors.
Project description
About Cave-Link
Cave-link is a radio device able to transmit data from a cave. You can add some measurement sensors. The data is consolidated on creator’s server (database) and displayed through a webpage where the data is dump to, as this example shows.
If you own a Cavelink, you should ask Felix Ziegler to get your specific URL, for the sensors you have.
If you know nothing about Cavelink system, the official website is the good place to start. Or maybe, you can also begin with Wikipedia.
What is this repository for?
This python module gather the data by parsing the webpage. You will then be able to display the data on your dashboard or store it to your own database. I also provide code samples to better explain this -see directory ‘samples’-.
How do I get set up?
To ensure a proper setup, I recommend the use of virtualenv (but optionnal).
sudo pip install cavelink
Then you can use the module that way:
from cavelink import cavelink as cl
webpage="http://www.cavelink.com/cl/da.php?s=142&g=10&w=1&l=10"
nb_rows = 5
cavelink = cl.Sensor(webpage, nb_rows)
motiers = cavelink.getJSON(datefmt='human') # or datefmt='epoch'
print(motiers)
You will get a the measurements and the sensor details formatted in JSON.
{ "measures": { "22.12.2018 16:00": 6.3, "22.12.2018 16:30": 5.67, "22.12.2018 17:00": 6.0, "22.12.2018 17:30": 5.45, "22.12.2018 18:00": 5.87 }, "sensor": { "group": "10", "number": "1", "station": "142", "unit": "C" } }
You can also fetch additionnal information, also available from the page. Please note that the following data is provided in JSON object as well. This is:
>>> print(cavelink.station) >>> print(cavelink.group) >>> print(cavelink.number) >>> print(cavelink.unit)
To parse the measures, you can use this sample:
import json
# convert the json-formatted string to a python dictionnay
motiers_json = json.loads(motiers)
# parse measures
for timestamp in motiers_json['measures']:
print('%s -> %s %s' % (timestamp,
motiers_json['measures'][timestamp],
motiers_json['sensor']['unit']))
Contribution guidelines
Feel free to submit issue or better, some pull requests !
Contributors
Sébastien Pittet (main contributor)
Loïc, Bruno and other friends at https://www.exoscale.com
Who do I talk to?
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file cavelink-1.1.2.tar.gz
.
File metadata
- Download URL: cavelink-1.1.2.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 76e4ddfbc6dde60df0215faae3cb962da2f9008da13dcdf681ce2427ce1d04aa |
|
MD5 | 9f7e84113fa7901e018b13f4569fd230 |
|
BLAKE2b-256 | 004e24a439d44e1f353ace1053a963ffc7d7a8206fe0ef3f9aaedc7525d23e68 |
File details
Details for the file cavelink-1.1.2-py3-none-any.whl
.
File metadata
- Download URL: cavelink-1.1.2-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e3d68f2dacc0fba97517db1e9cd7cf7876b82b94dd5851f5dbbbadd9ef429da8 |
|
MD5 | e98a329e845b64c25513b7d4d3f61368 |
|
BLAKE2b-256 | f611439b643d5da8149913066ce1fce6cf9136eeacb2bab0bed22613a31a6165 |