Broadlink RM-PRO and A1 sensor

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’

To install two switches;

switch 1:
  platform: broadlink
  host: IP_ADDRESS1
  mac: 'MAC_ADDRESS2'
  switches:
    reciever:
      command_on: 'switch_packet on'
      command_off: 'switch_packet off'

switch 2:
  platform: broadlink
  host: IP_ADDRESS2
  mac: 'MAC_ADDRESS2'
  switches:
    reciever:
      command_on: 'switch_packet on'
      command_off: 'switch_packet off'

There seems to be a bug in the broadlink repo: https://github.com/mjg59/python-broadlink/issues/24
So until that is fixed, you have to manually install crypto

@akshitgupta1695 : What is your config?

How to?

I did this

pi@raspberrypi:~ $ pip install pycrypto
Requirement already satisfied (use --upgrade to upgrade): pycrypto in /usr/local/lib/python2.7/dist-packages
Cleaning up…
pi@raspberrypi:~ $

I installed it by using…

sudo pip install pycrypto

You should install it for python 3 not 2.7

It depends of how you have installed hass.
If you have a virtual environment, enable it first and then run pip3 install pycrypto
It should be a bit similar to how you upgrade hass.

yes virtual environemnt AIO installer on Pi3. Trying now

switch:

  • platform: broadlink
    host: 192.168.1.60
    mac: “b4:43:0d:aa:81:42”
    switches:
    rahulfrontlights:
    friendly_name: Room Front Lights
    command_on: ‘6UsyAA8NBwoGCwoGCgYLBgYKBwsKBgoHBwoHCgsGBwoHCgcKBgoHCQcKBgoHCgsGBwoLBgcLAAAAAAAA=’
    command_off: ‘6UsyAA8NBwoGCwoGCgYLBgYKBwsKBgoHBwoHCgsGBwoHCgcKBgoHCQcKBgoHCgsGBwoLBgcLAAAAAAAA=’
    rahulsidelights:
    friendly_name: Room Side Lights
    command_on: ‘6UsyAA8OBwsHCgsGCwYLBgcKBwoKBwoGBgoHCgsGBwoHCgcKBgoGCgsGBwoKBwYKBwoHCgcLAAAAAAAA=’
    command_off: ‘6UsyAA8OBwsHCgsGCwYLBgcKBwoKBwoGBgoHCgsGBwoHCgcKBgoGCgsGBwoKBwYKBwoHCgcLAAAAAAAA=’
    rahulthemelights:
    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QLCQYJBgYKBwgKBgYJBgoGCgYJBgoLBQUKCgYJBgoGCQcJBw0PBQoGCgkGCgYJBgYKBwgKBgoGBwgGCgkHBQoGCQcJBgoGCQoGBgkKBgoHCAYKBgsGDQ0GDAQKCQgIBgoGBQoGCgkHCgUGCgUKCgYGCQYKBgsECgYKCgYFCgkHCQYLBQkGCgYODgYKBwgKBgkICAYGCQYMCAYJCAUJBgkKBgYKBgkGCgYJBgoKBgYJCgYJBwkGCgYJBw4OBQsFCgkGCgcIBgYKBgkKBgoGBQoGCwgIBAsFCgYJBgoGCgkGBgsIBgoGCQYKBgoGDwwHCwYICwYIBgoHBAoGCgoGCQcFCgULCQcFCgcIBgoFCgYLCAYGCgoGCQYKBgkHCQAF3AAAAAA=’

And none of the switch commands are working? Have you tried to install crypto?

Why do the Air Quality, Noise and Light status now are showed as “0” or “1” instead of Excelent, Normal and Dark?
Have you noticed that as well?

And my switches seems not be working as well. Worked just one time, and than nothing anymore… Trying to reboot HA now.

my config:

switch:
  platform: broadlink
  host: 192.168.1.153
  mac: 'b4:43:0d:XX:XX:XX' 
  switches:
    reciever:
      command_on: 'JgBUAFATExQnEyYUJxMUEyYUFBMnExQTExQTExQAAx5NFBIVJhQmFCcTFBMnExMUJxMTFBMTExQUAAMeTRQSFCcTJxQnExMUJhQSFSYUExMTFBQTFAANBQAAAAA='
      command_off: 'JgBUAFATJxMmFCcTJxQSFCgTEhQnExMUFBMTFBMAAw5OEycUJhMnFCcTExQnExMTJxQUExIUExQUAAMNTRQnEycTJxQmFBMUJhQTFCcTExQTExQTFAANBQAAAAA='
      friendly_name: 'TV Sala'
    recievera:
      command_on: '1xU0ABQrMg8RLTEPES4xDxEuMQ8RLTEPES0xEBEtMQ8QLzAPES4RLhEuES4RLhEuMQ8xEBEAAdkAAAAA'
      command_off: '1xU0ABQrMg8RLTEPES4xDxEuMQ8RLTEPES0xEBEtMQ8QLzAPES4RLhEuES4RLhEuMQ8xEBEAAdkAAAAA'
      friendly_name: 'Luzes Natal'

I decided that number is better than text, because then you will get a graph. If you want text, you can make a template sensor

1 Like

Agreed!!!

But the switches are not working here!
They work just once on each HA reboot.

I followed instructions
"How to obtain IR/RF packets?

Choose Call Service from the Developer Tools. Choose the service broadlink/learn_command from the list of Available services: and hit CALL SERVICE. Press the button on your remote with in 20 seconds. The packet will be printed in the log and as a persistent notification."

where is the packet??? Which log?

@oliverdog: Any errors in the log?

@anon35356645: In home assistant log or as a persistent notification on the frontpage of hass

in the home assistant log I can’t find it (EDIT what do I look for?)

Yes I see it in the persistent log, but I can’t copy it (beside I don’t see it all