Skip to content

Commit

Permalink
Update README and add precipitation sensor
Browse files Browse the repository at this point in the history
  • Loading branch information
Limych committed May 17, 2024
1 parent ead492b commit ec13c08
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 70 deletions.
154 changes: 92 additions & 62 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,69 +116,99 @@ I put a lot of work into making this repo and component available and updated to
> > How many days ahead to make forecast sensors.\
> > **Note:** If you only need a forecast sensors for today, specify `0`.

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.

> > > **condition**\
> > > A human-readable text summary.
> > >
> > > **temperature**\
> > > The current temperature of air.
> > >
> > > **temperature_feels_like**\
> > > The current air temperature feels like.
> > >
> > > **humidity**\
> > > The relative humidity of air.
> > >
> > > **pressure**\
> > > The sea-level air pressure in millibars.\
> > > At the same time, a second sensor is created, indicating the same pressure in mmHg.
> > >
> > > **wind_speed**\
> > > The wind speed.
> > >
> > > **wind_bearing**\
> > > The wind bearing.
> > >
> > > **clouds**\
> > > Description about cloud coverage.
> > >
> > > **rain**\
> > > The rain volume.
> > >
> > > **snow**\
> > > The snow volume.
> > >
> > > **storm**\
> > > The storm prediction.
> > >
> > > **geomagnetic**\
> > > The geomagnetic field value:\
> > > 1 = No noticeable geomagnetic disturbance\
> > > 2 = Small geomagnetic disturbances\
> > > 3 = Weak geomagnetic storm\
> > > 4 = Small geomagnetic storm\
> > > 5 = Moderate geomagnetic storm\
> > > 6 = Severe geomagnetic storm\
> > > 7 = Hard geomagnetic storm\
> > > 8 = Extreme geomagnetic storm
> > >
> > > **water_temperature**\
> > > The current temperature of water.
> > >
> > > **allergy_birch**\
> > > Birch pollen concentration:\
> > > 1–10 = Low\
> > > 11–50 = Moderate\
> > > 51–500 = High\
> > > 501+ = Very high
> > >
> > > **uv_index**\
> > > The ultraviolet index:\
> > > 0–2 = Low\
> > > 3–5 = Moderate\
> > > 6–7 = High\
> > > 8–10 = Very high\
> > > 11+ = Extreme
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.

List of sensors that will be created:
> **condition**\
> A human-readable text summary.
>
> **temperature**\
> The current temperature of air.
>
> **apparent_temperature**\
> The current apparent air temperature.
>
> **humidity**\
> The relative humidity of air.
>
> **pressure**\
> The sea-level air pressure in millibars.\
> At the same time, a second sensor is created, indicating the same pressure in mmHg.
>
> **wind_speed**\
> The wind speed.
>
> **wind_gusts_speed**\
> The wind gusts speed.
>
> **wind_bearing**\
> The wind bearing as an angle.
>
> **wind_bearing_2**\
> The wind bearing as text.
>
> **cloud_coverage**\
> Cloud coverage as a percentage.
>
> **precipitation**\
> The precipitation amount volume.
>
> **rain_amount**\
> The rain amount volume.
>
> **snow_amount**\
> The snow amount volume.
>
> **storm**\
> The storm prediction.
>
> **geomagnetic_field**\
> The geomagnetic field value:\
> 1 = No noticeable geomagnetic disturbance\
> 2 = Small geomagnetic disturbances\
> 3 = Weak geomagnetic storm\
> 4 = Small geomagnetic storm\
> 5 = Moderate geomagnetic storm\
> 6 = Severe geomagnetic storm\
> 7 = Hard geomagnetic storm\
> 8 = Extreme geomagnetic storm
>
> **water_temperature**\
> The temperature of water.
>
> **uv_index**\
> The ultraviolet index:\
> 0–2 = Low\
> 3–5 = Moderate\
> 6–7 = High\
> 8–10 = Very high\
> 11+ = Extreme
>
> **birch_pollen**\
> Birch pollen concentration index:\
> 1–10 = Low\
> 11–50 = Moderate\
> 51–500 = High\
> 501+ = Very high
>
> **grass_pollen**\
> Cereal grasses pollen concentration index:\
> 1–10 = Low\
> 11–50 = Moderate\
> 51–500 = High\
> 501+ = Very high
>
> **ragweed_pollen**\
> Ragweed pollen concentration index:\
> 1–10 = Low\
> 11–50 = Moderate\
> 51–500 = High\
> 501+ = Very high
>
> **road_condition**\
> Road surface condition as text.

## Track updates

