Student Techlife Student Techlife
  • Categories
    • Student Life
    • Technology
    • Home Assistant
    • 3D Printing
    • DIY
  • My House
  • My Projects
    • Home Assistant Glow
    • NIPKaart
    • Teddy Bear Hunting
    • NFC Scanner
  • Who am I?
  • Contact
0
842 Followers
165 Followers
Student Techlife Student Techlife Student Techlife
  • Categories
    • Student Life
    • Technology
    • Home Assistant
    • 3D Printing
    • DIY
  • My House
  • My Projects
    • Home Assistant Glow
    • NIPKaart
    • Teddy Bear Hunting
    • NFC Scanner
  • Who am I?
  • Contact
  • Home Assistant
  • Student Life

My TV 📺 is out of (own) control

  • June 2, 2019
  • Klaas Schoute

6-8-2019 – have stopped using the Broadlink RM Pro +

Nowadays I switched from the Broadlink to a Harmony Hub, so my code on Github has also been changed to the use of services that control the Harmony Hub. I have now added the basic code for using a Broadlink in this article.

Help my TV do weird things, Well no… it’s Home Assistant who is in control! Today we are going into the depths of a new part within my system, being able to operate your TV through “Hey Google turn on TV!” and more! 😀

To get this all working I use a Broadlink RM Pro, IFTTT and Google Assistant. Here and there you will find a link that refers to my code on github.

1. Find the right IR codes

I assume that you are already using a Broadlink device and that you have correctly set it up in Home Assistant. Then we have to figure out all the IR codes, so that we will later simulate the correct button from the remote control.

This goes as follow:

  1. In your UI go to developer tools -> Services.
  2. Choose the service: Broadlink.learn.
  3. Enter as service data: {“host”:”IP_ADDRESS OF BROADLINK”}
  4. Click on call service.
  5. Then point your remote control at the Broadlink device and press the desired button that you want to teach in.
  6. You now get a persistent notification in your UI with the IR code (base64 string), save it somewhere.
  7. Repeat these steps until you have saved all the buttons you want.

2. Scripts

Next, we will create script (see code below) for channels 0 through 9, each of which can send a broadlink package from the specific button with that number. If you have done this, check whether your TV responds with the correct numbers. During testing in my house, sometimes a IR code didn’t work well and I had to repeat the steps above.

# Channel 0
channel_0:
  alias: 'TV - Kanaal 0'
  sequence:
    - service: broadlink.send
      data:
        host: HOST_IP
        packet:
          - "IR CODE - BASE64 STRING"

You can of course also use the same service (service: broadlink.send) to have the TV change from source. put several packets underneath each other and especially view the documentation of the broadlink for even better examples.

3. Python code

I have found a python script (select_channel.py) on the community forum, with which Google Assistant will be able to independently match the right number combination and the underlying broadlink packages. So that you can call all channels on your TV with less hardcoded scripts.

4. If This Then That (IFTTT)

Now we will make sure that we can ask Google Assistant, to get the desired channel on TV through voice. Create a new applet with IF (Google Assistant) and THEN (Webhook). Below 2 screenshots so that you can see exactly what you must enter.

  • Google Assistant
  • Webhook

If you have also read my previous blog about bedtime / getting up, then you know that there must also be an automation (handle_ifttt.yaml) that handles the IFTTT requests. You have to add the attribute “channel” to the “data_template”, this to catch the number / tv channel that you say to google and use it in the python script.

From now on it is possible to say: “Hey Google! Channel 5 please”.

5. Switch TV on or off

It would also be nice if you could turn the TV on / off and that we could adjust the volume or mute the TV. How did I do that in the code? Well you can find it below.

---
# https://www.home-assistant.io/components/broadlink/#switch
#
platform: broadlink
host: BROADLINK_IP
mac: BROADLINK_MAC_ADDRESS
type: rm2_pro_plus
switches:
  tv_lg:
    friendly_name: "LG TV Power"
    command_on: 'IR CODE - BASE64 STRING'
    command_off: 'IR CODE - BASE64 STRING'
  tv_mute:
    friendly_name: "LG TV mute"
    command_on: 'IR CODE - BASE64 STRING'
    command_off: 'IR CODE - BASE64 STRING'
  tv_volume:
    friendly_name: "LG TV volume"
    command_on: 'IR CODE - BASE64 STRING'
    command_off: 'IR CODE - BASE64 STRING'

6. Make a remote in the UI

Who still uses his physical remote control?

To top it all off, sometimes it can also be nice if you can operate the TV from the UI / frontend. So I made a separate view (media_player.yaml) and build a kind of remote control made in lovelace.


Are things not clear? Or if you have come to ideas by reading this blog, about how I can make it cooler and better? Share it with me! Via Twitter, mail or Github.

Share
Tweet
Share
Klaas Schoute

Interaction technology (UX/UI) student who loves home automation, drones, open source projects and likes to take you on his adventure to the perfect smart student house.

Related Topics
  • broadlink
  • google home
  • Home Assistant
  • ifttt
  • remote
  • tv
Previous Article
  • Home Assistant
  • Student Life

Hey Google! Time to sleep 💤

  • May 16, 2019
  • Klaas Schoute
View Post
Next Article
  • Home Assistant
  • Student Life
  • Technology

So how is life after two months?

  • June 19, 2019
  • Klaas Schoute
View Post
You May Also Like
View Post
  • Home Assistant
  • Integration

easyEnergy market prices with new integration in Home Assistant

  • Klaas Schoute
  • February 26, 2023
View Post
  • Home Assistant
  • Integration

EnergyZero market prices with new integration in Home Assistant

  • Klaas Schoute
  • January 11, 2023
View Post
  • Projects
  • Student Life

🅿️ NIPKaart project update

  • Klaas Schoute
  • August 22, 2022
View Post
  • College
  • Home Assistant
  • Student Life

It’s a long time ago

  • Klaas Schoute
  • June 3, 2022
View Post
  • Home Assistant

First integration in Home Assistant!

  • Klaas Schoute
  • June 2, 2021
View Post
  • DIY
  • Home Assistant

Blitzwolf LT11 with ESPHome

  • Klaas Schoute
  • March 11, 2021
Green light in the bathroom
View Post
  • Home Assistant
  • Student Life

How I save water while showering🚿

  • Klaas Schoute
  • December 25, 2020
View Post
  • Home Assistant
  • Student Life
  • Technology

Is this going to be the future?

  • Klaas Schoute
  • November 4, 2020

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Author
Klaas Schoute
Interaction technology (UX/UI) student who loves home automation, drones, open source projects and likes to take you on his adventure to the perfect smart student house.
Recent Posts
  • easyEnergy market prices with new integration in Home Assistant February 26, 2023
  • EnergyZero market prices with new integration in Home Assistant January 11, 2023
  • Let’s contribute! Hacktoberfest 2022 October 2, 2022
  • 🅿️ NIPKaart project update August 22, 2022
  • It’s a long time ago June 3, 2022
Instagram
klaasnicolaas
When the weekend is almost over 😥
Iedereen een gelukkig nieuwjaar! 🥂
Finally received my @chonkerkeys last week, now online meetings are even more fun! 😁
Wauw wat een mooie show! Als je nog niet geweest moet je zeker gaan, kan nog t/m december 2022 (is alweer verlengd). #soldaatvanoranje #valkenburg #theaterhangaar
Follow


Student Techlife Student Techlife
  • Categories
  • My House
  • My Projects
  • Who am I?
  • Contact
Make a student life smarter

Input your search keywords and press Enter.