Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for switching TV on and off via CEC #240

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

dieterrosch
Copy link

Added two extra Alexa action to allow switching on and off the currently active CEC device by saying "Alexa, ask Kodi to switch (on/off) the (tv/television).

These two actions require the plugin from https://github.com/joshjowen/script.json-cec to be installed on Kodi, as there is currently no JSON API exposed for the CEC functionality.

@jingai
Copy link
Collaborator

jingai commented Dec 9, 2017

In my opinion, this belongs somewhere else, like home automation software. I don't think this skill is the place to turn on and off other equipment.

@m0ngr31
Copy link
Owner

m0ngr31 commented Dec 9, 2017

I'd hate to get involved with having to have a list of compatible plugins people need to install as well.

@dieterrosch
Copy link
Author

Hi Joe,

It's obviously up to you, but to be fair this is is a Kodi skill, and switching on and off the currently active CEC device IS a function Kodi supports out of the box using libCEC (since all the Raspberry Pi's have CEC Hardware). It even has functionality built-in to switch off the device when the screensaver kicks in. It's not like one is asking Kodi to switch on the kettle or some other device that has nothing to do with watching movies. Kodi and the TV it is connected to, are tightly coupled.

I agree having to use the plugin sucks, but at the moment Kodi doesn't expose the CEC functionality via JSON-RPC, so the plugin is the only way. If people don't need the functionality, they needn't install it. If the plug-in changes or stops working (unlikely since it is tiny and simple), it still doesn't break the skill, it just means that function won't work.

@willhowlett
Copy link

As this is a feature I would love to see I thought I'd give the pull request a go (using git fetch origin pull/240/head:240_cec to get the branch locally), however once deployed it breaks my endpoint with this error

"{u'message': u'An uncaught exception happened while servicing this request. You can investigate this with the zappa tail command.', u'traceback': ['Traceback (most recent call last):\\n', ' File \"/var/task/handler.py\", line 452, in handler\\n response = Response.from_app(self.wsgi_app, environ)\\n', ' File \"c:\\\\users\\\\will\\\\appdata\\\\local\\\\temp\\\\pip-build-4ykpow\\\\Werkzeug\\\\werkzeug\\\\wrappers.py\", line 903, in from_app\\n', ' File \"c:\\\\users\\\\will\\\\appdata\\\\local\\\\temp\\\\pip-build-4ykpow\\\\Werkzeug\\\\werkzeug\\\\wrappers.py\", line 57, in _run_wsgi_app\\n', ' File \"c:\\\\users\\\\will\\\\appdata\\\\local\\\\temp\\\\pip-build-4ykpow\\\\Werkzeug\\\\werkzeug\\\\test.py\", line 884, in run_wsgi_app\\n', \"TypeError: 'NoneType' object is not callable\\n\"]}"

Reverting back to Master and redeploying fixes the issue

@pittbull
Copy link

Getting this error message when merging:

Traceback (most recent call last):
  File "/var/task/handler.py", line 509, in lambda_handler
  return LambdaHandler.lambda_handler(event, context)
  File "/var/task/handler.py", line 237, in lambda_handler
  handler = cls()
  File "/var/task/handler.py", line 129, in __init__
  self.app_module = importlib.import_module(self.settings.APP_MODULE)
  File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module
  __import__(name)
  File "/var/task/alexa.py", line 1849
  kodi.AddonExecute(self, addon_id="script.json-cec", params={"command":"activate"}):
                              ^
SyntaxError: invalid syntax

How can I add this modification?

@dieterrosch
Copy link
Author

@bigwillch @pittbull - I have been away on holiday, so haven't seen these messages. I will pull the latest master over the weekend, and see if I run into the same issues.

@pittbull
Copy link

pittbull commented Jan 11, 2018

@dieterrosch
I were able to run the code by merging and altering the following:

Removed the " : " and "self" from these two lines:

kodi.AddonExecute(self, addon_id="script.json-cec", params={"command":"activate"}): kodi.AddonExecute(self, addon_id="script.json-cec", params={"command":"standby"}):

The code now executes upon calling Alexa. I am fairly new to Python and doing my best to learn so I am not sure if these changes are correct, but it runs - for now. :)

I would appreciate some feedback when you've tested it.

@GrahamTheCoder
Copy link

Great work on this project. The only thing I was surprised was missing in the project was actually turning on the TV. I can't use it with the TV off, and once I'm already holding the remote, it seems silly to use voice commands. Hope the kinks get worked out and it's merged 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants