Page 1 of 12

Python Plugin: Broadlink RM2

Posted: Monday 27 March 2017 18:23
by zak45
******************************************************
old version, no more to be used
******************************************************

Hi,
this is the second one (of 3) to share with you.
All information on the Wiki : http://www.domoticz.com/wiki/Plugins/BroadlinkRM2.html

Re: Python Plugin: Broadlink RM2

Posted: Tuesday 28 March 2017 7:45
by kniazio
I want to run the Broadlink plugin
It shows errors:

Code: Select all

2017-03-28 07:40:31.847 Error: (BroadlinkRM2) failed to load 'plugin.py', Python Path used was '/home/osmc/domoticz/plugins/Broadlink/:/usr/lib/python3.4/:/usr/lib/python3.4/plat-arm-linux-gnueabihf:/usr/lib/python3.4/lib-dynload'.
2017-03-28 07:40:31.847 Error: (Broadlink) Module Import failed, exception: 'ImportError'
2017-03-28 07:40:31.847 Error: (Broadlink) Module Import failed: ' Name: broadlink'
2017-03-28 07:40:52.474 Hardware Monitor: Fetching data (System sensors)
2017-03-28 07:41:22.514 Hardware Monitor: Fetching data (System sensors)
2017-03-28 07:41:52.559 Hardware Monitor: Fetching data (System sensors)
2017-03-28 07:42:00.018 Error: Broadlink hardware (6) thread seems to have ended unexpectedly 
My hardware: Raspberry Pi3
My os OSMC
please help

Re: Python Plugin: Broadlink RM2

Posted: Tuesday 28 March 2017 12:34
by zak45
can you execute python, type these commands:

import os
import sys
print(sys.platform)
print(sys.path)
print(os.__file__)

and provide the result.

thanks

Re: Python Plugin: Broadlink RM2

Posted: Tuesday 28 March 2017 12:50
by kniazio
zak45 wrote:can you execute python, type these commands:

import os
import sys
print(sys.platform)
print(sys.path)
print(os.__file__)

and provide the result.

thanks

Code: Select all

root@osmc:~# python
Python 2.7.9 (default, Aug 13 2016, 17:56:53)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> import sys
>>> print(sys.platform)
linux2
>>> print(sys.path)
['', '/usr/local/lib/python2.7/dist-packages/Adafruit_BMP-1.5.1-py2.7.egg', '/usr/local/lib/python2.7/dist-packages/Adafruit_GPIO-1.0.0-py2.7.egg', '/usr/local/lib/python2.7/dist-packages/spidev-3.2-py2.7-linux-armv7l.egg', '/usr/local/lib/python2.7/dist-packages/Adafruit_PureIO-0.2.0-py2.7.egg', '/usr/local/lib/python2.7/dist-packages/setuptools-4.0.1-py2.7.egg', '/usr/local/lib/python2.7/dist-packages/Adafruit_DHT-1.3.0-py2.7-linux-armv7l.egg', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-arm-linux-gnueabihf', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/PILcompat', '/usr/lib/python2.7/dist-packages/gtk-2.0']
>>> print(os.__file__)
/usr/lib/python2.7/os.pyc
>>>
I have also installed python 3.4
I do not know why he does not use it

Re: Python Plugin: Broadlink RM2

Posted: Tuesday 28 March 2017 13:11
by zak45
Domoticz Python framework require 3.x version.
What you can try , on line 55 of the plugin.py file, add:

sys.path.append('/usr/local/lib/python3.4/dist-packages')

before
import broadlink

but first verify that /usr/local/lib/python3.4/dist-packages is the valid directory to used...

Re: Python Plugin: Broadlink RM2

Posted: Tuesday 28 March 2017 13:24
by kniazio
zak45 wrote:Domoticz Python framework require 3.x version.
What you can try , on line 55 of the plugin.py file, add:

sys.path.append('/usr/local/lib/python3.4/dist-packages')

before
import broadlink

but first verify that /usr/local/lib/python3.4/dist-packages is the valid directory to used...
/usr/local/lib/python3.4/dist-packages is empty

Still the same mistakes

Re: Python Plugin: Broadlink RM2

