Created
February 3, 2018 14:25
-
-
Save dvas0004/28e215398b760544404fa432df159050 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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