meteocat 0.1.20 → 0.1.22

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/.releaserc CHANGED
@@ -3,9 +3,21 @@
3
3
  "plugins": [
4
4
  "@semantic-release/commit-analyzer",
5
5
  "@semantic-release/release-notes-generator",
6
- "@semantic-release/changelog",
6
+ [
7
+ "@semantic-release/changelog",
8
+ {
9
+ "changelogFile": "CHANGELOG.md"
10
+ }
11
+ ],
7
12
  "@semantic-release/npm",
8
- "@semantic-release/github"
13
+ "@semantic-release/github",
14
+ [
15
+ "@semantic-release/git",
16
+ {
17
+ "assets": ["CHANGELOG.md", "package.json", "pyproject.toml"],
18
+ "message": "v${nextRelease.version}\n\n${nextRelease.notes}"
19
+ }
20
+ ]
9
21
  ],
10
22
  "repositoryUrl": "https://github.com/figorr/meteocat"
11
23
  }
package/CHANGELOG.md CHANGED
@@ -1,16 +1,23 @@
1
- ## [0.1.20](https://github.com/figorr/meteocat/compare/v0.1.19...v0.1.20) (2024-12-06)
1
+ ## [0.1.22](https://github.com/figorr/meteocat/compare/v0.1.21...v0.1.22) (2024-12-07)
2
2
 
3
3
 
4
4
  ### Bug Fixes
5
5
 
