Python Plugin: Broadlink RM2

Python and python framework

Moderator: leecollings

Post Reply
zak45
Posts: 952
Joined: Sunday 22 January 2017 11:37
Target OS: Windows
Domoticz version: V2024.4
Contact:

Python Plugin: Broadlink RM2

Post 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
Last edited by zak45 on Sunday 11 February 2024 23:59, edited 1 time in total.
kniazio
Posts: 198
Joined: Thursday 06 October 2016 8:14
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.7243
Contact:

Re: Python Plugin: Broadlink RM2

Post 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
zak45
Posts: 952
Joined: Sunday 22 January 2017 11:37
Target OS: Windows
Domoticz version: V2024.4
Contact:

Re: Python Plugin: Broadlink RM2

Post 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
kniazio
Posts: 198
Joined: Thursday 06 October 2016 8:14
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.7243
Contact:

Re: Python Plugin: Broadlink RM2

Post 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
Attachments
winscp python.jpg
winscp python.jpg (194 KiB) Viewed 13141 times
zak45
Posts: 952
Joined: Sunday 22 January 2017 11:37
Target OS: Windows
Domoticz version: V2024.4
Contact:

Re: Python Plugin: Broadlink RM2

Post 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...
kniazio
Posts: 198
Joined: Thursday 06 October 2016 8:14
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.7243
Contact:

Re: Python Plugin: Broadlink RM2

Post 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
domoraspberryitaly
Posts: 6
Joined: Tuesday 28 March 2017 13:43
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Broadlink RM2

Post 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..
kniazio
Posts: 198
Joined: Thursday 06 October 2016 8:14
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.7243
Contact:

Re: Python Plugin: Broadlink RM2

Post by kniazio »

I installed Python 3.5
Still the same
domoraspberryitaly
Posts: 6
Joined: Tuesday 28 March 2017 13:43
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Broadlink RM2

Post 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
zak45
Posts: 952
Joined: Sunday 22 January 2017 11:37
Target OS: Windows
Domoticz version: V2024.4
Contact:

Re: Python Plugin: Broadlink RM2

Post 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 !!!
kniazio
Posts: 198
Joined: Thursday 06 October 2016 8:14
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.7243
Contact:

Re: Python Plugin: Broadlink RM2

Post 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
deennoo
Posts: 784
Joined: Wednesday 10 December 2014 13:06
Target OS: Linux
Domoticz version: beta
Location: Bordeaux France
Contact:

Re: Python Plugin: Broadlink RM2

Post 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 ?
Last edited by deennoo on Tuesday 28 March 2017 19:15, edited 1 time in total.
Domoticz stable 3.5877 for real & Domoticz beta for test
Rfxtrxe / RFLink / Milight / Yeelight / Tasmota / MQTT / BLE / Zigate
http://domo-attitude.fr
domoraspberryitaly
Posts: 6
Joined: Tuesday 28 March 2017 13:43
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Broadlink RM2

Post 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.
deennoo
Posts: 784
Joined: Wednesday 10 December 2014 13:06
Target OS: Linux
Domoticz version: beta
Location: Bordeaux France
Contact:

Re: Python Plugin: Broadlink RM2

Post 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 ?
Last edited by deennoo on Tuesday 28 March 2017 19:35, edited 2 times in total.
Domoticz stable 3.5877 for real & Domoticz beta for test
Rfxtrxe / RFLink / Milight / Yeelight / Tasmota / MQTT / BLE / Zigate
http://domo-attitude.fr
zak45
Posts: 952
Joined: Sunday 22 January 2017 11:37
Target OS: Windows
Domoticz version: V2024.4
Contact:

Re: Python Plugin: Broadlink RM2

Post by zak45 »

@deennoo
perfect!
will update the wiki.
domoraspberryitaly
Posts: 6
Joined: Tuesday 28 March 2017 13:43
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Broadlink RM2

Post by domoraspberryitaly »

I hope I can get this to work as well will check now :) Awesome plugin!
deennoo
Posts: 784
Joined: Wednesday 10 December 2014 13:06
Target OS: Linux
Domoticz version: beta
Location: Bordeaux France
Contact:

Re: RE: Re: Python Plugin: Broadlink RM2

Post 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
Domoticz stable 3.5877 for real & Domoticz beta for test
Rfxtrxe / RFLink / Milight / Yeelight / Tasmota / MQTT / BLE / Zigate
http://domo-attitude.fr
zak45
Posts: 952
Joined: Sunday 22 January 2017 11:37
Target OS: Windows
Domoticz version: V2024.4
Contact:

Re: Python Plugin: Broadlink RM2

Post 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 13018 times
deennoo
Posts: 784
Joined: Wednesday 10 December 2014 13:06
Target OS: Linux
Domoticz version: beta
Location: Bordeaux France
Contact:

Re: Python Plugin: Broadlink RM2

Post by deennoo »

On linux version we have this button :

Image

Learn or detection in french
Domoticz stable 3.5877 for real & Domoticz beta for test
Rfxtrxe / RFLink / Milight / Yeelight / Tasmota / MQTT / BLE / Zigate
http://domo-attitude.fr
deennoo
Posts: 784
Joined: Wednesday 10 December 2014 13:06
Target OS: Linux
Domoticz version: beta
Location: Bordeaux France
Contact:

Re: Python Plugin: Broadlink RM2

Post 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
Domoticz stable 3.5877 for real & Domoticz beta for test
Rfxtrxe / RFLink / Milight / Yeelight / Tasmota / MQTT / BLE / Zigate
http://domo-attitude.fr
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest