Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/development' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
tmenguy committed Sep 10, 2024
2 parents 2da7edc + 6f5c8bb commit dbb3e4b
Show file tree
Hide file tree
Showing 22 changed files with 208 additions and 108 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Publish 📦 to PyPI
on:
push:
tags:
- 'v*'
- "v*"

jobs:
build-n-publish:
Expand All @@ -24,11 +24,11 @@ jobs:
- name: Build a binary wheel and a source tarball
run: >-
python -m build .
# - name: Publish 📦 to Test PyPI
# uses: pypa/gh-action-pypi-publish@master
# with:
# password: ${{ secrets.PYPI_TEST_TOKEN }}
# repository_url: https://test.pypi.org/legacy/
# - name: Publish 📦 to Test PyPI
# uses: pypa/gh-action-pypi-publish@master
# with:
# password: ${{ secrets.PYPI_TEST_TOKEN }}
# repository-url: https://test.pypi.org/legacy/
- name: Publish 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/publish-to-test-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ on:
branches:
- development


jobs:
build-n-publish:
name: Build and publish 📦 to TestPyPI
Expand All @@ -30,4 +29,4 @@ jobs:
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_TEST_TOKEN }}
repository_url: https://test.pypi.org/legacy/
repository-url: https://test.pypi.org/legacy/
25 changes: 3 additions & 22 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,20 @@ exclude: ^(fixtures/)

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.9
rev: v0.6.1
hooks:
- id: ruff
args:
- --fix

- repo: https://github.com/asottile/pyupgrade
rev: v3.16.0
hooks:
- id: pyupgrade
args: [--py310-plus]
exclude: "external_src/int-tools"

- repo: https://github.com/asottile/add-trailing-comma
rev: v3.1.0
hooks:
- id: add-trailing-comma
args: [--py36-plus]
exclude: "external_src/int-tools"

- repo: https://github.com/asottile/yesqa
rev: v1.5.0
hooks:
- id: yesqa

- repo: https://github.com/psf/black
rev: 24.4.2
rev: 24.8.0
hooks:
- id: black
language_version: python3

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.10.0
rev: v1.11.1
hooks:
- id: mypy
name: mypy
Expand Down
21 changes: 20 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Security

-

## [8.1.0]

### Added

- Expose camera person status
- Add NLE support
- Add proper energy support
- Add cooler support
- Add BNS support

## [8.0.3]

### Added

- Add NLLF centralized ventilation controller

### Fixed

- Add BNSC switch capability

## [8.0.3]

