Skip to content

Commit

Permalink
24.08.0 (#450)
Browse files Browse the repository at this point in the history
- Fixed an issue with thing re-sync
- Updated number parsing logic
- ``ItemTimeSeriesEvent`` gets ignored
- Removed verbose error messages when openHAB server disconnects
- Updated dependencies
- Reformatted some files
  • Loading branch information
spacemanspiff2007 authored Aug 1, 2024
1 parent 5ccb2d6 commit b24f93c
Show file tree
Hide file tree
Showing 262 changed files with 1,292 additions and 894 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish-dockerhub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
jobs:
buildx:
runs-on: ubuntu-latest
environment: release
environment: dockerhub

steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
build-n-publish:
name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI
runs-on: ubuntu-latest
environment: release
environment: pypi
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run-tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- uses: pre-commit/[email protected].0
- uses: pre-commit/[email protected].1


tests:
Expand Down
27 changes: 9 additions & 18 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: check-ast
- id: check-builtin-literals
Expand All @@ -14,24 +14,15 @@ repos:
- id: trailing-whitespace


# - repo: https://github.com/pycqa/isort
# rev: 5.11.4
# hooks:
# - id: isort
# name: isort (python)


- repo: https://github.com/PyCQA/flake8
rev: '7.0.0'
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.0
hooks:
- id: flake8
# additional_dependencies:
# - flake8-bugbear==23.1.14
# - flake8-comprehensions==3.10.1
# - flake8-pytest-style==1.6
# - flake8-unused-arguments==0.0.12
# - flake8-noqa==1.3
# - pep8-naming==0.13.3
- id: ruff
# I001 [*] Import block is un-sorted or un-formatted
# UP035 [*] Import from {target} instead: {names}
# Q000 [*] Double quote found but single quotes preferred
# Q001 [*] Double quote multiline found but single quotes preferred
args: [ "--select", "I001,UP035,Q000,Q001", "--fix"]


- repo: https://github.com/pre-commit/pygrep-hooks
Expand Down
8 changes: 6 additions & 2 deletions .ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ indent-width = 4
target-version = "py38"
src = ["src", "test"]

# https://docs.astral.sh/ruff/settings/#ignore-init-module-imports
ignore-init-module-imports = true

extend-exclude = [
"__init__.py",
"src/__test_*.py"
]

[lint]
select = [
"E", "W", # https://docs.astral.sh/ruff/rules/#pycodestyle-e-w
"I", # https://docs.astral.sh/ruff/rules/#isort-i
Expand Down Expand Up @@ -57,6 +56,11 @@ ignore = [
quote-style = "single"


# https://docs.astral.sh/ruff/settings/#lintflake8-quotes
[lint.flake8-quotes]
inline-quotes = "single"
multiline-quotes = "single"


[lint.flake8-builtins]
builtins-ignorelist = ["id", "input"]
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def log(msg: str):
# Post processing of default value

regex_path = re.compile(r"^\w+Path\('([^']+)'\)")
assert regex_path.search('WindowsPath(\'lib\')').group(1) == 'lib'
assert regex_path.search("WindowsPath('lib')").group(1) == 'lib'

regex_item = re.compile(r'(class \w+Item)\(.+\)')

Expand Down
6 changes: 3 additions & 3 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Packages required to build the documentation
sphinx == 7.2.6
sphinx-autodoc-typehints == 2.0.0
sphinx == 7.4.7
sphinx-autodoc-typehints == 2.2.3
sphinx_rtd_theme == 2.0.0
sphinx-exec-code == 0.12
autodoc_pydantic == 2.0.1
autodoc_pydantic == 2.2.0
sphinx-copybutton == 0.5.2
8 changes: 8 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,14 @@ MyOpenhabRule()
```

# Changelog
#### 24.08.0 (2024-08-01)
- Fixed an issue with thing re-sync
- Updated number parsing logic
- ``ItemTimeSeriesEvent`` gets ignored
- Removed verbose error messages when openHAB server disconnects
- Updated dependencies
- Reformatted some files

#### 24.02.0 (2024-02-14)
- For openHAB >= 4.1 it's possible to wait for a minimum openHAB uptime before connecting (defaults to 60s)
- Renamed config entry mqtt.connection.client_id to identifier (backwards compatible)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# Packages for source formatting
# -----------------------------------------------------------------------------
pre-commit == 3.5.0 # 3.6.0 requires python >= 3.10
ruff == 0.2.1
ruff == 0.5.0

# -----------------------------------------------------------------------------
# Packages for other developement tasks
Expand Down
16 changes: 9 additions & 7 deletions requirements_setup.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
aiohttp == 3.9.3
pydantic == 2.6.1
aiohttp == 3.10.0
pydantic == 2.8.2
msgspec == 0.18.6
bidict == 0.22.1
watchdog == 4.0.0
ujson == 5.9.0
aiomqtt == 2.0.0
bidict == 0.23.1
watchdog == 4.0.1
ujson == 5.10.0
aiomqtt == 2.2.0

immutables == 0.20
eascheduler == 0.1.11
easyconfig == 0.3.2
pendulum == 2.1.2
stack_data == 0.6.3
colorama == 0.4.6
fastnumbers == 5.1.0


voluptuous == 0.14.2

typing-extensions == 4.9.0
typing-extensions == 4.12.2

aiohttp-sse-client == 0.2.1

Expand Down
6 changes: 3 additions & 3 deletions requirements_tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
# -----------------------------------------------------------------------------
# Packages to run source tests
# -----------------------------------------------------------------------------
packaging == 23.2
pytest == 7.4.4
pytest-asyncio == 0.23.4
packaging == 24.1
pytest == 8.3.2
pytest-asyncio == 0.23.8
2 changes: 1 addition & 1 deletion run/conf_testing/lib/HABAppTests/event_waiter.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def wait_for_event(self, **kwargs) -> EVENT_TYPE:
time.sleep(0.02)

if time.time() > start + self.timeout:
expected_values = "with " + ", ".join([f"{__k}={__v}" for __k, __v in kwargs.items()]) if kwargs else ""
expected_values = 'with ' + ', '.join([f'{__k}={__v}' for __k, __v in kwargs.items()]) if kwargs else ''
msg = f'Timeout while waiting for {self.event_filter.describe()} for {self.name} {expected_values}'
raise TestCaseFailed(msg)

Expand Down
2 changes: 1 addition & 1 deletion run/conf_testing/lib/HABAppTests/item_waiter.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def wait_for_attribs(self, **kwargs):
f'{name:>{indent:d}s}: {get_equal_text(getattr(self.item, name), target)}'
for name, target in kwargs.items()
]
failed_msg = "\n".join(failed)
failed_msg = '\n'.join(failed)
msg = f'Timeout waiting for {self.item.name}!\n{failed_msg}'
raise TestCaseFailed(msg)

Expand Down
6 changes: 3 additions & 3 deletions run/conf_testing/lib/HABAppTests/openhab_tmp_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ def __exit__(self, exc_type, exc_val, exc_tb):
def remove(self):
HABApp.openhab.interface_sync.remove_item(self.name)

def _create(self, label="", category="", tags: List[str] = [], groups: List[str] = [],
def _create(self, label='', category='', tags: List[str] = [], groups: List[str] = [],
group_type: str = '', group_function: str = '',
group_function_params: List[str] = []):
interface = HABApp.openhab.interface_sync
interface.create_item(self.type, self.name, label=label, category=category,
tags=tags, groups=groups, group_type=group_type,
group_function=group_function, group_function_params=group_function_params)

def create_item(self, label="", category="", tags: List[str] = [], groups: List[str] = [],
def create_item(self, label='', category='', tags: List[str] = [], groups: List[str] = [],
group_type: str = '', group_function: str = '',
group_function_params: List[str] = []) -> HABApp.openhab.items.OpenhabItem:

Expand All @@ -75,7 +75,7 @@ def create_item(self, label="", category="", tags: List[str] = [], groups: List[

return HABApp.openhab.items.OpenhabItem.get_item(self.name)

def modify(self, label="", category="", tags: List[str] = [], groups: List[str] = [],
def modify(self, label='', category='', tags: List[str] = [], groups: List[str] = [],
group_type: str = '', group_function: str = '', group_function_params: List[str] = []):

with EventWaiter(TOPIC_ITEMS, HABApp.core.events.EventFilter(HABApp.openhab.events.ItemUpdatedEvent)) as w:
Expand Down
3 changes: 2 additions & 1 deletion run/conf_testing/lib/HABAppTests/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import datetime
import itertools


# we only support milliseconds on openHAB side
now = datetime.datetime.now()
now = now.replace(microsecond=now.microsecond // 1000 * 1000)
Expand All @@ -17,7 +18,7 @@
'Dimmer': [0, 100, 55.5],
'Location': [(1, 2, 3), (-1.1, 2.2, 3.3), (5, 6)],
'Number': [-111, 222, -13.13, 55.55],
'Player': ["PLAY", "PAUSE", "REWIND", "FASTFORWARD"],
'Player': ['PLAY', 'PAUSE', 'REWIND', 'FASTFORWARD'],
'Rollershutter': [0, 100, 30.5],
'String': ['A', 'B', 'C', '', 'öäüß'],
'Switch': ['ON', 'OFF'],
Expand Down
2 changes: 2 additions & 0 deletions run/conf_testing/lib/HABAppTests/test_rule/_rule_ids.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
import typing

import HABAppTests

from ._rule_status import TestRuleStatus


LOCK = threading.Lock()


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import HABApp
from HABAppTests.errors import TestCaseFailed, TestCaseWarning


log = logging.getLogger('HABApp.Tests')


Expand Down
9 changes: 5 additions & 4 deletions run/conf_testing/lib/HABAppTests/test_rule/test_rule.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import logging
from pathlib import Path
from typing import Dict, Callable
from typing import List
from typing import Callable, Dict, List

import HABApp
from HABAppTests.test_rule.test_case import TestResult, TestResultStatus, TestCase
from ._rule_ids import get_test_rules, get_next_id, test_rules_running
from HABAppTests.test_rule.test_case import TestCase, TestResult, TestResultStatus

from ._rule_ids import get_next_id, get_test_rules, test_rules_running
from ._rule_status import TestRuleStatus


log = logging.getLogger('HABApp.Tests')


Expand Down
2 changes: 1 addition & 1 deletion run/conf_testing/lib/HABAppTests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def run_coro(coro: typing.Coroutine):
def find_astro_sun_thing() -> str:
items = HABApp.core.Items.get_items()
for item in items:
if isinstance(item, Thing) and item.name.startswith("astro:sun"):
if isinstance(item, Thing) and item.name.startswith('astro:sun'):
return item.name

raise ValueError('No astro thing found!')
Expand Down
6 changes: 4 additions & 2 deletions run/conf_testing/rules/habapp/test_event_listener.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import logging

from HABAppTests import TestBaseRule, get_random_name

from HABApp.core.events import ValueChangeEventFilter
from HABApp.core.items import Item
from HABApp.util import EventListenerGroup
from HABAppTests import TestBaseRule, get_random_name
from HABApp.rule_ctx import HABAppRuleContext
from HABApp.util import EventListenerGroup


log = logging.getLogger('HABApp.Tests.MultiMode')

Expand Down
6 changes: 4 additions & 2 deletions run/conf_testing/rules/habapp/test_group_listener.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import logging
import time

from HABAppTests import TestBaseRule
from HABAppTests.errors import TestCaseFailed

from HABApp.core.events import ValueUpdateEventFilter
from HABApp.core.items import Item
from HABApp.util import EventListenerGroup
from HABAppTests import TestBaseRule
from HABAppTests.errors import TestCaseFailed


log = logging.getLogger('HABApp.Tests.MultiMode')

Expand Down
12 changes: 9 additions & 3 deletions run/conf_testing/rules/habapp/test_habapp.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import time

from HABAppTests import EventWaiter, TestBaseRule, get_random_name

import HABApp
from HABApp.core.events import ItemNoUpdateEvent, ItemNoChangeEvent, ValueUpdateEvent, EventFilter, \
ValueUpdateEventFilter
from HABApp.core.events import (
EventFilter,
ItemNoChangeEvent,
ItemNoUpdateEvent,
ValueUpdateEvent,
ValueUpdateEventFilter,
)
from HABApp.core.items import Item
from HABAppTests import TestBaseRule, EventWaiter, get_random_name


class TestItemEvents(TestBaseRule):
Expand Down
4 changes: 3 additions & 1 deletion run/conf_testing/rules/habapp/test_parameter_files.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import logging

import HABApp
from HABAppTests import TestBaseRule

import HABApp


log = logging.getLogger('HABApp.TestParameterFiles')

# User Parameter files to create rules dynamically
Expand Down
3 changes: 2 additions & 1 deletion run/conf_testing/rules/habapp/test_rule_context.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from time import sleep

from HABAppTests import TestBaseRule

from HABApp import Rule
from HABApp.core.internals import get_current_context
from HABAppTests import TestBaseRule


class OtherRule(Rule):
Expand Down
4 changes: 3 additions & 1 deletion run/conf_testing/rules/habapp/test_scheduler.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import logging
import time

from HABAppTests import TestBaseRule, get_random_name

from HABApp.core.events import ValueUpdateEventFilter
from HABApp.core.items import Item
from HABAppTests import TestBaseRule, get_random_name


log = logging.getLogger('HABApp.TestParameterFiles')

Expand Down
3 changes: 2 additions & 1 deletion run/conf_testing/rules/habapp/test_util_fade.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import time

from HABAppTests import ItemWaiter, TestBaseRule

from HABApp.core.items import Item
from HABApp.util.fade.fade import Fade
from HABAppTests import ItemWaiter, TestBaseRule


class TestFadeRun(TestBaseRule):
Expand Down
Loading

0 comments on commit b24f93c

Please sign in to comment.