Integration with Broadlink TC2 and Broadlink Hub with Raspberry Pi

sorry about that

it worked thank you.

when I learn a code it does not show in logbook, it shows as a notification in the frontend. how can I copy it?

You can also find the code under Developer Tools → States.

1 Like

Hi I just used the

getBroadlinkSharedData.py

script to get the TC2 codes dumped.

I have a TC2 2 Gang, but the TC2.TXT files contains 6 codes … (Button ID from 245 to 250).

But I should have 2 codes no (or maybe 4, but not 6)???

Following these instructions

and getting the error
Input strings must be a multiple of 16 in length

I do not understand these phrases of the instruction

“If not working keep going 3,4,5,6 time until it works with the script.”

meand duplicate the code 3, 4, 5, 6 times???

Hi I have a strange problem.

I control a TC2 switch (RF433) from the RMPRO in HASS. When I trigger the switch with the automation, the signal sent is 2-3 times, so the TC2 goes ON, then OFF, then ON again. Same for when sending the signal OFF (goes OFF, then ON, then OFF).

A bit annoying.

  - platform: broadlink
    host: 192.168.1.90
    mac: 'b4:43:0d: 
    switches:
      storageroom:
        command_on: '6RRGAN8JFgkJFgkWCRYWCQkWFgkWCRYJCRYJFhYJCRYJFhYJCRYJFhYJCRYJFgkWCRYJFhYJCRYJFhYJFgkWCQkWCRYWCQkAAUjpFEYA3wkWCQkWCRYJFhYJCRYWCRYJFgkJFgkWFgkJFgkWFgkJFgkWFgkJFgkWCRYJFgkWFgkJFgkWFgkWCRYJCRYJFhYJCQABSOkURgDfCRYJCRYJFgkWFgkJFhYJFgkWCQkWCRYWCQkWCRYWCQkWCRYWCQkWCRYJFgkWCRYWCQkWCRYWCRYJFgkJFgkWFgkJAAFI6RRGAN8JFgkJFgkWCRYWCQkWFgkWCRYJCRYJFhYJCRYJFhYJCRYJFhYJCRYJFgkWCRYJFhYJCRYJFhYJFgkWCQkWCRYWCQkAAUjpFEYA3wkWCQkWCRYJFhYJCRYWCRYJFgkJFgkWFgkJFgkWFgkJFgkWFgkJFgkWCRYJFgkWFgkJFgkWFgkWCRYJCRYJFhYJCQABSOkURgDfCRYJCRYJFgkWFgkJFhYJFgkWCQkWCRYWCQkWCRYWCQkWCRYWCQkWCRYJFgkWCRYWCQkWCRYWCRYJFgkJFgkWFgkJAAFI'
        command_off: '6RRGAN8JCRYJFgkWCRYJFgkWFgkJFhYJCRYWCRYJCRYWCRYJCRYWCRYJCRYWCQkWFgkJFgkWCRYJFgkWFgkWCQkWFgkWCQkAAUjpFEYA3wkJFgkWCRYJFgkWCRYWCQkWFgkJFhYJFgkJFhYJFgkJFhYJFgkJFhYJCRYWCQkWCRYJFgkWCRYWCRYJCRYWCRYJCQABSOkURgDfCQkWCRYJFgkWCRYJFhYJCRYWCQkWFgkWCQkWFgkWCQkWFgkWCQkWFgkJFhYJCRYJFgkWCRYJFhYJFgkJFhYJFgkJAAFI6RRGAN8JCRYJFgkWCRYJFgkWFgkJFhYJCRYWCRYJCRYWCRYJCRYWCRYJCRYWCQkWFgkJFgkWCRYJFgkWFgkWCQkWFgkWCQkAAUjpFEYA3wkJFgkWCRYJFgkWCRYWCQkWFgkJFhYJFgkJFhYJFgkJFhYJFgkJFhYJCRYWCQkWCRYJFgkWCRYWCRYJCRYWCRYJCQABSOkURgDfCQkWCRYJFgkWCRYJFhYJCRYWCQkWFgkWCQkWFgkWCQkWFgkWCQkWFgkJFhYJCRYJFgkWCRYJFhYJFgkJFhYJFgkJAAFI'
        friendly_name: 'Storageroom'


  - alias: "Storageroom light on"
    initial_state: 'on'
    trigger:
      - platform: state
        from: 'off'
        to: 'on'
        entity_id: binary_sensor.door_window_sensor_158d000111a31c
    action:
      service: switch.turn_on
      entity_id: switch.storageroom
  - alias: "Storageroom light off"
    initial_state: 'on'
    trigger:
      - platform: state
        from: 'on'
        to: 'off'
        entity_id: binary_sensor.door_window_sensor_158d000111a31c
    action:
      service: switch.turn_off
      entity_id: switch.storageroom

