Broadlink IR Media Player (For old, dump TVs)


#1

Hi,
Please check my new custom component that controls old TV’s with the standard media player component and Broadlink rm devices.


Broadlink RM-PRO and A1 sensor
Volume Slider with Broadlink
Xiaomi Universal IR vs Broadlink RM Mini 3 for best compatibility with Hass.io
CustomUI, dynamically change items displayed
Setting switch state automatically
First stab at Appdeamon
Chromecast Radio with station and player selection
First stab at Appdeamon
Controlling Philips TV and Panasonic HDD recorder with Broadlink RM Pro
Chromecast Radio with station and player selection
#2

This seems a great idea! I currently have a bunch of switches for the common functions, which look ugly :smiley:
I definitely have to try this!
Thanks!


#3

Hey @Vassilis I was trying to setup this but since I am a beginner I am having an issue. This is not appearing in frontend and this is how I arranged my files.

Folders were added to the directory that configuration.yaml is:
/custom_components/media_player/broadlink.py (copied yours and made no changes)
/broadlink_media_codes/samsung.ini (made changes for my samsung tv)

In the configuration.yaml I added these as well:

broadlink:
media_player: !include media_player.yaml

While in media_player.yaml i added these:

### Media Player ###
  - platform: broadlink
    name: Box TV
    host: 192.169.1.3
    mac: XX:XX:XX:XX:XX:XX
    ircodes_ini: samsung.ini

This is what i got from log:

Failed config
General Errors:
- Component not found: broadlink
- Setup failed for broadlink: Component not found.

######################################################################

When I made a change in folders of custom_component (/custom_components/broadlink.py), this is what i got on my log:

2017-11-15 14:33:48 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/usr/lib/python3.5/asyncio/tasks.py”, line 241, in _step
result = coro.throw(exc)
File “/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/homeassistant/setup.py”, line 61, in async_setup_component
return (yield from task)
File “/usr/lib/python3.5/asyncio/futures.py”, line 380, in iter
yield self # This tells Task to wait for completion.
File “/usr/lib/python3.5/asyncio/tasks.py”, line 304, in _wakeup
future.result()
File “/usr/lib/python3.5/asyncio/futures.py”, line 293, in result
raise self._exception
File “/usr/lib/python3.5/asyncio/tasks.py”, line 239, in _step
result = coro.send(None)
File “/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/homeassistant/setup.py”, line 213, in _async_setup_component
hass.config.components.add(component.DOMAIN)
AttributeError: module ‘custom_components.broadlink’ has no attribute 'DOMAIN’
Failed config
General Errors:
- Platform not found: media_player.broadlink

Any help would be much appreciated.


#4

how that look on HA? can you add image?


#5

Hi,
The correct path is /custom_components/media_player/broadlink.py

Also try this config:

- platform: broadlink
  name: Box TV
  host: 192.169.1.3
  mac: 'XX:XX:XX:XX:XX:XX'
  ircodes_ini: 'broadlink_media_codes/samsung.ini'

#6

It looks as a regular media player

media_player


#7

Yep, that worked. Thank you.


#8

@Vassilis Is there a chance to list channels with double digits? I see there are 0-9 but I want to add some with double or tripple digits.


#9

Yes of course. You are free to edit the sources section.
Please add:

[sources]
Any source name you want = IR code

You can also remove any source you want.


#10

@Vassilis I was more thinking how is the procedure to have double digits.

ex.

Channel 1 = askdjaskdhalsjdlkasjlkasjdasd= <— this is one digit IR
.
.
.
Channel 10 = ?? <— how would I add double digit IR ( 1 & 0 )


#11

Oh, I see. I’m afraid I can’t help you at this moment.
I am thinking to implement the possibility to add more than one commands separated by a comma. Let me think about it.


#12

That’s exactly what I am looking for. I will see if I come with a solution as well and let you know in case I do.


#13

Hi,

I have 2 questions about this module, I’m planning to use it for controling old amplifiers in the house.

1 - It should work with RF 433 codes instead of IR ones ? I have some ir to RF relays to control Zones on the amplifier, I think RF would be more flexible.

2 - all my codes are already in a Pronto CCF file. I can export the learned codes from the CCF file, for instance I get :
0000 006D 0022 0002 0155 00AA 0015 0015 0015 0040 0015 0015 0015 0040 0015 0040 0015 0040 0015 0040 0015 0015 0015 0040 0015 0015 0015 0040 0015 0015 0015 0015 0015 0015 0015 0015 0015 0040 0015 0040 0015 0040 0015 0015 0015 0040 0015 0040 0015 0040 0015 0040 0015 0015 0015 0015 0015 0015 0015 0040 0015 0015 0015 0015 0015 0015 0015 0015 0015 0040 0015 05ED 0155 0055 0015 0E47

With “pronto2broadlink.py” it becomes an Hex suite compatible with broadlink :
2600500000012692121212371212123712371237123712121237121212371212121212121212123712371237121212371237123712371212121212121237121212121212121212371200051d0001264912000c530d05000000000000

