meteocat 4.0.0 → 4.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/ISSUE_TEMPLATE/bug_report.md +45 -45
- package/.github/ISSUE_TEMPLATE/config.yml +8 -8
- package/.github/ISSUE_TEMPLATE/improvement.md +39 -39
- package/.github/ISSUE_TEMPLATE/new_function.md +41 -41
- package/.github/labels.yml +63 -63
- package/.github/workflows/autocloser.yaml +27 -27
- package/.github/workflows/close-on-label.yml +48 -48
- package/.github/workflows/force-sync-labels.yml +18 -18
- package/.github/workflows/hassfest.yaml +13 -13
- package/.github/workflows/publish-zip.yml +67 -67
- package/.github/workflows/release.yml +41 -41
- package/.github/workflows/stale.yml +63 -63
- package/.github/workflows/sync-gitlab.yml +107 -107
- package/.github/workflows/sync-labels.yml +21 -21
- package/.github/workflows/validate.yaml +16 -16
- package/.pre-commit-config.yaml +37 -37
- package/.releaserc +37 -37
- package/AUTHORS.md +13 -13
- package/CHANGELOG.md +971 -954
- package/README.md +207 -207
- package/conftest.py +11 -11
- package/custom_components/meteocat/__init__.py +298 -298
- package/custom_components/meteocat/condition.py +63 -63
- package/custom_components/meteocat/config_flow.py +613 -613
- package/custom_components/meteocat/const.py +132 -132
- package/custom_components/meteocat/coordinator.py +248 -68
- package/custom_components/meteocat/helpers.py +58 -58
- package/custom_components/meteocat/manifest.json +25 -25
- package/custom_components/meteocat/options_flow.py +287 -287
- package/custom_components/meteocat/sensor.py +4 -2
- package/custom_components/meteocat/strings.json +1060 -1058
- package/custom_components/meteocat/translations/ca.json +1060 -1058
- package/custom_components/meteocat/translations/en.json +1060 -1058
- package/custom_components/meteocat/translations/es.json +1060 -1058
- package/custom_components/meteocat/version.py +1 -1
- package/custom_components/meteocat/weather.py +218 -218
- package/filetree.py +48 -48
- package/filetree.txt +80 -79
- package/hacs.json +8 -8
- package/info.md +11 -11
- package/package.json +22 -22
- package/poetry.lock +3222 -3222
- package/pyproject.toml +68 -68
- package/requirements.test.txt +3 -3
- package/setup.cfg +64 -64
- package/setup.py +10 -10
- package/tests/bandit.yaml +17 -17
- package/tests/conftest.py +19 -19
- package/tests/test_init.py +9 -9
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
from datetime import datetime
|
|
4
|
-
from typing import Any
|
|
5
|
-
from .const import CONDITION_MAPPING
|
|
6
|
-
from .helpers import is_night
|
|
7
|
-
import logging
|
|
8
|
-
|
|
9
|
-
_LOGGER = logging.getLogger(__name__)
|
|
10
|
-
|
|
11
|
-
def get_condition_from_statcel(
|
|
12
|
-
codi_estatcel: Any,
|
|
13
|
-
current_time: datetime,
|
|
14
|
-
location,
|
|
15
|
-
is_hourly: bool = True
|
|
16
|
-
) -> dict:
|
|
17
|
-
"""
|
|
18
|
-
Convierte el código 'estatCel' en condición de Home Assistant.
|
|
19
|
-
|
|
20
|
-
:param codi_estatcel: Código o lista de códigos del estado del cielo.
|
|
21
|
-
:param current_time: Fecha y hora actual (datetime).
|
|
22
|
-
:param hass: Instancia de Home Assistant.
|
|
23
|
-
:param is_hourly: Indica si los datos son de predicción horaria (True) o diaria (False).
|
|
24
|
-
:return: Diccionario con la condición y el icono.
|
|
25
|
-
"""
|
|
26
|
-
|
|
27
|
-
_LOGGER.debug(
|
|
28
|
-
"Entrando en get_condition_from_statcel con codi_estatcel: %s, is_hourly: %s",
|
|
29
|
-
codi_estatcel,
|
|
30
|
-
is_hourly,
|
|
31
|
-
)
|
|
32
|
-
|
|
33
|
-
# Asegurarse de que codi_estatcel sea una lista válida
|
|
34
|
-
if codi_estatcel is None:
|
|
35
|
-
codi_estatcel = []
|
|
36
|
-
elif isinstance(codi_estatcel, int): # Convertir enteros en lista
|
|
37
|
-
codi_estatcel = [codi_estatcel]
|
|
38
|
-
|
|
39
|
-
# Determinar si es de noche
|
|
40
|
-
is_night_flag = is_night(current_time, location)
|
|
41
|
-
|
|
42
|
-
# Identificar la condición basada en el código
|
|
43
|
-
for condition, codes in CONDITION_MAPPING.items():
|
|
44
|
-
if any(code in codes for code in codi_estatcel):
|
|
45
|
-
# Ajustar para condiciones nocturnas si aplica
|
|
46
|
-
if condition == "sunny" and is_night_flag:
|
|
47
|
-
_LOGGER.debug(
|
|
48
|
-
"Códigos EstatCel: %s, Es Noche: %s, Condición Devuelta: clear-night",
|
|
49
|
-
codi_estatcel,
|
|
50
|
-
is_night_flag,
|
|
51
|
-
)
|
|
52
|
-
return {"condition": "clear-night", "icon": None}
|
|
53
|
-
|
|
54
|
-
_LOGGER.debug(
|
|
55
|
-
"Códigos EstatCel: %s, Es Noche: %s, Condición Devuelta: %s",
|
|
56
|
-
codi_estatcel,
|
|
57
|
-
is_night_flag,
|
|
58
|
-
condition,
|
|
59
|
-
)
|
|
60
|
-
return {"condition": condition, "icon": None}
|
|
61
|
-
|
|
62
|
-
# Si no coincide ningún código, devolver condición desconocida
|
|
63
|
-
return {"condition": "unknown", "icon": None}
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from datetime import datetime
|
|
4
|
+
from typing import Any
|
|
5
|
+
from .const import CONDITION_MAPPING
|
|
6
|
+
from .helpers import is_night
|
|
7
|
+
import logging
|
|
8
|
+
|
|
9
|
+
_LOGGER = logging.getLogger(__name__)
|
|
10
|
+
|
|
11
|
+
def get_condition_from_statcel(
|
|
12
|
+
codi_estatcel: Any,
|
|
13
|
+
current_time: datetime,
|
|
14
|
+
location,
|
|
15
|
+
is_hourly: bool = True
|
|
16
|
+
) -> dict:
|
|
17
|
+
"""
|
|
18
|
+
Convierte el código 'estatCel' en condición de Home Assistant.
|
|
19
|
+
|
|
20
|
+
:param codi_estatcel: Código o lista de códigos del estado del cielo.
|
|
21
|
+
:param current_time: Fecha y hora actual (datetime).
|
|
22
|
+
:param hass: Instancia de Home Assistant.
|
|
23
|
+
:param is_hourly: Indica si los datos son de predicción horaria (True) o diaria (False).
|
|
24
|
+
:return: Diccionario con la condición y el icono.
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
_LOGGER.debug(
|
|
28
|
+
"Entrando en get_condition_from_statcel con codi_estatcel: %s, is_hourly: %s",
|
|
29
|
+
codi_estatcel,
|
|
30
|
+
is_hourly,
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
# Asegurarse de que codi_estatcel sea una lista válida
|
|
34
|
+
if codi_estatcel is None:
|
|
35
|
+
codi_estatcel = []
|
|
36
|
+
elif isinstance(codi_estatcel, int): # Convertir enteros en lista
|
|
37
|
+
codi_estatcel = [codi_estatcel]
|
|
38
|
+
|
|
39
|
+
# Determinar si es de noche
|
|
40
|
+
is_night_flag = is_night(current_time, location)
|
|
41
|
+
|
|
42
|
+
# Identificar la condición basada en el código
|
|
43
|
+
for condition, codes in CONDITION_MAPPING.items():
|
|
44
|
+
if any(code in codes for code in codi_estatcel):
|
|
45
|
+
# Ajustar para condiciones nocturnas si aplica
|
|
46
|
+
if condition == "sunny" and is_night_flag:
|
|
47
|
+
_LOGGER.debug(
|
|
48
|
+
"Códigos EstatCel: %s, Es Noche: %s, Condición Devuelta: clear-night",
|
|
49
|
+
codi_estatcel,
|
|
50
|
+
is_night_flag,
|
|
51
|
+
)
|
|
52
|
+
return {"condition": "clear-night", "icon": None}
|
|
53
|
+
|
|
54
|
+
_LOGGER.debug(
|
|
55
|
+
"Códigos EstatCel: %s, Es Noche: %s, Condición Devuelta: %s",
|
|
56
|
+
codi_estatcel,
|
|
57
|
+
is_night_flag,
|
|
58
|
+
condition,
|
|
59
|
+
)
|
|
60
|
+
return {"condition": condition, "icon": None}
|
|
61
|
+
|
|
62
|
+
# Si no coincide ningún código, devolver condición desconocida
|
|
63
|
+
return {"condition": "unknown", "icon": None}
|