I converted the TC2 signal following the instructions

Your TC2 code is so long.
The length of TC code is usually 148 and converted code is like a below.
“6RRGAN8JCRYWCQkWCRYJFhYJCRYWCQkWFgkJFgkWFgkJFgkWCRYWCRYJCRYWCQkWFgkWCRYJFgkWCRYJFgkWCQkWCRYWCQkAAUg=”
But it doesn’t now work in HA

You have to add ‘AAA=’ between the last ‘g’ and ‘=’ like this.
“6RRGAN8JCRYWCQkWCRYJFhYJCRYWCQkWFgkJFgkWFgkJFgkWCRYWCRYJCRYWCQkWFgkWCRYJFgkWCRYJFgkWCQkWCRYWCQkAAUgAAA==”
It will work well.

1 Like

No my problem,solved, was the position of the door sensor (vertical), putting them horizontal worked.

The code is 6 times long, only code working

Hi All,

Does anyone know how to get the states of the switches into frontend?

At the moment, when I turn on/off on the TC2 physically, the states on frontend do not change.

Also I can’t figure out how to change the title of the switch from “Switch”. I tried changing friendly_name to “Main” and Main (without quotes). Is this a bug or a configuration issue?

This is my config:
switch:

  • platform: broadlink
    host: 10.160.0.80
    mac: ‘34:EA:34:E7:F8:D6’
    friendly_name: Main
    timeout: 30

@osiris You can’t get the state from the TC2 switches because they are RF based switches so if you turn on/off physically you will not be able to see the change in HA.

Regarding the display of the switches names you should create a group and add it to the view you would like to see it in, for example, the default view, it should be something like this:

 switch:
  platform: broadlink
  host: 10.0.0.12
  mac: 'B4:00:00:00:00:00'
  timeout: 15
  switches:
    entrance_light:
      friendly_name: "Entrance Light"
      command_on: 'AAAAAAAAAAAAAAAAAAAAAAAA=='
      command_off: 'AAAAAAAAAAAAAAAAAAAAAAAA=='

    side_light:
      friendly_name: "Side Lights"
      command_on: 'AAAAAAAAAAAAAAAAAAAAAAAA=='
      command_off: 'AAAAAAAAAAAAAAAAAAAAAAAA=='


group:
  default_view:
    view: yes
    icon: mdi:home 
    entities:
      - group.g_entrance

  g_entrance:
    name: Entrance
    entities:
      - switch.entrance_light
      - switch.side_lights
1 Like

Thanks @NightRanger !

Any suggestions on how I can now get states on my lights setup? change the bulbs perhaps?

Use wifi light bulbs or zwave light switches instead of rf that are supported by HA.

1 Like

If they are compatible, you can build a RFLink Gateway i guess http://www.nemcon.nl/blog2/devlist

I am facing problem installing broadlink, got the below error when i tried to run

pip install broadlink==0.5

would appreciate your help as soon as possible.
providing that i am running python veionr 3.6.2

