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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions alexa.py
Original file line number Diff line number Diff line change
Expand Up @@ -1829,6 +1829,35 @@ def alexa_ejectmedia(kodi):

return question(card_title)

# Handle the SwitchOnTV intent.
@ask.intent('SwitchOnTV')
@preflight_check
def alexa_switchontv(kodi):
card_title = render_template('switch_on_tv').encode('utf-8')
log.info(card_title)
kodi.AddonExecute(self, addon_id="script.json-cec", params={"command":"activate"}):

if not 'queries_keep_open' in session.attributes:
return statement(card_title).simple_card(card_title, '')

return question(card_title)

# Handle the SwitchOffTV intent.
@ask.intent('SwitchOffTV')
@preflight_check
def alexa_switchofftv(kodi):
card_title = render_template('switch_off_tv').encode('utf-8')
log.info(card_title)

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


if not 'queries_keep_open' in session.attributes:
return statement(card_title).simple_card(card_title, '')

return question(card_title)



# Handle the CleanVideo intent.
@ask.intent('CleanVideo')
Expand Down
Binary file added kodi-alexa-dev-1512772539.zip
Binary file not shown.
6 changes: 6 additions & 0 deletions speech_assets/IntentSchema.json
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,12 @@
{
"intent": "EjectMedia"
},
{
"intent": "SwitchOnTV"
},
{
"intent": "SwitchOffTV"
},
{
"intent": "PartyMode"
},
Expand Down
8 changes: 8 additions & 0 deletions speech_assets/SampleUtterances.en.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ CurrentPlayItemTimeRemaining when will this end
Down down
Down go down
Down navigate down
SwitchOnTV switch on the tv
SwitchOnTV switch on tv
SwitchOnTV switch on the television
SwitchOnTV switch on television
SwitchOffTV switch off the tv
SwitchOffTV switch off tv
SwitchOffTV switch off the television
SwitchOffTV switch off television
EjectMedia eject
EjectMedia eject audio disc
EjectMedia eject blu-ray
Expand Down
4 changes: 4 additions & 0 deletions templates.de.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,10 @@ clean_video: "Säubere Video Bibliothek"

ejecting_media: "Medium auswerfen"

switch_on_tv: "Switching on the TV"

switch_off_tv: "Switching off the TV"

suspending_system: "Schalte das System in den Bereitschaftsmodus"

quitting: "Beenden"
Expand Down
4 changes: 4 additions & 0 deletions templates.en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,10 @@ clean_video: "Cleaning video library"

ejecting_media: "Ejecting media"

switch_on_tv: "Switching on the TV"

switch_off_tv: "Switching off the TV"

quitting: "Quitting"

suspending_system: "Suspending system"
Expand Down
3 changes: 3 additions & 0 deletions utterances.en.txt
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,9 @@ Suspend go to sleep
EjectMedia eject (/media/disc/compact disc/audio disc/blu-ray/blu-ray disc/c. d./d. v. d.)
EjectMedia eject the (media/disc/compact disc/audio disc/blu-ray/blu-ray disc/c. d./d. v. d.)

SwitchOnTV switch on (/the) (tv/television)
SwitchOnTV switch off (/the) (tv/television)

PlayerSeekForward (step/jump) (/forward/forwards) (/by) {ForwardDur}
PlayerSeekForward forward (step/jump) by {ForwardDur}
PlayerSeekSmallForward (/small) (step/jump) (forward/forwards)
Expand Down