Skip to content

Commit

Permalink
Merge pull request #37 from briis/version-1-0-1
Browse files Browse the repository at this point in the history
Version 1.0.1
  • Loading branch information
briis authored Dec 3, 2023
2 parents 186fd70 + 7dedaf7 commit 8dcde1f
Show file tree
Hide file tree
Showing 15 changed files with 141 additions and 10 deletions.
18 changes: 15 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
## Release 1.0.1

Date: `2023-12-03`

This release is now V1.0, as all the relevant entities from the previous release are now implemented. Unfortunately my PR for getting this in to Default HACS is not merged yet, but I hope that this will happen soon, and when this does the previous integration will be removed.

### Changes

- @zuper83 updated the Swedish Translation.
- Added new sensor `Precip Intensity` that express the intensity of rain in text. (Can be translated). Closing [#41](https://github.com/briis/weatherflow_forecast/issues/41)
- Fixing wrong value and unit for the `Air Density` sensor when using the Imperial Unit System. **WARNING** When digging in to this, the Units for the Metric system was also wrong and is change from µg/m³ to kg/m³. You can correct the unit under the _Developer Tools_ and then _STATISTICS_ if you get a warning during startup.

### TODO
- If sensors have been installed, and the user selectes to remove them again, ensure they are deleted from Home Assistant. Currently they must be manually removed.


## Release 1.0.0

Expand All @@ -16,9 +31,6 @@ This release is now V1.0, as all the relevant entities from the previous release
- Added new Binary Sensor `Is Lightning`. On when Lightning strikes are detected. (Closes #26)
- Added new Binary Sensor `Is Raining`. On when the rain rate is above 0mm. (Closes #26)

### TODO
- If sensors have been installed, and the user selectes to remove them again, ensure they are deleted from Home Assistant. Currently they must be manually removed.

## Release 0.3.3

Date: `2023-11-18`
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ All entities are prefixed with `[STATION NAME]_sensors_`
| Precipitation duration today Checked | Total rain minutes for the current day. (Reset at midnight). Only if Rain Check enabled and in the US | No |
| Precipitation duration yesterday | Total rain minutes yesterday | No |
| Precipitation duration yesterday Checked | Total rain minutes yesterday. Only if Rain Check enabled and in the US | No |
| Precipitation Intensity| A textual representation on the current rain rate | Yes |
| Precipitation last hour | Total rain accumulation for the last hour | No |
| Precipitation Rate | How much is it raining right now | Yes |
| Precipitation today | Total rain for the current day. (Reset at midnight) | No |
Expand Down
2 changes: 2 additions & 0 deletions custom_components/weatherflow_forecast/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
]

CONCENTRATION_GRAMS_PER_CUBIC_METER = "g/m³"
CONCENTRATION_KILO_PER_CUBIC_METER = "kg/m³"
CONCENTRATION_POUND_PER_CUBIC_FOOT = "lb/ft³"
CONF_ADD_SENSORS = "add_sensors"
CONF_API_TOKEN = "api_token"
CONF_DEVICE_ID = "device_id"
Expand Down
4 changes: 2 additions & 2 deletions custom_components/weatherflow_forecast/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/briis/weatherflow_forecast/issues",
"requirements": [
"pyweatherflow-forecast==1.0.0"
"pyweatherflow-forecast==1.0.1"
],
"version": "1.0.0"
"version": "1.0.1"
}
29 changes: 25 additions & 4 deletions custom_components/weatherflow_forecast/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
CONF_NAME,
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
DEGREE,
EntityCategory,
LIGHT_LUX,
Expand All @@ -41,6 +40,7 @@
DataUpdateCoordinator,
)
from homeassistant.util.dt import utc_from_timestamp
from homeassistant.util.unit_system import METRIC_SYSTEM

