Broadlink RM-PRO and A1 sensor

I got it, but I already tried converting an existing code to Broadlink, but it did not work.
What I mean is you will need to convert those codes into a base64 one which must be understandable by RM/MINI, and that work is much more difficult than relearn again using the script, once you still have the remotes of course…

Ok, just for clarification, those codes are from Broadlink mini.

I think you could try to adapt the script and input your codes manually to test. I don´t know how to do that.

That would be an alterantive for those who lost their remotes, because you still need to lear the codes and than get them from app.

Is it easy to get them from mini? I have more than 100 remote buttons already learned in the app.

They are in my android device in file device storage\broadlink\newremote\SharedData\jsonIrCode

After converting your first button on web services I got this:

MzgsMCwtNDYsMCwtMTEwLC0xMDcsMTcsNTcsMTcsNTYsMTcsNTcsMTcsMTksMTgsMTks
MTcsMjAsMTcsMjAsMTcsMTksMTgsNTYsMTcsNTYsMTcsNTcsMTcsMjAsMTcsMTksMTcs
MjAsMTcsMjAsMTcsMjAsMTcsMTksMTcsNTcsMTcsMTksMTgsMTksMTcsMjAsMTcsMjAs
MTcsMTksMTgsMTksMTcsNTcsMTcsMTksMTgsNTYsMTcsNTYsMTgsNTYsMTcsNTYsMTcs
NTcsMTcsNTYsMTcsMCw2LDIsLTExMCwtMTA3LDE3LDU3LDE3LDU2LDE3LDU3LDE3LDE5
LDE4LDE5LDE3LDIwLDE3LDIwLDE3LDE5LDE4LDU2LDE3LDU2LDE4LDU2LDE3LDIwLDE3
LDE5LDE3LDIwLDE3LDIwLDE3LDIwLDE3LDE5LDE3LDU3LDE3LDIwLDE3LDE5LDE3LDIw
LDE3LDIwLDE3LDE5LDE4LDE5LDE3LDU3LDE3LDE5LDE4LDU2LDE3LDU2LDE4LDU2LDE3
LDU2LDE3LDU3LDE3LDU2LDE3LDAsNiwxLC0xMDksLTEwNywxNyw1NywxNyw1NiwxNyw1
NywxNywxOSwxOCwxOSwxNywyMCwxNywyMCwxNywxOSwxNyw1NywxNyw1NiwxNyw1Nywx
NywyMCwxNywxOSwxNywyMCwxNywyMCwxNywyMCwxNywxOSwxNyw1NywxNywxOSwxOCwx
OSwxNywyMCwxNywyMCwxNywxOSwxOCwxOSwxNyw1NywxNywyMCwxNyw1NiwxNyw1Niwx
OCw1NiwxNyw1NiwxNyw1NywxNyw1NiwxNywwLDEzLDUsMCwwLDAsMCwwLDA=

It looks like many repetitions…
When in learning mode, rm-pro usually is able to learn as long as you keep pressing the button, this could cause the repetitions, could´t it?

By the way, this web service is this: http://base64converter.com/

I do not know if it is repetition or something else.
Anyway, if the module doesn’t natively support this format, it seems to me inefficient to find the way to convert it in base64 format.
You are right, it is much easier to use the script, it works like a charm. I just was confused by the problems you descried earlier.

my problems were solved after a rm update to last firmware.

hass isn’t in a virtualenv (haven’t figured that one out one windows, and imo this shouldn’t be required)
but there seems to be something wrong in general with dependencies and hass on windows…

i forced pip to install Crypto/pycripto in the \deps directory - where the now show.
i also added both libs to the requirements section so as to trigger hass’s own dependency mechanism:
in broadlink.py changed
REQUIREMENTS = []
to
REQUIREMENTS = [‘Crypto’,‘pycrypto’]

still no luck though,

Hi, I have 2 broadlink, one in Living room (pojector and few other IR controlled devices), and in TV room (TV, AVR, AC, and so on).

Does it make sense to get a Harmony Hub? A friend of mine is coming from the US and he can bring it relatively cheap (like 40US).
I wonder if it can have some good additional functionality

hello again - i figured it out.- [note: WINDOWS Specific]

first the required module Crypto is not installed with pip install Crypto
that installs another crypto module which is not the one we need.

pip install pycrypto fails on windows (an error which I ignored earlier … facepalm)
it requires binaries to be built which in turn requires Visual Studio

easy way out is to use a pre-built binary for windows from this repo
https://github.com/sfbahr/PyCrypto-Wheels
magic incantation:
pip install --use-wheel --no-index --find-links=https://github.com/sfbahr/PyCrypto-Wheels/raw/master/pycrypto-2.6.1-cp35-none-win_amd64.whl pycrypto

Thanks,
and may this little note save someone some time.

1 Like

I have made an initial version to support sp1 and sp2: https://github.com/home-assistant/home-assistant/pull/4961

I do not have these devices, so the code is untested.
I need someone to help test this, before I can add it to the main repo.

@undef Would be great if you could add it to the documentation; https://github.com/home-assistant/home-assistant.github.io/blob/next/source/_components/switch.broadlink.markdown

since 0.35 is released, do we need to remove broadlink.py from custom components?

