Home > alexa, Android, Raspberry Pi > Alexa Turn on the TV

Alexa Turn on the TV

December 20th, 2016 Leave a comment Go to comments

 

Turn your regular old TV into a Smart TV with this script that emulates a Wemo smartplug called “Fauxmo,” an IR led circuit hooked up to a GPIO pin and a Raspberry pi! This is a walkthrough for getting it setup on your raspberry pi on your home network and making it callable by your Alexa Smart Home assistant.

 

 

Install LIRC:

sudo apt-get install lirc

Add this to your /etc/modules file:

lirc_dev
lirc_rpi gpio_in_pin=23 gpio_out_pin=22
Change your /etc/lirc/hardware.conf file to:
########################################################
# /etc/lirc/hardware.conf
#
# Arguments which will be used when launching lircd
LIRCD_ARGS=”–uinput”

# Don’t start lircmd even if there seems to be a good config file
# START_LIRCMD=false

# Don’t start irexec, even if a good config file seems to exist.
# START_IREXEC=false

# Try to load appropriate kernel modules
LOAD_MODULES=true

# Run “lircd –driver=help” for a list of supported drivers.
DRIVER=”default”
# usually /dev/lirc0 is the correct setting for systems using udev
DEVICE=”/dev/lirc0″
MODULES=”lirc_rpi”

# Default configuration files for your hardware if any
LIRCD_CONF=””
LIRCMD_CONF=””
########################################################
Now restart lircd so it picks up these changes:
sudo /etc/init.d/lirc stop
sudo /etc/init.d/lirc start

In the 3.18.x RaspberryPi firmware you must modify one additional file for the lirc-rpi kernel extension to be loaded:
Edit your /boot/config.txt file and add:
dtoverlay=lirc-rpi,gpio_in_pin=23,gpio_out_pin=22
Reboot your RaspberryPi after making this change.

 

 

 

Here is my schematic for the IR LED

 

 

 

 

 

 

 

 

 

 

Get a TV Config File for LIRC:

http://lirc.sourceforge.net/remotes/
# Copy over your new configuration file
sudo cp ~/lircd.conf /etc/lirc/lircd.conf

# Send the KEY_POWER command once from the shell
irsend SEND_ONCE Vizio_VX37L KEY_POWER

 

Install Fauxmo as a network switch for your TV:

Install the requirements: Python 2.7, pip and required Python modules
sudo apt-get install python-pip ; sudo pip install requests

Download the fauxmo files and the AlexaTV.py and Fauxmo script Here:

wget “https://github.com/Spacecase808/echo/archive/master.zip”

Extract the zip file
unzip master.zip -d echo

Move to the newly created echo folder
cd echo/echo-master

Start the server – you should see some debugging text indicating the server has started polling.
python AlexaTV.py

Modify this line in the python script to have your IR command that you wish to issue on voice command:
os.system(“irsend SEND_ONCE Vizio_VX37L KEY_POWER”)

Testing:

The Echo integrates with the WeMo home automation protocol – simply say “Alexa, discover my devices” and it’ll search the local network for WeMo devices. So let’s give it a device to discover!

Say to your Echo “Alexa: discover my devices”. She’ll take a few seconds to find the new device. If she doesn’t find it the first time, try killing and restarting the process and discovering devices again.

Say, “Alexa: turn off TV”, or “Alexa, TV on”. You’ll see an echo of the output Philips TV On/Off command from: IP of alexa.

Alternatively you could always think of other ways issue the IR commands through SSH to the raspberry pi from the command line. I have had some fun setting timers for volume mutes during commercial breaks.

Hope you have fun making this one

-James

 

 

 

Categories: alexa, Android, Raspberry Pi Tags:
  1. No comments yet.
  1. No trackbacks yet.