Skip to content
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
37 changes: 37 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Release to PyPI

on:
release:
types:
- published

jobs:
publish-to-pypi:
runs-on: ubuntu-latest
permissions:
id-token: write


steps:
# Checkout the repository
- name: Checkout code
uses: actions/checkout@v4

# Set up Python
- name: Setup uv
uses: astral-sh/setup-uv@v6
with:
version: "0.7.8"
enable-cache: true
cache-dependency-glob: |
pyproject.toml

- name: Build package distributions
run: uv build

# Publish to PyPI
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/

6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Code Quality Checks
name: Lint/Test

on:
push:
Expand Down Expand Up @@ -41,7 +41,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.8, 3.9, 3.10, 3.11, 3.12, 3.13]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]

steps:
- name: Checkout code
Expand All @@ -59,7 +59,7 @@ jobs:
- name: Run pytest
run: uv run python -m pytest --cov=python_cayennelpp tests/ --cov-report=xml

- name: Code ./coverage1.xml
- name: Code Coverage
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Open-source library for python to decode CayenneLPP format payload.
The Cayenne Low Power Payload (LPP) provides a convenient and easy way to send data over LPWAN networks such as LoRaWAN.
More details on CayenneLPP payload: https://github.com/myDevicesIoT/cayenne-docs

> Note: while Python versions 2.7 and <=3.7 may work, they're not officially supported since they're EOL.

## Installation

To install the package use next pip command
Expand All @@ -23,6 +25,7 @@ To decode payload simply use method decode() from this package
>>>print(decode('03670110056700FF'))
[{'channel': 3, 'name': 'Temperature Sensor', 'value': 27.2}, {'channel': 5, 'name': 'Temperature Sensor', 'value': 25.5}]
```

## Additional info
The package may raise following exceptions:
- `TypeError` - if the provided data is not of the `str` type
Expand Down
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,8 @@ dev = [
"ruff>=0.11.12",
]

[[tool.uv.index]]
name = "testpypi"
url = "https://test.pypi.org/simple/"
publish-url = "https://test.pypi.org/legacy/"
explicit = true
2 changes: 2 additions & 0 deletions python_cayennelpp/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
"""Python CayenneLPP decoder library."""

__version__ = "0.0.5"
4 changes: 2 additions & 2 deletions python_cayennelpp/decoder.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Main decoder for CayenneLPP payload format."""

import logging
from typing import Any
from typing import Any, Dict, List
from python_cayennelpp.methods import hex_library

logger = logging.getLogger(__name__)
Expand All @@ -26,7 +26,7 @@ def decode(payload: str):
)
# parsing payload using hex_library.
# variable pointer represents caret in line to cut. result is returned result
result: list[dict[str, Any]] = []
result: List[Dict[str, Any]] = []
pointer = 0
try:
while pointer < len(payload):
Expand Down
4 changes: 2 additions & 2 deletions python_cayennelpp/methods.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""This module contains methods to decode CayenneLPP sensor data."""

from typing import Any
from typing import Any, Dict


def hex_to_int(hex_string: str, signed: bool = True):
Expand Down Expand Up @@ -114,7 +114,7 @@ def gps_location(data: str):
}


hex_library: dict[str, dict[str, Any]] = {
hex_library: Dict[str, Dict[str, Any]] = {
"00": {
"name": "Digital Input",
"size": 2,
Expand Down