Converted to base64, I see a code that is slightly different from what I expect :
JgBQAAABJpISEhI3EhISNxI3EjcSNxISEjcSEhI3EhISEhISEhISNxI3EjcSEhI3EjcSNxI3EhISEhISEjcSEhISEhISEhI3EgAFHQABJkkSAAxTDQUAAAAAAAA=

I was expecting the code to begin with JgA ?


#14

I have just tried to get this custom component set up but I get the following errors and none of my media players load anymore:

017-12-04 13:05:29 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/usr/lib/python3.6/asyncio/tasks.py”, line 181, in _step
result = coro.throw(exc)
File “/usr/lib/python3.6/site-packages/homeassistant/setup.py”, line 61, in async_setup_component
return (yield from task)
File “/usr/lib/python3.6/asyncio/futures.py”, line 331, in iter
yield self # This tells Task to wait for completion.
File “/usr/lib/python3.6/asyncio/tasks.py”, line 244, in _wakeup
future.result()
File “/usr/lib/python3.6/asyncio/futures.py”, line 244, in result
raise self._exception
File “/usr/lib/python3.6/asyncio/tasks.py”, line 179, in _step
result = coro.send(None)
File “/usr/lib/python3.6/site-packages/homeassistant/setup.py”, line 160, in _async_setup_component
conf_util.async_process_component_config(hass, config, domain)
File “/usr/lib/python3.6/site-packages/homeassistant/config.py”, line 619, in async_process_component_config
platform = get_platform(domain, p_name)
File “/usr/lib/python3.6/site-packages/homeassistant/loader.py”, line 104, in get_platform
return get_component(PLATFORM_FORMAT.format(domain, platform))
File “/usr/lib/python3.6/site-packages/homeassistant/loader.py”, line 142, in get_component
module = importlib.import_module(path)
File “/usr/lib/python3.6/importlib/init.py”, line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 978, in _gcd_import
File “”, line 961, in _find_and_load
File “”, line 950, in _find_and_load_unlocked
File “”, line 655, in _load_unlocked
File “”, line 674, in exec_module
File “”, line 781, in get_code
File “”, line 741, in source_to_code
File “”, line 205, in _call_with_frames_removed
File “/config/custom_components/media_player/broadlink.py”, line 7

^
SyntaxError: invalid syntax

Can someone please help me out here?


#15

It seems to me that you paste some extra invalid characters. Please use raw mode on GitHub.


#16

Just an update if there are any Pronto user, I found an automated way to get all broadlink-compatible IR codes from my configuration.
1 - Export the IR codes from the Pronto, using for instance CCFExtactor. You’ll get one file per code.
2 - use the pronto2broadlink.py script, with a slight modification : change last line (print…) to

print(binascii.b2a_base64(packet))

So that it return the base64 encoded chain right now.

3 - if you’re under Linux, this small shell script will do :

for i in *
do  
  echo $;  
  var=$(sed 's/ //g' "$i")
  python pronto2broadlink.py $var > "$i".bl
done

Et voila… You get as many ‘.ir.bl’ files as you had codes, that can be integrated in the .ini file
For instance :
CD_PDS707 Pause.ir had

0000 0067 0000 0022 0156 00AC 0016 0015 0015 0040 0016 0015 0015 0015 0016 0015 0016 0040 0016 0015 0016 0040 0016 0041 0015 0015 0016 0040 0015 0040 0016 003F 0016 0015 0016 0040 0016 0018 0016 0015 0016 0015 0015 0015 0016 0041 0015 0040 0016 0015 0015 0015 0016 0018 0015 0040 0016 0040 0016 0041 0015 0017 0016 0015 0016 003F 0016 0040 0015 0040 0016 0402

And CD_PDS707 Pause.ir.bl is

JgBIAAABF4wRERE0ERERERERETQRERE0ETURERE0ETQRMxERETQRExERERERERE1ETQRERERERMRNBE0ETUREhERETMRNBE0EQADRQ0FAAAAAAAAAAAAAAAAAAA=

Which works right away in the media_player.

I also think a RF code would do in the ini file, but I have troubles making the RM learn those.


#17

I just downloaded the python file as is. I didn’t alter it at all


#18

@Vassilis, thanks for this amazing contribution. now my TV controls are all combined in a single entity.

May I suggest an improvement for this component?

instead of using ping_host to determined the actual state of the device, perhaps using a value_template like those in template switches is more flexible.

the reason is my TV is a dumb TV and cannot connect to my LAN. What I did was I installed a Sonoff POW on the power cord. Now it reports the TV power consumption to HA. With that, I can determined the TV state using the value of the power consumption.

I believe with value_template, we can also determined the device state using any entity including the device_tracker entities.


#19

I’ve updated the component :slight_smile: Please check it.


#20

Wow. Thank you so much @Vassilis !

By the way, is it possible to retain the state of each entities (those without watt sensor nor network) after restart? Right now when I restart HA, the state of the entity will become “off”.

Another suggestion is to include Play, Pause and Stop control under General section. You see, I also use this component for my Blu-ray player which has those buttons. It would be great if I can have those buttons on the media player card instead of under sources.