Student Techlife
  • Categories
    • Student Life
    • Technology
    • Home Assistant
    • 3D Printing
    • DIY
  • My House
  • Projects
    • NIPKaart
    • Teddy Bear Hunting
    • NFC Scanner
  • Who am I?
  • Contact
Student Techlife Student Techlife
  • Categories
    • Student Life
    • Technology
    • Home Assistant
    • 3D Printing
    • DIY
  • My House
  • Projects
    • NIPKaart
    • Teddy Bear Hunting
    • NFC Scanner
  • Who am I?
  • Contact
365
139
61
  • Home Assistant
  • Student Life

My TV ๐Ÿ“บ is out of (own) control

  • June 2, 2019
  • No comments
  • 2.8K views
  • 4 minute read
  • Klaas Schoute
Total
0
Shares
1
0
0

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.

Total
1
Shares
Share 1
Tweet 0
Share 0
Avatar
Klaas Schoute

Computer science student who loves home automation 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
Green light in the bathroom
View Post
  • Home Assistant
  • Student Life

How I save water while showering๐Ÿšฟ

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

Is this going to be the future?

  • November 4, 2020
  • Klaas Schoute
View Post
  • College
  • Student Life

Back to school! ๐ŸŽ“

  • September 18, 2020
  • Klaas Schoute
View Post
  • Home Assistant
  • Student Life
  • Technology

Hello? What is your emergency? ๐Ÿ†˜

  • February 12, 2020
  • Klaas Schoute
View Post
  • College
  • Home Assistant
  • Student Life
  • Technology

My cookingplate died ๐Ÿณ

  • December 30, 2019
  • Klaas Schoute
View Post
  • Student Life

Shopping at Picnic ๐Ÿ›’

  • November 15, 2019
  • Klaas Schoute
View Post
  • Student Life
  • Technology

Welcome to Berlin! ๐Ÿ‡ฉ๐Ÿ‡ช

  • September 13, 2019
  • Klaas Schoute
View Post
  • Home Assistant
  • Student Life
  • Technology

Back to normal business ๐Ÿ‘จโ€๐Ÿ’ป

  • September 1, 2019
  • Klaas Schoute

Leave a Reply Cancel reply

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

Author
Klaas Schoute
Avatar
Computer science student who loves home automation and likes to take you on his adventure to…
Recent Posts
  • How I save water while showering๐Ÿšฟ December 25, 2020
  • Is this going to be the future? November 4, 2020
  • Back to school! ๐ŸŽ“ September 18, 2020
  • Hello? What is your emergency? ๐Ÿ†˜ February 12, 2020
  • My cookingplate died ๐Ÿณ December 30, 2019
Instagram
klaasnicolaas
standing on the balcony for an hour, for that one perfect photo โšก #dslr #thunder #rain #lightroom #netherlands #weather
Wat ik gisteren toch heb gespot! ๐Ÿ˜ฒ #naturephotography #ooievaar #oranjewoud
It's time ๐Ÿ•› for some programming for the Galaxy watch active2โŒš, Tizen OS here I come ๐Ÿ˜‹ #devops #tizenos @samsungnederland #wearable #smart #PAforyoungpeople
Maccie Christmas! ๐Ÿ˜… #mcdonalds #alkmaar
Follow
Archives
  • December 2020 (1)
  • November 2020 (1)
  • September 2020 (1)
  • February 2020 (1)
  • December 2019 (1)
  • November 2019 (1)
  • September 2019 (2)
  • August 2019 (1)
  • July 2019 (1)
  • June 2019 (3)
  • May 2019 (3)
  • April 2019 (3)
Student Techlife
  • Categories
  • My House
  • Projects
  • Who am I?
  • Contact

Input your search keywords and press Enter.