Control Your TV Via Google Home or Alexa Via Openhab and MQTT, ESP8266, Web Interface

10,089

19

6

About: I like to combine electronics like Arduino's, ESP8266 etc with 3D designing and 3D printing.

My Google Home Mini can stream Youtube etc on my TV, but was not able to switch on my TV. I solved this by this small device which receives commands via MQTT and sends IR signals to my TV.

The principle scheme is shown in the picture.

I attached a 18B20 temperature sensor for my home automation, it is not mandatory.

Step 1: Hardware

In this section I decribe the hardware. The module is powered by a 5V phone charger.

Components:

- ESP8266 (I used ESP-01 for its small size)

- IR LED

- Resistors (1K and 10K, 4.7K for the 18B20)

- Transistor to control the IR led (I used 2N2222)

- Voltage regulator (5V to 3.3V, I used XC6206)

- Capacitors for the voltage regulator (0.1 and 10 UF)

The electric scheme is attached. I made a compact module to fit in a small box.

The 18B20 was finally sealed in a heat shrink tube

Step 2: The Software and Openhab

The program is on my Github.

The Google Home Openhab integration is described here.

The module publishes a website via which you can control the module and read the temperature see the picture.

I use 3 MQTT topics for the communication:
power_topic = "SonyTV/power"
volumeup_topic = "SonyTV/volup"
volumedown_topic = "SonyTV/voldown"

You can find the IR codes online for your brand. I found the Sony TV codes here.

My Openhab items file:

Switch powerSony "Sony TV Power" [ "Switchable" ] {mqtt=">[mosquitto:SonyTV/power:command:*:default],<[mosquitto:SonyTV/power:state:default]"}
Switch powerSony2 "Sony TV Power2" [ "Switchable" ] {mqtt=">[mosquitto:SonyTV/power:command:*:default],<[mosquitto:SonyTV/power:state:default]"} Switch powerSony3 "Sony TV Power3" [ "Switchable" ] {mqtt=">[mosquitto:SonyTV/power:command:*:default],<[mosquitto:SonyTV/power:state:default]"} Switch volumeupSony"Sony TV Volume Up" [ "Switchable" ] {mqtt=">[mosquitto:SonyTV/volup:command:*:default],<[mosquitto:SonyTV/volup:state:default]"} Switch volumedownSony "Sony TV Volume Down" [ "Switchable" ] {mqtt=">[mosquitto:SonyTV/voldown:command:*:default],<[mosquitto:SonyTV/voldown:state:default]"}

Note: I use 3 different switches for the power, this is not mandatory of course. In Google Home they have aliases: "Sony TV", "My television" and "television".

My Sony TV only has a power toggle code, so 'power on' and 'power off' are the same. Therefore 'Google Home' does not know whether the TV is on or off. Anyone has a solution for this?

Share

    Recommendations

    • Organization Contest

      Organization Contest
    • Pie Contest

      Pie Contest
    • Build a Tool Contest

      Build a Tool Contest

    6 Discussions

    0
    None
    PercyFBAC6

    Reply 20 days ago

    Sure... But why buy, if you can build it?

    0
    None
    Wim3dBAC6

    Reply 19 days ago

    Thanks for your comment. A RM mini 3 seems like a great product, but I like to make things myself.
    With my device you can also control multiple devices if you program it with the right codes.