diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index b6804ca..eab9758 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -16,7 +16,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.12"] + python-version: ["3.7"] steps: - uses: actions/checkout@v3 @@ -27,14 +27,8 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install flake8 pytest + python -m pip install pytest if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - - name: Lint with flake8 - run: | - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - name: Test with pytest run: | pytest diff --git a/__init__.py b/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/demo.py b/demo.py index 1071667..a0ecc7a 100644 --- a/demo.py +++ b/demo.py @@ -4,7 +4,7 @@ import logging import sys -from pybls21 import S21Client +from pybls21.client import S21Client def help(): diff --git a/pybls21/__init__.py b/pybls21/__init__.py old mode 100755 new mode 100644 index 7830051..e69de29 --- a/pybls21/__init__.py +++ b/pybls21/__init__.py @@ -1 +0,0 @@ -from pybls21.client import S21Client diff --git a/pybls21/client.py b/pybls21/client.py old mode 100755 new mode 100644 index 8c289bd..60b0269 --- a/pybls21/client.py +++ b/pybls21/client.py @@ -2,13 +2,13 @@ from .constants import * from .exceptions import * -from .models import ClimateDevice, HVACMode, HVACAction, TEMP_CELSIUS, ClimateEntityFeature +from .models import ClimateDevice, ClimateEntityFeature, HVACAction, HVACMode, TEMP_CELSIUS -from typing import Callable, Optional +from typing import Callable, List, Optional from threading import Lock -def _parse_firmware_version(firmware_info: list[int]) -> str: +def _parse_firmware_version(firmware_info: List[int]) -> str: major_minor = firmware_info[0] major = (major_minor & 0xff00) >> 8 minor = major_minor & 0xff @@ -82,7 +82,7 @@ def _poll(self) -> ClimateDevice: current_fan_level: int = holding_registers[HR_SPEED_MODE] # 255 - manual temp_before_heating_x10: int = input_registers[IR_CurTEMP_SuAirIn] temp_after_heating_x10: int = input_registers[IR_CurTEMP_SuAirOut] - firmware_info: list[int] = input_registers[IR_VerMAIN_FMW_start:IR_VerMAIN_FMW_end+1] + firmware_info: List[int] = input_registers[IR_VerMAIN_FMW_start:IR_VerMAIN_FMW_end+1] operation_mode: int = holding_registers[HR_OPERATION_MODE] manual_fan_speed_percent: int = holding_registers[HR_ManualSPEED] diff --git a/pybls21/models.py b/pybls21/models.py old mode 100755 new mode 100644 index a6465c7..d0c9eb4 --- a/pybls21/models.py +++ b/pybls21/models.py @@ -1,56 +1,56 @@ -from typing import List, NamedTuple, Optional - -from enum import Enum - - -TEMP_CELSIUS: str = "°C" - - -class ClimateEntityFeature(int, Enum): - TARGET_TEMPERATURE = 1 - FAN_MODE = 8 - - -class HVACMode(str, Enum): - OFF = "off" - HEAT = "heat" - COOL = "cool" - AUTO = "auto" - FAN_ONLY = "fan_only" - - -class HVACAction(str, Enum): - COOLING = "cooling" - FAN = "fan" - HEATING = "heating" - IDLE = "idle" - OFF = "off" - - -class ClimateDevice(NamedTuple): - available: bool - name: str - unique_id: str - temperature_unit: str - precision: float - current_temperature: float - target_temperature: float - target_temperature_step: float - max_temp: float - min_temp: float - current_humidity: Optional[float] - hvac_mode: str - hvac_action: str - hvac_modes: List[str] - fan_mode: Optional[int] - fan_modes: Optional[List[int]] - supported_features: int - manufacturer: str - model: Optional[str] - sw_version: Optional[str] - is_boosting: bool - current_intake_temperature: float - manual_fan_speed_percent: int - max_fan_level: int - filter_state: int - alarm_state: int +from typing import List, NamedTuple, Optional + +from enum import Enum + + +TEMP_CELSIUS: str = "°C" + + +class ClimateEntityFeature(int, Enum): + TARGET_TEMPERATURE = 1 + FAN_MODE = 8 + + +class HVACMode(str, Enum): + OFF = "off" + HEAT = "heat" + COOL = "cool" + AUTO = "auto" + FAN_ONLY = "fan_only" + + +class HVACAction(str, Enum): + COOLING = "cooling" + FAN = "fan" + HEATING = "heating" + IDLE = "idle" + OFF = "off" + + +class ClimateDevice(NamedTuple): + available: bool + name: str + unique_id: str + temperature_unit: str + precision: float + current_temperature: float + target_temperature: float + target_temperature_step: float + max_temp: float + min_temp: float + current_humidity: Optional[float] + hvac_mode: str + hvac_action: str + hvac_modes: List[str] + fan_mode: Optional[int] + fan_modes: Optional[List[int]] + supported_features: int + manufacturer: str + model: Optional[str] + sw_version: Optional[str] + is_boosting: bool + current_intake_temperature: float + manual_fan_speed_percent: int + max_fan_level: int + filter_state: int + alarm_state: int diff --git a/pyproject.toml b/pyproject.toml deleted file mode 100644 index 1eecb10..0000000 --- a/pyproject.toml +++ /dev/null @@ -1,4 +0,0 @@ -[tool.pytest.ini_options] -addopts = [ - "--import-mode=importlib", -] \ No newline at end of file diff --git a/setup.py b/setup.py index cec627a..a205954 100755 --- a/setup.py +++ b/setup.py @@ -5,14 +5,14 @@ setuptools.setup( name="pybls21", - version="3.0.1", + version="3.0.2", author="Julius Vitkauskas", author_email="zadintuvas@gmail.com", description="An api allowing control of AC state (temperature, on/off, speed) of an Blauberg S21 device locally over TCP", long_description=long_description, long_description_content_type="text/markdown", url="https://github.com/jvitkauskas/pybls21", - packages=setuptools.find_packages(), + packages=setuptools.find_packages(exclude=["tests"]), install_requires=['pyModbusTCP>=0.2.1,<1.0'], classifiers=[ "Programming Language :: Python :: 3", diff --git a/tests/test_client.py b/tests/test_client.py index 5c1fa3a..8f7da28 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -2,9 +2,8 @@ from pyModbusTCP.server import ModbusServer, DataBank -from pybls21.constants import * -from pybls21.exceptions import * from pybls21.client import S21Client +from pybls21.constants import * from pybls21.models import HVACAction, HVACMode, ClimateDevice, ClimateEntityFeature @@ -304,6 +303,8 @@ def test_set_temperature(self): class TestDataBank(DataBank): + __test__ = False + def __init__(self): super().__init__(coils_size=25, d_inputs_size=72, h_regs_size=182, i_regs_size=51) self.reset()