meteocat 0.1.29 → 0.1.30
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 +11 -0
- package/custom_components/meteocat/__init__.py +1 -1
- package/custom_components/meteocat/config_flow.py +0 -9
- package/custom_components/meteocat/const.py +1 -0
- package/custom_components/meteocat/manifest.json +1 -1
- package/custom_components/meteocat/sensor.py +37 -0
- 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,14 @@
|
|
|
1
|
+
## [0.1.30](https://github.com/figorr/meteocat/compare/v0.1.29...v0.1.30) (2024-12-12)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* 0.1.30 ([2095760](https://github.com/figorr/meteocat/commit/20957606eae28a97e82607136f97fde1abe38f81))
|
|
7
|
+
* add precipitation accumulated sensor ([b05090a](https://github.com/figorr/meteocat/commit/b05090a563656123464d95b17b01ba2d7cada20f))
|
|
8
|
+
* add precipitation_accumulated ([261d877](https://github.com/figorr/meteocat/commit/261d877cf9f68a2106687900951731ba6a4539eb))
|
|
9
|
+
* delete precipitation test ([845d721](https://github.com/figorr/meteocat/commit/845d721ff4e49a2fe79c5cdcf92698d52a6cff36))
|
|
10
|
+
* fix variables json ([df403b1](https://github.com/figorr/meteocat/commit/df403b12ab12cd357f087dc1dceda30c51e4c8f0))
|
|
11
|
+
|
|
1
12
|
## [0.1.29](https://github.com/figorr/meteocat/compare/v0.1.28...v0.1.29) (2024-12-12)
|
|
2
13
|
|
|
3
14
|
|
|
@@ -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.30"
|
|
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."""
|
|
@@ -125,15 +125,6 @@ class MeteocatConfigFlow(ConfigFlow, domain=DOMAIN):
|
|
|
125
125
|
async with aiofiles.open(variables_file, "w", encoding="utf-8") as file:
|
|
126
126
|
await file.write(json.dumps({"variables": variables_data}, ensure_ascii=False, indent=4))
|
|
127
127
|
|
|
128
|
-
# Actualizar la caché
|
|
129
|
-
cache_data = {
|
|
130
|
-
"symbols": symbols_data,
|
|
131
|
-
"variables": variables_data
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
async with aiofiles.open(variables_file, "w", encoding="utf-8") as file:
|
|
135
|
-
await file.write(json.dumps(cache_data, ensure_ascii=False, indent=4))
|
|
136
|
-
|
|
137
128
|
_LOGGER.info(f"Variables guardadas en {variables_file}")
|
|
138
129
|
|
|
139
130
|
# Buscar la variable de temperatura
|
|
@@ -16,6 +16,7 @@ TEMPERATURE = "temperature" # Temperatura
|
|
|
16
16
|
HUMIDITY = "humidity" # Humedad relativa
|
|
17
17
|
PRESSURE = "pressure" # Presión atmosférica
|
|
18
18
|
PRECIPITATION = "precipitation" # Precipitación
|
|
19
|
+
PRECIPITATION_ACCUMULATED = "precipitation_accumulated" #Precipitación acumulada
|
|
19
20
|
SOLAR_GLOBAL_IRRADIANCE = "solar_global_irradiance" # Irradiación solar global
|
|
20
21
|
UV_INDEX = "uv_index" # UV
|
|
21
22
|
MAX_TEMPERATURE = "max_temperature" # Temperatura máxima
|
|
@@ -38,6 +38,7 @@ from .const import (
|
|
|
38
38
|
HUMIDITY,
|
|
39
39
|
PRESSURE,
|
|
40
40
|
PRECIPITATION,
|
|
41
|
+
PRECIPITATION_ACCUMULATED,
|
|
41
42
|
SOLAR_GLOBAL_IRRADIANCE,
|
|
42
43
|
UV_INDEX,
|
|
43
44
|
MAX_TEMPERATURE,
|
|
@@ -113,6 +114,14 @@ SENSOR_TYPES: tuple[MeteocatSensorEntityDescription, ...] = (
|
|
|
113
114
|
state_class=SensorStateClass.MEASUREMENT,
|
|
114
115
|
native_unit_of_measurement=UnitOfVolumetricFlux.MILLIMETERS_PER_HOUR,
|
|
115
116
|
),
|
|
117
|
+
MeteocatSensorEntityDescription(
|
|
118
|
+
key=PRECIPITATION_ACCUMULATED,
|
|
119
|
+
name="Precipitation Accumulated",
|
|
120
|
+
icon="mdi:weather-rainy",
|
|
121
|
+
device_class=SensorDeviceClass.PRECIPITATION,
|
|
122
|
+
state_class=SensorStateClass.MEASUREMENT,
|
|
123
|
+
native_unit_of_measurement="mm",
|
|
124
|
+
),
|
|
116
125
|
MeteocatSensorEntityDescription(
|
|
117
126
|
key=SOLAR_GLOBAL_IRRADIANCE,
|
|
118
127
|
name="Solar Global Irradiance",
|
|
@@ -299,8 +308,36 @@ class MeteocatSensor(CoordinatorEntity[MeteocatSensorCoordinator], SensorEntity)
|
|
|
299
308
|
# Manejo de errores si el formato no es válido
|
|
300
309
|
return None
|
|
301
310
|
|
|
311
|
+
# Nuevo sensor para la precipitación acumulada
|
|
312
|
+
if self.entity_description.key == "precipitation_accumulated":
|
|
313
|
+
stations = self.coordinator.data or []
|
|
314
|
+
total_precipitation = 0.0 # Usa float para permitir acumulación de decimales
|
|
315
|
+
|
|
316
|
+
for station in stations:
|
|
317
|
+
variables = station.get("variables", [])
|
|
318
|
+
|
|
319
|
+
# Filtramos por código de precipitación
|
|
320
|
+
variable_data = next(
|
|
321
|
+
(var for var in variables if var.get("codi") == PRECIPITATION_CODE),
|
|
322
|
+
None,
|
|
323
|
+
)
|
|
324
|
+
|
|
325
|
+
if variable_data:
|
|
326
|
+
# Sumamos las lecturas de precipitación
|
|
327
|
+
lectures = variable_data.get("lectures", [])
|
|
328
|
+
for lecture in lectures:
|
|
329
|
+
total_precipitation += float(lecture.get("valor", 0.0)) # Convertimos a float
|
|
330
|
+
|
|
331
|
+
_LOGGER.debug(f"Total precipitación acumulada: {total_precipitation} mm")
|
|
332
|
+
return total_precipitation
|
|
333
|
+
|
|
302
334
|
return None
|
|
303
335
|
|
|
336
|
+
@property
|
|
337
|
+
def precipitation_accumulated(self):
|
|
338
|
+
"""Return the accumulated precipitation state of the sensor."""
|
|
339
|
+
|
|
340
|
+
|
|
304
341
|
@staticmethod
|
|
305
342
|
def _convert_degrees_to_cardinal(degree: float) -> str:
|
|
306
343
|
"""Convert degrees to cardinal direction."""
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
# version.py
|
|
2
|
-
__version__ = "0.1.
|
|
2
|
+
__version__ = "0.1.30"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "meteocat",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.30",
|
|
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": {
|