from . import WeatherFlowForecastDataUpdateCoordinator
from .const import (
Expand All @@ -51,6 +51,8 @@
ATTR_HW_STATION_ID,
BATTERY_MODE_DESCRIPTION,
CONCENTRATION_GRAMS_PER_CUBIC_METER,
CONCENTRATION_KILO_PER_CUBIC_METER,
CONCENTRATION_POUND_PER_CUBIC_FOOT,
CONF_STATION_ID,
DOMAIN,
MANUFACTURER,
Expand All @@ -75,10 +77,10 @@ class WeatherFlowSensorEntityDescription(SensorEntityDescription):
WeatherFlowSensorEntityDescription(
key="air_density",
name="Air Density",
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
device_class=SensorDeviceClass.VOLATILE_ORGANIC_COMPOUNDS,
native_unit_of_measurement=CONCENTRATION_KILO_PER_CUBIC_METER,
state_class=SensorStateClass.MEASUREMENT,
suggested_display_precision=0,
suggested_display_precision=2,
icon="mdi:air-filter",
),
WeatherFlowSensorEntityDescription(
key="air_temperature",
Expand Down Expand Up @@ -235,6 +237,12 @@ class WeatherFlowSensorEntityDescription(SensorEntityDescription):
state_class=SensorStateClass.MEASUREMENT,
suggested_display_precision=1,
),
WeatherFlowSensorEntityDescription(
key="precip_intensity",
name="Precipitation Intensity",
icon="mdi:weather-rainy",
translation_key="precip_intensity",
),
WeatherFlowSensorEntityDescription(
key="precip_minutes_local_day",
name="Precipitation duration today",
Expand Down Expand Up @@ -462,6 +470,14 @@ def __init__(
self._attr_attribution = ATTR_ATTRIBUTION
self._attr_unique_id = f"{config.data[CONF_STATION_ID]} {description.key}"

@property
def native_unit_of_measurement(self) -> str | None:
"""Return unit of sensor."""

if self.entity_description.key == "air_density":
return super().native_unit_of_measurement if self.hass.config.units is METRIC_SYSTEM else CONCENTRATION_POUND_PER_CUBIC_FOOT
return super().native_unit_of_measurement

@property
def native_value(self) -> StateType:
"""Return state of the sensor."""
Expand All @@ -471,6 +487,11 @@ def native_value(self) -> StateType:
self.entity_description.key) if self.coordinator.data.sensor_data else None
return utc_from_timestamp(raw_data) if raw_data else None

if self.entity_description.key == "air_density":
raw_data = getattr(self.coordinator.data.sensor_data,
self.entity_description.key) if self.coordinator.data.sensor_data else None
return raw_data if self.hass.config.units is METRIC_SYSTEM else (raw_data * 0.06243)

return (
getattr(self.coordinator.data.sensor_data, self.entity_description.key)
if self.coordinator.data.sensor_data else None
Expand Down
11 changes: 11 additions & 0 deletions custom_components/weatherflow_forecast/translations/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,17 @@
"hurricane": "Vichřice"
}
},
"precip_intensity": {
"state": {
"no_rain": "Žádné",
"very_light": "Velmi lehké",
"light": "Lehké",
"moderate": "Střední",
"heavy": "Silné",
"very_heavy": "Velmi silné",
"extreme": "Extrémní"
}
},
"uv_description": {
"state": {
"extreme": "Extrémní",
Expand Down
11 changes: 11 additions & 0 deletions custom_components/weatherflow_forecast/translations/da.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,17 @@
"hurricane": "Orkan"
}
},
"precip_intensity": {
"state": {
"no_rain": "Ingen",
"very_light": "Meget Let",
"light": "Let",
"moderate": "Moderat",
"heavy": "Kraftig",
"very_heavy": "Meget Kraftig",
"extreme": "Ekstrem"
}
},
"uv_description": {
"state": {
"extreme": "Ekstrem høj",
Expand Down
11 changes: 11 additions & 0 deletions custom_components/weatherflow_forecast/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,17 @@
"hurricane": "Orkan"
}
},
"precip_intensity": {
"state": {
"no_rain": "kein",
"very_light": "sehr leicht",
"light": "leicht",
"moderate": "mäßig",
"heavy": "stark",
"very_heavy": "sehr stark",
"extreme": "extrem"
}
},
"uv_description": {
"state": {
"extreme": "extrem",
Expand Down
11 changes: 11 additions & 0 deletions custom_components/weatherflow_forecast/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,17 @@
"hurricane": "Hurricane"
}
},
"precip_intensity": {
"state": {
"no_rain": "None",
"very_light": "Very Light",
"light": "Light",
"moderate": "Moderate",
"heavy": "Heavy",
"very_heavy": "Very Heavy",
"extreme": "Extreme"
}
},
"uv_description": {
"state": {
"extreme": "Extreme",
Expand Down
11 changes: 11 additions & 0 deletions custom_components/weatherflow_forecast/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,17 @@
"hurricane": "Hurricane"
}
},
"precip_intensity": {
"state": {
"no_rain": "None",
"very_light": "Very Light",
"light": "Light",
"moderate": "Moderate",
"heavy": "Heavy",
"very_heavy": "Very Heavy",
"extreme": "Extreme"
}
},
"uv_description": {
"state": {
"extreme": "Extreme",
Expand Down
11 changes: 11 additions & 0 deletions custom_components/weatherflow_forecast/translations/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,17 @@
"hurricane": "Uragano"
}
},
"precip_intensity": {
"state": {
"no_rain": "Nessuna",
"very_light": "Molto leggera",
"light": "Leggera",
"moderate": "Moderata",
"heavy": "Intensa",
"very_heavy": "Molto intensa",
"extreme": "Estrema"
}
},
"uv_description": {
"state": {
"extreme": "Estremo",
Expand Down
11 changes: 11 additions & 0 deletions custom_components/weatherflow_forecast/translations/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,17 @@
"hurricane": "Orkaan"
}
},
"precip_intensity": {
"state": {
"no_rain": "Geen",
"very_light": "Zeer licht",
"light": "Licht",
"moderate": "Matig",
"heavy": "Zwaar",
"very_heavy": "Zeer zwaar",
"extreme": "Extreem"
}
},
"uv_description": {
"state": {
"extreme": "Extreem",
Expand Down
11 changes: 11 additions & 0 deletions custom_components/weatherflow_forecast/translations/sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,17 @@
"hurricane": "Orkan"
}
},
"precip_intensity": {
"state": {
"no_rain": "Uppehåll",
"very_light": "Stänk",
"light": "Lätt",
"moderate": "Måttligt",
"heavy": "Kraftigt",
"very_heavy": "Rikligt",
"extreme": "Extremt"
}
},
"uv_description": {
"state": {
"extreme": "Extrem",
Expand Down
2 changes: 1 addition & 1 deletion scripts/lint
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ set -e

cd "$(dirname "$0")/.."

ruff check . --fix
ruff check .
7 changes: 7 additions & 0 deletions scripts/lint-fix
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

set -e

cd "$(dirname "$0")/.."

ruff check . --fix

0 comments on commit 8dcde1f

Please sign in to comment.