Skip to main content

package for managing lists of fields for IoT

Project description

FieldDay

Package for helping to manage groups of data fields, the kind that may be passed around an IoT system.

FieldDay offers the possibility of coding and decoding named fields as groups. For example, if a list of json values is obtained from an IoT device, those fields can easily be renamed, decoded, recoded, labeled with descriptions, and converted to different units.

Installation

To install directly from GitHub:

python3 -m pip install "git+https://github.com/jmfife/fieldday.git#egg=fieldday[qty]"

If you have cloned or forked the repo already to your local directory and want to use it in live (editable mode):

python3 -m pip install -e ".[qty]"

Note in both cases above, the dependencies needed to use the pint-based data types (with built-in units) are also installed.

Quickstart

Install the package from GitHub:

python3 -m pip install "git+https://github.com/jmfife/fieldday.git#egg=fieldday[qty]"

Example of loading a JSON payload with certain fields and field types expected, then taking advantage of the extra dependency qty (see setup.py which associates qty with the Pint package under the hood) and converting the units on one of the fields from mV to V:

>>> import fieldday
>>> fieldtypes = {'V': (fieldday.FieldQty, {'desc': 'Battery voltage'}),
...               'L': (fieldday.FieldStr, {'desc': 'Load state'})}
>>> fieldset = fieldday.FieldSet('{"V": "12800 mV", "LOAD": "ON"}', field_types=fieldtypes)
>>> fieldset
{'V': FieldQty('12800 millivolt', 'Battery voltage', '', ''), 'LOAD': 'ON'}
>>> print(fieldset)
V: Battery voltage: 12800 millivolt
LOAD: ON
>>> fieldset.modify_fields({"V": lambda x: x.convert("V")})
>>> fieldset
{'V': FieldQty('12.8 volt', 'Battery voltage', '', ''), 'LOAD': 'ON'}
>>> print(fieldset)
V: Battery voltage: 12.8 volt
LOAD: ON
>>> fieldset.encode()
'{"V": "12.8 volt", "LOAD": "ON"}'

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

fieldday-1.0.0.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fieldday-1.0.0-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file fieldday-1.0.0.tar.gz.

File metadata

  • Download URL: fieldday-1.0.0.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.6

File hashes

Hashes for fieldday-1.0.0.tar.gz
Algorithm Hash digest
SHA256 db386d5aebac5906f3e3a85515f2db6333be131f2607c1309afc0f5bd70d4573
MD5 e04c6d56098b988f93960fbf19cf3935
BLAKE2b-256 c8ef8a9b8f89f2d09758e0c569742f443ba227e8ec5bf978a3c23dca105406e4

See more details on using hashes here.

File details

Details for the file fieldday-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: fieldday-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.6

File hashes

Hashes for fieldday-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 33f5c84c0eca217d79f4c0ec922598dd7f41f94930d9908c97fcf992497dc6b2
MD5 ba271c459d5bcba147f628fb77c57c24
BLAKE2b-256 ccc1ec20c946285def890e5752f6126c53c446d5a2ba94a387b3d4689cc98524

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page