Skip to content

Commit

Permalink
Merge pull request #876 from custom-components/dev
Browse files Browse the repository at this point in the history
2020-08-22
  • Loading branch information
alandtse authored Aug 23, 2020
2 parents d72e5b1 + 590070c commit d0dd3b0
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 9 deletions.
5 changes: 4 additions & 1 deletion custom_components/alexa_media/.translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@
"title": "Alexa Media Player - Action Required"
}
},
"title": "Alexa Media Player"
"abort": {
"forgot_password": "The Forgot Password page was detected. This normally is the result of too may failed logins. Amazon may require action before a relogin can be attempted.",
"login_failed": "Alexa Media Player failed to login."
}
},
"options": {
"step": {
Expand Down
6 changes: 5 additions & 1 deletion custom_components/alexa_media/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,10 +311,14 @@ async def async_update_data():
login_obj.status,
)
if login_obj.status:
await hass.bus.async_fire(
hass.bus.async_fire(
"alexa_media_player/relogin_required",
event_data={"email": hide_email(email), "url": login_obj.url},
)
hass.bus.async_fire(
"alexa_media_player_relogin_required",
event_data={"email": hide_email(email), "url": login_obj.url},
)
await login_obj.reset()
await login_obj.login()
await test_login_status(hass, config_entry, login_obj, setup_alexa)
Expand Down
5 changes: 3 additions & 2 deletions custom_components/alexa_media/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,9 @@ async def _test_login(self):
},
)
if login.status and login.status.get("login_failed"):
_LOGGER.debug("Login failed")
return self.async_abort(reason="Login failed")
_LOGGER.debug("Login failed: %s", login.status.get("login_failed"))
await login.close()
return self.async_abort(reason=login.status.get("login_failed"),)
new_schema = self._update_ord_dict(
self.data_schema,
{
Expand Down
2 changes: 1 addition & 1 deletion custom_components/alexa_media/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"issue_tracker": "https://github.com/custom-components/alexa_media_player/issues",
"dependencies": ["configurator"],
"codeowners": ["@keatontaylor", "@alandtse"],
"requirements": ["alexapy==1.12.1"]
"requirements": ["alexapy==1.12.2"]
}
23 changes: 20 additions & 3 deletions custom_components/alexa_media/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,17 @@
import logging
from typing import List, Text # noqa pylint: disable=unused-import

from homeassistant.const import DEVICE_CLASS_TIMESTAMP, STATE_UNAVAILABLE
from homeassistant.const import (
DEVICE_CLASS_TIMESTAMP,
STATE_UNAVAILABLE,
__version__ as HA_VERSION,
)
from homeassistant.exceptions import ConfigEntryNotReady, NoEntitySpecifiedError
from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity import Entity
from homeassistant.util import dt
import pytz
import semver

from . import (
CONF_EMAIL,
Expand Down Expand Up @@ -419,7 +424,14 @@ def __init__(self, client, n_json, account):
# Class info
self._type = "Timer"
super().__init__(
client, n_json, "remainingTime", account, f"next {self._type}", "mdi:timer"
client,
n_json,
"remainingTime",
account,
f"next {self._type}",
"mdi:timer-outline"
if semver.compare(HA_VERSION, "0.113.0") >= 0
else "mdi:timer",
)

@property
Expand Down Expand Up @@ -449,7 +461,12 @@ def paused(self) -> bool:
@property
def icon(self):
"""Return the icon of the sensor."""
return self._icon if not self.paused else "mdi:timer-off"
off_icon = (
"mdi:timer-off-outline"
if (semver.compare(HA_VERSION, "0.113.0") >= 0)
else "mdi:timer-off"
)
return self._icon if not self.paused else off_icon


class ReminderSensor(AlexaMediaNotificationSensor):
Expand Down
5 changes: 4 additions & 1 deletion custom_components/alexa_media/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@
"title": "Alexa Media Player - Action Required"
}
},
"title": "Alexa Media Player"
"abort": {
"forgot_password": "The Forgot Password page was detected. Amazon may require action before a relogin can be attempted.",
"login_failed": "Alexa Media Player failed to login."
}
},
"options": {
"step": {
Expand Down

0 comments on commit d0dd3b0

Please sign in to comment.