Expand Down
2 changes: 2 additions & 0 deletions fixtures/homesdata.json
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,8 @@
}
],
"therm_setpoint_default_duration": 120,
"temperature_control_mode": "cooling",
"cooling_mode": "schedule",
"persons": [
{
"id": "91827374-7e04-5298-83ad-a0cb8372dff1",
Expand Down
23 changes: 11 additions & 12 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ minversion = "7.0"
asyncio_mode = "auto"

[tool.ruff]
target-version = "py310"

[tool.ruff.lint]
select = [
"B002", # Python does not support the unary prefix increment
"B007", # Loop control variable {name} not used within loop body
Expand All @@ -23,17 +26,13 @@ select = [
"G", # flake8-logging-format
"I", # isort
"ICN001", # import concentions; {name} should be imported as {asname}
"ISC001", # Implicitly concatenated string literals on one line
"N804", # First argument of a class method should be named cls
"N805", # First argument of a method should be named self
"N815", # Variable {name} in class scope should not be mixedCase
"PGH001", # No builtin eval() allowed
"S307", # No builtin eval() allowed
"PGH004", # Use specific rule codes when using noqa
"PLC0414", # Useless import alias. Import alias does not rename original package.
"PLC", # pylint
"PLE", # pylint
"PLR", # pylint
"PLW", # pylint
"PL", # pylint
"Q000", # Double quotes found but single quotes preferred
"RUF006", # Store a reference to the return value of asyncio.create_task
"S102", # Use of exec detected
Expand Down Expand Up @@ -66,7 +65,7 @@ select = [
"T20", # flake8-print
"TID251", # Banned imports
"TRY004", # Prefer TypeError exception for invalid type
"TRY200", # Use raise from to specify exception cause
"B904", # Use raise from to specify exception cause
"TRY302", # Remove exception handler; error is immediately re-raised
"UP", # pyupgrade
"W", # pycodestyle
Expand Down Expand Up @@ -94,25 +93,25 @@ ignore = [
"UP038", # Use `X | Y` in `isinstance` call instead of `(X, Y)`
]

[tool.ruff.flake8-pytest-style]
[tool.ruff.lint.flake8-pytest-style]
fixture-parentheses = false

[tool.ruff.flake8-tidy-imports.banned-api]
[tool.ruff.lint.flake8-tidy-imports.banned-api]
"pytz".msg = "use zoneinfo instead"

[tool.ruff.isort]
[tool.ruff.lint.isort]
force-sort-within-sections = true
combine-as-imports = true
split-on-trailing-comma = false

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
# Allow for main entry & scripts to write to stdout
"src/pyatmo/__main__.py" = ["T201"]

# Exceptions for tests
"tests/*" = ["D10"]

[tool.ruff.mccabe]
[tool.ruff.lint.mccabe]
max-complexity = 25

[tool.setuptools_scm]
Expand Down
3 changes: 1 addition & 2 deletions src/pyatmo/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ def process_topology(self, disabled_homes_ids: list[str] | None = None) -> None:
disabled_homes_ids = []

for home in self.raw_data["homes"]:

home_id = home.get("id", "Unknown")
home_name = home.get("name", "Unknown")
self.all_homes_id[home_id] = home_name
Expand Down Expand Up @@ -237,7 +236,7 @@ async def update_devices(
{HOME: {"modules": [normalize_weather_attributes(device_data)]}},
)
else:
LOG.debug("No home %s found.", home_id)
LOG.debug("No home %s (%s) found.", home_id, home_id)

for module_data in device_data.get("modules", []):
module_data["home_id"] = home_id
Expand Down
3 changes: 2 additions & 1 deletion src/pyatmo/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@
SCHEDULES = "schedules"
EVENTS = "events"


STATION_TEMPERATURE_TYPE = "temperature"
STATION_PRESSURE_TYPE = "pressure"
STATION_HUMIDITY_TYPE = "humidity"
Expand All @@ -105,3 +104,5 @@

# 2 days of dynamic historical data stored
MAX_HISTORY_TIME_FRAME = 24 * 2 * 3600

UNKNOWN = "unknown"
29 changes: 28 additions & 1 deletion src/pyatmo/home.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ class Home:
persons: dict[str, Person]
events: dict[str, Event]

temperature_control_mode: str | None = None
therm_mode: str | None = None
therm_setpoint_default_duration: int | None = None
cooling_mode: str | None = None

def __init__(self, auth: AbstractAsyncAuth, raw_data: RawData) -> None:
"""Initialize a Netatmo home instance."""

Expand Down Expand Up @@ -76,6 +81,13 @@ def __init__(self, auth: AbstractAsyncAuth, raw_data: RawData) -> None:
}
self.events = {}

self.temperature_control_mode = raw_data.get("temperature_control_mode")
self.therm_mode = raw_data.get("therm_mode")
self.therm_setpoint_default_duration = raw_data.get(
"therm_setpoint_default_duration",
)
self.cooling_mode = raw_data.get("cooling_mode")

def get_module(self, module: dict) -> Module:
"""Return module."""

Expand All @@ -97,6 +109,14 @@ def update_topology(self, raw_data: RawData) -> None:
self.name = raw_data.get("name", "Unknown")

raw_modules = raw_data.get("modules", [])

self.temperature_control_mode = raw_data.get("temperature_control_mode")
self.therm_mode = raw_data.get("therm_mode")
self.therm_setpoint_default_duration = raw_data.get(
"therm_setpoint_default_duration",
)
self.cooling_mode = raw_data.get("cooling_mode")

for module in raw_modules:
if (module_id := module["id"]) not in self.modules:
self.modules[module_id] = self.get_module(module)
Expand Down Expand Up @@ -128,7 +148,9 @@ def update_topology(self, raw_data: RawData) -> None:
}

async def update(
self, raw_data: RawData, do_raise_for_reachability_error=False
self,
raw_data: RawData,
do_raise_for_reachability_error=False,
) -> None:
"""Update home with the latest data."""
has_error = False
Expand Down Expand Up @@ -204,6 +226,11 @@ def has_otm(self) -> bool:

return any("OTM" in room.device_types for room in self.rooms.values())

def has_bns(self) -> bool:
"""Check if any room has a BNS device."""

return any("BNS" in room.device_types for room in self.rooms.values())

def get_hg_temp(self) -> float | None:
"""Return frost guard temperature value for given home."""

Expand Down
Loading

0 comments on commit dbb3e4b

Please sign in to comment.