From 7d101acc6eace3cafb4f15b9f81b4c28bb7f3d42 Mon Sep 17 00:00:00 2001 From: Dave T <17680170+davet2001@users.noreply.github.com> Date: Thu, 2 Dec 2021 20:01:55 +0000 Subject: [PATCH 01/32] Add support for TEMPer2V1.3 --- temperusb/device_library.py | 5 +++++ tests/test_temper.py | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/temperusb/device_library.py b/temperusb/device_library.py index f5b08f9..1bcaf74 100644 --- a/temperusb/device_library.py +++ b/temperusb/device_library.py @@ -28,6 +28,11 @@ def __init__( DEVICE_LIBRARY = { + "TEMPer2V1.3": TemperConfig( + temp_sens_offsets=[2, 4], + hum_sens_offsets=None, + type=TemperType.FM75, + ), "TEMPerV1.2": TemperConfig( temp_sens_offsets=[2], hum_sens_offsets=None, diff --git a/tests/test_temper.py b/tests/test_temper.py index 808fd0c..a1a7c13 100644 --- a/tests/test_temper.py +++ b/tests/test_temper.py @@ -36,6 +36,16 @@ [32.1, 43.2], None, ], + [ + 'TEMPer2V1.3', + 0x0c45, + 0x7401, + 2, + b"\x01\x80\x33\x01\x00\x00\x00\x00", + b"\x80\x04\x0a\xe0\x15\x00\x1d\x15", # 0x0AE0, 0x1500 converts to 10.9C, 21.0C (fm75) + [10.9, 21.0], + None, + ], [ "TEMPerV1.2", 0x0C45, From 47cfa55abca180e96448829feffd9e9fcea873f7 Mon Sep 17 00:00:00 2001 From: Dave T <17680170+davet2001@users.noreply.github.com> Date: Thu, 2 Dec 2021 20:07:30 +0000 Subject: [PATCH 02/32] Print the output for each sensor. --- temperusb/cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/temperusb/cli.py b/temperusb/cli.py index a8de695..e2a8942 100644 --- a/temperusb/cli.py +++ b/temperusb/cli.py @@ -99,7 +99,7 @@ def main(): huminfo = huminfo[0:len(output) - 2] output = 'Device #%i%s: %s %s' % (i, portinfo, tempinfo, huminfo) - print(output) + print(output) if __name__ == '__main__': From 3fc73253b355ce8eade0d19be28c725f01494fa9 Mon Sep 17 00:00:00 2001 From: Dave T <17680170+davet2001@users.noreply.github.com> Date: Thu, 2 Dec 2021 20:10:59 +0000 Subject: [PATCH 03/32] Revert print change. --- temperusb/cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/temperusb/cli.py b/temperusb/cli.py index e2a8942..a8de695 100644 --- a/temperusb/cli.py +++ b/temperusb/cli.py @@ -99,7 +99,7 @@ def main(): huminfo = huminfo[0:len(output) - 2] output = 'Device #%i%s: %s %s' % (i, portinfo, tempinfo, huminfo) - print(output) + print(output) if __name__ == '__main__': From 6f44d58ee010d179d352e79daf58b28de3c76090 Mon Sep 17 00:00:00 2001 From: Dave T <17680170+davet2001@users.noreply.github.com> Date: Sat, 4 Dec 2021 08:52:07 +0000 Subject: [PATCH 04/32] Add continuous integration --- .github/workflows/ci.yml | 23 +++++++++++++++++++++++ requirements_test.txt | 3 +++ 2 files changed, 26 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 requirements_test.txt diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..598d303 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,23 @@ +name: CI + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.8", "3.9", "3.10"] + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements_test.txt + - name: Run unit tests + run: python -m pytest --import-mode=append tests/ + diff --git a/requirements_test.txt b/requirements_test.txt new file mode 100644 index 0000000..3d2b9eb --- /dev/null +++ b/requirements_test.txt @@ -0,0 +1,3 @@ +# Dependencies for running tests. +pytest +pyusb From f83aa0d20f77c26e37a396daddbfdd3875dd8851 Mon Sep 17 00:00:00 2001 From: Dave T <17680170+davet2001@users.noreply.github.com> Date: Sat, 4 Dec 2021 09:26:04 +0000 Subject: [PATCH 05/32] Test more python versions --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 598d303..6132299 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.8", "3.9", "3.10"] + python-version: ["2.7", "3.5", "3.6", "3.7", "3.8", "3.9", "3.10"] steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} From c334c5d50d70ab6122481a0bb8b077e1c4128ae5 Mon Sep 17 00:00:00 2001 From: Dave T <17680170+davet2001@users.noreply.github.com> Date: Sat, 4 Dec 2021 09:29:28 +0000 Subject: [PATCH 06/32] Test back to 3.5 but not 2.7 which fails --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6132299..a39d35b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["2.7", "3.5", "3.6", "3.7", "3.8", "3.9", "3.10"] + python-version: ["3.5", "3.6", "3.7", "3.8", "3.9", "3.10"] steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} From e49a707fa4fdcfc554aaf402192372ecb2f9b6c1 Mon Sep 17 00:00:00 2001 From: Dave T <17680170+davet2001@users.noreply.github.com> Date: Sat, 4 Dec 2021 09:36:11 +0000 Subject: [PATCH 07/32] Update compatible python versions --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 387e7ca..1679628 100644 --- a/README.md +++ b/README.md @@ -343,8 +343,7 @@ as seen on [Google+](https://plus.google.com/105569853186899442987/posts/N9T7xAj # Compatibility with Python versions -This should work on both Python 2 and 3. It was tested with Python 2.7.3 and 3.2.3. -The `snmp_passpersist` mode is Python 2 only because the upstream package is not ready yet. +This should work on Python 3.5 and above. It was tested with Python 3.5, 3.6, 3.7, 3.8, 3.9, 3.10. # Authors From 48cd4086dd18c84300043dd04e3e69598919118c Mon Sep 17 00:00:00 2001 From: Dave T <17680170+davet2001@users.noreply.github.com> Date: Sat, 4 Dec 2021 09:46:00 +0000 Subject: [PATCH 08/32] Add pip as an installation method --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1679628..43f547f 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,11 @@ Under Debian/Ubuntu, treat yourself to some package goodness: # Installation and usage -Clone the repository, cd into its top-level directory, and run +To install using pip, run + + pip install temperusb + +To install from source, clone the repository, cd into its top-level directory, and run sudo python setup.py install From aa8d87c0c2809ed6b678e26d4e034398875193d4 Mon Sep 17 00:00:00 2001 From: Dave T <17680170+davet2001@users.noreply.github.com> Date: Sat, 4 Dec 2021 09:52:59 +0000 Subject: [PATCH 09/32] Run CI on PR, not just on push --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a39d35b..bf86d52 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,6 @@ name: CI -on: [push] +on: [push, pull_request] jobs: build: From 308c97b8634fb024fd75f299255b18166a0193cd Mon Sep 17 00:00:00 2001 From: Dave T <17680170+davet2001@users.noreply.github.com> Date: Mon, 18 Apr 2022 18:10:28 +0100 Subject: [PATCH 10/32] Support TEMPerHumiV1.1 Add support for TEMPerHumiV1.1 Thank you @bjornenki --- temperusb/device_library.py | 5 +++++ tests/test_temper.py | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/temperusb/device_library.py b/temperusb/device_library.py index 598065f..ddeb5e3 100644 --- a/temperusb/device_library.py +++ b/temperusb/device_library.py @@ -59,6 +59,11 @@ def __init__( hum_sens_offsets=[4], type=TemperType.SI7021, ), + "TEMPerHumiV1.1": TemperConfig( + temp_sens_offsets=[2], + hum_sens_offsets=[4], + type=TemperType.FM75, + ), "TEMPer1F_H1_V1.4": TemperConfig( temp_sens_offsets=[2], hum_sens_offsets=[4], diff --git a/tests/test_temper.py b/tests/test_temper.py index 8efce6e..9b239aa 100644 --- a/tests/test_temper.py +++ b/tests/test_temper.py @@ -96,6 +96,16 @@ [32.1], [98.7], ], + [ + "TEMPer1F_H1_V1.4", + 0x0C45, + 0x7401, + 1, + b"\x01\x80\x33\x01\x00\x00\x00\x00", + b"\x00\x00\x20\x1A\x0C\x0C", # 0x201A,0x0C0C converts to 32.1C,98.7% (fm75) + [32.1], + [98.7], + ], [ "TEMPerNTC1.O", 0x0C45, From 948e8cf86e478d6be0a7ae58d9ab6de79a44ccdc Mon Sep 17 00:00:00 2001 From: Dave T <17680170+davet2001@users.noreply.github.com> Date: Mon, 18 Apr 2022 18:15:57 +0100 Subject: [PATCH 11/32] Fix test for TEMPerHumiV1.1 --- tests/test_temper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_temper.py b/tests/test_temper.py index 9b239aa..58e5222 100644 --- a/tests/test_temper.py +++ b/tests/test_temper.py @@ -87,7 +87,7 @@ [87.6], ], [ - "TEMPer1F_H1_V1.4", + "TEMPerHumiV1.1", 0x0C45, 0x7401, 1, From 9ce631b4d1f4cfc2a64c97127fb79edcedb741f3 Mon Sep 17 00:00:00 2001 From: Dave T <17680170+davet2001@users.noreply.github.com> Date: Thu, 21 Apr 2022 20:09:19 +0000 Subject: [PATCH 12/32] Support TEMPerHumiV1.0 --- temperusb/device_library.py | 5 +++++ tests/test_temper.py | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/temperusb/device_library.py b/temperusb/device_library.py index ddeb5e3..f6969f8 100644 --- a/temperusb/device_library.py +++ b/temperusb/device_library.py @@ -59,6 +59,11 @@ def __init__( hum_sens_offsets=[4], type=TemperType.SI7021, ), + "TEMPerHumiV1.0": TemperConfig( + temp_sens_offsets=[2], + hum_sens_offsets=[4], + type=TemperType.FM75, + ), "TEMPerHumiV1.1": TemperConfig( temp_sens_offsets=[2], hum_sens_offsets=[4], diff --git a/tests/test_temper.py b/tests/test_temper.py index 58e5222..408269a 100644 --- a/tests/test_temper.py +++ b/tests/test_temper.py @@ -86,6 +86,16 @@ [12.3], [87.6], ], + [ + "TEMPerHumiV1.0", + 0x0C45, + 0x7401, + 1, + b"\x01\x80\x33\x01\x00\x00\x00\x00", + b"\x00\x00\x20\x1A\x0C\x0C", # 0x201A,0x0C0C converts to 32.1C,98.7% (fm75) + [32.1], + [98.7], + ], [ "TEMPerHumiV1.1", 0x0C45, From 99835b68c8488a10b5295b822aa345dcd4d16f31 Mon Sep 17 00:00:00 2001 From: Dave T <17680170+davet2001@users.noreply.github.com> Date: Tue, 2 May 2023 22:27:11 +0100 Subject: [PATCH 13/32] Drop old python <3.7, add 3.11 to CI tests --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bf86d52..484473f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.5", "3.6", "3.7", "3.8", "3.9", "3.10"] + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} From df1fead5b309912765b7e752fd51a06204f59df6 Mon Sep 17 00:00:00 2001 From: Dave T Date: Tue, 2 May 2023 21:12:46 +0000 Subject: [PATCH 14/32] Add experimental support for TEMPer2_V3.7 --- temperusb/device_library.py | 5 +++++ temperusb/temper.py | 1 + 2 files changed, 6 insertions(+) diff --git a/temperusb/device_library.py b/temperusb/device_library.py index f6969f8..2d2bc4c 100644 --- a/temperusb/device_library.py +++ b/temperusb/device_library.py @@ -84,6 +84,11 @@ def __init__( hum_sens_offsets=None, type=TemperType.FM75, ), + "TEMPer2_V3.7": TemperConfig( + temp_sens_offsets=[2, 10], + hum_sens_offsets=None, + type=TemperType.FM75, + ), "TEMPer2V1.4": TemperConfig( temp_sens_offsets=[2], hum_sens_offsets=None, diff --git a/temperusb/temper.py b/temperusb/temper.py index f94cec4..dcfc965 100644 --- a/temperusb/temper.py +++ b/temperusb/temper.py @@ -19,6 +19,7 @@ VIDPIDS = [ (0x0c45, 0x7401), (0x0c45, 0x7402), + (0x1a86, 0xe025), ] REQ_INT_LEN = 8 ENDPOINT = 0x82 From d4a75051a2adeedd24d19f444ebd1d2c6ad01136 Mon Sep 17 00:00:00 2001 From: Dave T Date: Mon, 8 May 2023 09:57:29 +0000 Subject: [PATCH 15/32] Update permissions rule for new sensor id --- etc/99-tempsensor.rules | 1 + 1 file changed, 1 insertion(+) diff --git a/etc/99-tempsensor.rules b/etc/99-tempsensor.rules index 037a343..6a8986d 100644 --- a/etc/99-tempsensor.rules +++ b/etc/99-tempsensor.rules @@ -1,2 +1,3 @@ SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="0c45", ATTRS{idProduct}=="7401", MODE="666" SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="0c45", ATTRS{idProduct}=="7402", MODE="666" +SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="e025", MODE="666" From 19dd9f88ebde56da626df0cabe0536e6ec8d87e7 Mon Sep 17 00:00:00 2001 From: Philipp Born Date: Sun, 18 Jun 2023 15:44:05 +0200 Subject: [PATCH 16/32] feat(TemperDevice): add get_product function Signed-off-by: Philipp Born --- temperusb/temper.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/temperusb/temper.py b/temperusb/temper.py index dcfc965..d8c77a6 100644 --- a/temperusb/temper.py +++ b/temperusb/temper.py @@ -194,6 +194,12 @@ def set_sensor_count(self, count): self._sensor_count = int(count) + def get_product(self): + """ + Get device product name. + """ + return self._device.product + def get_ports(self): """ Get device USB ports. From 7043ba9ce0713c7cba34d4df0568d2c464e6ed03 Mon Sep 17 00:00:00 2001 From: Dave T <17680170+davet2001@users.noreply.github.com> Date: Tue, 19 Dec 2023 15:16:02 +0000 Subject: [PATCH 17/32] Add python 3.12 to tests --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bf86d52..f32f342 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.5", "3.6", "3.7", "3.8", "3.9", "3.10"] + python-version: ["3.5", "3.6", "3.7", "3.8", "3.9", "3.10", "3.12"] steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} From 403bb0e82f674523aea7e563f5782790a49d3b8b Mon Sep 17 00:00:00 2001 From: Dave T <17680170+davet2001@users.noreply.github.com> Date: Tue, 19 Dec 2023 15:17:44 +0000 Subject: [PATCH 18/32] Add python 3.11 to tests --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f32f342..26d35e3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.5", "3.6", "3.7", "3.8", "3.9", "3.10", "3.12"] + python-version: ["3.5", "3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} From 63e48f9ef628215b1172a3bc2fac39820c2f0753 Mon Sep 17 00:00:00 2001 From: Dave T <17680170+davet2001@users.noreply.github.com> Date: Tue, 19 Dec 2023 15:37:47 +0000 Subject: [PATCH 19/32] Update compatible python versions --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 43f547f..b9901ca 100644 --- a/README.md +++ b/README.md @@ -347,7 +347,7 @@ as seen on [Google+](https://plus.google.com/105569853186899442987/posts/N9T7xAj # Compatibility with Python versions -This should work on Python 3.5 and above. It was tested with Python 3.5, 3.6, 3.7, 3.8, 3.9, 3.10. +This should work on Python 3.7 and above. It was tested with Python 3.7, 3.8, 3.9, 3.10, 3.11, 3.12. # Authors From 8a86428fe46ad3bbae993f38584aa6bcef9121f1 Mon Sep 17 00:00:00 2001 From: Dave T Date: Tue, 2 May 2023 21:44:57 +0000 Subject: [PATCH 20/32] Add support for devcontainer development --- .devcontainer/Dockerfile | 22 +++++++++++++++++ .devcontainer/devcontainer.json | 43 +++++++++++++++++++++++++++++++++ .vscode/settings.json | 10 ++++++++ etc/99-tempsensor.rules | 1 - 4 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json create mode 100644 .vscode/settings.json diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..5e3b9e7 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,22 @@ +# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.145.1/containers/python-3/.devcontainer/base.Dockerfile + +# [Choice] Python version: 3, 3.9, 3.8, 3.7, 3.6 +ARG VARIANT="3" +FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT} + +# [Option] Install Node.js +ARG INSTALL_NODE="true" +ARG NODE_VERSION="lts/*" +RUN if [ "${INSTALL_NODE}" = "true" ]; then su vscode -c "source /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi + +# [Optional] If your pip requirements rarely change, uncomment this section to add them to the image. +# COPY requirements.txt /tmp/pip-tmp/ +# RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \ +# && rm -rf /tmp/pip-tmp + +# [Optional] Uncomment this section to install additional OS packages. +# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ +# && apt-get -y install --no-install-recommends + +# [Optional] Uncomment this line to install global node packages. +# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g " 2>&1 \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..581e30a --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,43 @@ +{ + "name": "Python 3", + "build": { + "dockerfile": "Dockerfile", + "context": "..", + "args": { + // Update 'VARIANT' to pick a Python version: 3, 3.6, 3.7, 3.8, 3.9 + "VARIANT": "3", + // Options + "INSTALL_NODE": "false", + "NODE_VERSION": "lts/*" + } + }, + "containerEnv": { + "PYTHONPATH": "." + }, + // Set *default* container specific settings.json values on container create. + "settings": { + "terminal.integrated.shell.linux": "/bin/bash", + "python.pythonPath": "/usr/local/bin/python", + "python.linting.enabled": true, + "python.linting.pylintEnabled": true, + "python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8", + "python.formatting.blackPath": "/usr/local/py-utils/bin/black", + "python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf", + "python.linting.banditPath": "/usr/local/py-utils/bin/bandit", + "python.linting.flake8Path": "/usr/local/py-utils/bin/flake8", + "python.linting.mypyPath": "/usr/local/py-utils/bin/mypy", + "python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle", + "python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle", + "python.linting.pylintPath": "/usr/local/py-utils/bin/pylint" + }, + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "ms-python.python" + ] + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "pip3 install --user -r requirements.txt", + // Uncomment to connect as a non-root user. See https://aka.ms/vscode-remote/containers/non-root. + // "remoteUser": "vscode" +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..77694e9 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,10 @@ +{ + "python.envFile": "${workspaceFolder}/.env", + "python.testing.pytestArgs": [ + "tests" + ], + "python.testing.unittestEnabled": false, + "python.testing.nosetestsEnabled": false, + "python.testing.pytestEnabled": true, + "python.pythonPath": "/usr/local/bin/python", +} \ No newline at end of file diff --git a/etc/99-tempsensor.rules b/etc/99-tempsensor.rules index 6a8986d..037a343 100644 --- a/etc/99-tempsensor.rules +++ b/etc/99-tempsensor.rules @@ -1,3 +1,2 @@ SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="0c45", ATTRS{idProduct}=="7401", MODE="666" SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="0c45", ATTRS{idProduct}=="7402", MODE="666" -SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="e025", MODE="666" From e2a2c4e61a19bab5ddeb2eb54f7ac5b9e08b294e Mon Sep 17 00:00:00 2001 From: Dave T <17680170+davet2001@users.noreply.github.com> Date: Tue, 19 Dec 2023 16:48:29 +0000 Subject: [PATCH 21/32] Update devcontainer spec using newer template --- .devcontainer/devcontainer.json | 55 ++++++++++----------------------- requirements.txt | 1 + requirements_test.txt | 4 +-- tests/__init__.py | 0 4 files changed, 20 insertions(+), 40 deletions(-) create mode 100644 requirements.txt create mode 100644 tests/__init__.py diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 581e30a..2babca0 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,43 +1,22 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/python { "name": "Python 3", - "build": { - "dockerfile": "Dockerfile", - "context": "..", - "args": { - // Update 'VARIANT' to pick a Python version: 3, 3.6, 3.7, 3.8, 3.9 - "VARIANT": "3", - // Options - "INSTALL_NODE": "false", - "NODE_VERSION": "lts/*" - } - }, - "containerEnv": { - "PYTHONPATH": "." - }, - // Set *default* container specific settings.json values on container create. - "settings": { - "terminal.integrated.shell.linux": "/bin/bash", - "python.pythonPath": "/usr/local/bin/python", - "python.linting.enabled": true, - "python.linting.pylintEnabled": true, - "python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8", - "python.formatting.blackPath": "/usr/local/py-utils/bin/black", - "python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf", - "python.linting.banditPath": "/usr/local/py-utils/bin/bandit", - "python.linting.flake8Path": "/usr/local/py-utils/bin/flake8", - "python.linting.mypyPath": "/usr/local/py-utils/bin/mypy", - "python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle", - "python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle", - "python.linting.pylintPath": "/usr/local/py-utils/bin/pylint" - }, - // Add the IDs of extensions you want installed when the container is created. - "extensions": [ - "ms-python.python" - ] + // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile + "image": "mcr.microsoft.com/devcontainers/python:1-3.12-bullseye", + + // Features to add to the dev container. More info: https://containers.dev/features. + // "features": {}, + // Use 'forwardPorts' to make a list of ports inside the container available locally. // "forwardPorts": [], + // Use 'postCreateCommand' to run commands after the container is created. - // "postCreateCommand": "pip3 install --user -r requirements.txt", - // Uncomment to connect as a non-root user. See https://aka.ms/vscode-remote/containers/non-root. - // "remoteUser": "vscode" -} \ No newline at end of file + "postCreateCommand": "pip3 install --user -r requirements.txt -r requirements_test.txt", + + // Configure tool-specific properties. + "customizations": {} + + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" +} diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..4f21f91 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +pyusb==1.2.1 \ No newline at end of file diff --git a/requirements_test.txt b/requirements_test.txt index 3d2b9eb..448d54c 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -1,3 +1,3 @@ # Dependencies for running tests. -pytest -pyusb +pytest>=7.4.3 + diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 From eb048f87eae9ede97167ffe055ffd6f773d30a2b Mon Sep 17 00:00:00 2001 From: Dave T <17680170+davet2001@users.noreply.github.com> Date: Tue, 19 Dec 2023 16:49:48 +0000 Subject: [PATCH 22/32] Remove unnecessary dockerfile --- .devcontainer/Dockerfile | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 .devcontainer/Dockerfile diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile deleted file mode 100644 index 5e3b9e7..0000000 --- a/.devcontainer/Dockerfile +++ /dev/null @@ -1,22 +0,0 @@ -# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.145.1/containers/python-3/.devcontainer/base.Dockerfile - -# [Choice] Python version: 3, 3.9, 3.8, 3.7, 3.6 -ARG VARIANT="3" -FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT} - -# [Option] Install Node.js -ARG INSTALL_NODE="true" -ARG NODE_VERSION="lts/*" -RUN if [ "${INSTALL_NODE}" = "true" ]; then su vscode -c "source /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi - -# [Optional] If your pip requirements rarely change, uncomment this section to add them to the image. -# COPY requirements.txt /tmp/pip-tmp/ -# RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \ -# && rm -rf /tmp/pip-tmp - -# [Optional] Uncomment this section to install additional OS packages. -# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ -# && apt-get -y install --no-install-recommends - -# [Optional] Uncomment this line to install global node packages. -# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g " 2>&1 \ No newline at end of file From 87d89a083c77a45b26c561c1c9112dba47c4ed98 Mon Sep 17 00:00:00 2001 From: Dave T <17680170+davet2001@users.noreply.github.com> Date: Tue, 19 Dec 2023 16:51:28 +0000 Subject: [PATCH 23/32] Update 99-tempsensor.rules --- etc/99-tempsensor.rules | 1 + 1 file changed, 1 insertion(+) diff --git a/etc/99-tempsensor.rules b/etc/99-tempsensor.rules index 037a343..6a8986d 100644 --- a/etc/99-tempsensor.rules +++ b/etc/99-tempsensor.rules @@ -1,2 +1,3 @@ SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="0c45", ATTRS{idProduct}=="7401", MODE="666" SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="0c45", ATTRS{idProduct}=="7402", MODE="666" +SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="e025", MODE="666" From 84ed9dfe1e14c701506d8074c0176e02b4169633 Mon Sep 17 00:00:00 2001 From: Dave T <17680170+davet2001@users.noreply.github.com> Date: Tue, 19 Dec 2023 16:54:55 +0000 Subject: [PATCH 24/32] Add pyusb to test requirements. --- requirements.txt | 2 +- requirements_test.txt | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 4f21f91..7e2effa 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1 @@ -pyusb==1.2.1 \ No newline at end of file +pyusb==1.2.1 diff --git a/requirements_test.txt b/requirements_test.txt index 448d54c..8900955 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -1,3 +1,4 @@ # Dependencies for running tests. -pytest>=7.4.3 +pyusb==1.2.1 +pytest==7.4.3 From 441ab3104cf0829b74ee2754eb59c9d547f36a56 Mon Sep 17 00:00:00 2001 From: Dave T <17680170+davet2001@users.noreply.github.com> Date: Tue, 19 Dec 2023 20:53:35 +0000 Subject: [PATCH 25/32] Modify devcontainer to give access to usb devices --- .devcontainer/Dockerfile | 5 +++++ .devcontainer/devcontainer.json | 16 +++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 .devcontainer/Dockerfile diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..41fcd25 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,5 @@ +FROM mcr.microsoft.com/devcontainers/base:alpine-3.18 + +RUN apk add --no-cache \ + libusb=1.0.26-r2 \ + py3-pip=23.1.2-r0 diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 2babca0..3c46125 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,9 +1,12 @@ // For format details, see https://aka.ms/devcontainer.json. For config options, see the -// README at: https://github.com/devcontainers/templates/tree/main/src/python +// README at: https://github.com/devcontainers/templates/tree/main/src/alpine { - "name": "Python 3", + "name": "Python Alpine", // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile - "image": "mcr.microsoft.com/devcontainers/python:1-3.12-bullseye", + "build": { + "dockerfile": "Dockerfile", + "context": ".." + }, // Features to add to the dev container. More info: https://containers.dev/features. // "features": {}, @@ -14,9 +17,12 @@ // Use 'postCreateCommand' to run commands after the container is created. "postCreateCommand": "pip3 install --user -r requirements.txt -r requirements_test.txt", + // Priviledged mode is necessary to get access to usb + "runArgs": ["--privileged"] + // Configure tool-specific properties. - "customizations": {} + // "customizations": {}, // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. - // "remoteUser": "root" + //"remoteUser": "root" } From e3e10e8148176679f81c562e7bbefb3ebed42843 Mon Sep 17 00:00:00 2001 From: Dave T <17680170+davet2001@users.noreply.github.com> Date: Tue, 19 Dec 2023 15:44:41 +0000 Subject: [PATCH 26/32] Update CHANGELOG.md --- CHANGELOG.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ee86c2..07a6bc0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,16 @@ All notable changes to this project will be documented in this file. No changes yet. -## [1.6.0] +## [1.6.1] - 2023-12-19 +### Added +- Support for for TEMPer2V1.3 +- Support for TEMPerHumiV1.1 +- Support for TEMPerHumiV1.0 +- Experimental support for TEMPer2_V3.7 +- get_product() function to get product name +- Updates to documentation + +## [1.6.0] - 2021-11-03 ### Added - A new architecture for supporting different device types. - Tests using pytest From 08cafca21b7b209157dce08bdd1c95b0c8a00188 Mon Sep 17 00:00:00 2001 From: Dave T <17680170+davet2001@users.noreply.github.com> Date: Tue, 19 Dec 2023 21:05:22 +0000 Subject: [PATCH 27/32] Update version info --- setup.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 4360b85..b1cb6c9 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ author='Philipp Adelt', author_email='autosort-github@philipp.adelt.net ', url='https://github.com/padelt/temper-python', - version='1.6.0', + version='1.6.1', description='Reads temperature from TEMPerV1 devices (USB 0c45:7401)', long_description=open('README.md', encoding='utf-8').read(), long_description_content_type='text/markdown', @@ -24,7 +24,6 @@ 'Development Status :: 5 - Production/Stable', 'Environment :: Console', 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)', - 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 3', ], ) From d30bf8b4c072bfc6d66e56a360f11853ccaf6b3d Mon Sep 17 00:00:00 2001 From: Dave T <17680170+davet2001@users.noreply.github.com> Date: Thu, 21 Dec 2023 22:14:35 +0000 Subject: [PATCH 28/32] Add publish script --- .devcontainer/devcontainer.json | 7 ++++++- scripts/publish_to_pypi.sh | 36 +++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100755 scripts/publish_to_pypi.sh diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 3c46125..b8c8fea 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -18,11 +18,16 @@ "postCreateCommand": "pip3 install --user -r requirements.txt -r requirements_test.txt", // Priviledged mode is necessary to get access to usb - "runArgs": ["--privileged"] + "runArgs": ["--privileged"], // Configure tool-specific properties. // "customizations": {}, // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. //"remoteUser": "root" + + // Access local .pypi api keys + "mounts": [ + "source=${localEnv:HOME}${localEnv:USERPROFILE}/.pypirc,target=/home/vscode/.pypirc,type=bind,consistency=cached" + ] } diff --git a/scripts/publish_to_pypi.sh b/scripts/publish_to_pypi.sh new file mode 100755 index 0000000..3d1b860 --- /dev/null +++ b/scripts/publish_to_pypi.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# Script to automate publishing to pypi +# Dave T 2023-12-21 +pypi_config_file=~/.pypirc + +pip install twine + +if [ ! -f dist/*.tar.gz ]; then + echo "No releases found. Please run python3 -m setup.py sdist" + exit +fi +twine check dist/* + +echo "Ready to publish." +echo "Default is publishing to testpypi." +read -r -p "If you are fully ready, please publish to pypi by typing 'thisisnotatest': " response +echo "response=$response" +if [ "$response" = "thisisnotatest" ]; then + repository=pypi +else + repository=testpypi +fi + +if [ -f $pypi_config_file ]; then + echo "Using $pypi_config_file for API keys" +else + echo "$pypi_config_file not found, please paste pypi API token below:" + read twine_api_key + export TWINE_USERNAME=__token__ + export TWINE_PASSWORD=$twine_api_key +fi +echo "Publishing to $repository..." +twine upload --repository $repository dist/* +echo "Publishing complete!" +echo +echo "Don't forget to tag this release!" \ No newline at end of file From 75d356ed4ea348ff1d61365d43dffa6aa6078725 Mon Sep 17 00:00:00 2001 From: Dave T <17680170+davet2001@users.noreply.github.com> Date: Thu, 21 Dec 2023 22:20:30 +0000 Subject: [PATCH 29/32] Correct typo --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 07a6bc0..155de48 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ No changes yet. ## [1.6.1] - 2023-12-19 ### Added -- Support for for TEMPer2V1.3 +- Support for TEMPer2V1.3 - Support for TEMPerHumiV1.1 - Support for TEMPerHumiV1.0 - Experimental support for TEMPer2_V3.7 From 7a26fd21806a434bbe81495173b1d1cfccbe6fd2 Mon Sep 17 00:00:00 2001 From: Dave T <17680170+davet2001@users.noreply.github.com> Date: Sun, 18 Aug 2024 21:30:46 +0100 Subject: [PATCH 30/32] Add new sensor TEMPer2_M12_V1.3 --- temperusb/device_library.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/temperusb/device_library.py b/temperusb/device_library.py index 2d2bc4c..d1f0b26 100644 --- a/temperusb/device_library.py +++ b/temperusb/device_library.py @@ -84,6 +84,11 @@ def __init__( hum_sens_offsets=None, type=TemperType.FM75, ), + "TEMPer2_M12_V1.3": TemperConfig( + temp_sens_offsets=[2, 4], + hum_sens_offsets=None, + type=TemperType.FM75, + ), "TEMPer2_V3.7": TemperConfig( temp_sens_offsets=[2, 10], hum_sens_offsets=None, From 7638c7e7bec83f841957bc4875b7567a3002a289 Mon Sep 17 00:00:00 2001 From: Dave T <17680170+davet2001@users.noreply.github.com> Date: Thu, 9 Jan 2025 22:58:06 +0000 Subject: [PATCH 31/32] Support python 3.13, drop 3.7 --- .github/workflows/ci.yml | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0f32ca9..355f7c5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} diff --git a/README.md b/README.md index b9901ca..ea57c0d 100644 --- a/README.md +++ b/README.md @@ -347,7 +347,7 @@ as seen on [Google+](https://plus.google.com/105569853186899442987/posts/N9T7xAj # Compatibility with Python versions -This should work on Python 3.7 and above. It was tested with Python 3.7, 3.8, 3.9, 3.10, 3.11, 3.12. +This should work on Python 3.8 and above. It was tested with Python 3.8, 3.9, 3.10, 3.11, 3.12, 3.13. # Authors From 6a47e0a09337727c452ef4681e6bd7b295f66695 Mon Sep 17 00:00:00 2001 From: Dave T <17680170+davet2001@users.noreply.github.com> Date: Thu, 9 Jan 2025 22:52:13 +0000 Subject: [PATCH 32/32] Add TEMPer2_M12_V1.3 --- temperusb/device_library.py | 5 +++++ tests/test_temper.py | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/temperusb/device_library.py b/temperusb/device_library.py index d1f0b26..90cdebb 100644 --- a/temperusb/device_library.py +++ b/temperusb/device_library.py @@ -99,6 +99,11 @@ def __init__( hum_sens_offsets=None, type=TemperType.FM75, ), + "TEMPer2_M12_V1.3": TemperConfig( + temp_sens_offsets=[2, 4], + hum_sens_offsets=None, + type=TemperType.FM75, + ), # The config used if the sensor type is not recognised. # If your sensor is working but showing as unrecognised, please # add a new entry above based on "generic_fm75" below, and submit diff --git a/tests/test_temper.py b/tests/test_temper.py index 408269a..e0c8a59 100644 --- a/tests/test_temper.py +++ b/tests/test_temper.py @@ -66,6 +66,16 @@ [32.1], None, ], + [ + "TEMPer2_M12_V1.3", + 0x0C45, + 0x7401, + 2, + b"\x01\x80\x33\x01\x00\x00\x00\x00", + b"\x00\x00\x20\x1A\x2B\x33", # 0x201A,0x2B33 converts to 32.1C, 43.2C (fm75) + [32.1, 43.2], + None, + ], [ "TEMPer1F_V1.3", # Has 1 sensor at offset 4 0x0C45,