Expand Down
28 changes: 23 additions & 5 deletions custom_components/gismeteo/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
DEGREE,
PERCENTAGE,
Platform,
UnitOfLength,
UnitOfPrecipitationDepth,
UnitOfPressure,
UnitOfSpeed,
UnitOfTemperature,
Expand Down Expand Up @@ -164,6 +164,13 @@
device_class=SensorDeviceClass.PRESSURE,
native_unit_of_measurement=UnitOfPressure.HPA,
),
SensorEntityDescription(
key=ATTR_FORECAST_PRECIPITATION_AMOUNT,
translation_key="precipitation",
device_class=SensorDeviceClass.PRECIPITATION,
native_unit_of_measurement=UnitOfPrecipitationDepth.MILLIMETERS,
entity_registry_enabled_default=False,
),
SensorEntityDescription(
key=ATTR_FORECAST_WIND_SPEED,
translation_key="wind_speed",
Expand Down Expand Up @@ -202,14 +209,16 @@
key=ATTR_FORECAST_RAIN_AMOUNT,
translation_key="rain_amount",
icon="mdi:weather-rainy",
native_unit_of_measurement=UnitOfLength.MILLIMETERS,
device_class=SensorDeviceClass.PRECIPITATION,
native_unit_of_measurement=UnitOfPrecipitationDepth.MILLIMETERS,
entity_registry_enabled_default=False,
),
SensorEntityDescription(
key=ATTR_FORECAST_SNOW_AMOUNT,
translation_key="snow_amount",
icon="mdi:weather-snowy",
native_unit_of_measurement=UnitOfLength.MILLIMETERS,
device_class=SensorDeviceClass.PRECIPITATION,
native_unit_of_measurement=UnitOfPrecipitationDepth.MILLIMETERS,
entity_registry_enabled_default=False,
),
SensorEntityDescription(
Expand Down Expand Up @@ -289,6 +298,13 @@
device_class=SensorDeviceClass.PRESSURE,
native_unit_of_measurement=UnitOfPressure.HPA,
),
SensorEntityDescription(
key=ATTR_FORECAST_PRECIPITATION_AMOUNT,
translation_key="precipitation_forecast",
device_class=SensorDeviceClass.PRECIPITATION,
native_unit_of_measurement=UnitOfPrecipitationDepth.MILLIMETERS,
entity_registry_enabled_default=False,
),
SensorEntityDescription(
key=ATTR_FORECAST_WIND_SPEED,
translation_key="wind_speed_forecast",
Expand Down Expand Up @@ -328,14 +344,16 @@
key=ATTR_FORECAST_RAIN_AMOUNT,
translation_key="rain_amount_forecast",
icon="mdi:weather-rainy",
native_unit_of_measurement=UnitOfLength.MILLIMETERS,
device_class=SensorDeviceClass.PRECIPITATION,
native_unit_of_measurement=UnitOfPrecipitationDepth.MILLIMETERS,
entity_registry_enabled_default=False,
),
SensorEntityDescription(
key=ATTR_FORECAST_SNOW_AMOUNT,
translation_key="snow_amount_forecast",
icon="mdi:weather-snowy",
native_unit_of_measurement=UnitOfLength.MILLIMETERS,
device_class=SensorDeviceClass.PRECIPITATION,
native_unit_of_measurement=UnitOfPrecipitationDepth.MILLIMETERS,
entity_registry_enabled_default=False,
),
SensorEntityDescription(
Expand Down
2 changes: 0 additions & 2 deletions custom_components/gismeteo/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,6 @@ def __init__(
super().__init__(coordinator, location_name)

self.entity_description = description
# if day:
# self.entity_description.translation_key += "-day"

self._attr_unique_id = (
f"{coordinator.unique_id}-{description.key}"
Expand Down
2 changes: 2 additions & 0 deletions custom_components/gismeteo/weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from homeassistant.config_entries import SOURCE_IMPORT
from homeassistant.const import (
CONF_NAME,
UnitOfPrecipitationDepth,
UnitOfPressure,
UnitOfSpeed,
UnitOfTemperature,
Expand Down Expand Up @@ -72,6 +73,7 @@ class GismeteoWeather(GismeteoEntity, CoordinatorWeatherEntity):
_attr_attribution = ATTRIBUTION
_attr_native_temperature_unit = UnitOfTemperature.CELSIUS
_attr_native_pressure_unit = UnitOfPressure.MMHG
_attr_native_precipitation_unit = UnitOfPrecipitationDepth.MILLIMETERS
_attr_native_wind_speed_unit = UnitOfSpeed.METERS_PER_SECOND
_attr_supported_features = (
WeatherEntityFeature.FORECAST_DAILY | WeatherEntityFeature.FORECAST_HOURLY
Expand Down
2 changes: 1 addition & 1 deletion tests/test_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ async def test__fix_types(caplog):
async def test__gen_entities(mock_coordinator):
"""Test _gen_entities function."""
res = _gen_entities("Test location", mock_coordinator, {}, False)
assert len(res) == 20
assert len(res) == 21

res = _gen_entities(
"Test location",
Expand Down

0 comments on commit ec13c08

Please sign in to comment.