Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Naming things. Code formatting. Software tests and CI. #3

Merged
merged 8 commits into from
Apr 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
70 changes: 70 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Tests

on:
pull_request: ~
push:
branches: [ main ]

# Allow job to be triggered manually.
workflow_dispatch:

# Cancel in-progress jobs when pushing to the same branch.
concurrency:
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.ref }}

jobs:

tests:

runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ["ubuntu-latest"]
python-version: ["3.7", "3.12"]
fail-fast: false

env:
OS: ${{ matrix.os }}
PYTHON: ${{ matrix.python-version }}

name: "
Python ${{ matrix.python-version }},
OS ${{ matrix.os }}"
steps:

- name: Acquire sources
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: x64
cache: 'pip'
cache-dependency-path: 'pyproject.toml'

- name: Set up project
run: |

# `setuptools 0.64.0` adds support for editable install hooks (PEP 660).
# https://github.com/pypa/setuptools/blob/main/CHANGES.rst#v6400
pip install "setuptools>=64" --upgrade

# Install package in editable mode.
pip install --use-pep517 --prefer-binary --editable='.[develop,test]'

- name: Run linter and software tests
run: |
poe check

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
files: ./coverage.xml
flags: unittests
env_vars: OS,PYTHON
name: codecov-umbrella
fail_ci_if_error: true
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
.coverage
coverage.xml
*.egg-info
*.pyc
__pycache__
2 changes: 1 addition & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Changes for temp-matrix
# Changes for ds18b20-datalogger

## Unreleased

Expand Down
53 changes: 0 additions & 53 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -619,56 +619,3 @@ Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.

END OF TERMS AND CONDITIONS

How to Apply These Terms to Your New Programs

If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.

To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.

Also add information on how to contact you by electronic and paper mail.

If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:

<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.

The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".

You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.

The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.
4 changes: 4 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include *.md
recursive-include docs *.md
recursive-include ds18b20_datalogger *.py *.json
prune tests
90 changes: 73 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# temp-matrix
Temperature sensor matrix using Raspberry Pi, DS18B20, MQTT, Kotori DAQ,
and Grafana. For bee hive monitoring.
# ds18b20-datalogger

A data logger specializing in reading an array of DS18B20 sensors.

A temperature sensor matrix with heatmap visualization for bee hive monitoring,
using Raspberry Pi, Python, DS18B20, MQTT, Kotori DAQ, and Grafana.


| View from outside | View from inside (sensor tip details) |
|:----:|:----:|
Expand All @@ -11,19 +15,44 @@ Lab protocol and development details:
https://community.hiveeyes.org/t/laborprotokoll-4x5-temp-matrix-mit-ds18b20/5102


## Project Information

» [Documentation]
| [Changelog]
| [PyPI]
| [Issues]
| [Source code]
| [License]

[![CI][badge-tests]][project-tests]
[![Coverage Status][badge-coverage]][project-codecov]
[![License][badge-license]][project-license]
[![Downloads per month][badge-downloads-per-month]][project-downloads]

[![Supported Python versions][badge-python-versions]][project-pypi]
[![Status][badge-status]][project-pypi]
[![Package version][badge-package-version]][project-pypi]


