diff --git a/aioecowitt/__init__.py b/aioecowitt/__init__.py index 45562d1..0b63348 100644 --- a/aioecowitt/__init__.py +++ b/aioecowitt/__init__.py @@ -1,4 +1,5 @@ """aioEcoWitt API wrapper.""" + from .server import EcoWittListener from .sensor import EcoWittSensor, EcoWittSensorTypes from .station import EcoWittStation diff --git a/aioecowitt/__main__.py b/aioecowitt/__main__.py index 7533551..7e49f0f 100644 --- a/aioecowitt/__main__.py +++ b/aioecowitt/__main__.py @@ -1,4 +1,5 @@ """Run local Test server.""" + from __future__ import annotations import asyncio diff --git a/aioecowitt/calc.py b/aioecowitt/calc.py index 60bfbd9..936ad43 100644 --- a/aioecowitt/calc.py +++ b/aioecowitt/calc.py @@ -1,4 +1,5 @@ """Weather datapoint calculator.""" + from __future__ import annotations import datetime as dt diff --git a/aioecowitt/sensor.py b/aioecowitt/sensor.py index dbfd535..84757e7 100644 --- a/aioecowitt/sensor.py +++ b/aioecowitt/sensor.py @@ -1,4 +1,5 @@ """Sensor and mapping data from ecowitt.""" + from __future__ import annotations import datetime as dt diff --git a/aioecowitt/server.py b/aioecowitt/server.py index a26c967..40a3476 100644 --- a/aioecowitt/server.py +++ b/aioecowitt/server.py @@ -1,4 +1,5 @@ """aioEcoWitt API server.""" + from __future__ import annotations import logging diff --git a/aioecowitt/station.py b/aioecowitt/station.py index 89e3c69..db3cf8a 100644 --- a/aioecowitt/station.py +++ b/aioecowitt/station.py @@ -1,4 +1,5 @@ """Station mapping from ecowitt.""" + from __future__ import annotations from dataclasses import dataclass, field diff --git a/misc/fake_client.py b/misc/fake_client.py index b37f55a..18a8f62 100644 --- a/misc/fake_client.py +++ b/misc/fake_client.py @@ -1,90 +1,91 @@ """ A bone-simple fake client used to test the hass integration """ + import http.client import sys import urllib.parse -MY_PASSKEY = '34271334ED1FADA6D8B988B14267E55D' +MY_PASSKEY = "34271334ED1FADA6D8B988B14267E55D" # MY_PASSKEY = '35271334ED1FADA7D8B988B22222E22D' paramset_a = { - 'PASSKEY': MY_PASSKEY, - 'stationtype': 'EasyWeatherV1.4.9', - 'dateutc': '2020-11-13+17:10:24', - 'tempinf': 76.8, - 'humidityin': 22, - 'baromrelin': 28.760, - 'baromabsin': 28.760, - 'tempf': 65.8, - 'humidity': 24, - 'winddir': 319, - 'windspeedmph': 0.9, - 'windgustmph': 1.1, - 'rainratein': 0.000, - 'eventrainin': 0.000, - 'dailyrainin': 0.000, - 'weeklyrainin': 0.024, - 'monthlyrainin': 0.028, - 'yearlyrainin': 0.843, - 'solarradiation': 375.53, - 'uv': 3, - 'pm25_ch1': 8.0, - 'pm25_avg_24h_ch1': 5.2, - 'freq': '915M', - 'model': 'HP3500_V1.6.2', - 'leak_ch1': 0, - 'leakbatt1': 5, + "PASSKEY": MY_PASSKEY, + "stationtype": "EasyWeatherV1.4.9", + "dateutc": "2020-11-13+17:10:24", + "tempinf": 76.8, + "humidityin": 22, + "baromrelin": 28.760, + "baromabsin": 28.760, + "tempf": 65.8, + "humidity": 24, + "winddir": 319, + "windspeedmph": 0.9, + "windgustmph": 1.1, + "rainratein": 0.000, + "eventrainin": 0.000, + "dailyrainin": 0.000, + "weeklyrainin": 0.024, + "monthlyrainin": 0.028, + "yearlyrainin": 0.843, + "solarradiation": 375.53, + "uv": 3, + "pm25_ch1": 8.0, + "pm25_avg_24h_ch1": 5.2, + "freq": "915M", + "model": "HP3500_V1.6.2", + "leak_ch1": 0, + "leakbatt1": 5, } paramset_b = { - 'PASSKEY': MY_PASSKEY, - 'stationtype': 'EasyWeatherV1.5.4', - 'dateutc': '2020-11-16+15:30:24', - 'tempinf': 68.7, - 'humidityin': 52, - 'baromrelin': 29.785, - 'baromabsin': 29.785, - 'tempf': 46.4, - 'humidity': 94, - 'winddir': 260, - 'winddir_avg10m': 260, - 'windspeedmph': 0.0, - 'windspdmph_avg10m': 0.0, - 'windgustmph': 0.0, - 'maxdailygust': 6.9, - 'rainratein': 0.000, - 'eventrainin': 0.118, - 'hourlyrainin': 0.000, - 'dailyrainin': 0.118, - 'weeklyrainin': 0.118, - 'monthlyrainin': 0.378, - 'yearlyrainin': 6.268, - 'solarradiation': 0.00, - 'uv': 0, - 'soilmoisture1': 0, - 'soilad1': 120, - 'wh65batt': 1, - 'wh25batt': 0, - 'console_batt': 2.5, - 'soilbatt1': 1.5, - 'leak_ch1': 0, - 'leakbatt1': 5, - 'leak_ch2': 1, - 'leakbatt2': 3, - 'tf_co2': 56.7, - 'humi_co2': 72, - 'pm25_co2': 24.7, - 'pm25_24h_co2': 29.4, - 'pm10_co2': 24.7, - 'pm10_24h_co2': 29.9, - 'co2': 455, - 'co2_24h': 464, - 'co2_batt': 6, - 'tf_ch1': 71.1, - 'tf_batt1': 1.40, - 'freq': '868M', - 'model': 'HP1000SE-PRO_Pro_V1.6.0', + "PASSKEY": MY_PASSKEY, + "stationtype": "EasyWeatherV1.5.4", + "dateutc": "2020-11-16+15:30:24", + "tempinf": 68.7, + "humidityin": 52, + "baromrelin": 29.785, + "baromabsin": 29.785, + "tempf": 46.4, + "humidity": 94, + "winddir": 260, + "winddir_avg10m": 260, + "windspeedmph": 0.0, + "windspdmph_avg10m": 0.0, + "windgustmph": 0.0, + "maxdailygust": 6.9, + "rainratein": 0.000, + "eventrainin": 0.118, + "hourlyrainin": 0.000, + "dailyrainin": 0.118, + "weeklyrainin": 0.118, + "monthlyrainin": 0.378, + "yearlyrainin": 6.268, + "solarradiation": 0.00, + "uv": 0, + "soilmoisture1": 0, + "soilad1": 120, + "wh65batt": 1, + "wh25batt": 0, + "console_batt": 2.5, + "soilbatt1": 1.5, + "leak_ch1": 0, + "leakbatt1": 5, + "leak_ch2": 1, + "leakbatt2": 3, + "tf_co2": 56.7, + "humi_co2": 72, + "pm25_co2": 24.7, + "pm25_24h_co2": 29.4, + "pm10_co2": 24.7, + "pm10_24h_co2": 29.9, + "co2": 455, + "co2_24h": 464, + "co2_batt": 6, + "tf_ch1": 71.1, + "tf_batt1": 1.40, + "freq": "868M", + "model": "HP1000SE-PRO_Pro_V1.6.0", } @@ -101,12 +102,12 @@ def usage(): port = sys.argv[2] # add a sensor - if len(sys.argv) > 3 and sys.argv[3] == 'add': - paramset_b['humidity2'] = 21 + if len(sys.argv) > 3 and sys.argv[3] == "add": + paramset_b["humidity2"] = 21 print("Connecting to host {0} on port {0}".format(host, port)) conn = http.client.HTTPConnection(host, port) - headers = {'Content-type': 'application/x-www-form-urlencoded'} + headers = {"Content-type": "application/x-www-form-urlencoded"} params = urllib.parse.urlencode(paramset_b) print(params) conn.request("POST", "", params, headers) diff --git a/requirements_tests.txt b/requirements_tests.txt index 299e0a6..3b23521 100644 --- a/requirements_tests.txt +++ b/requirements_tests.txt @@ -1,7 +1,7 @@ pytest==8.1.0 pytest-aiohttp==1.0.5 pytest-timeout==2.2.0 -black==23.12.1 +black==24.2.0 flake8==7.0.0 isort==5.13.2 mypy==1.8.0 diff --git a/setup.py b/setup.py index ef64d3e..a1b4cda 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,5 @@ """Setup module for EcoWitt.""" + from pathlib import Path from setuptools import find_packages, setup diff --git a/tests/test_sensor.py b/tests/test_sensor.py index 8300e9a..24e7c2b 100644 --- a/tests/test_sensor.py +++ b/tests/test_sensor.py @@ -1,4 +1,5 @@ """Test ecowitt sensor module.""" + import pytest from aioecowitt import server