Skip to content

Commit

Permalink
Add Support for Wind Gusts (#199)
Browse files Browse the repository at this point in the history
* Based on a suggestion from issue #197
  • Loading branch information
cloneofghosts authored Mar 11, 2024
1 parent 9205ef6 commit 8f9ea57
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 10 deletions.
2 changes: 1 addition & 1 deletion custom_components/pirateweather/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/alexander0042/pirate-weather-ha/issues",
"requirements": ["python-forecastio==1.4.0"],
"version": "1.4.4"
"version": "1.4.5"
}
8 changes: 4 additions & 4 deletions custom_components/pirateweather/sensor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Support for PirateWeather (Dark Sky Compatable weather service."""
"""Support for Pirate Weather (Dark Sky Compatable) weather service."""

import logging

Expand Down Expand Up @@ -67,7 +67,7 @@
CONF_UNITS = "units"

DEFAULT_LANGUAGE = "en"
DEFAULT_NAME = "PirateWeather"
DEFAULT_NAME = "Pirate Weather"

DEPRECATED_SENSOR_TYPES = {
"apparent_temperature_max",
Expand Down Expand Up @@ -741,7 +741,7 @@ async def async_setup_entry(


class PirateWeatherSensor(SensorEntity):
"""Class for an PirateWeather sensor."""
"""Class for an Pirate Weather sensor."""

# _attr_should_poll = False
_attr_attribution = ATTRIBUTION
Expand Down Expand Up @@ -799,7 +799,7 @@ def name(self):

@property
def available(self) -> bool:
"""Return if weather data is available from PirateWeather."""
"""Return if weather data is available from Pirate Weather."""
return self._weather_coordinator.data is not None

@property
Expand Down
26 changes: 22 additions & 4 deletions custom_components/pirateweather/weather.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Support for the Pirate Weather (PW) service."""
"""Support for the Pirate Weather service."""

from __future__ import annotations

Expand Down Expand Up @@ -140,6 +140,7 @@ def _map_daily_forecast(forecast) -> Forecast:
"humidity": round(forecast.d.get("humidity") * 100, 2),
"cloud_coverage": round(forecast.d.get("cloudCover") * 100, 0),
"native_wind_speed": round(forecast.d.get("windSpeed"), 2),
"wind_gust_speed": round(forecast.d.get("windGust"), 2),
"wind_bearing": round(forecast.d.get("windBearing"), 0),
}

Expand All @@ -154,6 +155,7 @@ def _map_hourly_forecast(forecast) -> Forecast:
"native_pressure": forecast.d.get("pressure"),
"native_wind_speed": round(forecast.d.get("windSpeed"), 2),
"wind_bearing": round(forecast.d.get("windBearing"), 0),
"wind_gust_speed": round(forecast.d.get("windGust"), 2),
"humidity": round(forecast.d.get("humidity") * 100, 2),
"native_precipitation": round(forecast.d.get("precipIntensity"), 2),
"precipitation_probability": round(
Expand Down Expand Up @@ -189,7 +191,7 @@ async def async_setup_entry(


class PirateWeather(SingleCoordinatorWeatherEntity[WeatherUpdateCoordinator]):
"""Implementation of an PirateWeather sensor."""
"""Implementation of an Pirate Weather sensor."""

_attr_attribution = ATTRIBUTION
_attr_should_poll = False
Expand Down Expand Up @@ -235,7 +237,7 @@ def unique_id(self):

@property
def supported_features(self) -> WeatherEntityFeature:
"""Determine supported features based on available data sets reported by WeatherKit."""
"""Determine supported features based on available data sets reported by Pirate Weather."""
features = WeatherEntityFeature(0)

features |= WeatherEntityFeature.FORECAST_DAILY
Expand All @@ -244,7 +246,7 @@ def supported_features(self) -> WeatherEntityFeature:

@property
def available(self):
"""Return if weather data is available from PirateWeather."""
"""Return if weather data is available from Pirate Weather."""
return self._weather_coordinator.data is not None

@property
Expand All @@ -264,6 +266,15 @@ def native_temperature(self):

return round(temperature, 2)

@property
def cloud_coverage(self):
"""Return the cloud coverage."""
cloudCover = (
self._weather_coordinator.data.currently().d.get("cloudCover") * 100.0
)

return round(cloudCover, 2)

@property
def humidity(self):
"""Return the humidity."""
Expand All @@ -278,6 +289,13 @@ def native_wind_speed(self):

return round(windspeed, 2)

@property
def wind_gust_speed(self):
"""Return the wind gust speed."""
windGust = self._weather_coordinator.data.currently().d.get("windGust")

return round(windGust, 2)

@property
def wind_bearing(self):
"""Return the wind bearing."""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Weather data coordinator for the OpenWeatherMap (OWM) service."""
"""Weather data coordinator for the Pirate Weather service."""

import logging

Expand Down

0 comments on commit 8f9ea57

Please sign in to comment.