Skip to content

Commit ec13c08

Browse files
committed
Update README and add precipitation sensor
1 parent ead492b commit ec13c08

File tree

5 files changed

+118
-70
lines changed

5 files changed

+118
-70
lines changed

README.md

Lines changed: 92 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -116,69 +116,99 @@ I put a lot of work into making this repo and component available and updated to
116116
> > How many days ahead to make forecast sensors.\
117117
> > **Note:** If you only need a forecast sensors for today, specify `0`.
118118

119+
When `sensors` option are enabled, it creates 21 sensors. Each shows one aspect of current weather. Only few basic sensors are enabled by default. But you can enable any sensor through device settings.
119120

120-
> > > **condition**\
121-
> > > A human-readable text summary.
122-
> > >
123-
> > > **temperature**\
124-
> > > The current temperature of air.
125-
> > >
126-
> > > **temperature_feels_like**\
127-
> > > The current air temperature feels like.
128-
> > >
129-
> > > **humidity**\
130-
> > > The relative humidity of air.
131-
> > >
132-
> > > **pressure**\
133-
> > > The sea-level air pressure in millibars.\
134-
> > > At the same time, a second sensor is created, indicating the same pressure in mmHg.
135-
> > >
136-
> > > **wind_speed**\
137-
> > > The wind speed.
138-
> > >
139-
> > > **wind_bearing**\
140-
> > > The wind bearing.
141-
> > >
142-
> > > **clouds**\
143-
> > > Description about cloud coverage.
144-
> > >
145-
> > > **rain**\
146-
> > > The rain volume.
147-
> > >
148-
> > > **snow**\
149-
> > > The snow volume.
150-
> > >
151-
> > > **storm**\
152-
> > > The storm prediction.
153-
> > >
154-
> > > **geomagnetic**\
155-
> > > The geomagnetic field value:\
156-
> > > 1 = No noticeable geomagnetic disturbance\
157-
> > > 2 = Small geomagnetic disturbances\
158-
> > > 3 = Weak geomagnetic storm\
159-
> > > 4 = Small geomagnetic storm\
160-
> > > 5 = Moderate geomagnetic storm\
161-
> > > 6 = Severe geomagnetic storm\
162-
> > > 7 = Hard geomagnetic storm\
163-
> > > 8 = Extreme geomagnetic storm
164-
> > >
165-
> > > **water_temperature**\
166-
> > > The current temperature of water.
167-
> > >
168-
> > > **allergy_birch**\
169-
> > > Birch pollen concentration:\
170-
> > > 1–10 = Low\
171-
> > > 11–50 = Moderate\
172-
> > > 51–500 = High\
173-
> > > 501+ = Very high
174-
> > >
175-
> > > **uv_index**\
176-
> > > The ultraviolet index:\
177-
> > > 0–2 = Low\
178-
> > > 3–5 = Moderate\
179-
> > > 6–7 = High\
180-
> > > 8–10 = Very high\
181-
> > > 11+ = Extreme
121+
When you add `forecast_days` option, integration creates additional 21 sensors for each day. Each shows one aspect of forecast weather for that day. As usual, only few basic sensors are enabled by default.
122+
123+
List of sensors that will be created:
124+
> **condition**\
125+
> A human-readable text summary.
126+
>
127+
> **temperature**\
128+
> The current temperature of air.
129+
>
130+
> **apparent_temperature**\
131+
> The current apparent air temperature.
132+
>
133+
> **humidity**\
134+
> The relative humidity of air.
135+
>
136+
> **pressure**\
137+
> The sea-level air pressure in millibars.\
138+
> At the same time, a second sensor is created, indicating the same pressure in mmHg.
139+
>
140+
> **wind_speed**\
141+
> The wind speed.
142+
>
143+
> **wind_gusts_speed**\
144+
> The wind gusts speed.
145+
>
146+
> **wind_bearing**\
147+
> The wind bearing as an angle.
148+
>
149+
> **wind_bearing_2**\
150+
> The wind bearing as text.
151+
>
152+
> **cloud_coverage**\
153+
> Cloud coverage as a percentage.
154+
>
155+
> **precipitation**\
156+
> The precipitation amount volume.
157+
>
158+
> **rain_amount**\
159+
> The rain amount volume.
160+
>
161+
> **snow_amount**\
162+
> The snow amount volume.
163+
>
164+
> **storm**\
165+
> The storm prediction.
166+
>
167+
> **geomagnetic_field**\
168+
> The geomagnetic field value:\
169+
> 1 = No noticeable geomagnetic disturbance\
170+
> 2 = Small geomagnetic disturbances\
171+
> 3 = Weak geomagnetic storm\
172+
> 4 = Small geomagnetic storm\
173+
> 5 = Moderate geomagnetic storm\
174+
> 6 = Severe geomagnetic storm\
175+
> 7 = Hard geomagnetic storm\
176+
> 8 = Extreme geomagnetic storm
177+
>
178+
> **water_temperature**\
179+
> The temperature of water.
180+
>
181+
> **uv_index**\
182+
> The ultraviolet index:\
183+
> 0–2 = Low\
184+
> 3–5 = Moderate\
185+
> 6–7 = High\
186+
> 8–10 = Very high\
187+
> 11+ = Extreme
188+
>
189+
> **birch_pollen**\
190+
> Birch pollen concentration index:\
191+
> 1–10 = Low\
192+
> 11–50 = Moderate\
193+
> 51–500 = High\
194+
> 501+ = Very high
195+
>
196+
> **grass_pollen**\
197+
> Cereal grasses pollen concentration index:\
198+
> 1–10 = Low\
199+
> 11–50 = Moderate\
200+
> 51–500 = High\
201+
> 501+ = Very high
202+
>
203+
> **ragweed_pollen**\
204+
> Ragweed pollen concentration index:\
205+
> 1–10 = Low\
206+
> 11–50 = Moderate\
207+
> 51–500 = High\
208+
> 501+ = Very high
209+
>
210+
> **road_condition**\
211+
> Road surface condition as text.
182212