Posted: Tuesday 28 March 2017 13:45
by domoraspberryitaly
Hey all, first post hope everyone is doing well! Been trying the plugin. I noticed plugin.py needs a python version higher then 3.4 due to hex() call. Running raspberry pi.. If I could fix I would..

Re: Python Plugin: Broadlink RM2

Posted: Tuesday 28 March 2017 14:28
by kniazio
I installed Python 3.5
Still the same

Re: Python Plugin: Broadlink RM2

Posted: Tuesday 28 March 2017 15:07
by domoraspberryitaly
Our issues are different, I think. Yours is a config issue re python, what I found is that the readily available python version 3.4 for raspberry is not compatible with the Python script of the plugin. I found at least the .hex() method not to be available until 3.5

Re: Python Plugin: Broadlink RM2

Posted: Tuesday 28 March 2017 17:26
by zak45
@kniazio
don't know how your OS manage different python version.
What I have seen is that Domoticz Python framework is looking on : /usr/lib/python3.4
so... looks like this is the version required / find and that the plugin will use.
when you do : pip install broadlink (or any other command), this should install the module probably there:
/usr/local/lib/python3.4/dist-packages

maybe for you this go to python2.7 ??

@domoraspberryitaly

Welcome !!!

Re: Python Plugin: Broadlink RM2

Posted: Tuesday 28 March 2017 18:38
by kniazio
zak45 wrote:@kniazio
don't know how your OS manage different python version.
What I have seen is that Domoticz Python framework is looking on : /usr/lib/python3.4
so... looks like this is the version required / find and that the plugin will use.
when you do : pip install broadlink (or any other command), this should install the module probably there:
/usr/local/lib/python3.4/dist-packages

maybe for you this go to python2.7 ??

@domoraspberryitaly

Welcome !!!
I have already done pip install broadlink
Installed in python 2.7

Re: Python Plugin: Broadlink RM2

Posted: Tuesday 28 March 2017 18:44
by deennoo
Whoa looks like perfect ! can we call you pluginator ?

Will try it on linux quickly and update my blog how-to on this device.


Just one question for a better integration, isn't possible to use learn switch from switch page ?

Re: Python Plugin: Broadlink RM2

Posted: Tuesday 28 March 2017 19:13
by domoraspberryitaly
Python 2.7 on raspberry wont work due to the methods used in plugin.py (and maybe elsewhere) that require 3.5 as I wrote earlier.. I'll see if I can do some work on it to make it compatible.

Re: Python Plugin: Broadlink RM2

Posted: Tuesday 28 March 2017 19:29
by deennoo
Just test on debian, Domoticz looks lib at

Code: Select all

/usr/local/lib/python3.4/dist-packages/
this mean you need to install python who is used for domoticz

Code: Select all

sudo apt-get install python3-pip libglib2.0-dev
sudo pip3 install Crypto 
sudo pip3 install broadlink
When done, you have to copy lib on the good dir :

Code: Select all

sudo cp -r /usr/local/lib/python3.4/dist-packages/Crypto/ /usr/lib/python3.4/
sudo cp -r /usr/local/lib/python3.4/dist-packages/broadlink /usr/lib/python3.4/
Then restart domoticz en enjoy !

Code: Select all

sudo service domoticz restart
@zak45 maybe you can update your wiki with this thank you for this great plugin !

when did you release the one for Orange Box ? ahrd to transforme to freebox revolution ?

Re: Python Plugin: Broadlink RM2

Posted: Tuesday 28 March 2017 19:34
by zak45
@deennoo
perfect!
will update the wiki.

Re: Python Plugin: Broadlink RM2

Posted: Tuesday 28 March 2017 19:44
by domoraspberryitaly
I hope I can get this to work as well will check now :) Awesome plugin!

Re: RE: Re: Python Plugin: Broadlink RM2

Posted: Tuesday 28 March 2017 20:02
by deennoo
zak45 wrote:@deennoo
perfect!
will update the wiki.
All credits too another Python plugin dev Zaraki673

http://easydomoticz.com/forum/viewtopic.php?t=3278

Re: Python Plugin: Broadlink RM2

Posted: Tuesday 28 March 2017 20:37
by zak45
deennoo wrote:Whoa looks like perfect ! can we call you pluginator ?

Will try it on linux quickly and update my blog how-to on this device.


