Page 6 of 13

Re: Using BROADLINK RM2 on DOMOTICZ

Posted: Saturday 22 October 2016 23:30
by aldodemi

Re: Using BROADLINK RM2 on DOMOTICZ

Posted: Sunday 23 October 2016 16:21
by forumfab
aldodemi wrote:Hi @forumfab, try now https://github.com/mjg59/python-broadlink
Hi aldodemi,

Now it's ok, i'll try

Bests regards

Forumfab

Re: Using BROADLINK RM2 on DOMOTICZ

Posted: Monday 07 November 2016 14:09
by forumfab
Hi aldodemi,

May i suggest to take a look about the protection of the Broadlink codes, full or parts for the BROADLINK API, in therm of laws .

Any part of code couldn't be use without BROADLINK agreement

Reverse engineering, is fully forbiden ..
Idem for the RM-BRIDGE , full or parts

Re: Using BROADLINK RM2 on DOMOTICZ

Posted: Monday 07 November 2016 18:48
by solucionesmipc
aldodemi wrote:Found another way to drive RM2 directly from Domoticz (I'm trying at least to do that :-)):

https://github.com/mjg59/python-broadlink

From python it works, now try to integrate in Domoticz.

I've created two different python command file:

- one to record code
- one to send code

As I have two device from Broadlink (RM2 and A1) I need to search for the correct one before learn code or send code via RM2.....

hI Aldo

please share your record command file.

i am not familiar with python.

thanks

diego

Re: Using BROADLINK RM2 on DOMOTICZ

Posted: Wednesday 09 November 2016 7:28
by sisaenkov
Broadlink RM Tasker supports RM3 mini since v1.3.0.
I use this app with domoticz and RM-Pro.

Re: RE: Re: Using BROADLINK RM2 on DOMOTICZ

Posted: Wednesday 09 November 2016 14:08
by Justintime
sisaenkov wrote:Broadlink RM Tasker supports RM3 mini since v1.3.0.
I use this app with domoticz and RM-Pro.
So you can write a tutorial in the wiki? As i understand it only works with Domoticz in combination with Windows?

Hmzz read the rm Tasker. But it says it's a battery drainer.

Re: RE: Re: Using BROADLINK RM2 on DOMOTICZ

Posted: Wednesday 09 November 2016 14:34
by sisaenkov
Justintime wrote:So you can write a tutorial in the wiki? As i understand it only works with Domoticz in combination with Windows?
I use Android wall tablet with this plugin and Raspberry with Domoticz.
There is no promblems to make it works.

You can get HTTP-command for IR/RF action from RM Plugin's Web API and put it in the On/Off-field of any Dummy-switch.
Image

P.S.
Here is my little example of using RM-Pro with wireless roller blinds: https://www.youtube.com/watch?v=opL8yxLomHI
Hmzz read the rm Tasker. But it says it's a battery drainer.
Yes, it is.
I'm waiting for Orange Pi to setup Android on it. Then will transfer RM Tasker from tablet to OPi.

Re: RE: Re: RE: Re: Using BROADLINK RM2 on DOMOTICZ

Posted: Wednesday 09 November 2016 14:37
by Justintime
sisaenkov wrote:
Justintime wrote:So you can write a tutorial in the wiki? As i understand it only works with Domoticz in combination with Windows?
I use Android wall tablet with this plugin and Raspberry with Domoticz.
There is no promblems to make it works.

You can get HTTP-command for IR/RF action from RM Plugin's Web API and put it in the On/Off-field of any Dummy-switch.
Image

P.S.
Here is my little example of using RM-Pro with wireless roller blinds: https://www.youtube.com/watch?v=opL8yxLomHI
Hmzz read the rm Tasker. But it says it's a battery drainer.
Yes, it is.
I'm waiting for Orange Pi to setup Android on it. Then will transfer RM Tasker from tablet to OPi.
Yes i understand if you have a wall tablet for Domoticz there is no problem with battery drain.
And this is another way to get it work in Domoticz. Not the one I need.

But thanks for sharing though. Looks nice.

Re: Using BROADLINK RM2 on DOMOTICZ

Posted: Friday 11 November 2016 0:42
by noddy119
Firstly Domoticz is a great piece of software :D

Using the python library from Matthew Garrett:-https://github.com/mjg59/python-broadlink I have created a some python scripts. One that locates the devices and reveals the required Host and MAC addresses, one that writes a learned code to a text file and another that reads it back and plays it through my blackbean RM3 mini IR. Banggood.com are selling these for £11 with free shipping: http://www.banggood.com/Broadlink-Black ... s=category

After a battle I now have a dummy Domoticz switch that turns my TV on and off! This only needs python and the library created by Matthew- no need for RM Bridge... It is simple to use as the script does not need changing per remote code only a text file (which is passed as a parameter) creating for each code.

I am running Domoticz on an Ubuntu Server, Domoticz v3.5837, Python 2.7

Python script for locating your Broadlink devices

Code: Select all

#!/usr/bin/python

#Script to locate Broadlink devices on local network by Graeme Brown Dec 23 2016
#These must be set up using the Broadlink app first!

import broadlink
import time

print "************************************************"
print "Using python library created by Matthew Garrett"
print "https://github.com/mjg59/python-broadlink"
print "************************************************"
print "Scanning network for Broadlink devices...."

mydevices = broadlink.discover(timeout=5)
print "Found " + str(len(mydevices )) + " broadlink devices"
time.sleep(1)
print "..............."

for index, item in enumerate(mydevices):

  mydevices[index].auth()

  ipadd = mydevices[index].host
  ipadd = str(ipadd)
  print "Device " + str(index + 1) +" Host address = " + ipadd[1:19]
  macadd = ''.join(format(x, '02x') for x in mydevices[index].mac[::-1])
  macadd = str(macadd)
 
  mymacadd = macadd[:2] + " " + macadd[2:4] + " " + macadd[4:6] + " " + macadd[6:8] + " " + macadd[8:10] + " " + macadd[10:12]
  print "Device " + str(index + 1) +" MAC address = " + mymacadd
  print "..............."
Python script for learning a remote code and saving to a text file - runs from command line (learn.py)

Code: Select all

#!/usr/bin/python

import broadlink
import time
import sys

device = broadlink.rm(host=("<your RM3 IP address>",80), mac=bytearray.fromhex("<your RM3 mac>"))

print "Connecting to Broadlink device...."
device.auth()
time.sleep(1)
print "Connected...."

codeName = raw_input("Please Enter Code Name  e.g. tvOff ")
time.sleep(1)
print "When Broadlink white led is lit press the button on your remote within 5 seconds"

device.host
device.enter_learning()
time.sleep(5)
ir_packet = device.check_data()
#convert code to hex
myhex = str(ir_packet).encode('hex'); 

if ir_packet == None:
	print "No button press read - quitting"
	sys.exit()
else:

# record learned hex code to file
	f = open(codeName +".txt",'w')
f.write(myhex)
f.close()

print "Hex code written to file named " + codeName + ".txt"
Python script to play back from text file (playcode.py). Test this from the command line first and then comment out the print and time.sleep lines so it runs faster from within Domoticz.

Code: Select all

#!/usr/bin/python

import broadlink
import time
import sys

try:
    fileName = sys.argv[1]
except IndexError:
    fileName = 'null'

if fileName == 'null':
	print "Error - no file name parameter suffixed"
	sys.exit()
else:

	device = broadlink.rm(host=("<your RM3 IP address>",80), mac=bytearray.fromhex("<your RM3 mac>"))

print "Connecting to Broadlink device...."
device.auth()
time.sleep(1)
print "Connected...."
time.sleep(1)
device.host

file = open(fileName, 'r')

myhex = file.read()

device.send_data(myhex.decode('hex'))
print "Code Sent...."
The path to put in your dummy switch on & off action is something like:

Code: Select all

script:///home/domoticz/scripts/python/playcode.py /home/domoticz/scripts/python/tvOff.txt
Important: After the path to the script, you need a space and the full path to the text file containing the learned code.

Re: Using BROADLINK RM2 on DOMOTICZ

Posted: Friday 11 November 2016 8:40
by sisaenkov
Nice way. Seems to be easier, but not so fast as Android plugin.

Re: Using BROADLINK RM2 on DOMOTICZ

Posted: Friday 11 November 2016 14:42
by djassa1
This is normal that actually this script is slower than rm-bridge, it does not stay connected to the broadlink like the later. In fact it needs to connect each time you send a command which takes several seconds.
If someone can build a script that runs like a daemon and waiting for commands to send to the braoadlink, it will become much faster that the rm-bridge because all commands will be sent locally with no handshake directly to the device.

Thanks to have built this script already, a very good thing in the right direction to control these really cheap ir and rf blasters.

Re: Using BROADLINK RM2 on DOMOTICZ

Posted: Friday 11 November 2016 18:24
by djassa1
Finally, just without all the sleep instructions in the playback code, make it as fast as the Android bridge or even faster. May be these sleep instruction are in case the device does not respond promptly but in my case with an RM2 I have no problems at all without the sleep instructions.

Re: Using BROADLINK RM2 on DOMOTICZ

Posted: Friday 11 November 2016 21:27
by noddy119
Thanks djassa1.

I changed my original post to advise to comment out the sleep and print lines as once you have it working via the command line they are not needed and do slow the execution down. I have a dummy switch linked to a mute code and there is no lag at all.

Re: Using BROADLINK RM2 on DOMOTICZ

Posted: Saturday 12 November 2016 14:08
by djassa1
Thanks to you noddy119 and to the library developer to bring us finally a non dependent app to a tier application to control the broadlink. Now, no reason to have an Android device with a pretty instable gateway app that make the broadlink unusable some times.
Yes the playback is really fast and react as expected.

Re: Using BROADLINK RM2 on DOMOTICZ

Posted: Sunday 13 November 2016 12:50
by forumfab
Hi all,

I did send some mails to BROADLINK's Team about this new project ( Python project)
For the moment there is no negativ reaction

In my point of view, it's a good new !

Of course the RM BRIDGE and RM WINDOWS TOOLS are still protected

But i think that it could be a great solution to have a full Python solution too.

In my point of view, this solution will be a full alternativ if :

- This solution could be a full package that could be simply install under linux ( wheezy, and Jessie )
- This package could integrated the librairies and the applications .PY and all other tools
- This project could arrive with the integration of an API ( like on the RM BRIDGE)

Bests regards

Re: Using BROADLINK RM2 on DOMOTICZ

Posted: Monday 14 November 2016 11:17
by Justintime
forumfab wrote:Hi all,

I did send some mails to BROADLINK's Team about this new project ( Python project)
For the moment there is no negativ reaction

In my point of view, it's a good new !

Of course the RM BRIDGE and RM WINDOWS TOOLS are still protected

But i think that it could be a great solution to have a full Python solution too.

In my point of view, this solution will be a full alternativ if :

- This solution could be a full package that could be simply install under linux ( wheezy, and Jessie )
- This package could integrated the librairies and the applications .PY and all other tools
- This project could arrive with the integration of an API ( like on the RM BRIDGE)

Bests regards
I think they will benefit also. If there is a "noob" way for implenting this in Domoticz. They will sell more..... as i speak for myself. I will order one.

Programming is not my cup of tea. Not with a proper manual.

Re: Using BROADLINK RM2 on DOMOTICZ

Posted: Tuesday 15 November 2016 13:00
by getafe83
Hello everybody.
Could someone explain the steps to use the python script ?.
I have copied the setup.py file and the Broadlink folder from the GitHub project, into a Raspberry Pi but I do not know how to make it work.

Re: Using BROADLINK RM2 on DOMOTICZ

Posted: Wednesday 16 November 2016 1:22
by getafe83
Hi,
I created a file called learn.py with the Noddy119 code.
But this gives the following error:

Code: Select all

pi@raspberrypi:~$ python learn.py
  File "learn.py", line 3
    import broadlink 
    ^
IndentationError: unexpected inden
t
pi@raspberrypi:~$ 

Re: Using BROADLINK RM2 on DOMOTICZ

Posted: Thursday 17 November 2016 17:07
by Keptenkurk
@getafe83. I sent you a PM
/paul

Re: Using BROADLINK RM2 on DOMOTICZ

Posted: Thursday 24 November 2016 12:17
by djassa1
Thanks @siklosi I will give it a try and let you know if it's faster than doing the whole handshake every time.