meteocat 0.1.38 → 0.1.39
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 +20 -0
- package/conftest.py +11 -0
- package/custom_components/meteocat/__init__.py +31 -5
- package/custom_components/meteocat/condition.py +15 -5
- package/custom_components/meteocat/const.py +9 -4
- package/custom_components/meteocat/coordinator.py +566 -127
- package/custom_components/meteocat/helpers.py +39 -40
- package/custom_components/meteocat/manifest.json +1 -1
- package/custom_components/meteocat/sensor.py +136 -19
- package/custom_components/meteocat/strings.json +20 -0
- package/custom_components/meteocat/translations/ca.json +20 -0
- package/custom_components/meteocat/translations/en.json +20 -0
- package/custom_components/meteocat/translations/es.json +20 -0
- package/custom_components/meteocat/version.py +1 -1
- package/custom_components/meteocat/weather.py +171 -0
- package/filetree.txt +2 -1
- package/package.json +1 -1
- package/pyproject.toml +1 -1
- package/custom_components/meteocat/entity.py +0 -98
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
# from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
# import asyncio
|
|
4
|
-
# import logging
|
|
5
|
-
# from homeassistant.components.weather import WeatherEntity
|
|
6
|
-
# from homeassistant.const import (
|
|
7
|
-
# DEGREE,
|
|
8
|
-
# PERCENTAGE,
|
|
9
|
-
# UnitOfPressure,
|
|
10
|
-
# UnitOfSpeed,
|
|
11
|
-
# UnitOfTemperature,
|
|
12
|
-
# UnitOfVolumetricFlux,
|
|
13
|
-
# )
|
|
14
|
-
|
|
15
|
-
# from .const import (
|
|
16
|
-
# DOMAIN,
|
|
17
|
-
# CONF_API_KEY,
|
|
18
|
-
# TOWN_ID,
|
|
19
|
-
# TEMPERATURE,
|
|
20
|
-
# HUMIDITY,
|
|
21
|
-
# WIND_SPEED,
|
|
22
|
-
# WIND_DIRECTION,
|
|
23
|
-
# )
|
|
24
|
-
# from .condition import get_condition_from_statcel
|
|
25
|
-
# from .coordinator import MeteocatEntityCoordinator
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
# _LOGGER = logging.getLogger(__name__)
|
|
29
|
-
|
|
30
|
-
# async def async_setup_entry(hass, config_entry, async_add_entities):
|
|
31
|
-
# """Configura el componente weather basado en una entrada de configuración."""
|
|
32
|
-
# api_key = config_entry.data[CONF_API_KEY]
|
|
33
|
-
# town_id = config_entry.data[TOWN_ID]
|
|
34
|
-
|
|
35
|
-
# # Crear el coordinador
|
|
36
|
-
# coordinator = MeteocatEntityCoordinator(hass, api_key, town_id)
|
|
37
|
-
# # Asegurarse de que el coordinador esté actualizado antes de agregar la entidad
|
|
38
|
-
# await coordinator.async_refresh()
|
|
39
|
-
|
|
40
|
-
# async_add_entities([MeteocatWeatherEntity(coordinator)], True)
|
|
41
|
-
|
|
42
|
-
# class MeteocatWeatherEntity(WeatherEntity):
|
|
43
|
-
# """Entidad de clima para la integración Meteocat."""
|
|
44
|
-
|
|
45
|
-
# def __init__(self, coordinator: MeteocatEntityCoordinator):
|
|
46
|
-
# """Inicializa la entidad MeteocatWeather."""
|
|
47
|
-
# self._coordinator = coordinator
|
|
48
|
-
# self._attr_temperature_unit = UnitOfTemperature.CELSIUS
|
|
49
|
-
# self._data = {}
|
|
50
|
-
|
|
51
|
-
# async def async_update(self):
|
|
52
|
-
# """Actualiza los datos meteorológicos."""
|
|
53
|
-
# try:
|
|
54
|
-
# # Usamos el coordinador para obtener los datos actualizados
|
|
55
|
-
# if self._coordinator.data:
|
|
56
|
-
# hourly_forecast = self._coordinator.data["hourly_forecast"]
|
|
57
|
-
# current_forecast = hourly_forecast["variables"]
|
|
58
|
-
# codi_estatcel = current_forecast.get("estatCel", {}).get("valor")
|
|
59
|
-
# is_night = current_forecast.get("is_night", False)
|
|
60
|
-
# self._data = {
|
|
61
|
-
# "temperature": current_forecast.get(TEMPERATURE, {}).get("valor"),
|
|
62
|
-
# "humidity": current_forecast.get(HUMIDITY, {}).get("valor"),
|
|
63
|
-
# "wind_speed": current_forecast.get(WIND_SPEED, {}).get("valor"),
|
|
64
|
-
# "wind_bearing": current_forecast.get(WIND_DIRECTION, {}).get("valor"),
|
|
65
|
-
# "condition": get_condition_from_statcel(codi_estatcel, is_night)["condition"],
|
|
66
|
-
# }
|
|
67
|
-
# except Exception as err:
|
|
68
|
-
# _LOGGER.error("Error al actualizar la predicción de Meteocat: %s", err)
|
|
69
|
-
|
|
70
|
-
# @property
|
|
71
|
-
# def name(self):
|
|
72
|
-
# """Retorna el nombre de la entidad."""
|
|
73
|
-
# return f"Clima {self._coordinator._town_id}"
|
|
74
|
-
|
|
75
|
-
# @property
|
|
76
|
-
# def temperature(self):
|
|
77
|
-
# """Retorna la temperatura actual."""
|
|
78
|
-
# return self._data.get("temperature")
|
|
79
|
-
|
|
80
|
-
# @property
|
|
81
|
-
# def humidity(self):
|
|
82
|
-
# """Retorna la humedad relativa actual."""
|
|
83
|
-
# return self._data.get("humidity")
|
|
84
|
-
|
|
85
|
-
# @property
|
|
86
|
-
# def wind_speed(self):
|
|
87
|
-
# """Retorna la velocidad del viento."""
|
|
88
|
-
# return self._data.get("wind_speed")
|
|
89
|
-
|
|
90
|
-
# @property
|
|
91
|
-
# def wind_bearing(self):
|
|
92
|
-
# """Retorna la dirección del viento."""
|
|
93
|
-
# return self._data.get("wind_bearing")
|
|
94
|
-
|
|
95
|
-
# @property
|
|
96
|
-
# def condition(self):
|
|
97
|
-
# """Retorna la condición climática."""
|
|
98
|
-
# return self._data.get("condition")
|