Skip to content

Commit

Permalink
chore: update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
eifinger committed Sep 21, 2021
1 parent 023c601 commit 38cc27c
Show file tree
Hide file tree
Showing 120 changed files with 2,968 additions and 1,475 deletions.
2 changes: 1 addition & 1 deletion custom_components/alexa_media/.translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"error": {
"2fa_key_invalid": "Clé 2FA intégrée non valide",
"connection_error": "Erreur de connexion; vérifier le réseau et réessayer",
"hass_url_invalid": "Impossible de se connecter à l'URL de Home Assistant. Veuillez vérifier l'URL interne sous Configuration - > Général",
"hass_url_invalid": "Impossible de se connecter à l'URL de Home Assistant. Veuillez vérifier l'URL externe sous Configuration - > Général",
"identifier_exists": "Email pour l'URL Alexa déjà enregistré",
"invalid_credentials": "Informations d'identification invalides",
"unknown_error": "Erreur inconnue, veuillez signaler les informations du journal"
Expand Down
2 changes: 1 addition & 1 deletion custom_components/alexa_media/.translations/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"error": {
"2fa_key_invalid": "Invalid Built-In 2FA key",
"connection_error": "Errore durante la connessione; controlla la rete e riprova",
"hass_url_invalid": "Impossibile collegarsi ad Home Assistant. Controllare l'URL interno nel menu Configurazione -> Generale",
"hass_url_invalid": "Impossibile collegarsi ad Home Assistant. Controllare l'URL esterno nel menu Configurazione -> Generale",
"identifier_exists": "L'Email per l'URL di Alexa è già stata registrata",
"invalid_credentials": "Credenziali non valide",
"unknown_error": "Errore sconosciuto, si prega di abilitare il debug avanzato e riportare i log informativi"
Expand Down
2 changes: 1 addition & 1 deletion custom_components/alexa_media/.translations/pt_PT.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"error": {
"2fa_key_invalid": "Chave 2FA integrada inválida",
"connection_error": "Erro ao conectar; verifique a rede e tente novamente",
"hass_url_invalid": "Não foi possível conectar ao URL do Home Assistant. Verifique o URL interno em Configuração - > Geral",
"hass_url_invalid": "Não foi possível conectar ao URL do Home Assistant. Verifique o URL externo em Configuração - > Geral",
"identifier_exists": "E-mail para URL Alexa já registado",
"invalid_credentials": "Credenciais inválidas",
"unknown_error": "Erro desconhecido, por favor habilite depuração avançada e informações de log de relatório"
Expand Down
16 changes: 10 additions & 6 deletions custom_components/alexa_media/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,16 +621,20 @@ async def async_update_data() -> Optional[AlexaEntityData]:
device_registry, config_entry.entry_id
):
for (_, identifier) in device_entry.identifiers:
if (
identifier
in hass.data[DATA_ALEXAMEDIA]["accounts"][email]["devices"][
if identifier in hass.data[DATA_ALEXAMEDIA]["accounts"][email][
"devices"
]["media_player"].keys() or identifier in map(
lambda x: slugify(f"{x}_{email}"),
hass.data[DATA_ALEXAMEDIA]["accounts"][email]["devices"][
"media_player"
].keys()
].keys(),
):
break
else:
device_registry.async_remove_device(device_entry.id)
_LOGGER.debug("Removing stale device %s", device_entry.name)
_LOGGER.debug(
"%s: Removing stale device %s", hide_email(email), device_entry.name
)

await login_obj.save_cookiefile()
if login_obj.access_token:
Expand All @@ -656,7 +660,7 @@ async def process_notifications(login_obj, raw_notifications=None):
previous = hass.data[DATA_ALEXAMEDIA]["accounts"][email].get(
"notifications", {}
)
notifications = {"process_timestamp": datetime.utcnow()}
notifications = {"process_timestamp": dt.utcnow()}
for notification in raw_notifications:
n_dev_id = notification.get("deviceSerialNumber")
if n_dev_id is None:
Expand Down
6 changes: 2 additions & 4 deletions custom_components/alexa_media/alexa_entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,7 @@ def parse_color_from_coordinator(
if value is not None:
hue = value.get("hue", 0)
saturation = value.get("saturation", 0)
brightness = parse_brightness_from_coordinator(coordinator, entity_id, since)
if brightness is not None:
return hue, saturation, brightness / 100
return hue, saturation, 1
return None


Expand Down Expand Up @@ -324,7 +322,7 @@ def is_cap_state_still_acceptable(
if formatted_time_of_sample:
try:
time_of_sample = datetime.strptime(
formatted_time_of_sample, "%Y-%m-%dT%H:%M:%S.%fZ"
formatted_time_of_sample, "%Y-%m-%dT%H:%M:%S.%f%z"
)
return time_of_sample >= since
except ValueError:
Expand Down
2 changes: 1 addition & 1 deletion custom_components/alexa_media/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"""
from datetime import timedelta

__version__ = "3.10.4"
__version__ = "3.10.8"
PROJECT_URL = "https://github.com/custom-components/alexa_media_player/"
ISSUE_URL = f"{PROJECT_URL}issues"

Expand Down
275 changes: 150 additions & 125 deletions custom_components/alexa_media/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,8 @@ async def _set_state(self, power_on, brightness=None, mired=None, hs=None):
self._requested_hs = None
else:
self._requested_hs = self.hs_color
self._requested_state_at = (
datetime.datetime.utcnow()
self._requested_state_at = datetime.datetime.now(
datetime.timezone.utc
) # must be set last so that previous getters work properly
self.async_write_ha_state()

Expand Down Expand Up @@ -362,125 +362,150 @@ def alexa_brightness_to_ha(alexa: Optional[float]) -> Optional[float]:
return (alexa / 100 * 255) if alexa is not None else None


# This is a fairly complete list of all the colors that Alexa will respond to.
# A couple weirder ones are skipped because the HA color utility don't know the RGB value
ALEXA_COLORS = [
"crimson",
"dark_red",
"firebrick",
"orange_red",
"red",
"deep_pink",
"hot_pink",
"light_pink",
"maroon",
"medium_violet_red",
"pale_violet_red",
"pink",
"plum",
"tomato",
"chocolate",
"dark_orange",
"maroon",
"coral",
"light_coral",
"light_salmon",
"peru",
"salmon",
"sienna",
"gold",
"goldenrod",
"lime",
"olive",
"yellow",
"chartreuse",
"dark_green",
"dark_olive_green",
"dark_sea_green",
"forest_green",
"green",
"green_yellow",
"lawn_green",
"light_green",
"lime_green",
"medium_sea_green",
"medium_spring_green",
"olive_drab",
"pale_green",
"sea_green",
"spring_green",
"yellow_green",
"blue",
"cadet_blue",
"cyan",
"dark_blue",
"dark_cyan",
"dark_slate_blue",
"dark_turquoise",
"deep_sky_blue",
"dodger_blue",
"light_blue",
"light_sea_green",
"light_sky_blue",
"medium_blue",
"medium_turquoise",
"midnight_blue",
"navy_blue",
"pale_turquoise",
"powder_blue",
"royal_blue",
"sky_blue",
"slate_blue",
"steel_blue",
"teal",
"turquoise",
"blue_violet",
"dark_magenta",
"dark_orchid",
"dark_violet",
"fuchsia",
"indigo",
"lavender",
"magenta",
"medium_orchid",
"medium_purple",
"orchid",
"purple",
"rosy_brown",
"violet",
"alice_blue",
"antique_white",
"blanched_almond",
"cornsilk",
"dark_khaki",
"floral_white",
"gainsboro",
"ghost_white",
"honeydew",
"ivory",
"khaki",
"lavender_blush",
"lemon_chiffon",
"light_cyan",
"light_steel_blue",
"light_yellow",
"linen",
"mint_cream",
"misty_rose",
"moccasin",
"old_lace",
"pale_goldenrod",
"papaya_whip",
"peach_puff",
"seashell",
"silver",
"snow",
"tan",
"thistle",
"wheat",
"white",
"white_smoke",
]
# This is a fairly complete list of all the colors that Alexa will respond to and their associated RGB value.
ALEXA_COLORS = {
"alice_blue": (240, 248, 255),
"antique_white": (250, 235, 215),
"aqua": (0, 255, 255),
"aquamarine": (127, 255, 212),
"azure": (240, 255, 255),
"beige": (245, 245, 220),
"bisque": (255, 228, 196),
"black": (0, 0, 0),
"blanched_almond": (255, 235, 205),
"blue": (0, 0, 255),
"blue_violet": (138, 43, 226),
"brown": (165, 42, 42),
"burlywood": (222, 184, 135),
"cadet_blue": (95, 158, 160),
"chartreuse": (127, 255, 0),
"chocolate": (210, 105, 30),
"coral": (255, 127, 80),
"cornflower_blue": (100, 149, 237),
"cornsilk": (255, 248, 220),
"crimson": (220, 20, 60),
"cyan": (0, 255, 255),
"dark_blue": (0, 0, 139),
"dark_cyan": (0, 139, 139),
"dark_goldenrod": (184, 134, 11),
"dark_green": (0, 100, 0),
"dark_grey": (169, 169, 169),
"dark_khaki": (189, 183, 107),
"dark_magenta": (139, 0, 139),
"dark_olive_green": (85, 107, 47),
"dark_orange": (255, 140, 0),
"dark_orchid": (153, 50, 204),
"dark_red": (139, 0, 0),
"dark_salmon": (233, 150, 122),
"dark_sea_green": (143, 188, 143),
"dark_slate_blue": (72, 61, 139),
"dark_slate_grey": (47, 79, 79),
"dark_turquoise": (0, 206, 209),
"dark_violet": (148, 0, 211),
"deep_pink": (255, 20, 147),
"deep_sky_blue": (0, 191, 255),
"dim_grey": (105, 105, 105),
"dodger_blue": (30, 144, 255),
"firebrick": (178, 34, 34),
"floral_white": (255, 250, 240),
"forest_green": (34, 139, 34),
"fuchsia": (255, 0, 255),
"gainsboro": (220, 220, 220),
"ghost_white": (248, 248, 255),
"gold": (255, 215, 0),
"goldenrod": (218, 165, 32),
"green": (0, 128, 0),
"green_yellow": (173, 255, 47),
"grey": (128, 128, 128),
"honey_dew": (240, 255, 240),
"hot_pink": (255, 105, 180),
"indian_red": (205, 92, 92),
"indigo": (75, 0, 130),
"ivory": (255, 255, 240),
"khaki": (240, 230, 140),
"lavender": (230, 230, 250),
"lavender_blush": (255, 240, 245),
"lawn_green": (124, 252, 0),
"lemon_chiffon": (255, 250, 205),
"light_blue": (173, 216, 230),
"light_coral": (240, 128, 128),
"light_cyan": (224, 255, 255),
"light_goldenrod_yellow": (250, 250, 210),
"light_green": (144, 238, 144),
"light_grey": (211, 211, 211),
"light_pink": (255, 182, 193),
"light_salmon": (255, 160, 122),
"light_sea_green": (32, 178, 170),
"light_sky_blue": (135, 206, 250),
"light_slate_grey": (119, 136, 153),
"light_steel_blue": (176, 196, 222),
"light_yellow": (255, 255, 224),
"lime": (0, 255, 0),
"lime_green": (50, 205, 50),
"linen": (250, 240, 230),
"magenta": (255, 0, 255),
"maroon": (128, 0, 0),
"medium_aqua_marine": (102, 205, 170),
"medium_blue": (0, 0, 205),
"medium_orchid": (186, 85, 211),
"medium_purple": (147, 112, 219),
"medium_sea_green": (60, 179, 113),
"medium_slate_blue": (123, 104, 238),
"medium_spring_green": (0, 250, 154),
"medium_turquoise": (72, 209, 204),
"medium_violet_red": (199, 21, 133),
"midnight_blue": (25, 25, 112),
"mint_cream": (245, 255, 250),
"misty_rose": (255, 228, 225),
"moccasin": (255, 228, 181),
"navajo_white": (255, 222, 173),
"navy": (0, 0, 128),
"old_lace": (253, 245, 230),
"olive": (128, 128, 0),
"olive_drab": (107, 142, 35),
"orange": (255, 165, 0),
"orange_red": (255, 69, 0),
"orchid": (218, 112, 214),
"pale_goldenrod": (238, 232, 170),
"pale_green": (152, 251, 152),
"pale_turquoise": (175, 238, 238),
"pale_violet_red": (219, 112, 147),
"papaya_whip": (255, 239, 213),
"peach_puff": (255, 218, 185),
"peru": (205, 133, 63),
"pink": (255, 192, 203),
"plum": (221, 160, 221),
"powder_blue": (176, 224, 230),
"purple": (128, 0, 128),
"rebecca_purple": (102, 51, 153),
"red": (255, 0, 0),
"rosy_brown": (188, 143, 143),
"royal_blue": (65, 105, 225),
"saddle_brown": (139, 69, 19),
"salmon": (250, 128, 114),
"sandy_brown": (244, 164, 96),
"sea_green": (46, 139, 87),
"sea_shell": (255, 245, 238),
"sienna": (160, 82, 45),
"silver": (192, 192, 192),
"sky_blue": (135, 206, 235),
"slate_blue": (106, 90, 205),
"slate_grey": (112, 128, 144),
"snow": (255, 250, 250),
"spring_green": (0, 255, 127),
"steel_blue": (70, 130, 180),
"tan": (210, 180, 140),
"teal": (0, 128, 128),
"thistle": (216, 191, 216),
"tomato": (255, 99, 71),
"turquoise": (64, 224, 208),
"violet": (238, 130, 238),
"wheat": (245, 222, 179),
"white": (255, 255, 255),
"white_smoke": (245, 245, 245),
"yellow": (255, 255, 0),
"yellow_green": (154, 205, 50),
}


def red_mean(color1: Tuple[int, int, int], color2: Tuple[int, int, int]) -> float:
Expand All @@ -506,11 +531,11 @@ def rgb_to_alexa_color(
rgb: Tuple[int, int, int]
) -> Tuple[Optional[Tuple[float, float]], Optional[Text]]:
"""Convert a given RGB value into the closest Alexa color."""
name = min(
ALEXA_COLORS,
key=lambda color_name: red_mean(rgb, alexa_color_name_to_rgb(color_name)),
(name, alexa_rgb) = min(
ALEXA_COLORS.items(),
key=lambda alexa_color: red_mean(alexa_color[1], rgb),
)
red, green, blue = alexa_color_name_to_rgb(name)
red, green, blue = alexa_rgb
return color_RGB_to_hs(red, green, blue), name


Expand Down
2 changes: 1 addition & 1 deletion custom_components/alexa_media/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"domain": "alexa_media",
"name": "Alexa Media Player",
"version": "3.10.4",
"version": "3.10.8",
"config_flow": true,
"documentation": "https://github.com/custom-components/alexa_media_player/wiki",
"issue_tracker": "https://github.com/custom-components/alexa_media_player/issues",
Expand Down
Loading

0 comments on commit 38cc27c

Please sign in to comment.