## What's Inside
* README.md - this file
* LICENSE
* temp-matrix_5x6.py - sensor reading and data logging to hiveeyes
* temp-matrix_5x6-grafana_desktop.json - description of [Grafana Dashboard](https://swarm.hiveeyes.org/grafana/d/T49wHSaIk/mois-ex-wtf-test-ds18b20-5x6-temp-matrix-svg-pixmap?orgId=2&from=1712771622514&to=1712807415379)

* `temp-matrix_5x6.py`

Sensor reading and data logging to Kotori DAQ / Hiveeyes.

* `temp-matrix_5x6-grafana_desktop.json`

JSON representation for corresponding [Grafana Dashboard].


## Setup
We recommend to install the program into a Python virtualenv.
```shell
python3 -m venv .venv
source .venv/bin/activate
pip install 'ds18b20-datalogger @ git+https://github.com/hiveeyes/temp-matrix.git'
pip install 'ds18b20-datalogger @ git+https://github.com/hiveeyes/ds18b20-datalogger.git'
```

In this spirit, you keep the installation separate from your system Python, so
Expand All @@ -44,24 +73,26 @@ I am getting valid mapping using a 2.2k resistor.
https://community.hiveeyes.org/t/ds18b20-temperatur-sensoren-am-one-wire-bus-anordnen/1399

### Data Publishing

ssh youruser@yourpi
screen
cd temp-matrix
source paho-mqtt/bin/activate
python temp-matrix_5x6.py`
```shell
ssh youruser@yourpi
screen
cd ds18b20-datalogger
source paho-mqtt/bin/activate
python temp-matrix_5x6.py
```

### MQTT data upload to Hiveeyes
https://community.hiveeyes.org/t/daten-per-mqtt-und-python-ans-backend-auf-swarm-hiveeyes-org-ubertragen/94/6

### Format your array
https://community.hiveeyes.org/t/how-to-visualize-2-dimensional-temperature-data-in-grafana/974/9

matrix = [[temp_ir_1_1, temp_ir_1_2, temp_ir_1_3, temp_ir_1_4, temp_ir_1_5, temp_ir_1_6], \
[temp_ir_2_1, temp_ir_2_2, temp_ir_2_3, temp_ir_2_4, temp_ir_2_5, temp_ir_2_6], \
[temp_ir_3_1, temp_ir_3_2, temp_ir_3_3, temp_ir_3_4, temp_ir_3_5, temp_ir_3_6], \
[temp_ir_4_1, temp_ir_4_2, temp_ir_4_3, temp_ir_4_4, temp_ir_4_5, temp_ir_4_6], \
```python
matrix = [[temp_ir_1_1, temp_ir_1_2, temp_ir_1_3, temp_ir_1_4, temp_ir_1_5, temp_ir_1_6],
[temp_ir_2_1, temp_ir_2_2, temp_ir_2_3, temp_ir_2_4, temp_ir_2_5, temp_ir_2_6],
[temp_ir_3_1, temp_ir_3_2, temp_ir_3_3, temp_ir_3_4, temp_ir_3_5, temp_ir_3_6],
[temp_ir_4_1, temp_ir_4_2, temp_ir_4_3, temp_ir_4_4, temp_ir_4_5, temp_ir_4_6],
[temp_ir_5_1, temp_ir_5_2, temp_ir_5_3, temp_ir_5_4, temp_ir_5_5, temp_ir_5_6]]
```

## Data visualization in Grafana
https://swarm.hiveeyes.org/grafana/d/Y9PcgE4Sz/mois-ex-wtf-test-ir-sensor-svg-pixmap-copy
Expand All @@ -75,3 +106,28 @@ In order to learn how to start hacking on this program, please have a look at th
documentation about how to install a [development sandbox](./docs/sandbox.md).

Contributions of any kind are always welcome and appreciated. Thank you.



[Grafana Dashboard]: https://swarm.hiveeyes.org/grafana/d/T49wHSaIk/mois-ex-wtf-test-ds18b20-5x6-temp-matrix-svg-pixmap?orgId=2&from=1712771622514&to=1712807415379

[Changelog]: https://github.com/hiveeyes/ds18b20-datalogger/blob/main/CHANGES.md
[development documentation]: https://ds18b20-datalogger.readthedocs.io/en/latest/sandbox.html
[Documentation]: https://ds18b20-datalogger.readthedocs.io/
[Issues]: https://github.com/hiveeyes/ds18b20-datalogger/issues
[License]: https://github.com/hiveeyes/ds18b20-datalogger/blob/main/LICENSE
[PyPI]: https://pypi.org/project/ds18b20-datalogger/
[Source code]: https://github.com/hiveeyes/ds18b20-datalogger

[badge-coverage]: https://codecov.io/gh/hiveeyes/ds18b20-datalogger/branch/main/graph/badge.svg
[badge-downloads-per-month]: https://pepy.tech/badge/ds18b20-datalogger/month
[badge-license]: https://img.shields.io/github/license/hiveeyes/ds18b20-datalogger.svg
[badge-package-version]: https://img.shields.io/pypi/v/ds18b20-datalogger.svg
[badge-python-versions]: https://img.shields.io/pypi/pyversions/ds18b20-datalogger.svg
[badge-status]: https://img.shields.io/pypi/status/ds18b20-datalogger.svg
[badge-tests]: https://github.com/hiveeyes/ds18b20-datalogger/actions/workflows/main.yml/badge.svg
[project-codecov]: https://codecov.io/gh/hiveeyes/ds18b20-datalogger
[project-downloads]: https://pepy.tech/project/ds18b20-datalogger/
[project-license]: https://github.com/hiveeyes/ds18b20-datalogger/blob/main/LICENSE
[project-pypi]: https://pypi.org/project/ds18b20-datalogger
[project-tests]: https://github.com/hiveeyes/ds18b20-datalogger/actions/workflows/main.yml
2 changes: 1 addition & 1 deletion docs/sandbox.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Install
```shell
git clone https://github.com/hiveeyes/temp-matrix
git clone https://github.com/hiveeyes/ds18b20-datalogger
python3 -m venv .venv
source .venv/bin/activate
pip install --editable='.[develop,docs,release,test]'
Expand Down
Empty file added ds18b20_datalogger/__init__.py
Empty file.
7 changes: 7 additions & 0 deletions ds18b20_datalogger/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from ds18b20_datalogger.core import read_ds18b20_sensor_matrix, send_measurement_mqtt

Check warning on line 1 in ds18b20_datalogger/cli.py

View check run for this annotation

Codecov / codecov/patch

ds18b20_datalogger/cli.py#L1

Added line #L1 was not covered by tests


def main():
reading = read_ds18b20_sensor_matrix()
send_measurement_mqtt(reading)

Check warning on line 6 in ds18b20_datalogger/cli.py

View check run for this annotation

Codecov / codecov/patch

ds18b20_datalogger/cli.py#L4-L6

Added lines #L4 - L6 were not covered by tests
# print(strftime("%Y-%m-%d %H:%M:%S", time.localtime())," Done sending. Going to sleep for 15min.") # noqa: ERA001
Loading