6
- * 0.1.20 ([d21f624](https://github.com/figorr/meteocat/commit/d21f624a60171e69c5e634446e66f968b9486ee8))
7
- * fix jobs ([132bca0](https://github.com/figorr/meteocat/commit/132bca073eabffd02d09543501bec06b64df052a))
8
- * fix semantic-release ([f4a6a59](https://github.com/figorr/meteocat/commit/f4a6a595e1be07e853016de9b4be6508f2732016))
9
- * fix semantic-release version update ([4a88b8d](https://github.com/figorr/meteocat/commit/4a88b8dc9c06854c3e0b1f113f47ed666d5433ff))
10
- * include semantic-release ([77ebe6f](https://github.com/figorr/meteocat/commit/77ebe6f26291c314bc340e03092a83c31bc041ea))
11
- * update version files ([eb7e8f4](https://github.com/figorr/meteocat/commit/eb7e8f4cb19c4c7c7e1cd1b16c144a7e2eab1ff9))
6
+ * 0.1.22 ([54b39fa](https://github.com/figorr/meteocat/commit/54b39fad5e645673c2d46ca3209e82d92db03b95))
7
+ * add platforms ([fbbad49](https://github.com/figorr/meteocat/commit/fbbad49a6de960719d0c4f6a734c6dd1e0f3dfb5))
8
+ * bump meteocatpy to 0.0.7 ([f00b48d](https://github.com/figorr/meteocat/commit/f00b48da53e0f309686fa7214c60647bb0965495))
9
+ * fix coordinator to use entry_data ([5ca5050](https://github.com/figorr/meteocat/commit/5ca50501e04e8b3f6cb222f0f183dea1cc726242))
10
+ * fix UV icon ([f2c86e3](https://github.com/figorr/meteocat/commit/f2c86e3e03df987e40bdf955113f2235db347229))
12
11
 
13
- # CHANGELOG
12
+ ## [0.1.21](https://github.com/figorr/meteocat/compare/v0.1.20...v0.1.21) (2024-12-06)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * 0.1.21 ([a4df744](https://github.com/figorr/meteocat/commit/a4df7445f5dc05fe0a74c9d949fa551a77af6cf0))
18
+ * delete node_modules ([3b817a5](https://github.com/figorr/meteocat/commit/3b817a53c5fd6dcc44f17865f6fb39bb79c032ab))
19
+ * new repo file structure ([7ef2dbe](https://github.com/figorr/meteocat/commit/7ef2dbe67bc41c77e0f931d833578540dafe0ca8))
20
+ * semantic-release job ([a78eb5c](https://github.com/figorr/meteocat/commit/a78eb5c6dbbaef556a40053f98257906adeeecaa))
14
21
 
15
22
 
16
23
  ## v0.1.14 (2024-11-22)
@@ -7,24 +7,12 @@ from homeassistant.config_entries import ConfigEntry
7
7
  from homeassistant.core import HomeAssistant
8
8
  from homeassistant.exceptions import HomeAssistantError
9
9
  from .coordinator import MeteocatSensorCoordinator, MeteocatEntityCoordinator
10
- from .const import (
11
- DOMAIN,
12
- CONF_API_KEY,
13
- TOWN_NAME,
14
- TOWN_ID,
15
- VARIABLE_NAME,
16
- VARIABLE_ID,
17
- STATION_NAME,
18
- STATION_ID,
19
- )
10
+ from .const import DOMAIN, PLATFORMS
20
11
 
21
12
  _LOGGER = logging.getLogger(__name__)
22
13
 
23
14
  # Versión
24
- __version__ = "0.1.20"
25
-
26
- # Plataformas soportadas por la integración
27
- PLATFORMS = ["sensor", "entity"]
15
+ __version__ = "0.1.22"
28
16
 
29
17
 
30
18
  async def async_setup(hass: core.HomeAssistant, config: dict) -> bool:
@@ -38,71 +26,50 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
38
26
 
39
27
  # Extraer los datos necesarios de la entrada de configuración
40
28
  entry_data = entry.data
41
- required_fields = [
42
- CONF_API_KEY, TOWN_NAME, TOWN_ID, VARIABLE_ID, STATION_NAME, STATION_ID
43
- ]
44
29
 
45
30
  # Validar que todos los campos requeridos estén presentes
31
+ required_fields = [
32
+ "api_key", "town_name", "town_id", "variable_name",
33
+ "variable_id", "station_name", "station_id"
34
+ ]
46
35
  if not all(field in entry_data for field in required_fields):
47
36
  _LOGGER.error("Faltan datos en la configuración. Por favor, reconfigura la integración.")
48
37
  return False
49
38
 
50
- api_key = entry_data[CONF_API_KEY]
51
- town_name = entry_data[TOWN_NAME]
52
- town_id = entry_data[TOWN_ID]
53
- variable_name = entry_data[VARIABLE_NAME]
54
- variable_id = entry_data[VARIABLE_ID]
55
- station_name = entry_data[STATION_NAME]
56
- station_id = entry_data[STATION_ID]
57
-
58
39
  _LOGGER.info(
59
- f"Integración configurada para el municipio '{town_name}' (ID: {town_id}), "
60
- f"variable '{variable_name}' (ID: {variable_id}), estación {station_name} (ID: {station_id})."
40
+ f"Integración configurada para el municipio '{entry_data['town_name']}' "
41
+ f"(ID: {entry_data['town_id']}), variable '{entry_data['variable_name']}' "
42
+ f"(ID: {entry_data['variable_id']}), estación '{entry_data['station_name']}' "
43
+ f"(ID: {entry_data['station_id']})."
61
44
  )
62
45
 
63
46
  # Inicializa y refresca los coordinadores
64
47
  try:
65
- # Pasar los datos adicionales al constructor del coordinador
48
+ # Crear el coordinador para sensores
66
49
  sensor_coordinator = MeteocatSensorCoordinator(
67
- hass,
68
- entry,
69
- town_name=town_name,
70
- town_id=town_id,
71
- station_name=station_name,
72
- station_id=station_id,
73
- variable_name=variable_name,
74
- variable_id=variable_id,
50
+ hass=hass,
51
+ entry_data=entry_data, # Pasa los datos como un diccionario
75
52
  )
76
- # Pasar los mismos datos al constructor de MeteocatEntityCoordinator
53
+
54
+ # Crear el coordinador para entidades de predicción
77
55
  entity_coordinator = MeteocatEntityCoordinator(
78
- hass,
79
- entry,
80
- town_name=town_name,
81
- town_id=town_id,
82
- station_name=station_name,
83
- station_id=station_id,
84
- variable_name=variable_name,
85
- variable_id=variable_id,
56
+ hass=hass,
57
+ entry_data=entry_data, # Pasa los mismos datos
86
58
  )
87
59
 
60
+ # Ejecutar la primera actualización
88
61
  await sensor_coordinator.async_config_entry_first_refresh()
89
62
  await entity_coordinator.async_config_entry_first_refresh()
90
63
  except HomeAssistantError as err:
91
64
  _LOGGER.error(f"Error al inicializar los coordinadores: {err}")
92
65
  return False
93
66
 
94
- # Guardar los datos y los coordinadores en hass.data
67
+ # Guardar los coordinadores en hass.data
95
68
  hass.data.setdefault(DOMAIN, {})
96
69
  hass.data[DOMAIN][entry.entry_id] = {
97
70
  "sensor_coordinator": sensor_coordinator,
98
71
  "entity_coordinator": entity_coordinator,
99
- "api_key": api_key,
100
- "town_id": town_id,
101
- "town_name": town_name,
102
- "station_id": station_id,
103
- "station_name": station_name,
104
- "variable_id": variable_id,
105
- "variable_name": variable_name,
72
+ **entry_data,
106
73
  }
107
74
 
108
75
  # Configurar las plataformas
@@ -110,6 +77,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
110
77
 
111
78
  return True
112
79
 
80
+
113
81
  async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
114
82
  """Desactiva una entrada de configuración para Meteocat."""
115
83
  if entry.entry_id in hass.data.get(DOMAIN, {}):
@@ -44,3 +44,9 @@ CONDITION_MAPPING = {
44
44
  "fog": [11, 12],
45
45
  "snow-rainy": [27, 29, 30],
46
46
  }
47
+
48
+ # Platforms
49
+ PLATFORMS = {
50
+ "sensor",
51
+ "entity",
52
+ }
@@ -33,24 +33,26 @@ class MeteocatSensorCoordinator(DataUpdateCoordinator):
33
33
  def __init__(
34
34
  self,
35
35
  hass: HomeAssistant,
36
- api_key: str,
37
- town_name: str,
38
- town_id: str,
39
- station_name: str,
40
- station_id: str,
41
- variable_name: str,
42
- variable_id: str,
36
+ entry_data: dict,
43
37
  update_interval: timedelta = DEFAULT_SENSOR_UPDATE_INTERVAL,
44
38
  ):
45
- """Inicializa el coordinador de sensores de Meteocat."""
46
- self.api_key = api_key
47
- self.town_name = town_name
48
- self.town_id = town_id
49
- self.station_name = station_name
50
- self.station_id = station_id
51
- self.variable_name = variable_name
52
- self.variable_id = variable_id
53
- self.meteocat_station_data = MeteocatStationData(api_key)
39
+ """
40
+ Inicializa el coordinador de sensores de Meteocat.
41
+
42
+ Args:
43
+ hass (HomeAssistant): Instancia de Home Assistant.
44
+ entry_data (dict): Datos de configuración obtenidos de core.config_entries.
45
+ update_interval (timedelta): Intervalo de actualización.
46
+ """
47
+ self.api_key = entry_data["api_key"] # Usamos la API key de la configuración
48
+ self.town_name = entry_data["town_name"] # Usamos el nombre del municipio
49
+ self.town_id = entry_data["town_id"] # Usamos el ID del municipio
50
+ self.station_name = entry_data["station_name"] # Usamos el nombre de la estación
51
+ self.station_id = entry_data["station_id"] # Usamos el ID de la estación
52
+ self.variable_name = entry_data["variable_name"] # Usamos el nombre de la variable
53
+ self.variable_id = entry_data["variable_id"] # Usamos el ID de la variable
54
+ self.meteocat_station_data = MeteocatStationData(self.api_key)
55
+
54
56
  super().__init__(
55
57
  hass,
56
58
  _LOGGER,
@@ -59,12 +61,7 @@ class MeteocatSensorCoordinator(DataUpdateCoordinator):
59
61
  )
60
62
 
61
63
  async def _async_update_data(self) -> Dict:
62
- """
63
- Actualiza los datos de los sensores desde la API de Meteocat.
64
-
65
- Returns:
66
- dict: Datos actualizados de los sensores.
67
- """
64
+ """Actualiza los datos de los sensores desde la API de Meteocat."""
68
65
  try:
69
66
  data = await self.meteocat_station_data.get_station_data_with_variables(self.station_id)
70
67
  _LOGGER.debug("Datos de sensores actualizados exitosamente: %s", data)
@@ -105,24 +102,26 @@ class MeteocatEntityCoordinator(DataUpdateCoordinator):
105
102
  def __init__(
106
103
  self,
107
104
  hass: HomeAssistant,
108
- api_key: str,
109
- town_name: str,
110
- town_id: str,
111
- station_name: str,
112
- station_id: str,
113
- variable_name: str,
114
- variable_id: str,
105
+ entry_data: dict,
115
106
  update_interval: timedelta = DEFAULT_ENTITY_UPDATE_INTERVAL,
116
107
  ):
117
- """Inicializa el coordinador de datos para entidades de predicción."""
118
- self.api_key = api_key
119
- self.town_name = town_name
120
- self.town_id = town_id
121
- self.station_name = station_name
122
- self.station_id = station_id
123
- self.variable_name = variable_name
124
- self.variable_id = variable_id
125
- self.meteocat_forecast = MeteocatForecast(api_key)
108
+ """
109
+ Inicializa el coordinador de datos para entidades de predicción.
110
+
111
+ Args:
112
+ hass (HomeAssistant): Instancia de Home Assistant.
113
+ entry_data (dict): Datos de configuración obtenidos de core.config_entries.
114
+ update_interval (timedelta): Intervalo de actualización.
115
+ """
116
+ self.api_key = entry_data["api_key"]
117
+ self.town_name = entry_data["town_name"]
118
+ self.town_id = entry_data["town_id"]
119
+ self.station_name = entry_data["station_name"]
120
+ self.station_id = entry_data["station_id"]
121
+ self.variable_name = entry_data["variable_name"]
122
+ self.variable_id = entry_data["variable_id"]
123
+ self.meteocat_forecast = MeteocatForecast(self.api_key)
124
+
126
125
  super().__init__(
127
126
  hass,
128
127
  _LOGGER,
@@ -131,12 +130,7 @@ class MeteocatEntityCoordinator(DataUpdateCoordinator):
131
130
  )
132
131
 
133
132
  async def _async_update_data(self) -> Dict:
134
- """
135
- Actualiza los datos de las entidades de predicción desde la API de Meteocat.
136
-
137
- Returns:
138
- dict: Datos actualizados de predicción horaria y diaria.
139
- """
133
+ """Actualiza los datos de las entidades de predicción desde la API de Meteocat."""
140
134
  try:
141
135
  hourly_forecast = await self.meteocat_forecast.get_prediccion_horaria(self.town_id)
142
136
  daily_forecast = await self.meteocat_forecast.get_prediccion_diaria(self.town_id)
@@ -7,6 +7,6 @@
7
7
  "iot_class": "cloud_polling",
8
8
  "documentation": "https://gitlab.com/figorr/meteocat",
9
9
  "loggers": ["meteocatpy"],
10
- "requirements": ["meteocatpy==0.0.6", "packaging>=20.3", "wrapt>=1.14.0"],
11
- "version": "0.1.20"
10
+ "requirements": ["meteocatpy==0.0.7", "packaging>=20.3", "wrapt>=1.14.0"],
11
+ "version": "0.1.22"
12
12
  }
@@ -91,7 +91,7 @@ SENSOR_TYPES: tuple[MeteocatSensorEntityDescription, ...] = (
91
91
  MeteocatSensorEntityDescription(
92
92
  key=UV_INDEX,
93
93
  name="UV Index",
94
- icon="mdi:sun",
94
+ icon="mdi:weather-sunny",
95
95
  state_class=SensorStateClass.MEASUREMENT,
96
96
  native_unit_of_measurement=UV_INDEX_UNIT,
97
97
  ),
@@ -181,10 +181,5 @@ class MeteocatSensor(CoordinatorEntity[MeteocatSensorCoordinator], SensorEntity)
181
181
  identifiers={(DOMAIN, self._town_id)},
182
182
  name=self._town_name,
183
183
  manufacturer="Meteocat",
184
- model="Meteocat API",
185
- additional_properties={
186
- "Town ID": self._town_id,
187
- "Station Name": self._station_name,
188
- "Station ID": self._station_id,
189
- },
184
+ model="Meteocat API"
190
185
  )
@@ -1,2 +1,2 @@
1
1
  # version.py
2
- __version__ = "0.1.20"
2
+ __version__ = "0.1.22"
package/filetree.txt CHANGED
@@ -4,6 +4,7 @@
4
4
  ├── .gitignore
5
5
  ├── .gitlab-ci.yml
6
6
  ├── .pre-commit-config.yaml
7
+ ├── .releaserc
7
8
  ├── .releaserc.toml
8
9
  ├── AUTHORS.md
9
10
  ├── CHANGELOG.md
@@ -31,8 +32,10 @@
31
32
  ├── filetree.txt
32
33
  ├── hacs.json
33
34
  ├── package-lock.json
35
+ ├── package.json
34
36
  ├── poetry.lock
35
37
  ├── pyproject.toml
38
+ ├── releaserc.json
36
39
  ├── requirements.test.txt
37
40
  ├── setup.cfg
38
41
  ├── setup.py
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "meteocat",
3
- "version": "0.1.20",
3
+ "version": "0.1.22",
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.20"
3
+ version = "0.1.22"
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"