183213
## Track updates
184214

custom_components/gismeteo/const.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
DEGREE,
2727
PERCENTAGE,
2828
Platform,
29-
UnitOfLength,
29+
UnitOfPrecipitationDepth,
3030
UnitOfPressure,
3131
UnitOfSpeed,
3232
UnitOfTemperature,
@@ -164,6 +164,13 @@
164164
device_class=SensorDeviceClass.PRESSURE,
165165
native_unit_of_measurement=UnitOfPressure.HPA,
166166
),
167+
SensorEntityDescription(
168+
key=ATTR_FORECAST_PRECIPITATION_AMOUNT,
169+
translation_key="precipitation",
170+
device_class=SensorDeviceClass.PRECIPITATION,
171+
native_unit_of_measurement=UnitOfPrecipitationDepth.MILLIMETERS,
172+
entity_registry_enabled_default=False,
173+
),
167174
SensorEntityDescription(
168175
key=ATTR_FORECAST_WIND_SPEED,
169176
translation_key="wind_speed",
@@ -202,14 +209,16 @@
202209
key=ATTR_FORECAST_RAIN_AMOUNT,
203210
translation_key="rain_amount",
204211
icon="mdi:weather-rainy",
205-
native_unit_of_measurement=UnitOfLength.MILLIMETERS,
212+
device_class=SensorDeviceClass.PRECIPITATION,
213+
native_unit_of_measurement=UnitOfPrecipitationDepth.MILLIMETERS,
206214
entity_registry_enabled_default=False,
207215
),
208216
SensorEntityDescription(
209217
key=ATTR_FORECAST_SNOW_AMOUNT,
210218
translation_key="snow_amount",
211219
icon="mdi:weather-snowy",
212-
native_unit_of_measurement=UnitOfLength.MILLIMETERS,
220+
device_class=SensorDeviceClass.PRECIPITATION,
221+
native_unit_of_measurement=UnitOfPrecipitationDepth.MILLIMETERS,
213222
entity_registry_enabled_default=False,
214223
),
215224
SensorEntityDescription(
@@ -289,6 +298,13 @@
289298
device_class=SensorDeviceClass.PRESSURE,
290299
native_unit_of_measurement=UnitOfPressure.HPA,
291300
),
301+
SensorEntityDescription(
302+
key=ATTR_FORECAST_PRECIPITATION_AMOUNT,
303+
translation_key="precipitation_forecast",
304+
device_class=SensorDeviceClass.PRECIPITATION,
305+
native_unit_of_measurement=UnitOfPrecipitationDepth.MILLIMETERS,
306+
entity_registry_enabled_default=False,
307+
),
292308
SensorEntityDescription(
293309
key=ATTR_FORECAST_WIND_SPEED,
294310
translation_key="wind_speed_forecast",
@@ -328,14 +344,16 @@
328344
key=ATTR_FORECAST_RAIN_AMOUNT,
329345
translation_key="rain_amount_forecast",
330346
icon="mdi:weather-rainy",
331-
native_unit_of_measurement=UnitOfLength.MILLIMETERS,
347+
device_class=SensorDeviceClass.PRECIPITATION,
348+
native_unit_of_measurement=UnitOfPrecipitationDepth.MILLIMETERS,
332349
entity_registry_enabled_default=False,
333350
),
334351
SensorEntityDescription(
335352
key=ATTR_FORECAST_SNOW_AMOUNT,
336353
translation_key="snow_amount_forecast",
337354
icon="mdi:weather-snowy",
338-
native_unit_of_measurement=UnitOfLength.MILLIMETERS,
355+
device_class=SensorDeviceClass.PRECIPITATION,
356+
native_unit_of_measurement=UnitOfPrecipitationDepth.MILLIMETERS,
339357
entity_registry_enabled_default=False,
340358
),
341359
SensorEntityDescription(

custom_components/gismeteo/sensor.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,6 @@ def __init__(
172172
super().__init__(coordinator, location_name)
173173

174174
self.entity_description = description
175-
# if day:
176-
# self.entity_description.translation_key += "-day"
177175

178176
self._attr_unique_id = (
179177
f"{coordinator.unique_id}-{description.key}"

custom_components/gismeteo/weather.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from homeassistant.config_entries import SOURCE_IMPORT
1919
from homeassistant.const import (
2020
CONF_NAME,
21+
UnitOfPrecipitationDepth,
2122
UnitOfPressure,
2223
UnitOfSpeed,
2324
UnitOfTemperature,
@@ -72,6 +73,7 @@ class GismeteoWeather(GismeteoEntity, CoordinatorWeatherEntity):
7273
_attr_attribution = ATTRIBUTION
7374
_attr_native_temperature_unit = UnitOfTemperature.CELSIUS
7475
_attr_native_pressure_unit = UnitOfPressure.MMHG
76+
_attr_native_precipitation_unit = UnitOfPrecipitationDepth.MILLIMETERS
7577
_attr_native_wind_speed_unit = UnitOfSpeed.METERS_PER_SECOND
7678
_attr_supported_features = (
7779
WeatherEntityFeature.FORECAST_DAILY | WeatherEntityFeature.FORECAST_HOURLY

tests/test_sensor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ async def test__fix_types(caplog):
5252
async def test__gen_entities(mock_coordinator):
5353
"""Test _gen_entities function."""
5454
res = _gen_entities("Test location", mock_coordinator, {}, False)
55-
assert len(res) == 20
55+
assert len(res) == 21
5656

5757
res = _gen_entities(
5858
"Test location",

0 commit comments

Comments
 (0)