meteocat 3.1.0 → 4.0.0

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 (57) 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 +954 -898
  20. package/README.md +207 -204
  21. package/conftest.py +11 -11
  22. package/custom_components/meteocat/__init__.py +298 -293
  23. package/custom_components/meteocat/condition.py +63 -59
  24. package/custom_components/meteocat/config_flow.py +613 -435
  25. package/custom_components/meteocat/const.py +132 -120
  26. package/custom_components/meteocat/coordinator.py +1040 -205
  27. package/custom_components/meteocat/helpers.py +58 -63
  28. package/custom_components/meteocat/manifest.json +25 -24
  29. package/custom_components/meteocat/options_flow.py +287 -277
  30. package/custom_components/meteocat/sensor.py +366 -4
  31. package/custom_components/meteocat/strings.json +1058 -867
  32. package/custom_components/meteocat/translations/ca.json +1058 -867
  33. package/custom_components/meteocat/translations/en.json +1058 -867
  34. package/custom_components/meteocat/translations/es.json +1058 -867
  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 +79 -70
  39. package/hacs.json +8 -8
  40. package/images/daily_forecast_2_alerts.png +0 -0
  41. package/images/daily_forecast_no_alerts.png +0 -0
  42. package/images/diagnostic_sensors.png +0 -0
  43. package/images/dynamic_sensors.png +0 -0
  44. package/images/options.png +0 -0
  45. package/images/regenerate_assets.png +0 -0
  46. package/images/setup_options.png +0 -0
  47. package/images/system_options.png +0 -0
  48. package/info.md +11 -11
  49. package/package.json +22 -22
  50. package/poetry.lock +3222 -3222
  51. package/pyproject.toml +68 -68
  52. package/requirements.test.txt +3 -3
  53. package/setup.cfg +64 -64
  54. package/setup.py +10 -10
  55. package/tests/bandit.yaml +17 -17
  56. package/tests/conftest.py +19 -19
  57. package/tests/test_init.py +9 -9
@@ -1,59 +1,63 @@
1
- from __future__ import annotations
2
-
3
- from datetime import datetime
4
- from .const import CONDITION_MAPPING
5
- from .helpers import is_night
6
- import logging
7
-
8
- _LOGGER = logging.getLogger(__name__)
9
-
10
- def get_condition_from_statcel(
11
- codi_estatcel, current_time: datetime, hass, is_hourly: bool = True
12
- ) -> dict:
13
- """
14
- Convierte el código 'estatCel' en condición de Home Assistant.
15
-
16
- :param codi_estatcel: Código o lista de códigos del estado del cielo.
17
- :param current_time: Fecha y hora actual (datetime).
18
- :param hass: Instancia de Home Assistant.
19
- :param is_hourly: Indica si los datos son de predicción horaria (True) o diaria (False).
20
- :return: Diccionario con la condición y el icono.
21
- """
22
-
23
- _LOGGER.debug(
24
- "Entrando en get_condition_from_statcel con codi_estatcel: %s, is_hourly: %s",
25
- codi_estatcel,
26
- is_hourly,
27
- )
28
-
29
- # Asegurarse de que codi_estatcel sea una lista válida
30
- if codi_estatcel is None:
31
- codi_estatcel = []
32
- elif isinstance(codi_estatcel, int): # Convertir enteros en lista
33
- codi_estatcel = [codi_estatcel]
34
-
35
- # Determinar si es de noche
36
- is_night_flag = is_night(current_time, hass)
37
-
38
- # Identificar la condición basada en el código
39
- for condition, codes in CONDITION_MAPPING.items():
40
- if any(code in codes for code in codi_estatcel):
41
- # Ajustar para condiciones nocturnas si aplica
42
- if condition == "sunny" and is_night_flag:
43
- _LOGGER.debug(
44
- "Códigos EstatCel: %s, Es Noche: %s, Condición Devuelta: clear-night",
45
- codi_estatcel,
46
- is_night_flag,
47
- )
48
- return {"condition": "clear-night", "icon": None}
49
-
50
- _LOGGER.debug(
51
- "Códigos EstatCel: %s, Es Noche: %s, Condición Devuelta: %s",
52
- codi_estatcel,
53
- is_night_flag,
54
- condition,
55
- )
56
- return {"condition": condition, "icon": None}
57
-
58
- # Si no coincide ningún código, devolver condición desconocida
59
- 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}