Skip to content

Commit

Permalink
Revert commits 644ca23 and e1bdd48
Browse files Browse the repository at this point in the history
  • Loading branch information
cloneofghosts authored Jun 16, 2024
1 parent e1bdd48 commit 1d9dd2a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 31 deletions.
2 changes: 1 addition & 1 deletion custom_components/pirateweather/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
"requirements": [
"python-forecastio==1.4.0"
],
"version": "1.5.2.1"
"version": "1.5.2"
}
51 changes: 21 additions & 30 deletions custom_components/pirateweather/sensor.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
"""Support for Pirate Weather (Dark Sky Compatable) weather service."""

import logging

from dataclasses import dataclass, field
from typing import Literal, NamedTuple

import voluptuous as vol
import homeassistant.helpers.config_validation as cv
import homeassistant.helpers.template as template_helper
import voluptuous as vol


from homeassistant.components.sensor import (
PLATFORM_SCHEMA,
SensorDeviceClass,
SensorEntity,
SensorEntityDescription,
SensorStateClass,
)
from typing import Literal, NamedTuple

from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import StateType
from homeassistant.helpers.typing import DiscoveryInfoType

from homeassistant.const import (
ATTR_ATTRIBUTION,
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
Expand All @@ -26,28 +35,27 @@
CONF_SCAN_INTERVAL,
DEGREE,
PERCENTAGE,
UV_INDEX,
UnitOfLength,
UnitOfPrecipitationDepth,
UnitOfPressure,
UnitOfSpeed,
UnitOfTemperature,
UnitOfLength,
UnitOfVolumetricFlux,
UnitOfPrecipitationDepth,
UV_INDEX,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import DiscoveryInfoType, StateType

from .const import (
ALL_CONDITIONS,
DEFAULT_SCAN_INTERVAL,
DOMAIN,
ENTRY_WEATHER_COORDINATOR,
PW_PLATFORM,
ALL_CONDITIONS,
PW_PLATFORMS,
PW_PLATFORM,
PW_PREVPLATFORM,
PW_ROUND,
)


from .weather_update_coordinator import WeatherUpdateCoordinator

_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -778,6 +786,7 @@ async def async_setup_entry(
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up Pirate Weather sensor entities based on a config entry."""

domain_data = hass.data[DOMAIN][config_entry.entry_id]

name = domain_data[CONF_NAME]
Expand Down Expand Up @@ -984,6 +993,7 @@ def extra_state_attributes(self):
@property
def native_value(self) -> StateType:
"""Return the state of the device."""

self.update_unit_of_measurement()

if self.type == "alerts":
Expand Down Expand Up @@ -1125,25 +1135,6 @@ def get_state(self, data):
]:
state = state * 3.6

if self.type in [
"uv_index",
]:
if state < 0 or state > 100:
_LOGGER.warning(
"UV Index is reporting %s which is outside the expected range! Setting UV Index to -1! Please report this issue to https://github.com/Pirate-Weather/pirateweather if not already reported.",
state,
)
state = -1
if self.type in [
"cloud_cover",
]:
if state > 100:
_LOGGER.warning(
"Cloud cover is reporting %s which is above 100%! Setting cloud cover to 100%! Please report this issue to https://github.com/Pirate-Weather/pirateweather if not already reported.",
state,
)
state = 100

if self.type in [
"dew_point",
"temperature",
Expand Down Expand Up @@ -1206,4 +1197,4 @@ def convert_to_camel(data):
"""
components = data.split("_")
capital_components = "".join(x.title() for x in components[1:])
return f"{components[0]}{capital_components}"
return f"{components[0]}{capital_components}"

0 comments on commit 1d9dd2a

Please sign in to comment.