warning: GMP or MPIR library not found; Not building Crypto.PublicKey._fastmath.
building 'Crypto.Random.OSRNG.winrandom' extension
creating build\temp.win32-3.6
creating build\temp.win32-3.6\Release
creating build\temp.win32-3.6\Release\src
C:\Program Files\Microsoft Visual Studio 14.0\VC\BIN\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Isrc/ -Isrc/inc-msvc/ -Ic:\users\user\appdata\local\programs\python\python36-32\include -Ic:\users\user\appdata\local\programs\python\python36-32\include "-IC:\Program Files\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE" "-IC:\Program Files\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files\Windows Kits\10\include\10.0.10240.0\shared" "-IC:\Program Files\Windows Kits\10\include\10.0.10240.0\um" "-IC:\Program Files\Windows Kits\10\include\10.0.10240.0\winrt" /Tcsrc/winrand.c /Fobuild\temp.win32-3.6\Release\src/winrand.obj
winrand.c
C:\Program Files\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(26): error C2061: syntax error: identifier 'intmax_t'
C:\Program Files\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(27): error C2061: syntax error: identifier 'rem'
C:\Program Files\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(27): error C2059: syntax error: ';'
C:\Program Files\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(28): error C2059: syntax error: '}'
C:\Program Files\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(30): error C2061: syntax error: identifier 'imaxdiv_t'
C:\Program Files\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(30): error C2059: syntax error: ';'
C:\Program Files\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(40): error C2143: syntax error: missing '{' before '__cdecl'
C:\Program Files\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(41): error C2146: syntax error: missing ')' before identifier '_Number'
C:\Program Files\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(41): error C2061: syntax error: identifier '_Number'
C:\Program Files\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(41): error C2059: syntax error: ';'
C:\Program Files\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(42): error C2059: syntax error: ')'
C:\Program Files\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(45): error C2143: syntax error: missing '{' before '__cdecl'
C:\Program Files\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(46): error C2146: syntax error: missing ')' before identifier '_Numerator'
C:\Program Files\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(46): error C2061: syntax error: identifier '_Numerator'
C:\Program Files\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(46): error C2059: syntax error: ';'
C:\Program Files\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(46): error C2059: syntax error: ','
C:\Program Files\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(48): error C2059: syntax error: ')'
C:\Program Files\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(50): error C2143: syntax error: missing '{' before '__cdecl'
C:\Program Files\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(56): error C2143: syntax error: missing '{' before '__cdecl'
C:\Program Files\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(63): error C2143: syntax error: missing '{' before '__cdecl'
C:\Program Files\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(69): error C2143: syntax error: missing '{' before '__cdecl'
C:\Program Files\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(76): error C2143: syntax error: missing '{' before '__cdecl'
C:\Program Files\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(82): error C2143: syntax error: missing '{' before '__cdecl'
C:\Program Files\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(89): error C2143: syntax error: missing '{' before '__cdecl'
C:\Program Files\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(95): error C2143: syntax error: missing '{' before '__cdecl'
error: command 'C:\\Program Files\\Microsoft Visual Studio 14.0\\VC\\BIN\\cl.exe' failed with exit status 2

----------------------------------------

Command “c:\users\user\appdata\local\programs\python\python36-32\python.exe -u -c “import setuptools, tokenize;file=‘C:\Users\user\AppData\Local\Temp\pip-build-pgyufl0e\pycrypto\setup.py’;f=getattr(tokenize, ‘open’, open)(file);code=f.read().replace(’\r\n’, ‘\n’);f.close();exec(compile(code, file, ‘exec’))” install --record C:\Users\user\AppData\Local\Temp\pip-xyg769yb-record\install-record.txt --single-version-externally-managed --compile” failed with error code 1 in C:\Users\user\AppData\Local\Temp\pip-build-pgyufl0e\pycrypto\

I have the same problem with the same python version