Skip to content

Commit

Permalink
Removed all references to Alerts
Browse files Browse the repository at this point in the history
  • Loading branch information
briis committed Oct 22, 2022
1 parent 6240ecc commit 55b4454
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 53 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,6 +1,10 @@
# Change Log


## [1.0.15] - 2022-10-22

### Fixed

## [1.0.14] - 2022-10-13

### Fixed
Expand Down
4 changes: 2 additions & 2 deletions custom_components/weatherbit/manifest.json
Expand Up @@ -4,9 +4,9 @@
"config_flow": true,
"documentation": "https://github.com/briis/weatherbit",
"issue_tracker": "https://github.com/briis/weatherbit/issues",
"version": "1.0.14",
"version": "1.0.15",
"requirements": [
"pyweatherbitdata==1.0.13"
"pyweatherbitdata==1.0.15"
],
"codeowners": [
"@briis"
Expand Down
104 changes: 53 additions & 51 deletions custom_components/weatherbit/sensor.py
Expand Up @@ -37,20 +37,22 @@
ATTR_FORECAST_WIND_BEARING,
ATTR_FORECAST_NATIVE_WIND_SPEED,
)
from pyweatherbitdata.data import AlertDescription, ForecastDetailDescription

# from pyweatherbitdata.data import AlertDescription, ForecastDetailDescription
from pyweatherbitdata.data import ForecastDetailDescription
from .const import (
ATTR_ALERTS_CITY_NAME,
ATTR_ALERT_DESCRIPTION_EN,
ATTR_ALERT_DESCRIPTION_LOC,
ATTR_ALERT_EFFECTIVE,
ATTR_ALERT_ENDS,
ATTR_ALERT_EXPIRES,
ATTR_ALERT_ONSET,
ATTR_ALERT_REGIONS,
ATTR_ALERT_SEVERITY,
ATTR_ALERT_TITLE,
ATTR_ALERT_URI,
ATTR_ALERTS,
# ATTR_ALERTS_CITY_NAME,
# ATTR_ALERT_DESCRIPTION_EN,
# ATTR_ALERT_DESCRIPTION_LOC,
# ATTR_ALERT_EFFECTIVE,
# ATTR_ALERT_ENDS,
# ATTR_ALERT_EXPIRES,
# ATTR_ALERT_ONSET,
# ATTR_ALERT_REGIONS,
# ATTR_ALERT_SEVERITY,
# ATTR_ALERT_TITLE,
# ATTR_ALERT_URI,
# ATTR_ALERTS,
ATTR_AQI_LEVEL,
ATTR_FORECAST_CLOUDINESS,
ATTR_FORECAST_SNOW,
Expand All @@ -63,7 +65,7 @@
from .entity import WeatherbitEntity
from .models import WeatherBitEntryData

_KEY_ALERTS = "alerts"
# _KEY_ALERTS = "alerts"
_KEY_AQI = "aqi"


Expand Down Expand Up @@ -286,13 +288,13 @@ class WeatherBitSensorEntityDescription(
unit_type="none",
extra_attributes=False,
),
WeatherBitSensorEntityDescription(
key="alerts",
name="Weather Alerts",
icon="mdi:alert",
unit_type="none",
extra_attributes=True,
),
# WeatherBitSensorEntityDescription(
# key="alerts",
# name="Weather Alerts",
# icon="mdi:alert",
# unit_type="none",
# extra_attributes=True,
# ),
WeatherBitSensorEntityDescription(
key="forecast_day_1",
name="Forecast Day 1",
Expand Down Expand Up @@ -418,8 +420,8 @@ def __init__(
def native_value(self) -> StateType:
"""Return the state of the sensor."""

if self.entity_description.key == _KEY_ALERTS:
return getattr(self.coordinator.data, "alert_count")
# if self.entity_description.key == _KEY_ALERTS:
# return getattr(self.coordinator.data, "alert_count")

if self.entity_description.is_forecast_item:
self.forecast_data = getattr(self.forecast_coordinator.data, "forecast")
Expand Down Expand Up @@ -447,34 +449,34 @@ def icon(self):
@property
def extra_state_attributes(self):
"""Return the sensor state attributes."""
if self.entity_description.key == _KEY_ALERTS:
data = []
count = 1
alerts: AlertDescription = getattr(
self.coordinator.data, self.entity_description.key
)
for item in alerts:
data.append(
{
f"Alert No {count}": "-------------------",
ATTR_ALERT_TITLE: item.title,
ATTR_ALERT_SEVERITY: item.severity,
ATTR_ALERT_EFFECTIVE: item.effective_utc,
ATTR_ALERT_ONSET: item.onset_utc,
ATTR_ALERT_ENDS: item.ends_utc,
ATTR_ALERT_EXPIRES: item.expires_utc,
ATTR_ALERT_URI: item.uri,
ATTR_ALERTS_CITY_NAME: item.city_name,
ATTR_ALERT_REGIONS: item.regions,
ATTR_ALERT_DESCRIPTION_EN: item.en_description,
ATTR_ALERT_DESCRIPTION_LOC: item.loc_description,
}
)
count += 1
return {
**super().extra_state_attributes,
ATTR_ALERTS: data,
}
# if self.entity_description.key == _KEY_ALERTS:
# data = []
# count = 1
# alerts: AlertDescription = getattr(
# self.coordinator.data, self.entity_description.key
# )
# for item in alerts:
# data.append(
# {
# f"Alert No {count}": "-------------------",
# ATTR_ALERT_TITLE: item.title,
# ATTR_ALERT_SEVERITY: item.severity,
# ATTR_ALERT_EFFECTIVE: item.effective_utc,
# ATTR_ALERT_ONSET: item.onset_utc,
# ATTR_ALERT_ENDS: item.ends_utc,
# ATTR_ALERT_EXPIRES: item.expires_utc,
# ATTR_ALERT_URI: item.uri,
# ATTR_ALERTS_CITY_NAME: item.city_name,
# ATTR_ALERT_REGIONS: item.regions,
# ATTR_ALERT_DESCRIPTION_EN: item.en_description,
# ATTR_ALERT_DESCRIPTION_LOC: item.loc_description,
# }
# )
# count += 1
# return {
# **super().extra_state_attributes,
# ATTR_ALERTS: data,
# }
if self.entity_description.is_forecast_item:
_wind_spd = (
SpeedConverter.convert(
Expand Down

0 comments on commit 55b4454

Please sign in to comment.