Yes, you should do that

@anon35356645

The harmony setup is alot quicker (and easier IMO, no recording codes, they have a huge database of devices and you just enter your make and model) The ability to create activities in harmony and call them from the API is also a big plus. If you’re getting it for $40, I say go for it.

Thanks for making this official component in HA. I can now automated my IR devices with HA thanks to this component. I didn’t know that RM Pro has a temperature sensor in it. So this is kind of a surprise bonus for me.

With the support of SP1 and SP2, it can now support every switches RM Pro can control except the TC2 switches. I really hope it will be supported soon.

on removing and upgrading i am getting following error:

16-12-18 17:27:19 homeassistant.core: Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/usr/lib/python3.4/asyncio/tasks.py”, line 233, in _step
result = coro.throw(exc)
File “/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/core.py”, line 1050, in _event_to_service_call
yield from service_handler.func(service_call)
File “/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/switch/init.py”, line 87, in async_handle_switch_service
yield from switch.async_turn_on()
File “/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/helpers/entity.py”, line 353, in async_turn_on
None, ft.partial(self.turn_on, **kwargs))
File “/usr/lib/python3.4/asyncio/futures.py”, line 388, in iter
yield self # This tells Task to wait for completion.
File “/usr/lib/python3.4/asyncio/tasks.py”, line 286, in _wakeup
value = future.result()
File “/usr/lib/python3.4/asyncio/futures.py”, line 277, in result
raise self._exception
File “/usr/lib/python3.4/concurrent/futures/thread.py”, line 54, in run
result = self.fn(*self.args, **self.kwargs)
File “/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/switch/broadlink.py”, line 134, in turn_on
if self._sendpacket(self._command_on):
File “/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/switch/broadlink.py”, line 148, in _sendpacket
self._device.send_data(packet)
File “/home/hass/.homeassistant/deps/broadlink/init.py”, line 376, in send_data
self.send_packet(0x6a, packet)
File “/home/hass/.homeassistant/deps/broadlink/init.py”, line 214, in send_packet
aes = AES.new(bytes(self.key), AES.MODE_CBC, bytes(self.iv))
File “/srv/hass/hass_venv/lib/python3.4/site-packages/Crypto/Cipher/AES.py”, line 95, in new
return AESCipher(key, *args, **kwargs)
File “/srv/hass/hass_venv/lib/python3.4/site-packages/Crypto/Cipher/AES.py”, line 59, in init
blockalgo.BlockAlgo.init(self, _AES, key, *args, **kwargs)
File “/srv/hass/hass_venv/lib/python3.4/site-packages/Crypto/Cipher/blockalgo.py”, line 141, in init
self._cipher = factory.new(key, *args, **kwargs)
ValueError: AES key must be either 16, 24, or 32 bytes long

Confirming that both RM2 (TV On/Off) and MP2 (based on SP2) is working with pull 4961.

1 Like

on removing and upgrading i am getting following error and unable to send commands :File “/srv/hass/hass_venv/lib/python3.4/site-packages/Crypto/Cipher/blockalgo.py”, line 141, in init
self._cipher = factory.new(key, *args, **kwargs)
ValueError: AES key must be either 16, 24, or 32 bytes long

How would you use the code for 2 broadlink

switch:
  platform: broadlink
  host: IP_ADDRESS
  mac: 'MAC_ADDRESS'
  switches:
    reciever:
      command_on: 'switch_packet on'
      command_off: 'switch_packet off'

platform: broadlink 1

and another
platform: broadlink 2

or just 2 times
platform: broadlink

?

Other proble3m.
Following these instructions
"Choose Call Service from the Developer Tools. Choose the service broadlink/learn_command from the list of Available services: and hit CALL SERVICE. "

but I don’t have any broadlink learn command???
This is the code added in configuration, what is wrong with it?

# Broadlink living room
switch:
  platform: broadlink
  host: 192.168.1.89
  mac: 'MAC'
  switches:
    p11_asus_router:
      command_on: 'JgAcAB0dHB44HhweGx4cHR06HB0cHhwdHB8bHhwADQUAAAAAAAAAAAAAAAA='
      command_off: 'JgAcAB0dHB44HhweGx4cHR06HB0cHhwdHB8bHhwADQUAAAAAAAAAAAAAAAA='

16-12-18 16:38:09 homeassistant.components.switch: Error while setting up platform broadlink
Traceback (most recent call last):
File “/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py”, line 150, in _async_setup_platform
entity_platform.add_entities, discovery_info
File “/usr/lib/python3.4/asyncio/futures.py”, line 388, in iter
yield self # This tells Task to wait for completion.
File “/usr/lib/python3.4/asyncio/tasks.py”, line 286, in _wakeup
value = future.result()
File “/usr/lib/python3.4/asyncio/futures.py”, line 277, in result
raise self._exception
File “/usr/lib/python3.4/concurrent/futures/thread.py”, line 54, in run
result = self.fn(*self.args, **self.kwargs)
File “/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/switch/broadlink.py”, line 48, in setup_platform
import broadlink
File “/home/hass/.homeassistant/deps/broadlink/init.py”, line 4, in
from Crypto.Cipher import AES
ImportError: No module named ‘Crypto’