Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugs + reported issues #62

Merged
merged 3 commits into from
Oct 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"domain": "fmi",
"version": "0.4.9",
"version": "0.5.0",
"name": "Finnish Meteorological Institute",
"documentation": "https://www.home-assistant.io/integrations/fmi/",
"requirements": [
"fmi-weather-client==0.1.1",
"fmi-weather-client==0.1.2",
"geopy>=2.1.0"
],
"dependencies": [],
Expand Down
9 changes: 9 additions & 0 deletions sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
PERCENTAGE
)

from homeassistant.components.sensor import (
SensorStateClass
)

from homeassistant.const import CONF_NAME
from homeassistant.helpers.update_coordinator import CoordinatorEntity

Expand Down Expand Up @@ -393,6 +397,11 @@ def unit_of_measurement(self):
"""Return the unit of measurement of this entity, if any."""
return self._unit_of_measurement

@property
def state_class(self):
"""Return the state class."""
return SensorStateClass.MEASUREMENT

@property
def icon(self):
"""Icon to use in the frontend, if any."""
Expand Down
40 changes: 20 additions & 20 deletions weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

from homeassistant.components.weather import (
ATTR_FORECAST_CONDITION,
ATTR_FORECAST_PRECIPITATION,
ATTR_FORECAST_TEMP,
ATTR_FORECAST_NATIVE_PRECIPITATION,
ATTR_FORECAST_NATIVE_TEMP,
ATTR_FORECAST_TIME,
ATTR_FORECAST_WIND_BEARING,
ATTR_FORECAST_WIND_SPEED,
ATTR_FORECAST_NATIVE_WIND_SPEED,
ATTR_WEATHER_HUMIDITY,
ATTR_WEATHER_PRESSURE,
ATTR_FORECAST_TEMP_LOW,
ATTR_FORECAST_NATIVE_TEMP_LOW,
WeatherEntity,
)

Expand Down Expand Up @@ -108,15 +108,15 @@ def available(self):
return self._fmi.current is not None

@property
def temperature(self):
def native_temperature(self):
"""Return the temperature."""
if self._fmi is None:
return None

return self._fmi.current.data.temperature.value

@property
def temperature_unit(self):
def native_temperature_unit(self):
"""Return the unit of measurement."""
if self._fmi is None:
return None
Expand All @@ -132,15 +132,15 @@ def humidity(self):
return self._fmi.current.data.humidity.value

@property
def precipitation(self):
def native_precipitation(self):
"""Return the humidity."""
if self._fmi is None:
return None

return self._fmi.current.data.precipitation_amount.value

@property
def wind_speed(self):
def native_wind_speed(self):
"""Return the wind speed."""
if self._fmi is None:
return None
Expand All @@ -158,7 +158,7 @@ def wind_bearing(self):
return self._fmi.current.data.wind_direction.value

@property
def pressure(self):
def native_pressure(self):
"""Return the pressure."""
if self._fmi is None:
return None
Expand Down Expand Up @@ -197,20 +197,20 @@ def forecast(self):
ATTR_FORECAST_CONDITION: get_weather_symbol(
forecast.symbol.value
),
ATTR_FORECAST_TEMP: forecast.temperature.value,
ATTR_FORECAST_TEMP_LOW: forecast.temperature.value,
ATTR_FORECAST_PRECIPITATION: forecast.precipitation_amount.value,
ATTR_FORECAST_WIND_SPEED: forecast.wind_speed.value,
ATTR_FORECAST_NATIVE_TEMP: forecast.temperature.value,
ATTR_FORECAST_NATIVE_TEMP_LOW: forecast.temperature.value,
ATTR_FORECAST_NATIVE_PRECIPITATION: forecast.precipitation_amount.value,
ATTR_FORECAST_NATIVE_WIND_SPEED: forecast.wind_speed.value,
ATTR_FORECAST_WIND_BEARING: forecast.wind_direction.value,
ATTR_WEATHER_PRESSURE: forecast.pressure.value,
ATTR_WEATHER_HUMIDITY: forecast.humidity.value,
}
)
else:
if data[-1][ATTR_FORECAST_TEMP] < forecast.temperature.value:
data[-1][ATTR_FORECAST_TEMP] = forecast.temperature.value
if data[-1][ATTR_FORECAST_TEMP_LOW] > forecast.temperature.value:
data[-1][ATTR_FORECAST_TEMP_LOW] = forecast.temperature.value
if data[-1][ATTR_FORECAST_NATIVE_TEMP] < forecast.temperature.value:
data[-1][ATTR_FORECAST_NATIVE_TEMP] = forecast.temperature.value
if data[-1][ATTR_FORECAST_NATIVE_TEMP_LOW] > forecast.temperature.value:
data[-1][ATTR_FORECAST_NATIVE_TEMP_LOW] = forecast.temperature.value
else:
data = []
for forecast in self._fmi.forecast.forecasts:
Expand All @@ -221,9 +221,9 @@ def forecast(self):
ATTR_FORECAST_CONDITION: get_weather_symbol(
forecast.symbol.value
),
ATTR_FORECAST_TEMP: forecast.temperature.value,
ATTR_FORECAST_PRECIPITATION: forecast.precipitation_amount.value,
ATTR_FORECAST_WIND_SPEED: forecast.wind_speed.value,
ATTR_FORECAST_NATIVE_TEMP: forecast.temperature.value,
ATTR_FORECAST_NATIVE_PRECIPITATION: forecast.precipitation_amount.value,
ATTR_FORECAST_NATIVE_WIND_SPEED: forecast.wind_speed.value,
ATTR_FORECAST_WIND_BEARING: forecast.wind_direction.value,
ATTR_WEATHER_PRESSURE: forecast.pressure.value,
ATTR_WEATHER_HUMIDITY: forecast.humidity.value,
Expand Down