Just one question for a better integration, isn't possible to use learn switch from switch page ?
So... hummm.. not sure to understand :
Capture.JPG
Capture.JPG (239.93 KiB) Viewed 13015 times

Re: Python Plugin: Broadlink RM2

Posted: Tuesday 28 March 2017 20:39
by deennoo
On linux version we have this button :

Image

Learn or detection in french

Re: Python Plugin: Broadlink RM2

Posted: Tuesday 28 March 2017 20:49
by deennoo
I'm facing an issue when trying to record an IR code

Code: Select all


2017-03-28 20:45:47.331 User: Admin initiated a switch command (3379/Broadlink - Command/Set Level)

2017-03-28 20:45:47.364 (Broadlink) Calling message handler 'onCommand'.

2017-03-28 20:45:47.364 (Broadlink) onCommand called for Unit 1: Parameter 'Set Level', Level: 10 , Connected : True

2017-03-28 20:45:47.394 (Broadlink) Connected to Broadlink device.

2017-03-28 20:45:47.394 (Broadlink) All plugin system is on pause for 5s...

2017-03-28 20:45:47.394 (Broadlink) When Broadlink led is lit press the button on your remote within 5 seconds


2017-03-28 20:45:52.781 (Broadlink) b'&\x00\x84\x03\x11/\x13/\x12/\x13/\x11\x10\x11\x10\x11\x0f\x12/\x12\x00\x07[\x96\x91\x12\x0f\x11\x10\x11\x0f\x12\x0f\x110\x12/\x13\x0f\x10\x10\x11/\x13/\x12/\x120\x12\x0e\x12\x0f\x12\x0f\x12\x0e\x12\x92\x12\x0f\x11\x10\x11\x10\x11\x0f\x11\x10\x11\x10\x11\x0f\x11\x0f\x12/\x120\x12/\x12\x0f\x110\x12/\x110\x12/\x12\x10\x11\x0f\x12\x0f\x110\x12\x00\x07[\x96\x90\x13\x0f\x11\x0f\x12\x0f\x11\x10\x110\x12/\x12\x0f\x12\x0f\x110\x12/\x110\x12/\x13\x0f\x11\x0f\x12\x0f\x11\x0f\x12\x92\x12\x0f\x11\x10\x11\x0f\x12\x0f\x11\x0f\x12\x0f\x12\x0f\x11\x0f\x120\x11/\x120\x12\x0e\x120\x12/\x120\x110\x11\x0f\x12\x0f\x11\x10\x110\x12\x00\x07\\\x95\x91\x12\x0f\x12\x0f\x11\x10\x11\x0f\x11/\x120\x12\x0f\x11\x10\x110\x12/\x12/\x13.\x12\x0f\x12\x0f\x11\x10\x11\x0f\x12\x91\x13\x0f\x11\x0f\x12\x0f\x11\x10\x11\x10\x11\x0f\x11\x10\x11\x10\x11/\x120\x12.\x12\x0f\x12/\x13/\x12/\x120\x12\x0f\x11\x10\x11\x0f\x12.\x13\x00\x07[\x96\x91\x12\x0f\x11\x0f\x12\x0f\x12\x0f\x110\x12/\x12\x0f\x11\x10\x11/\x120\x12/\x120\x11\x10\x11\x0f\x12\x0f\x11\x10\x11\x92\x12\x0f\x11\x10\x11\x0e\x12\x0f\x12\x0f\x11\x10\x11\x10\x11\x0f\x12/\x120\x12/\x12\x0f\x12/\x12/\x12/\x12/\x13\x0f\x11\x0f\x12\x0f\x110\x12\x00\x07\\\x95\x90\x13\x0e\x12\x10\x11\x0f\x12\x0f\x110\x12/\x12\x10\x11\x0f\x11/\x120\x110\x12/\x13\x0f\x11\x0f\x12\x0f\x11\x10\x11\x92\x12\x0f\x11\x10\x11\x0f\x12\x0f\x11\x0f\x12\x10\x10\x10\x11\x0f\x110\x12/\x120\x12\x0f\x110\x12/\x120\x11/\x12\x10\x11\x0f\x11\x10\x110\x12\x00\x07\\\x94\x92\x12\x0f\x11\x0f\x12\x0f\x11\x10\x110\x12/\x12\x0f\x12\x0e\x120\x12/\x110\x12/\x12\x0f\x12\x0f\x11\x10\x11\x10\x11\x91\x12\x0f\x12\x0f\x12\x0f\x11\x10\x11\x10\x11\x0f\x12\x0f\x11\x10\x11/\x12/\x12/\x13\x0f\x110\x110\x12/\x13/\x12\x0f\x11\x10\x11\x0f\x110\x11\x00\x07]\x94\x92\x12\x0f\x11\x10\x11\x10\x11\x0f\x11/\x13/\x12\x0f\x11\x10\x11/\x13/\x12/\x120\x11\x10\x11\x0f\x11\x10\x11\x0f\x12\x91\x12\x0f\x12\x0f\x11\x10\x11\x0f\x12\x0f\x12\x0f\x11\x10\x11\x0f\x12/\x13/\x12/\x11\x10\x11/\x120\x12/\x120\x12\x0e\x12\x10\x11\x0f\x12/\x11\x00\x07\\\x95\x92\x12\x0e\x12\x0f\x12\x0f\x12\x0f\x110\x12/\x12\x0f\x11\x0f\x12/\x120\x12/\x12/\x13\x0f\x11\x0f\x12\x0f\x11\x10\x11\x92\x12\x0f\x11\x10\x11\x0f\x11\x10\x11\x0f\x11\x10\x11\x0f\x12\x0f\x110\x12/\x13/\x12\x0f\x110\x12/\x12/\x12/\x13\x0f\x11\x0f\x12\x0f\x110\x12\x00\x07\\\x95\x90\x12\x0f\x12\x0f\x12\x0f\x11\x10\x110\x12/\x12\x0f\x12\x0f\x110\x11/\x13/\x12/\x12\x10\x11\x0f\x11\x10\x11\x10\x11\x92\x12\x0e\x12\x0f\x12\x0f\x12\x0f\x11\x10\x11\x0f\x12\x0f\x11\x10\x11/\x12/\x120\x12\x0f\x110\x12/\x120\x100\x12\x0f\x12\x0f\x11\x10\x110\x12\x00\x07\\\x95\x91\x12\x0f\x11\x10\x11\x10\x11\x0f\x11/\x13/\x12\x0f\x11\x0f\x120\x12/\x12/\x110\x12\x0f\x12\x0f\x11\x10\x11\x0f\x12\x91\x12\x0f\x12\x0f\x12\x0f\x11\x0f\x12\x0f\x12\x0f\x11\x10\x11\x10\x11/\x13/\x11/\x13\x0f\x11/\x13/\x12/\x120\x12\x0f\x11\x10\x11\x0f\x11/\x12\x00\x07\\\x96\x91\x12\x0f\x11\x10\x11\x0f\x12\x0f\x110\x11/\x13\x0e\x12\x0f\x12/\x120\x12/\x13/\x12\x0f\x11\x10\x10\x10\x11\x0f\x11\x93\x11\x10\x11\x0f\x11\x10\x11\x0f\x12\x0f\x11\x10\x11\x10\x11\x0f\x12/\x120\x110\x12\x0f\x12.\x120\x12/\x12/\x13\x0f\x11\x0f\x12\x0f\x110\x12\x00\r\x05\x00\x00\x00\x00'

