Skip to content

Instantly share code, notes, and snippets.

@dvas0004
Created February 3, 2018 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dvas0004/28e215398b760544404fa432df159050 to your computer and use it in GitHub Desktop.
Save dvas0004/28e215398b760544404fa432df159050 to your computer and use it in GitHub Desktop.
@ask.intent("TVPowerIntent", convert={'power':str})
def sourcetv(power):
power = power.lower()
msg = "Sorry! batman did not recognise your command"
if power == "on":
subprocess.check_output('echo "on 0" | cec-client RPI -s -d 1', shell=True)
msg = render_template('confirmed', confirmation="the t.v. is now on")
elif power == "off":
subprocess.check_output('echo "standby 0" | cec-client RPI -s -d 1', shell=True)
msg = render_template('confirmed', confirmation="the t.v. is now off")
return statement(msg)
@ask.intent("TVSourceIntent", convert={'sourcename':str})
def sourcetv(sourcename):
print sourcename
sourcename = sourcename.lower()
if sourcename == "kodi":
subprocess.check_output('echo "as" | cec-client RPI -s -d 1', shell=True)
msg = render_template('confirmed', confirmation="kodi is on t.v.")
elif sourcename == "satellite":
subprocess.check_output('echo "tx 1F:82:30:00" | cec-client RPI -s -d 1', shell=True)
msg = render_template('confirmed', confirmation="telia is on t.v.")
else:
msg = render_template('sorry', apologies="batman did not recognise "+sourcename)
return statement(msg)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment