meteocat 0.1.37 → 0.1.38

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 CHANGED
@@ -1,3 +1,12 @@
1
+ ## [0.1.38](https://github.com/figorr/meteocat/compare/v0.1.37...v0.1.38) (2024-12-18)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * 0.1.38 ([58014ef](https://github.com/figorr/meteocat/commit/58014ef56ca54f2b458fe6e142fbcf27cd8d211d))
7
+ * add degrees attribute translations ([341cf84](https://github.com/figorr/meteocat/commit/341cf849024f98ff1f31b66ec7ff6a2a39123148))
8
+ * add degrees property to wind direction ([9570a79](https://github.com/figorr/meteocat/commit/9570a7911d112624818da224369bacec1ee74902))
9
+
1
10
  ## [0.1.37](https://github.com/figorr/meteocat/compare/v0.1.36...v0.1.37) (2024-12-17)
2
11
 
3
12
 
@@ -20,7 +20,7 @@ from .const import DOMAIN, PLATFORMS
20
20
  _LOGGER = logging.getLogger(__name__)
21
21
 
22
22
  # Versión
23
- __version__ = "0.1.37"
23
+ __version__ = "0.1.38"
24
24
 
25
25
  def safe_remove(path: Path, is_folder: bool = False):
26
26
  """Elimina de forma segura un archivo o carpeta si existe."""
@@ -8,5 +8,5 @@
8
8
  "documentation": "https://gitlab.com/figorr/meteocat",
9
9
  "loggers": ["meteocatpy"],
10
10
  "requirements": ["meteocatpy==0.0.15", "packaging>=20.3", "wrapt>=1.14.0"],
11
- "version": "0.1.37"
11
+ "version": "0.1.38"
12
12
  }
@@ -482,6 +482,41 @@ class MeteocatSensor(CoordinatorEntity[MeteocatSensorCoordinator], SensorEntity)
482
482
  ]
483
483
  index = round(degree / 22.5) % 16
484
484
  return directions[index]
485
+
486
+ @property
487
+ def extra_state_attributes(self):
488
+ """Return additional attributes of the sensor."""
489
+ attributes = super().extra_state_attributes or {}
490
+
491
+ # Agregar grados como atributo solo para WIND_DIRECTION
492
+ if self.entity_description.key == WIND_DIRECTION:
493
+ # Obtener el código del sensor desde CODE_MAPPING
494
+ sensor_code = self.CODE_MAPPING.get(self.entity_description.key)
495
+
496
+ if sensor_code is not None:
497
+ # Acceder a los datos de la estación desde el coordinator
498
+ stations = self.coordinator.data or []
499
+ degrees_value = None
500
+
501
+ for station in stations:
502
+ variables = station.get("variables", [])
503
+ # Buscar la variable correspondiente al código
504
+ variable_data = next(
505
+ (var for var in variables if var.get("codi") == sensor_code),
506
+ None,
507
+ )
508
+ if variable_data:
509
+ # Obtener la última lectura de grados
510
+ lectures = variable_data.get("lectures", [])
511
+ if lectures:
512
+ degrees_value = lectures[-1].get("valor")
513
+ break
514
+
515
+ # Asignar el valor al atributo
516
+ if degrees_value is not None:
517
+ attributes["degrees"] = degrees_value
518
+
519
+ return attributes
485
520
 
486
521
  @property
487
522
  def device_info(self) -> DeviceInfo:
@@ -48,6 +48,11 @@
48
48
  "NW": "NW",
49
49
  "NNW": "NNW",
50
50
  "unknown": "Unknown"
51
+ },
52
+ "state_attributes": {
53
+ "degrees": {
54
+ "name": "Degrees"
55
+ }
51
56
  }
52
57
  },
53
58
  "temperature": {
@@ -48,6 +48,11 @@
48
48
  "NW": "NO",
49
49
  "NNW": "NNO",
50
50
  "unknown": "Desconegut"
51
+ },
52
+ "state_attributes": {
53
+ "degrees": {
54
+ "name": "Graus"
55
+ }
51
56
  }
52
57
  },
53
58
  "temperature": {
@@ -48,6 +48,11 @@
48
48
  "NW": "NW",
49
49
  "NNW": "NNW",
50
50
  "unknown": "Unknown"
51
+ },
52
+ "state_attributes": {
53
+ "degrees": {
54
+ "name": "Degrees"
55
+ }
51
56
  }
52
57
  },
53
58
  "temperature": {
@@ -48,6 +48,11 @@
48
48
  "NW": "NO",
49
49
  "NNW": "NNO",
50
50
  "unknown": "Desconocido"
51
+ },
52
+ "state_attributes": {
53
+ "degrees": {
54
+ "name": "Grados"
55
+ }
51
56
  }
52
57
  },
53
58
  "temperature": {
@@ -1,2 +1,2 @@
1
1
  # version.py
2
- __version__ = "0.1.37"
2
+ __version__ = "0.1.38"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "meteocat",
3
- "version": "0.1.37",
3
+ "version": "0.1.38",
4
4
  "description": "[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\r [![Python version compatibility](https://img.shields.io/pypi/pyversions/meteocat)](https://pypi.org/project/meteocat)\r [![pipeline status](https://gitlab.com/figorr/meteocat/badges/master/pipeline.svg)](https://gitlab.com/figorr/meteocat/commits/master)",
5
5
  "main": "index.js",
6
6
  "directories": {
package/pyproject.toml CHANGED
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "meteocat"
3
- version = "0.1.37"
3
+ version = "0.1.38"
4
4
  description = "Script para obtener datos meteorológicos de la API de Meteocat"
5
5
  authors = ["figorr <jdcuartero@yahoo.es>"]
6
6
  license = "Apache-2.0"