alandtse / alexa_media_player Goto Github PK
View Code? Open in Web Editor NEWThis is a custom component to allow control of Amazon Alexa devices in Home Assistant using the unofficial Alexa API.
License: Apache License 2.0
This is a custom component to allow control of Amazon Alexa devices in Home Assistant using the unofficial Alexa API.
License: Apache License 2.0
As I mentioned before in the home assistant commnuity support thread to this component, it would be nice so have a possibility to autoupdate this. This would be possible if add this to the custom updater component.
This issue is to refactor the codebase and ensure that the authentication and component access flow throughout the component is consistent. Major areas are how the configurator is being handled.
Moving this issue to its own so we can declutter #14.
I haven't tested it, but perhaps we change the Accept-Language header to "*" so we can accept whatever Amazon gives us and avoid having to check per region.
@dreimer1986, can you check?
I have a use case where I have echos that are on distinct accounts to intentionally restrict them from smarthome features, so that my kids can't torture each other, but I would love to be able remotely control them. Can the ability to have multiple accounts be added?
I'm rusty with python and have just started using home assistant a couple days ago, but I needed a notification component so I made this hackish custom component.
I'll be setting up the rest of my systems before I might come back to clean this up. Posting this just in case someone need something similar.
It might be easier for someone w/ more experience to clean it up.
There are some unnecessary imports, should probably confirm that the echo devices exist in hass, renamed to echo tts, have media_player.alexa dependencies set, and allow setting volume in config file too?
configurations:
notify:
- id: alexa_tts
name: Alexa TTS
platform: alexa_tts
alexa_devices:
- echo_dot
notify/alexa_tts.py
"""
Support for the Alexa media player Alex as a notification service.
"""
import logging
import json
from homeassistant.components import media_player
from homeassistant.components.notify import (
BaseNotificationService, ATTR_TITLE)
from homeassistant.const import (
CONF_API_KEY, CONF_DOMAIN, CONF_RECIPIENT, CONF_SENDER)
_LOGGER = logging.getLogger(__name__)
DEPENDENCIES = ['media_player','logger']
ALEXA_DEVICES = 'alexa_devices'
SERVICE_NAME = "Alexa TTS Notification"
ERROR_PREFIX = SERVICE_NAME + " Service Error"
def get_service(hass, config, discovery_info=None):
"""Get the Alexa TTS notification service."""
alexa_devices = config[ALEXA_DEVICES]
alexa_service = AlexaNotificationService(alexa_devices, hass)
if (alexa_service.devices_are_valid):
return alexa_service
else:
_LOGGER.error(ERROR_PREFIX+"alexa tts notification service devices are invalid")
return alexa_service
class AlexaNotificationService(BaseNotificationService):
"""Implement a notification service for the Alexa TTS notifier service."""
def __init__(self, alexa_devices, hass):
"""Initialize the service."""
_LOGGER.info(SERVICE_NAME + " is initializing")
self.alexa_devices = alexa_devices
self.hass = hass
def devices_are_valid(self):
_LOGGER.info(SERVICE_NAME + " is checking if devices are valid")
"""Check whether device exist."""
if not self.alexa_devices:
_LOGGER.error(ERROR_PREFIX + "alexa_devices parameter is empty or missing.")
return False
devices_are_valid = True
for device in self.alexa_devices:
if not device:
_LOGGER.error(ERROR_PREFIX+"An empty device is passed.")
devices_are_valid = False
continue
if (device not in hass.media_player):
_LOGGER.error(("{}: Device {} is invalid.").format(ERROR_PREFIX,
str(device)))
devices_are_valid = False
return devices_are_valid
def send_message(self, message="", **kwargs):
title = kwargs.get(ATTR_TITLE)
data = '. '.join(filter(None, [title, message]))
_LOGGER.info(SERVICE_NAME + " is sending message to alexa devices with data: " + data)
for alexa_device in self.alexa_devices:
_LOGGER.info(SERVICE_NAME + " TTS Service call on :" + alexa_device)
self.hass.services.call('media_player', 'alexa_tts',
{'entity_id':"media_player." + alexa_device,'message':data})
Hi
I'm trying to make of the last_called attribute. Ie things like "Alexa Turn On Lights" / "Alexa Turn On TV" and then based on the echo that was used turn on the lights for that room.
This #65 suggest that @brianhanifin got it working. But in my test there a good 10 seconds delay until the correct echo is reported back correctly.
Is there any way to force a refresh of the last_called attribute?
Cheers
I cant get alexa tts in my echo plus. I want spanish tts .Im from mexico and I try to conect to http://alexa.amazon.com.mx but not work. It only work with amazon.com. But i get this error in log Updating alexa media_player took longer than the scheduled update interval 0:00:10 and sometimes this error Error executing service <ServiceCall tts.google_say AttributeError: 'NoneType' object has no attribute 'group' any idea?
can anyone help please getting this error
2018-12-24 12:40:15 ERROR (MainThread) [homeassistant.components.media_player] Error while setting up platform alexa
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 128, in _async_setup_platform
SLOW_SETUP_MAX_WAIT, loop=hass.loop)
File "/usr/local/lib/python3.6/asyncio/tasks.py", line 358, in wait_for
return fut.result()
File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/media_player/alexa.py", line 146, in setup_platform
config.get(CONF_DEBUG))
File "/config/custom_components/media_player/alexa.py", line 618, in __init__
self.login_with_cookie()
File "/config/custom_components/media_player/alexa.py", line 641, in login_with_cookie
self.login(cookies=cookies)
File "/config/custom_components/media_player/alexa.py", line 776, in login
self._data = self.get_inputs(soup)
File "/config/custom_components/media_player/alexa.py", line 654, in get_inputs
for field in form.find_all('input'):
AttributeError: 'NoneType' object has no attribute 'find_all'
recently changed my password as i had an account compromised and now this won't work i have changed the password in my !secrets file
Lxml is not building in hassio so the dependency cannot be satisfied.
sense updated my homeassitant to 0.87 version cant set mediaplayer alexa
2019-02-07 22:55:38 DEBUG (SyncWorker_3) [custom_components.media_player.alexa] Trying cookie from file /config/alexa_media.pickle
2019-02-07 22:55:38 DEBUG (SyncWorker_3) [custom_components.media_player.alexa] Error loading pickled cookie from /config/alexa_media.pickle: An exception of type FileNotFoundError occurred. Arguments:
(2, 'No such file or directory')
2019-02-07 22:55:38 DEBUG (SyncWorker_3) [custom_components.media_player.alexa] No valid cookies for log in; using credentials
2019-02-07 22:55:40 DEBUG (SyncWorker_3) [custom_components.media_player.alexa] Get to https://alexa.amazon.com/api/devices-v2/device was redirected to https://www.amazon.com/ap/signin?showRmrMe=1&openid.return_to=https%3A%2F%2Falexa.amazon.com%2Fapi%2Fdevices-v2%2Fdevice&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.assoc_handle=amzn_dp_project_dee&openid.mode=checkid_setup&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_
2019-02-07 22:55:40 DEBUG (SyncWorker_3) [custom_components.media_player.alexa] Preparing post to https://www.amazon.com/ap/signin/143-6557016-2207107 Captcha: None SecurityCode: None Claimsoption: None VerificationCode: None
2019-02-07 22:55:41 DEBUG (SyncWorker_3) [custom_components.media_player.alexa] Error message: Important Message!
To better protect your account, please re-enter your password and then enter the characters as they are shown in the image below.
i have also deleted alexa_media.pickle file to see if help and nothing
A bad saved cookie won't login as the if-else login test logic is improperly nested. There's no else logic to go to the main login logic. I'll fix it soon.
If you're planning to upstream, you'll need to change your LICENSE to Apache-2.0 so that you can submit your addon later to the main tree. The issue is anyone who offers you a pull request will assume you're taking their code as GPL-3.0, which cannot be converted by you to Apache-2.0 later without explicitly asking for permission to convert. Asking to change licenses later is a pain particularly since you don't have a CLA in place. VLC Media player went through this and you can see the pain in that experience here. Based on the PR history, you seem clean of 3rd party code for now, so you may want to nip it in the bud.
Good job btw. Hope this succeeds.
Imported beta echo dot in italian using "amazon.it" in configuration.yaml , echo is imported and show music, but don't accept tts commands. Fix it in next version if you can, thanks.
For users without 2FA, Amazon will occasionally request a sms or email verification. This was the cause of at least one Captcha loop report.
Hello,
I had everything working fine, then i started getting errors so i updated the alexa.py file.. but now i home assistant can't find any devices and i get this error in the log:
"2018-07-18 17:04:08 WARNING (MainThread) [homeassistant.core] Unable to find service media_player/alexa_tts"
am i doing something wrong?
Best regards,
Diogo Ramos
It would be great I could could support the custom updater.
File "/config/custom_components/media_player/alexa.py", line 677
xcept Exception as ex:
^
SyntaxError: invalid syntax
its seems now the custom componets have diferent path, maybe update the structure?
home-assistant/core#20807
media_player/alexa.py
to alexa/media_player.py
Currently, we hardcode EN-US as the locale for much of the selection. It appears to cause no issues so far, but it may in the future.
Spawned from #74 where umlauts were not processed correctly by Amazon.
would it be possible to add to the media_player.alexa_tts option to have a input text for alexa to speack the input text directly on the media player?
Today I learned that alexa_remote_control.sh
can retrieve the last alexa device that was called. So, I downloaded the code and looked at the last_alexa()
function. After some experimenting I figured out that function generates the Alexa API URL of https://alexa.amazon.com/api/activities?startTime=&size=1&offset=1
.
A sample of JSON response is provided below. But the path we want is activities.sourceDeviceIds.serialNumber
! With the device's serial number we can direct TTS responses to the correct Echo. This is important to users like myself that have an Echo device in every major room of the house (Kitchen, Living Room, Family Room, Bed Room, etc.)
What do you say? Do you want to make an amazing upgrade to our favorite TTS component? :)
{
"activities": [{
"_disambiguationId": null,
"activityStatus": "SUCCESS",
"creationTimestamp": 1547351733581,
"description": "{\"summary\":\"turn on the living room computer\",\"firstUtteranceId\":\"A7WXQPH584YP:1.0/2019/01/13/03/G090QU0674750NLT/55:31::TNIH_2V.bcbda961-b9c8-4243-9d2d-b1f2279d6f1bZXV/1\",\"firstStreamId\":\"A7WXQPH584YP:1.0/2019/01/13/03/G090QU0674750NLT/55:31::TNIH_2V.bcbda961-b9c8-4243-9d2d-b1f2279d6f1bZXV\"}",
"domainAttributes": null,
"domainType": null,
"feedbackAttributes": null,
"id": "A12BCDEF3GH4I5#1547351733581#A7WXQPH584YP#G090QU0674750NLT",
"intentType": null,
"providerInfoDescription": null,
"registeredCustomerId": "A12BCDEF3GH4I5",
"sourceActiveUsers": null,
"sourceDeviceIds": [{
"deviceAccountId": null,
"deviceType": "A7WXQPH584YP",
"serialNumber": "G090QU0674750NLT"
}],
"utteranceId": "A7WXQPH584YP:1.0/2019/01/13/03/G090QU0674750NLT/55:31::TNIH_2V.bcbda961-b9c8-4243-9d2d-b1f2279d6f1bZXV",
"version": 1
}],
"endDate": 1547351733581,
"startDate": 1547351733581
}
last_alexa()
from alexa_remote_control.shlast_alexa()
{
${CURL} ${OPTS} -s -b ${COOKIE} -A "Mozilla/5.0" -H "DNT: 1" -H "Connection: keep-alive" -L\
-H "Content-Type: application/json; charset=UTF-8" -H "Referer: https://alexa.${AMAZON}/spa/index.html" -H "Origin: https://alexa.${AMAZON}"\
-H "csrf: $(awk "\$0 ~/.${AMAZON}.*csrf[ \\s\\t]+/ {print \$7}" ${COOKIE})" -X GET \
"https://${ALEXA}/api/activities?startTime=&size=1&offset=1" | jq -r '.activities[0].sourceDeviceIds[0].serialNumber' | xargs -i jq -r --arg device {} '.devices[] | select( .serialNumber == $device) | .accountName' ${DEVLIST}
}
The use of the configurator is very hackish right now. It appears there is a push for components to move to config flow which appears in the integrations panel.
I haven't found the definitive dev guide on config flow yet, but it's mentioned in the integration score guide.
Here's one component that uses it.
If anyone sees the right document or thread, please post it here.
Changing the configuration settings will continue to use prior cookies to log in. We should perform a check on logged in user and if it doesn't match, log out and delete the cookie. We recently added a check for the logged in user so that can be reused.
This probably makes sense to deal with the multi-account login logic #37 at the same time.
Error loading custom_components.media_player.alexa. Make sure all dependencies are installed
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/homeassistant/loader.py", line 147, in _load_file
module = importlib.import_module(path)
File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/config/custom_components/media_player/alexa.py", line 16, in <module>
from homeassistant.components.media_player import (
ImportError: cannot import name 'MEDIA_TYPE_MUSIC' from 'homeassistant.components.media_player' (/usr/local/lib/python3.7/site-packages/homeassistant/components/media_player/__init__.py)
Caused by change in package bundling:
Note for custom component developers: We are moving to a new file structure. Platforms now live embedded in components. Custom platforms will have to be updated to follow this pattern. This is a breaking change in case your custom platform overrides a built-in platform. Rename your custom platform from, ie light/hue.py to hue/light.py.
First I want to thank you for your hard work making alexa tts work in HA.
Just now I upgraded HA to version 0.78.0 and Alexa media_player is gone from dashboard I am now having exception in the logs:
2018-09-18 19:09:09 ERROR (MainThread) [homeassistant.components.media_player] Error while setting up platform alexa
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 128, in _async_setup_platform
SLOW_SETUP_MAX_WAIT, loop=hass.loop)
File "/usr/local/lib/python3.6/asyncio/tasks.py", line 358, in wait_for
return fut.result()
File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/media_player/alexa.py", line 142, in setup_platform
config.get(CONF_DEBUG))
File "/config/custom_components/media_player/alexa.py", line 607, in __init__
self.login_with_cookie()
File "/config/custom_components/media_player/alexa.py", line 630, in login_with_cookie
self.login(cookies=cookies)
File "/config/custom_components/media_player/alexa.py", line 701, in login
if (cookies is not None and self.test_loggedin(cookies)):
File "/config/custom_components/media_player/alexa.py", line 673, in test_loggedin
'/api/devices-v2/device')
File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 525, in get
return self.request('GET', url, **kwargs)
File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 512, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 644, in send
history = [resp for resp in gen] if allow_redirects else []
File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 644, in <listcomp>
history = [resp for resp in gen] if allow_redirects else []
File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 192, in resolve_redirects
proxies = self.rebuild_proxies(prepared_request, proxies)
File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 276, in rebuild_proxies
environ_proxies = get_environ_proxies(url, no_proxy=no_proxy)
File "/usr/local/lib/python3.6/site-packages/requests/utils.py", line 763, in get_environ_proxies
return getproxies()
File "/usr/local/lib/python3.6/urllib/request.py", line 2480, in getproxies_environment
for name, value in os.environ.items():
File "/usr/local/lib/python3.6/_collections_abc.py", line 744, in __iter__
yield (key, self._mapping[key])
File "/usr/local/lib/python3.6/os.py", line 669, in __getitem__
raise KeyError(key) from None
KeyError: 'OPENBLAS_MAIN_FREE'
Could it be caused by breaking changes in Home Assistant or is it just unsuccessful upgrade that would require for me to clear something and authenticate again?
Need to figure out how to avoid this error. I don't think it's a functional problem and we can still get accepted into HA with this error but it's not desirable.
Running 0.9.0. Error is added to the log once per minute.
Error doing job: Future exception was never retrieved
Traceback (most recent call last):
File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/media_player/alexa.py", line 167, in <lambda>
track_utc_time_change(hass, lambda now: update_devices(), second=30)
File "/usr/local/lib/python3.6/site-packages/homeassistant/util/__init__.py", line 325, in wrapper
result = method(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/homeassistant/util/__init__.py", line 325, in wrapper
result = method(*args, **kwargs)
File "/config/custom_components/media_player/alexa.py", line 189, in update_devices
update_devices, url)
File "/config/custom_components/media_player/alexa.py", line 253, in __init__
self.refresh(device)
File "/config/custom_components/media_player/alexa.py", line 293, in refresh
self._session['progress'] else None)
TypeError: argument of type 'NoneType' is not iterable
Hass.io 0.75.3 running on ResinOS 2.3.0+rev1. Supervisor 125.
For at least one German user attempting to login, the login process brings them to the switch account page. This page apparently relies on Javascript to render the switch user box and log off option, which means bs4 can't read the form option to process and our login script can't find a <form>
to pass data to.
Based on reviewing the captured html page, this can be partially replicated by disabling javascript and going to the appropriate switch account link from the main Amazon page which demonstrates a broken page without selectable info.
I think the region is a coincidence and likely could happen to any account.
The equivalent US switch account url is here
We need to explore options (best to worst in my mind)
EDIT: 1 may not be possible after some further looking; the post request is being protected by a data and crsf token which is generated by the JavaScript. 2 will probably work as it's a simple get to https://alexa.amazon.com/logout which then 302s to the Alexa login page.
Background: I have 4 Amazon Echos in the house. 2 of them were originally activated by me, 2 of them were activated by my wife. Once activate, you can attach multiple accounts to a device. All 4 of the devices are shown in my Amazon account, and my wife's account. When we are at a given device we can say "Alexa, switch accounts". This way my wife can play her music and I can play mine.
Problem: This script will successfully pull all 4 devices and show them, however, I can't control the ones originally activated by my wife. The reason is because this script is making the web request with my wife's deviceOwnerCustomerId (reported by Amazon as the owner), but I'm signed in as myself (a different deviceOwnerCustomerId). If I change the code to always use the deviceOwnerCustomerId of myself (hardcode) the script works fine.
Solution: I believe the fix for this is this component should access https://alexa.amazon.com/api/bootstrap and pull the deviceOwnerCustomerId of the current user. It would only need to do this one time (perhaps after it stores the cookies). It should then use this deviceOwnerCustomerId to make the calls, and not try to make the calls for another user that is not signed in. At the very least, perhaps a config option can be setup so that you can override the deviceOwnerCustomerId for all the calls.
This is not the same thing as #37 where they are asking for multiple logins.
I understand this code was copied from another library - I actually contacted the author of that plugin as well.
Hi,
When I run a spotify playlist in my HA automation for example, the media_player.echo_plus_bathroom
stays in state standby
in HA even though music is correctly playing. If I say alexa play chillout lounge on spotify
the same happens, no feedback on HA.
- service: media_player.play_media
data:
entity_id: media_player.echo_plus_bathroom
media_content_id: Chillout Lounge
media_content_type: SPOTIFY
It only happens for playlists apparently, and the Alexa App on my phone doesn't get feedback either. I'm running this in France
When sending an command to a single echo this works,
but sending an command to a alexa group of devices this won't work.
This problem concerns tunein and spotify.
Not sure if other services are affected.
Call service code:
{
"entity_id": "media_player.uberall",
"media_content_id": "Release Radar",
"media_content_type": "SPOTIFY"
}
{
"entity_id": "media_player.uberall",
"media_content_id": "eins live",
"media_content_type": "TUNEIN"
}
Thank you for your work put in to this component.
Please add possibility to change Echo device volume while it is in standby
state.
Currently volume can be changed when media_player in Home Assistant is in state playing
and paused
but in order to make alexa_tts service constantly speak text at certain volume.
Please add possibility to change Echo device volume and select tunein station via json?
When a specific piece of media is being played it shows all the info as expected.
However if a Radio station is being played on the device the media information is just set to 'standby'. Can the radio information be exposed in the media information attributes?
Create a test suite for the Alexa API to check for regression
Some ppl here complained about Alexa handling their TTS requests as speech command like "Alexa switch light x on". I'd like to actively use this in my case to run my custom skill doing stuff. Background is I want Alexa to say something when I need it to, but more as question where I can reply to and the reply triggers something. Example is I enter the home zone and get a "Welcome home, do you want your PC being switched on?" "Yeah/Nope" and it passes my answer to Home Assistant doin specific stuff. TTS does not allow that but passing my skill a secific command I can realize such behavior. Can this "mis"-behavior be added as a feature maybe?
Apologies in advance, I haven't fully fixed this yet, but wanted to report the issue and give you my findings.
As documented in the community thread, the Alexa component will fail to load with a JSONDecodeError.
The cause of the error is in AlexaAPI.get_devices because a valid JSON is not being returned from the Alexa device page, but instead an Amazon sign-on page is being returned.
This is because the login method has an incorrect test.
if 'devices' in post_resp.text
This fails because the sign in page does contain 'devices' so will give an incorrect true condition. The test should instead check for a json, which apparently in python requires a try clause.
(edit fixed a bug in the code)
try:
from json.decoder import JSONDecodeError
except ImportError:
JSONDecodeError = ValueError
try:
post_resp.json()['devices']
except JSONDecodeError:
status['login_failed'] = True
if ('login_failed' in status and status['login_failed']):
_LOGGER.debug("Log in failure.")
else:
status['login_failed'] = False
status['login_successful'] = True
_LOGGER.debug("Succesfully logged in.")
This should fix the login test, but it doesn't fix it completely as the AlexaAPI.get_devices call may still get another sign-in page. (This is where I had to stop; not sure why the existing login session isn't enough). I think the solution would be to have the get_devices page (and probably all API calls) automatically login if it detects it's getting the sign-in page.
I'll probably try to implement it and will submit a PR if I get to it before you.
I managed to get as far as successfully configuring the component but then it gets the below error which repeats approximately every 50 seconds.
018-08-08 18:27:45 DEBUG (SyncWorker_14) [custom_components.media_player.alexa] Using cookies to log in.
2018-08-08 18:27:47 DEBUG (SyncWorker_14) [custom_components.media_player.alexa] Logged in.
2018-08-08 18:27:47 DEBUG (SyncWorker_14) [custom_components.media_player.alexa] Log in successful with cookies
2018-08-08 18:27:47 DEBUG (SyncWorker_14) [custom_components.media_player.alexa] Setting up Alexa devices
2018-08-08 18:27:54 ERROR (MainThread) [homeassistant.core] Error doing job: Future exception was never retrieved
Traceback (most recent call last):
File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/media_player/alexa.py", line 192, in setup_alexa
update_devices()
File "/usr/local/lib/python3.6/site-packages/homeassistant/util/__init__.py", line 325, in wrapper
result = method(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/homeassistant/util/__init__.py", line 325, in wrapper
result = method(*args, **kwargs)
File "/config/custom_components/media_player/alexa.py", line 164, in update_devices
update_devices, url)
File "/config/custom_components/media_player/alexa.py", line 228, in __init__
self.refresh(device)
File "/config/custom_components/media_player/alexa.py", line 267, in refresh
self._media_is_muted = self._session['volume']['muted']
TypeError: 'NoneType' object is not subscriptable
If there is any further info you require let me know.
Regards,
Michal
The get_last_called Alexa request is not cached and will be pulled by every media_player refresh. This can result in excessive load if there are multiple echos on an account.
Also currently I have a flow in node red that sets the volume on all media devices to 10% at night and 30% during the morning. It would be great if I could set this and have it queued in the background. As well as possibly queueing mute state?
Originally posted by @niemyjski in #57 (comment)
Since update to version 1.0.0 on hassio 0.88.1 alex_tts seams to be not working ... with last version before 1.0.0 all was fine ... any hint or advice?
Currently I have your 0.9.0 script working, mainly for TTS push messages on NAS device errors. Problem I have now is that my amazon account is polluted with devices I stopped using ages ago like a 1st gen Fire TV Stick and "Mobile Devies" and a "This device". A way to stop enlisting these would be very nice.
I was trying to send a message to my Echos using if/else statement to change message depending on certain factors - like you can using the notify services. I assumed it would work with your custom alexa media player but it does not. Not sure if it can be worked in or not.
Example:
media_player.alexa_tts
{
"entity_id":"echo"
"message": "{% if ('sensor.somesensor', true) %}this{% else %}that{% endif %}"
}
Thank you for your great component
It would be great if the alexa.py component could support alexa multiroom groups.
Sep 01 16:58:42 raspberrypi hass[11271]: File "/home/homeassistant/.homeassistant/custom_components/media_player/alexa.py", line 203, in update_devices
Sep 01 16:58:42 raspberrypi hass[11271]: bluetooth = AlexaAPI.get_bluetooth(url, login_obj._session).json()
Sep 01 16:58:42 raspberrypi hass[11271]: AttributeError: 'NoneType' object has no attribute 'json'
Should be a simple fix to move the .json into the API like get_devices.
EDIT: Added other similar json errors.
Sep 01 10:20:56 raspberrypi hass[11271]: alexa_clients[device['serialNumber']].refresh(device)
Sep 01 10:20:56 raspberrypi hass[11271]: File "/home/homeassistant/.homeassistant/custom_components/media_player/alexa.py", line 321, in refresh
Sep 01 10:20:56 raspberrypi hass[11271]: session = self.alexa_api.get_state().json()
Sep 01 10:20:56 raspberrypi hass[11271]: AttributeError: 'NoneType' object has no attribute 'json'
I've been using this custom component very successfully for several months—Alexa TTS is so awesome.
However, updating to v0.10.0 seems to have broken the component for me and HASS throws the following error:
2019-01-25 16:13:41 ERROR (MainThread) [homeassistant.core] Error doing job: Future exception was never retrieved
Traceback (most recent call last):
File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/media_player/alexa.py", line 201, in <lambda>
track_utc_time_change(hass, lambda now: update_devices(), second=30)
File "/usr/local/lib/python3.6/site-packages/homeassistant/util/__init__.py", line 315, in wrapper
result = method(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/homeassistant/util/__init__.py", line 315, in wrapper
result = method(*args, **kwargs)
File "/config/custom_components/media_player/alexa.py", line 235, in update_devices
update_devices, url, authentication)
File "/config/custom_components/media_player/alexa.py", line 318, in __init__
self.refresh(device)
File "/config/custom_components/media_player/alexa.py", line 358, in refresh
self._last_called = self._get_last_called()
File "/config/custom_components/media_player/alexa.py", line 448, in _get_last_called
if self._device_serial_number == self.alexa_api.get_last_device_serial():
File "/config/custom_components/media_player/alexa.py", line 1008, in get_last_device_serial
if last_activity['activityStatus'](0) != 'DISCARDED_NON_DEVICE_DIRECTED_INTENT':
TypeError: 'str' object is not callable
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.