2017-03-28 20:45:52.781 Error: (Broadlink) 'onCommand' failed 'AttributeError':''bytes' object has no attribute 'hex''.

2017-03-28 20:45:52.781 Error: (Broadlink) ----> Line 117 in /home/nico/domoticz/plugins/Broadlink/plugin.py, function onCommand

2017-03-28 20:45:52.781 Error: (Broadlink) ----> Line 339 in /home/nico/domoticz/plugins/Broadlink/plugin.py, function learn

2017-03-28 20:45:54.556 User: Admin initiated a switch command (3379/Broadlink - Command/Set Level)

2017-03-28 20:45:54.585 (Broadlink) Calling message handler 'onCommand'.

2017-03-28 20:45:54.585 (Broadlink) onCommand called for Unit 1: Parameter 'Set Level', Level: 10 , Connected : True

2017-03-28 20:45:54.615 (Broadlink) Connected to Broadlink device.

2017-03-28 20:45:54.615 (Broadlink) All plugin system is on pause for 5s...

2017-03-28 20:45:54.615 (Broadlink) When Broadlink led is lit press the button on your remote within 5 secondes

2017-03-28 20:45:59.855 (Broadlink) b'&\x00\xe0\x01\x95\x91\x13\x0e\x12\x0f\x10\x11\x10\x11\x101\x13-\x13\x0f\x10\x10\x110\x110\x13/\x13.\x13\x0e\x12\x0f\x10\x10\x12\x10\x11\x92\x11\x10\x11\x10\x11\x0f\x0e\x12\x10\x11\x10\x11\x10\x10\x10\x10\x120\x110\x13/\x13\x0e\x101\x100\x120\x101\x13\x0e\x10\x11\x11\x0f\x120\x11\x00\x07\\\x96\x90\x12\x0f\x12\x0f\x11\x10\x10\x10\x110\x13/\x12\x0f\x11\x10\x100\x12/\x13/\x110\x12\x0f\x11\x10\x10\x11\x10\x10\x12\x91\x13\x0f\x10\x10\x11\x10\x11\x0f\x12\x0f\x12\x0f\x11\x10\x11\x0e\x120\x12/\x12/\x13\x0f\x110\x12/\x12.\x13/\x12\x0f\x11\x0f\x12\x10\x11/\x13\x00\x07[\x95\x92\x11\x0f\x12\x0e\x12\x10\x11\x0f\x110\x13/\x12\x0f\x11\x10\x11/\x13/\x11/\x13/\x12\x0f\x11\x10\x11\x0f\x12\x0f\x11\x92\x12\x0f\x12\x0f\x11\x10\x11\x10\x11\x0f\x11\x0f\x12\x0f\x12\x0f\x12/\x110\x12/\x13\x0e\x12/\x120\x12/\x12/\x12\x10\x11\x0e\x12\x0f\x12/\x12\x00\x07\\\x95\x92\x11\x0f\x12\x10\x11\x0f\x11\x10\x11/\x12/\x12\x10\x11\x0f\x12/\x13/\x12/\x12/\x11\x11\x11\x0f\x11\x0f\x11\x10\x11\x92\x12\x0f\x11\x10\x11\x10\x11\x0f\x12\x0f\x11\x10\x11\x0f\x12\x0f\x110\x12/\x13/\x11\x0f\x110\x12/\x13/\x12/\x12\x10\x11\x0f\x11\x0f\x120\x11\x00\x07\\\x95\x91\x13\x0f\x11\x0f\x12\x0f\x11\x10\x11/\x13/\x11\x10\x11\x0f\x110\x12/\x13/\x12/\x13\x0e\x12\x0f\x11\x10\x11\x10\x10\x92\x12\x10\x11\x0f\x12\x0f\x11\x10\x11\x0e\x12\x0f\x12\x0f\x11\x10\x110\x12/\x12/\x13\x0e\x120\x11/\x120\x110\x12\x0f\x12\x0f\x11\x10\x11/\x13\x00\x07\\\x94\x91\x12\x0f\x12\x0f\x11\x10\x11\x0f\x12/\x13/\x12\x0e\x12\x10\x11/\x12/\x12/\x13/\x12\x0f\x11\x10\x11\x10\x11\x0f\x11\x92\x12\x0f\x12\x0f\x11\x10\x11\x10\x11\x0f\x12\x0f\x11\x10\x11\x0f\x11/\x120\x12/\x13\x0e\x12/\x120\x12/\x110\x12\x0e\x12\x10\x11\x0f\x12/\x13\x00\r\x05\x101\x100\x120\x101'

2017-03-28 20:45:59.855 Error: (Broadlink) 'onCommand' failed 'AttributeError':''bytes' object has no attribute 'hex''.

2017-03-28 20:45:59.855 Error: (Broadlink) ----> Line 117 in /home/nico/domoticz/plugins/Broadlink/plugin.py, function onCommand

2017-03-28 20:45:59.855 Error: (Broadlink) ----> Line 339 in /home/nico/domoticz/plugins/Broadlink/plugin.py, function learn

My config

Image