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.
Files changed (49) hide show
  1. package/.github/ISSUE_TEMPLATE/bug_report.md +45 -45
  2. package/.github/ISSUE_TEMPLATE/config.yml +8 -8
  3. package/.github/ISSUE_TEMPLATE/improvement.md +39 -39
  4. package/.github/ISSUE_TEMPLATE/new_function.md +41 -41
  5. package/.github/labels.yml +63 -63
  6. package/.github/workflows/autocloser.yaml +27 -27
  7. package/.github/workflows/close-on-label.yml +48 -48
  8. package/.github/workflows/force-sync-labels.yml +18 -18
  9. package/.github/workflows/hassfest.yaml +13 -13
  10. package/.github/workflows/publish-zip.yml +67 -67
  11. package/.github/workflows/release.yml +41 -41
  12. package/.github/workflows/stale.yml +63 -63
  13. package/.github/workflows/sync-gitlab.yml +107 -107
  14. package/.github/workflows/sync-labels.yml +21 -21
  15. package/.github/workflows/validate.yaml +16 -16
  16. package/.pre-commit-config.yaml +37 -37
  17. package/.releaserc +37 -37
  18. package/AUTHORS.md +13 -13
  19. package/CHANGELOG.md +971 -954
  20. package/README.md +207 -207
  21. package/conftest.py +11 -11
  22. package/custom_components/meteocat/__init__.py +298 -298
  23. package/custom_components/meteocat/condition.py +63 -63
  24. package/custom_components/meteocat/config_flow.py +613 -613
  25. package/custom_components/meteocat/const.py +132 -132
  26. package/custom_components/meteocat/coordinator.py +248 -68
  27. package/custom_components/meteocat/helpers.py +58 -58
  28. package/custom_components/meteocat/manifest.json +25 -25
  29. package/custom_components/meteocat/options_flow.py +287 -287
  30. package/custom_components/meteocat/sensor.py +4 -2
  31. package/custom_components/meteocat/strings.json +1060 -1058
  32. package/custom_components/meteocat/translations/ca.json +1060 -1058
  33. package/custom_components/meteocat/translations/en.json +1060 -1058
  34. package/custom_components/meteocat/translations/es.json +1060 -1058
  35. package/custom_components/meteocat/version.py +1 -1
  36. package/custom_components/meteocat/weather.py +218 -218
  37. package/filetree.py +48 -48
  38. package/filetree.txt +80 -79
  39. package/hacs.json +8 -8
  40. package/info.md +11 -11
  41. package/package.json +22 -22
  42. package/poetry.lock +3222 -3222
  43. package/pyproject.toml +68 -68
  44. package/requirements.test.txt +3 -3
  45. package/setup.cfg +64 -64
  46. package/setup.py +10 -10
  47. package/tests/bandit.yaml +17 -17
  48. package/tests/conftest.py +19 -19
  49. 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}