Skip to content

Commit

Permalink
DarkSky removed from HA as of 2023.4.0b6 (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
pnbruckner authored Apr 5, 2023
1 parent cd40a93 commit d2e9b06
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions custom_components/illuminance/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@
from astral.location import Location
import voluptuous as vol

from homeassistant.components.darksky.weather import MAP_CONDITION as DSW_MAP_CONDITION
try:
from homeassistant.components.darksky.weather import (
MAP_CONDITION as DSW_MAP_CONDITION
)
except ImportError:
DSW_MAP_CONDITION = None

from homeassistant.components.sensor import (
DOMAIN as SENSOR_DOMAIN,
PLATFORM_SCHEMA,
Expand Down Expand Up @@ -412,7 +418,14 @@ def _get_mappings(self, attribution: str | None, domain: str) -> None:
if pat.fullmatch(attribution):
self._sk_mapping += mapping
if DARKSKY_PATTERN.fullmatch(attribution) and domain == SENSOR_DOMAIN:
self._cd_mapping = DSW_MAP_CONDITION
if DSW_MAP_CONDITION is None:
_LOGGER.warning(
"%s appears to be a DarkSky sensor, "
"but DarkSky is no longer supported",
self.weather_entity,
)
else:
self._cd_mapping = DSW_MAP_CONDITION
self._entity_status = EntityStatus.OK_CONDITION

def _calculate_illuminance(self, now: datetime) -> Num:
Expand Down

0 comments on commit d2e9b06

Please sign in to comment.