Broadlink IR Media Player (For old, dump TVs)


#81

RC 0.67.0b0

2018-04-06 23:23:28 ERROR (MainThread) [homeassistant.components.media_player] Error while setting up platform broadlink
Traceback (most recent call last):
  File "/srv/ha/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 82, in async_setup
    SLOW_SETUP_MAX_WAIT, loop=hass.loop)
  File "/usr/lib/python3.6/asyncio/tasks.py", line 358, in wait_for
    return fut.result()
  File "/usr/lib/python3.6/asyncio/coroutines.py", line 210, in coro
    res = func(*args, **kw)
  File "/home/homeassi/.homeassistant/custom_components/media_player/broadlink.py", line 65, in async_setup_platform
    broadlink_device = broadlink.rm((ip_addr, 80), mac_addr)
TypeError: __init__() missing 1 required positional argument: 'devtype'

#82

Don’t know if this is correct, but it works with:

broadlink_device = broadlink.rm((ip_addr, 80), mac_addr, None)

in custom_components/media_player/broadlink.py, line 65


#83

@Vassilis could you please update the readme on your git page for this component to show the correct use of the power_consumption_entity in the example? I’m not sure how to code it correctly. Thanks in advance. (or if someone else can please post their example code)


#84

This seems to work for me -

media_player:
  - platform: broadlink
    name: Home Theater
    host: !secret broadlink_host
    mac: !secret broadlink_mac
    ircodes_ini: 'ir_codes.ini'
    power_consumption_entity: sensor.tv_power
    power_consumption_threshold: 5

#85

thank you!


#86

Dear Vassilis,
I would like to do some automation,
I am using your broadlink.py.

I want volume slider whcih works with your file and broadlink,
also i want to do some automation which shows slider when we increase with physical remote,

Please guide me
thanks in adv.


#87

I really like this project! Many thanks to @Vassilis
As I’m kind of new to building custom components and not a very expertised python programmer I have a question.
Would it be possible to control a switch which is available in home assistant, from a custom component script? What would the code look like?
In my case I have a TV connected to a Sonoff outlet so instead of turning the TV on and off via an ir-signal I’d like to just turn on and off the Sonoff switch because that’s why more reliable in my setup.
Thanks in advance!

This is my basic idea but I guess I need some type of import or something…

def turn_off(self):
    self.send_ir('general', 'turn_off')
    self._state = STATE_OFF
    self.schedule_update_ha_state()
    

  #This is where my idea starts I know that it doesn't work at all... 

    service_data = {'entity_id': 'switch.steckdose_1' }
    hass.services.call('light', 'turn_off', service_data, False)

#88

Hi,

What is the possibility of sending more than one signal at a time? for example 5 + 3 + 9?

Thanks


#89

Hi! Please take a look here:


#91

Hello ,your media_player can you add play button?


#93

Hi @Vassilis,

I followed your istruction but I can’t figure out how to manage power_consumption_threshold.

My dump TV is connected through a tp-link hs110 (with power meter). I’ve setup the component as following with a threshold of 28 w:

media_player:
  - platform: broadlink
    name: TV Cucina
    host: 192.168.2.205
    mac: '78:0F:77:5A:CB:78'
    ircodes_ini: 'broadlink_media_codes/philips.ini'
    power_consumption_entity: switch.presa_tpl1
    power_consumption_threshold: 28

The switch works but the status of media player doesn’t change.

Can you please support me?

Thank you in advance!


#94

Doesn’t work anymore in 0.84.0b0

2018-12-06 14:32:58 ERROR (MainThread) [homeassistant.loader] Error loading custom_components.media_player.broadlink. Make sure all dependencies are installed
Traceback (most recent call last):
  File "/srv/ha/lib/python3.6/site-packages/homeassistant/loader.py", line 92, 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 "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/homeassi/.homeassistant/custom_components/media_player/broadlink.py", line 20, in <module>
    from homeassistant.helpers.restore_state import async_get_last_state
ImportError: cannot import name 'async_get_last_state'
2018-12-06 14:32:58 ERROR (MainThread) [homeassistant.loader] Unable to find component media_player.broadlink

I think it has something to do with last states stored in .storage/core.restore_state, but cant find any PR at the moment.

EDIT: Got it


Custom component to declare/set variables
#95

Fixed. Thanks for the hint.


#96

Getting the following error after initial install.

Sat Dec 08 2018 21:41:17 GMT-0600 (Central Standard Time)

Error loading custom_components.media_player.broadlink. Make sure all dependencies are installed
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/loader.py", line 92, in get_component
    module = importlib.import_module(path)
  File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/config/custom_components/media_player/broadlink.py", line 21, in <module>
    from homeassistant.helpers.restore_state import RestoreEntity
ImportError: cannot import name 'RestoreEntity'

my config:

media_player:
  - platform: broadlink
    name: Livingroom TV
    host: 192.168.1.4
    mac: 'NOPE'
    ircodes_ini: 'broadlink_media_codes/livingroom.ini'
    ping_host: 192.168.1.15

any ideas?


#97

Hi, you are using the latest code which is compatible only with the upcoming version 0.84.X. Please use this code instead, but remember to update again when you install 0.84


#98

I bet that’s it! I have the latest code from Github


#99

hello I cloned your git in home / homeassistant / .homeassistant

media_player:

  • platform: broadlink
    name: Sony
    host: 192.160.1.7
    mac: '78: 0F: 77: 32: 12: A6 ’
    ircodes_ini: ‘broadlink_media_codes / sony.ini’
    ping_host: 192.168.1.4

but the error configuration:
Component not found: broadlink
Platform not found: media_player.broadlink

why?
what should I do?


#100

SO, by going back to the previous version of broadlink.py solved the original problem but now I get an error that the hassio: component failed to load. Also, the media player now shows up in the UI but nothing works.


#101

The file should be in
.homeassistant/custom_components/media_player/broadlink.py


#102

Hi!
Since you’ve been able to fix this, maybe you could hint as to how you did it? We also experience this same issue in the custom component variable, see: Custom component to declare/set variables,

which has been working flawlessly over the last 13 months, and hasn’t changed…