Pizzaface / Alexa-Chromecast-Skill-2.0

Allows Amazon Alexa to control Google Chromecast - Designed for Raspberry Pi
359 stars 65 forks source link

main.py will not run, regardless of environment variables #10

Closed Jademalo closed 6 years ago

Jademalo commented 6 years ago

I've been trying for an hour now, but main.py absolutely refuses to run regardless of what I do.

I ran aws-setup.sh, everything went fine save for a small issue with the lambda compile and having to add a sleep before running the lambda command. Once it was compiled this eventually ran without issue, and correctly set up AWS.

I then created the skill, though I had to delete the MOVIE definitions because it threw errors relating to them not existing. I think it's due to there not being MOVIE in customSlotTypes.txt.

I then added AWS_SNS_TOPIC_ARN and CHROMECAST_NAME to the environment variables as described. My chromecast is called "Kitchen", so this is what the variable is set to, and is what was used during aws-setup.sh

When trying to run main.py, I get the following error;

Traceback (most recent call last): File "./src/local/main.py", line 22, in <module> chromecast_skill = Skill(chromecast_name=os.getenv('CHROMECAST_NAME', 'Living Room')) File "/home/scotty/Source/AlexaChromecast/Alexa-Chromecast-Skill-2.0-master/src/local/ChromecastSkill.py", line 10, in __init__ self.cast = next(cc for cc in chromecasts if cc.device.friendly_name == chromecast_name) StopIteration

I tried changing 'Living Room' inside main.py to 'Kitchen' to see if that would help, and got the following error;

Traceback (most recent call last): File "./src/local/main.py", line 23, in <module> Subscriber({'chromecast': chromecast_skill}, PORT) File "/home/scotty/Source/AlexaChromecast/Alexa-Chromecast-Skill-2.0-master/src/local/SkillSubscriber.py", line 56, in __init__ endpoint_url = 'http://{}:{}'.format(self.get_external_ip(), port) File "/home/scotty/Source/AlexaChromecast/Alexa-Chromecast-Skill-2.0-master/src/local/SkillSubscriber.py", line 72, in get_external_ip return get('https://api.ipify.org').text File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 69, in get return request('get', url, params=params, **kwargs) File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 50, in request response = session.request(method=method, url=url, **kwargs) File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 465, in request resp = self.send(prep, **send_kwargs) File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 573, in send r = adapter.send(request, **kwargs) File "/usr/local/lib/python2.7/dist-packages/requests/adapters.py", line 370, in send timeout=timeout File "/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/connectionpool.py", line 544, in urlopen body=body, headers=headers) File "/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/connectionpool.py", line 344, in _make_request self._raise_timeout(err=e, url=url, timeout_value=conn.timeout) File "/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/connectionpool.py", line 314, in _raise_timeout if 'timed out' in str(err) or 'did not complete (read)' in str(err): # Python 2.6 TypeError: __str__ returned non-string (type Error)

Any advice? Thanks

LukeChannings commented 6 years ago

Hi Jademalo,

I made some updates today that might make it a bit easier to setup, and may solve your issues.

There's now a start.sh script that pulls environment variables directly from .env and I've tested it works, just make sure to install new local dependencies: sudo pip install -r ./src/local/requirements.txt.

I've also added the MOVIE slot type to customSlotTypes.txt so people don't trip up on that one.

After you do all that if you run python -c 'import pychromecast; chromecasts = pychromecast.get_chromecasts(); print(chromecasts)' is your Chromecast listed?

Keep in mind that in order for the local service to run it'll need to open a port, which usually it can do automatically with UPnP. If you've got UPnP disabled you'll need to manually map a port and pass a PORT environment variable.

In the future can you include the command you ran (omitting any sensitive information) with your trace, as well as the version of Python and OS you're running.

Thanks

Jademalo commented 6 years ago

Sorry for the slow reply, been super busy the last few weeks.

Thanks for the changes! I'll give it all a shot when I get a chance, I'll get back to you if there are any further issues. My router should fully support UPnP, I don't have it disabled.

Fingers crossed it all works, thanks again!

LukeChannings commented 6 years ago

Closing due to inactivity