meteocat 0.1.32 → 0.1.34
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/CHANGELOG.md +19 -0
- package/custom_components/meteocat/__init__.py +1 -1
- package/custom_components/meteocat/coordinator.py +19 -3
- package/custom_components/meteocat/manifest.json +1 -1
- package/custom_components/meteocat/sensor.py +4 -4
- package/custom_components/meteocat/version.py +1 -1
- package/package.json +1 -1
- package/pyproject.toml +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
## [0.1.34](https://github.com/figorr/meteocat/compare/v0.1.33...v0.1.34) (2024-12-14)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* 0.1.34 ([14c1437](https://github.com/figorr/meteocat/commit/14c1437a95fd41a014146fd63ce80892a2d4a284))
|
|
7
|
+
* fix data validation ([a2c4282](https://github.com/figorr/meteocat/commit/a2c428207b062a06c5c07377ab3bf8ffbc65d277))
|
|
8
|
+
* fix Feels Like round(1) ([6329807](https://github.com/figorr/meteocat/commit/63298077e5aa09cb61413b0578ccd7e4baeb5c51))
|
|
9
|
+
* remove data validation ([250e582](https://github.com/figorr/meteocat/commit/250e5825dbda556e3e8e0c2e4a8014993e1de705))
|
|
10
|
+
* set timeout and data validation ([b7dba2e](https://github.com/figorr/meteocat/commit/b7dba2e9e742bee04c8e16d3694c7ac647ec83ab))
|
|
11
|
+
|
|
12
|
+
## [0.1.33](https://github.com/figorr/meteocat/compare/v0.1.32...v0.1.33) (2024-12-14)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* 0.1.33 ([461a423](https://github.com/figorr/meteocat/commit/461a423bd8596234bc182697d9f2725dd5234334))
|
|
18
|
+
* fix feels like options ([8e22c9e](https://github.com/figorr/meteocat/commit/8e22c9efd175d84eede50b4ce5c1f7abac14dc00))
|
|
19
|
+
|
|
1
20
|
## [0.1.32](https://github.com/figorr/meteocat/compare/v0.1.31...v0.1.32) (2024-12-14)
|
|
2
21
|
|
|
3
22
|
|
|
@@ -14,7 +14,7 @@ from .const import DOMAIN, PLATFORMS
|
|
|
14
14
|
_LOGGER = logging.getLogger(__name__)
|
|
15
15
|
|
|
16
16
|
# Versión
|
|
17
|
-
__version__ = "0.1.
|
|
17
|
+
__version__ = "0.1.34"
|
|
18
18
|
|
|
19
19
|
def safe_remove(path: Path, is_folder: bool = False):
|
|
20
20
|
"""Elimina de forma segura un archivo o carpeta si existe."""
|
|
@@ -4,8 +4,9 @@ import os
|
|
|
4
4
|
import json
|
|
5
5
|
import aiofiles
|
|
6
6
|
import logging
|
|
7
|
+
import asyncio
|
|
7
8
|
from datetime import timedelta
|
|
8
|
-
from typing import Dict
|
|
9
|
+
from typing import Dict, Any
|
|
9
10
|
|
|
10
11
|
from homeassistant.core import HomeAssistant
|
|
11
12
|
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
|
@@ -77,10 +78,22 @@ class MeteocatSensorCoordinator(DataUpdateCoordinator):
|
|
|
77
78
|
async def _async_update_data(self) -> Dict:
|
|
78
79
|
"""Actualiza los datos de los sensores desde la API de Meteocat."""
|
|
79
80
|
try:
|
|
80
|
-
# Obtener datos desde la API
|
|
81
|
-
data = await
|
|
81
|
+
# Obtener datos desde la API con manejo de tiempo límite
|
|
82
|
+
data = await asyncio.wait_for(
|
|
83
|
+
self.meteocat_station_data.get_station_data(self.station_id),
|
|
84
|
+
timeout=30 # Tiempo límite de 30 segundos
|
|
85
|
+
)
|
|
82
86
|
_LOGGER.debug("Datos de sensores actualizados exitosamente: %s", data)
|
|
83
87
|
|
|
88
|
+
# Validar que los datos sean una lista de diccionarios
|
|
89
|
+
if not isinstance(data, list) or not all(isinstance(item, dict) for item in data):
|
|
90
|
+
_LOGGER.error(
|
|
91
|
+
"Formato inválido: Se esperaba una lista de dicts, pero se obtuvo %s. Datos: %s",
|
|
92
|
+
type(data).__name__,
|
|
93
|
+
data,
|
|
94
|
+
)
|
|
95
|
+
raise ValueError("Formato de datos inválido")
|
|
96
|
+
|
|
84
97
|
# Determinar la ruta al archivo en la carpeta raíz del repositorio
|
|
85
98
|
output_file = os.path.join(
|
|
86
99
|
self.hass.config.path(), "custom_components", "meteocat", "files", "station_data.json"
|
|
@@ -90,6 +103,9 @@ class MeteocatSensorCoordinator(DataUpdateCoordinator):
|
|
|
90
103
|
await save_json_to_file(data, output_file)
|
|
91
104
|
|
|
92
105
|
return data
|
|
106
|
+
except asyncio.TimeoutError as err:
|
|
107
|
+
_LOGGER.warning("Tiempo de espera agotado al obtener datos de la API de Meteocat.")
|
|
108
|
+
raise ConfigEntryNotReady from err
|
|
93
109
|
except ForbiddenError as err:
|
|
94
110
|
_LOGGER.error(
|
|
95
111
|
"Acceso denegado al obtener datos de sensores (Station ID: %s): %s",
|
|
@@ -321,15 +321,15 @@ class MeteocatSensor(CoordinatorEntity[MeteocatSensorCoordinator], SensorEntity)
|
|
|
321
321
|
)
|
|
322
322
|
|
|
323
323
|
# Lógica de selección
|
|
324
|
-
if -50 <= temperature <= 10:
|
|
324
|
+
if -50 <= temperature <= 10 and wind_speed > 4.8:
|
|
325
325
|
_LOGGER.debug(f"Sensación térmica por frío, calculada según la fórmula de Wind Chill: {windchill} ºC")
|
|
326
|
-
return round(windchill,
|
|
326
|
+
return round(windchill, 1)
|
|
327
327
|
elif temperature > 26 and humidity > 40:
|
|
328
328
|
_LOGGER.debug(f"Sensación térmica por calor, calculada según la fórmula de Heat Index: {heat_index} ºC")
|
|
329
|
-
return round(heat_index,
|
|
329
|
+
return round(heat_index, 1)
|
|
330
330
|
else:
|
|
331
331
|
_LOGGER.debug(f"Sensación térmica idéntica a la temperatura actual: {temperature} ºC")
|
|
332
|
-
return round(temperature,
|
|
332
|
+
return round(temperature, 1)
|
|
333
333
|
|
|
334
334
|
sensor_code = self.CODE_MAPPING.get(self.entity_description.key)
|
|
335
335
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
# version.py
|
|
2
|
-
__version__ = "0.1.
|
|
2
|
+
__version__ = "0.1.34"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "meteocat",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.34",
|
|
4
4
|
"description": "[](https://opensource.org/licenses/Apache-2.0)\r [](https://pypi.org/project/meteocat)\r [](https://gitlab.com/figorr/meteocat/commits/master)",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"directories": {
|