diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 396f7d5..a339b1e 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -1,10 +1,9 @@ --- name: Bug report about: Create a report to help us improve -title: '' -labels: '' -assignees: '' - +title: "" +labels: "" +assignees: "" --- Before reporting a bug, make sure you are running the latest version of `tekmar-packetserv` add-on and the `tekmar-482` integration. @@ -22,9 +21,10 @@ If applicable, add screenshots of the problem and/or configuration. Copy any log messages/errors from the Home Assistant add-on logs. **Home Assistant (please complete the following information):** - - Home Assistant Core Version: - - Gateway 482 Firmware Version: - - Gateway 482 Protocol Version: + +- Home Assistant Core Version: +- Gateway 482 Firmware Version: +- Gateway 482 Protocol Version: **Additional context** Add any other context about the problem here. diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index fbb5822..7de6e89 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -1,4 +1,4 @@ -name: Lint +name: Add-on Lint on: push: diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml new file mode 100644 index 0000000..b7b1544 --- /dev/null +++ b/.github/workflows/linter.yml @@ -0,0 +1,30 @@ +--- +name: Lint Code Base +on: + push: + pull_request: + branches: + - main +permissions: read-all +jobs: + build: + name: Lint Code Base + runs-on: ubuntu-latest + permissions: + contents: read + packages: read + statuses: write + steps: + - name: Checkout Code + uses: actions/checkout@v5 + with: + fetch-depth: 0 + - name: Lint Code Base + uses: github/super-linter@v7 + env: + VALIDATE_ALL_CODEBASE: true + VALIDATE_JSCPD: false + VALIDATE_PYTHON_MYPY: false + VALIDATE_PYTHON_PYLINT: false + DEFAULT_BRANCH: main + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/README.md b/README.md index 6229310..20ebf18 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # Tekmar Packet Server (tekmar-packetserv) + ![Supports aarch64 Architecture][aarch64-shield] ![Supports amd64 Architecture][amd64-shield] @@ -31,7 +32,7 @@ This Add-On is part of the Tekmar 482 Integration. Install this integration toge ## Credits Implemented using "tN4 Gateway 482 - Custom Integration Tools" and "Tekmar Home Automation -(tHA) Protocol" from: https://www.watts.com/products/hvac-hot-water-solutions/controls/control-accessories/482/482 +(tHA) Protocol" from: [https://www.watts.com/products/hvac-hot-water-solutions/controls/control-accessories/482/482](https://www.watts.com/products/hvac-hot-water-solutions/controls/control-accessories/482/482) Tekmar, tekmarNet, tN4, tN2, and related logos and trademarks are copyright 2021 Watts. diff --git a/tekmar_packetserv/CHANGELOG.md b/tekmar_packetserv/CHANGELOG.md index 0647b2a..04e7998 100644 --- a/tekmar_packetserv/CHANGELOG.md +++ b/tekmar_packetserv/CHANGELOG.md @@ -4,33 +4,42 @@ - Drop support for armhf, armv7, and i386 architectures. ## 1.2.2 + - Update documentation. ## 1.2.1 + - Update S6-Overlay structure - Fixes reloading on serial port errors ## 1.2.0 + - Add Socket and RFC2217 serial options. ## 1.1.0 + - Add custom apparmor file. - S6-Overlay 3.x ## 1.0.2 + - Add EN translation. ## 1.0.1 + - Add allowed IP address (CIDR format) setting for security. ## 1.0.0 + - First stable release. ## 0.9.1 through 0.9.9 + - Fine tuning on errors. - Internal cleanup for use as add-on. - Test with bad input sent to packet server - Test for USB serial unplugged while running ## 0.9.0 + - First test version. diff --git a/tekmar_packetserv/DOCS.md b/tekmar_packetserv/DOCS.md index 55aa831..8b016b2 100644 --- a/tekmar_packetserv/DOCS.md +++ b/tekmar_packetserv/DOCS.md @@ -14,7 +14,7 @@ This Add-On requires additional hardware: This Add-On is part of the Tekmar 482 Integration. Install this integration together with the add-on: -https://github.com/WillCodeForCats/tekmar-482 +[https://github.com/WillCodeForCats/tekmar-482](https://github.com/WillCodeForCats/tekmar-482) ## Configuration @@ -32,17 +32,21 @@ communicate with the Add-On across your LAN. ### Serial Port Configuration Serial Port Mode: device + - For a locally connected USB to serial adapter Serial Port Mode: socket + - For a IP to serial port server using a TCP socket connection. Serial Port Mode: rfc2217 + - For a IP to serial port server using a TCP connection using the RFC2217 protocol. For "socket" and "rfc2217" types you will also need to configure the parameters for Serial Server IP and Serial Server Port. On IP-to-Serial servers use "9600,8,N,1" for the serial port: + - Baud Rate 9600 - Eight Bits - No Parity @@ -51,13 +55,13 @@ On IP-to-Serial servers use "9600,8,N,1" for the serial port: ## Known Issues and Limitations - If serial communications are lost the packet server won't show an error until the next -new incoming connection. + new incoming connection. - Any errors will cause the packet server to stop, and it will need to be -restarted manually or by enabling the "watchdog" option. + restarted manually or by enabling the "watchdog" option. ## Credits Implemented using "tN4 Gateway 482 - Custom Integration Tools" and "Tekmar Home Automation -(tHA) Protocol" from: https://www.watts.com/products/hvac-hot-water-solutions/controls/control-accessories/482/482 +(tHA) Protocol" from: [https://www.watts.com/products/hvac-hot-water-solutions/controls/control-accessories/482/482](https://www.watts.com/products/hvac-hot-water-solutions/controls/control-accessories/482/482) Tekmar, tekmarNet, tN4, tN2, and related logos and trademarks are copyright 2021 Watts. diff --git a/tekmar_packetserv/Dockerfile b/tekmar_packetserv/Dockerfile index be2c7dc..34e68b8 100755 --- a/tekmar_packetserv/Dockerfile +++ b/tekmar_packetserv/Dockerfile @@ -3,14 +3,31 @@ FROM ${BUILD_FROM} ENV LANG=C.UTF-8 -ARG TEMPIO_VERSION BUILD_ARCH +ARG TEMPIO_VERSION +ARG BUILD_ARCH + +# Install tempio and Python dependencies in a single layer RUN \ + # Install system packages + apk add --no-cache \ + python3 \ + py3-pip \ + curl && \ + # Download and install tempio with error handling curl -sSLf -o /usr/bin/tempio \ - "https://github.com/home-assistant/tempio/releases/download/${TEMPIO_VERSION}/tempio_${BUILD_ARCH}" - -# Install requirements for add-on -RUN apk add --no-cache python3 -RUN apk add --no-cache py3-pip -RUN pip3 --no-cache-dir install pyserial + "https://github.com/home-assistant/tempio/releases/download/${TEMPIO_VERSION}/tempio_${BUILD_ARCH}" || \ + (echo "ERROR: Failed to download tempio from GitHub releases" && \ + echo "URL: https://github.com/home-assistant/tempio/releases/download/${TEMPIO_VERSION}/tempio_${BUILD_ARCH}" && \ + echo "TEMPIO_VERSION: ${TEMPIO_VERSION}" && \ + echo "BUILD_ARCH: ${BUILD_ARCH}" && \ + exit 1) && \ + # Verify the download was successful and file exists + test -f /usr/bin/tempio || \ + (echo "ERROR: tempio binary was not downloaded successfully" && exit 1) && \ + chmod +x /usr/bin/tempio && \ + # Install Python packages + pip3 --no-cache-dir install pyserial==3.5 && \ + # Clean up + rm -rf /var/cache/apk/* COPY rootfs / diff --git a/tekmar_packetserv/README.md b/tekmar_packetserv/README.md index 4f3f598..eba78ab 100644 --- a/tekmar_packetserv/README.md +++ b/tekmar_packetserv/README.md @@ -4,11 +4,11 @@ This is a Home Assistant Add-On used by the [Tekmar Gateway 482 Integration](htt Install this integration together with the add-on: -https://github.com/WillCodeForCats/tekmar-482 +[https://github.com/WillCodeForCats/tekmar-482](https://github.com/WillCodeForCats/tekmar-482) -### Credits +## Credits Implemented using "tN4 Gateway 482 - Custom Integration Tools" and "Tekmar Home Automation -(tHA) Protocol" from: https://www.watts.com/products/hvac-hot-water-solutions/controls/control-accessories/482/482 +(tHA) Protocol" from: [https://www.watts.com/products/hvac-hot-water-solutions/controls/control-accessories/482/482](https://www.watts.com/products/hvac-hot-water-solutions/controls/control-accessories/482/482) Tekmar, tekmarNet, tN4, tN2, and related logos and trademarks are copyright 2021 Watts. diff --git a/tekmar_packetserv/rootfs/usr/local/packetserv/fields.py b/tekmar_packetserv/rootfs/usr/local/packetserv/fields.py index 0673b58..9d1951e 100755 --- a/tekmar_packetserv/rootfs/usr/local/packetserv/fields.py +++ b/tekmar_packetserv/rootfs/usr/local/packetserv/fields.py @@ -1,22 +1,21 @@ -""" Field identifying and parsing. +"""Field identifying and parsing. - The contents of this module allow the specifcation of formats of arrays - of bytes (similar to the python's struct module), but with more - granularity. +The contents of this module allow the specifcation of formats of arrays +of bytes (similar to the python's struct module), but with more +granularity. - Each field basically has two properties: a name and a size (in bytes). +Each field basically has two properties: a name and a size (in bytes). - Each field has basically two methods: pack and unpack. +Each field has basically two methods: pack and unpack. - The unpack method takes a sequence of bytes and unpacks the data into - a list of values. The method returns the unpacked list and any trailing - (packed) data as a tuple. - - The pack method takes a sequence of values and packs them into a list of - bytes. The method returns the packed list and any extra values as a - tuple. - """ +The unpack method takes a sequence of bytes and unpacks the data into +a list of values. The method returns the unpacked list and any trailing +(packed) data as a tuple. +The pack method takes a sequence of values and packs them into a list of +bytes. The method returns the packed list and any extra values as a +tuple. +""" # ****************************************************************************** LITTLE_ENDIAN = False diff --git a/tekmar_packetserv/rootfs/usr/local/packetserv/packet.py b/tekmar_packetserv/rootfs/usr/local/packetserv/packet.py index 5649c17..5773f40 100755 --- a/tekmar_packetserv/rootfs/usr/local/packetserv/packet.py +++ b/tekmar_packetserv/rootfs/usr/local/packetserv/packet.py @@ -1,14 +1,14 @@ -""" Packet object. +"""Packet object. - Basically a packet has a type and some data and is represented in two - forms: its raw (object) form and in string form. +Basically a packet has a type and some data and is represented in two +forms: its raw (object) form and in string form. - In string form, it looks like a sequence of hex bytes, e.g. - 0102030F\n +In string form, it looks like a sequence of hex bytes, e.g. + 0102030F\n - The 01 is the packet type and 02, 03, and 0F is the packet data. A - packet is always delimited by a newline character (in string form). - """ +The 01 is the packet type and 02, 03, and 0F is the packet data. A +packet is always delimited by a newline character (in string form). +""" # ****************************************************************************** from fields import FieldList, Int8 diff --git a/tekmar_packetserv/rootfs/usr/local/packetserv/packetserv.py b/tekmar_packetserv/rootfs/usr/local/packetserv/packetserv.py index 9e031d5..12ea111 100755 --- a/tekmar_packetserv/rootfs/usr/local/packetserv/packetserv.py +++ b/tekmar_packetserv/rootfs/usr/local/packetserv/packetserv.py @@ -1,4 +1,4 @@ -""" Packet server application. """ +"""Packet server application.""" import datetime import ipaddress diff --git a/tekmar_packetserv/rootfs/usr/local/packetserv/tpck.py b/tekmar_packetserv/rootfs/usr/local/packetserv/tpck.py index eef24fb..c779c31 100755 --- a/tekmar_packetserv/rootfs/usr/local/packetserv/tpck.py +++ b/tekmar_packetserv/rootfs/usr/local/packetserv/tpck.py @@ -1,10 +1,9 @@ -""" Allow reading and writing of packets using the tpck protocol. - - The tpck protocol provides data delimiting and validation for - communication links that can not support the simplicity of the - string-based packet transfer. - """ +"""Allow reading and writing of packets using the tpck protocol. +The tpck protocol provides data delimiting and validation for +communication links that can not support the simplicity of the +string-based packet transfer. +""" # ****************************************************************************** import packet