diff --git a/README.md b/README.md index 3978045f..9472a80c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[Alexa Media Player Custom Component](https://github.com/keatontaylor/alexa_media_player) for homeassistant +[Alexa Media Player Custom Component](https://github.com/custom-components/alexa_media_player) for homeassistant # What This Is: This is a custom component to allow control of Amazon Alexa devices in [Homeassistant](https://home-assistant.io) using the unofficial Alexa API. Please note this mimics the Alexa app but Amazon may cut off access at anytime. @@ -16,15 +16,15 @@ Allows for control of Amazon Echo products as home assistant media devices with * Album Image # Installation and Configuration -Please see the [wiki.](https://github.com/keatontaylor/alexa_media_player/wiki/Installation-and-Configuration) +Please see the [wiki.](https://github.com/custom-components/alexa_media_player/wiki/Installation-and-Configuration) # Notable Additional Features ## Play Music -We can basically do anything a Alexa [Routine](https://www.amazon.com/gp/help/customer/display.html?nodeId=G202200080) can do. You'll have to [discover specifics](https://github.com/keatontaylor/alexa_media_player/wiki/Sequence-Discovery), but here are some examples (and please help add them below!). +We can basically do anything a Alexa [Routine](https://www.amazon.com/gp/help/customer/display.html?nodeId=G202200080) can do. You'll have to [discover specifics](https://github.com/custom-components/alexa_media_player/wiki/Sequence-Discovery), but here are some examples (and please help add them below!). To play music using the `media_player.play_media` service, you have to define the media_content_type appropriately. Search the [forum](https://community.home-assistant.io/t/echo-devices-alexa-as-media-player-testers-needed/58639/2055) for other examples. ## Notification service (versions >= 1.2.0) -Please see [Notification Component](https://github.com/keatontaylor/alexa_media_player/wiki/Notification-Component) for TTS, announcements, or mobile push. +Please see [Notification Component](https://github.com/custom-components/alexa_media_player/wiki/Notification-Component) for TTS, announcements, or mobile push. **Please note we do not support the the Media Player UI for TTS!** ## Online status of devices @@ -63,7 +63,7 @@ We also support [HACS](https://custom-components.github.io/hacs/). **This cannot In order to find Alexa Media Player, you first need to add the repository: 1. Open HACS 2. Go to Settings -3. Enter `https://github.com/keatontaylor/alexa_media_player`in **ADD CUSTOM REPOSITORY**. Select type `integration`. +3. Enter `https://github.com/custom-components/alexa_media_player`in **ADD CUSTOM REPOSITORY**. Select type `integration`. ## Guard Mode (versions >= 1.3.0) Arm and disarm Alexa guard mode using an Alarm Control Panel. To arm, use `ARM_AWAY`. `ARM_HOME` is the same as `DISARM`. Please ensure you've enabled through the [Alexa app](https://www.amazon.com/b?ie=UTF8&node=18021383011). @@ -71,13 +71,13 @@ Arm and disarm Alexa guard mode using an Alarm Control Panel. To arm, use `ARM_A We do not support any Guard notifications at the moment. ## Notification service (versions >= 1.2.0) -Please see [Notification Component](https://github.com/keatontaylor/alexa_media_player/wiki/Notification-Component). +Please see [Notification Component](https://github.com/custom-components/alexa_media_player/wiki/Notification-Component). # Further Documentation -Please see the [wiki](https://github.com/keatontaylor/alexa_media_player/wiki) +Please see the [wiki](https://github.com/custom-components/alexa_media_player/wiki) # Changelog -Use the commit history but we try to maintain this [wiki](https://github.com/keatontaylor/alexa_media_player/wiki/Changelog). +Use the commit history but we try to maintain this [wiki](https://github.com/custom-components/alexa_media_player/wiki/Changelog). # License [Apache-2.0](LICENSE). By providing a contribution, you agree the contribution is licensed under Apache-2.0. This is required for Home Assistant contributions. diff --git a/custom_components/alexa_media/__init__.py b/custom_components/alexa_media/__init__.py index 66f51a7d..6ee9aee1 100644 --- a/custom_components/alexa_media/__init__.py +++ b/custom_components/alexa_media/__init__.py @@ -130,7 +130,8 @@ async def setup_platform_callback(hass, config, login, callback_data): callback_data (json): Returned data from configurator passed through request_configuration and configuration_callback """ - _LOGGER.debug(("Status: %s got captcha: %s securitycode: %s" + _LOGGER.debug(("Configurator closed for Status: %s\n" + " got captcha: %s securitycode: %s" " Claimsoption: %s AuthSelectOption: %s " " VerificationCode: %s"), login.status, @@ -196,7 +197,7 @@ async def configuration_callback(callback_data): "Alexa Media Player - Verification Method - {}".format(email), configuration_callback, description=('Please select the verification method. ' - '(e.g., sms or email).\n{}'.format(options) + '(e.g., `sms` or `email`).\n{}'.format(options) # + links + footer), submit_caption="Confirm", @@ -212,7 +213,7 @@ async def configuration_callback(callback_data): "Alexa Media Player - OTP Method - {}".format(email), configuration_callback, description=('Please select the OTP method. ' - '(e.g., 0, 1).
{}'.format(options) + '(e.g., `0`, `1`).
{}'.format(options) # + links + footer), submit_caption="Confirm", @@ -462,10 +463,12 @@ async def update_bluetooth_state(login_obj, device_serial): ['media_player'] [device_serial]) - for b_state in bluetooth['bluetoothStates']: - if device_serial == b_state['deviceSerialNumber']: - device['bluetooth_state'] = b_state - return device['bluetooth_state'] + if 'bluetoothStates' in bluetooth: + for b_state in bluetooth['bluetoothStates']: + if device_serial == b_state['deviceSerialNumber']: + device['bluetooth_state'] = b_state + return device['bluetooth_state'] + return None async def last_call_handler(call): """Handle last call service request. @@ -588,10 +591,11 @@ async def ws_handler(message_obj): json_payload) bluetooth_state = await update_bluetooth_state(login_obj, serial) - hass.bus.async_fire( - ('{}_{}'.format(DOMAIN, - hide_email(email)))[0:32], - {'bluetooth_change': bluetooth_state}) + if bluetooth_state: + hass.bus.async_fire( + ('{}_{}'.format(DOMAIN, + hide_email(email)))[0:32], + {'bluetooth_change': bluetooth_state}) elif command == 'PUSH_MEDIA_QUEUE_CHANGE': # Player availability update serial = (json_payload['dopplerId']['deviceSerialNumber']) diff --git a/custom_components/alexa_media/const.py b/custom_components/alexa_media/const.py index fcdbd04c..019a267d 100644 --- a/custom_components/alexa_media/const.py +++ b/custom_components/alexa_media/const.py @@ -9,8 +9,8 @@ """ from datetime import timedelta -__version__ = '2.0.0' -PROJECT_URL = "https://github.com/keatontaylor/alexa_media_player/" +__version__ = '2.0.1' +PROJECT_URL = "https://github.com/custom-components/alexa_media_player/" ISSUE_URL = "{}issues".format(PROJECT_URL) DOMAIN = 'alexa_media' diff --git a/custom_components/alexa_media/manifest.json b/custom_components/alexa_media/manifest.json index cd951a9e..43d1eb0d 100644 --- a/custom_components/alexa_media/manifest.json +++ b/custom_components/alexa_media/manifest.json @@ -1,8 +1,9 @@ { "domain": "alexa_media", "name": "Alexa Media Player", - "documentation": "https://github.com/keatontaylor/alexa_media_player/wiki", + "documentation": "https://github.com/custom-components/alexa_media_player/wiki", "dependencies": [], "codeowners": ["@keatontaylor", "@alandtse"], - "requirements": ["alexapy==1.0.0"] + "requirements": ["alexapy==1.0.1"], + "homeassistant": "0.96.0" } diff --git a/custom_components/alexa_media/media_player.py b/custom_components/alexa_media/media_player.py index 081749f0..88e88273 100644 --- a/custom_components/alexa_media/media_player.py +++ b/custom_components/alexa_media/media_player.py @@ -193,10 +193,10 @@ async def _handle_event(self, event): if (event.data['bluetooth_change']['deviceSerialNumber'] == self.device_serial_number): self._bluetooth_state = event.data['bluetooth_change'] - self._source = self._get_source() - self._source_list = self._get_source_list() + self._source = await self._get_source() + self._source_list = await self._get_source_list() if (self.hass and self.async_schedule_update_ha_state): - await self.async_schedule_update_ha_state() + self.async_schedule_update_ha_state() elif 'player_state' in event.data: player_state = event.data['player_state'] if (player_state['dopplerId'] diff --git a/info.md b/info.md index 1a3b20d7..af483ca4 100644 --- a/info.md +++ b/info.md @@ -1,4 +1,4 @@ -[Alexa Media Player Custom Component](https://github.com/keatontaylor/alexa_media_player) for homeassistant +[Alexa Media Player Custom Component](https://github.com/custom-components/alexa_media_player) for homeassistant This is a custom component to allow control of Amazon Alexa devices in [Homeassistant](https://home-assistant.io) using the unofficial Alexa API. Please note this mimics the Alexa app but Amazon may cut off access at anytime. @@ -10,8 +10,8 @@ This is a custom component to allow control of Amazon Alexa devices in [Homeassi ## Useful links -- [General documentation](https://github.com/keatontaylor/alexa_media_player/wiki) -- [Installation and Configuration](https://github.com/keatontaylor/alexa_media_player/wiki/Installation-and-Configuration) -- [FAQ](https://github.com/keatontaylor/alexa_media_player/wiki/FAQ) -- [Repository](https://github.com/keatontaylor/alexa_media_player) +- [General documentation](https://github.com/custom-components/alexa_media_player/wiki) +- [Installation and Configuration](https://github.com/custom-components/alexa_media_player/wiki/Installation-and-Configuration) +- [FAQ](https://github.com/custom-components/alexa_media_player/wiki/FAQ) +- [Repository](https://github.com/custom-components/alexa_media_player) - [Forum post](https://community.home-assistant.io/t/echo-devices-alexa-as-media-player-testers-needed/58639)