Skip to content

Commit

Permalink
Correct major deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
PoppyPop committed Jan 3, 2025
1 parent 3cedaf0 commit 3165564
Show file tree
Hide file tree
Showing 12 changed files with 283 additions and 292 deletions.
2 changes: 1 addition & 1 deletion .devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "homeassistat_ecowitt",
"image": "mcr.microsoft.com/vscode/devcontainers/python:0-3.10-bullseye",
"image": "mcr.microsoft.com/devcontainers/python:3.12",
"postCreateCommand": "scripts/setup",
"forwardPorts": [8123],
"portsAttributes": {
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/constraints.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
pre-commit==2.18.1
black==22.3.0
flake8==4.0.1
reorder-python-imports==3.0.1
pre-commit==4.0.1
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ coverage.xml
# Home Assistant configuration
config/*
!config/configuration.yaml

.ruff_cache
29 changes: 9 additions & 20 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,31 +1,20 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.3.0
rev: v5.0.0
hooks:
- id: check-added-large-files
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: local
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.6.4
hooks:
- id: black
name: black
entry: black
language: system
types: [python]
require_serial: true
- id: flake8
name: flake8
entry: flake8
language: system
types: [python]
require_serial: true
- id: reorder-python-imports
name: Reorder python imports
entry: reorder-python-imports
language: system
types: [python]
args: [--application-directories=custom_components]
# Run the linter.
- id: ruff
args: [--fix]
# Run the formatter.
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.2.1
hooks:
Expand Down
11 changes: 6 additions & 5 deletions .ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

target-version = "py310"

select = [
lint.select = [
"B007", # Loop control variable {name} not used within loop body
"B014", # Exception handler with duplicate exception
"C", # complexity
Expand All @@ -26,7 +26,7 @@ select = [
"W", # pycodestyle
]

ignore = [
lint.ignore = [
"D202", # No blank lines allowed after function docstring
"D203", # 1 blank line required before class docstring
"D213", # Multi-line docstring summary should start at the second line
Expand All @@ -36,15 +36,16 @@ ignore = [
"D411", # Missing blank line before section
"E501", # line too long
"E731", # do not assign a lambda expression, use a def
"C901",
]

exclude = ["tests/fake_client.py"]

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

[pyupgrade]
[lint.pyupgrade]
keep-runtime-typing = true

[mccabe]
[lint.mccabe]
max-complexity = 25
39 changes: 24 additions & 15 deletions custom_components/integration_ecowitt/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""The Ecowitt Weather Station Component."""

import asyncio
import logging
import time
Expand Down Expand Up @@ -71,9 +72,9 @@ async def async_setup(hass: HomeAssistant, config: dict):
if CONF_UNIT_WIND not in config[DOMAIN]:
config[DOMAIN][CONF_UNIT_WIND] = hass.config.units.wind_speed_unit
if CONF_UNIT_RAIN not in config[DOMAIN]:
config[DOMAIN][
CONF_UNIT_RAIN
] = hass.config.units.accumulated_precipitation_unit
config[DOMAIN][CONF_UNIT_RAIN] = (
hass.config.units.accumulated_precipitation_unit
)
if CONF_UNIT_LIGHTNING not in config[DOMAIN]:
config[DOMAIN][CONF_UNIT_LIGHTNING] = hass.config.units.length_unit
if CONF_UNIT_WINDCHILL not in config[DOMAIN]:
Expand Down Expand Up @@ -103,6 +104,10 @@ async def async_setup(hass: HomeAssistant, config: dict):
return True


async def async_update_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Set up the Ecowitt component from UI."""


async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Set up the Ecowitt component from UI."""

Expand Down Expand Up @@ -131,13 +136,16 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
ecowitt_data[REG_ENTITIES][pl] = []

if not entry.options:
entry.options = {
CONF_UNIT_BARO: hass.config.units.pressure_unit,
CONF_UNIT_WIND: hass.config.units.wind_speed_unit,
CONF_UNIT_RAIN: hass.config.units.accumulated_precipitation_unit,
CONF_UNIT_LIGHTNING: hass.config.units.length_unit,
CONF_UNIT_WINDCHILL: W_TYPE_HYBRID,
}
hass.config_entries.async_update_entry(
entry=entry,
options={
CONF_UNIT_BARO: hass.config.units.pressure_unit,
CONF_UNIT_WIND: hass.config.units.wind_speed_unit,
CONF_UNIT_RAIN: hass.config.units.accumulated_precipitation_unit,
CONF_UNIT_LIGHTNING: hass.config.units.length_unit,
CONF_UNIT_WINDCHILL: W_TYPE_HYBRID,
},
)

# preload some model info
stationinfo = ecowitt_data[DATA_STATION]
Expand Down Expand Up @@ -265,10 +273,11 @@ async def _first_data_rec():
_LOGGER.error("No sensors found to monitor, check device config.")
return False

for component in ECOWITT_PLATFORMS:
hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, component)
)
# for component in ECOWITT_PLATFORMS:
# hass.async_create_task(
# await hass.config_entries.async_forward_entry_setups(entry, component)
# )
await hass.config_entries.async_forward_entry_setups(entry, ECOWITT_PLATFORMS)

ecowitt_data[DATA_READY] = True

Expand Down Expand Up @@ -443,7 +452,7 @@ def device_info(self):
"manufacturer": DOMAIN,
"model": self._stationinfo[DATA_MODEL],
"sw_version": self._stationinfo[DATA_STATIONTYPE],
"via_device": (DOMAIN, self._stationinfo[DATA_STATIONTYPE]),
# "via_device": (DOMAIN, self._stationinfo[DATA_STATIONTYPE]),
# "frequency": self._stationinfo[DATA_FREQ],
}

Expand Down
1 change: 1 addition & 0 deletions custom_components/integration_ecowitt/binary_sensor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Support for Ecowitt Weather Stations."""

import logging

from homeassistant.components.binary_sensor import BinarySensorEntity
Expand Down
1 change: 1 addition & 0 deletions custom_components/integration_ecowitt/config_flow.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Config flow for ecowitt."""

import logging

import voluptuous as vol
Expand Down
Loading

0 comments on commit 3165564

Please sign in to comment.