Python Plugin : Broadlink RM2 V4

Python and python framework

Moderator: leecollings

User avatar
michaldobrotka
Posts: 50
Joined: Sunday 01 November 2015 17:21
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Python Plugin : Broadlink RM2 V4

Post by michaldobrotka »

Hallo Everybody,
I was using Broadlink plugin on separate Raspberry pi zero w running on stretch and stable Domoticz 3.8153 with Python 3.4.2 for months. My main system was on Betas.
Last week I wanted to upgrade both to stable 4.9. Main system is working (no Python), but Zero with Broadling not.
I backed up command library and made DB backup, but Im back in time and fighting with Python again. As mentioned here in this thread – im trying to install Python 3.4.3 instead 3.5.
I have installed it with:

Code: Select all

sudo apt-get install python3.4 libpython3.4 python3.4-dev
but pip3 is missing :( and with :

Code: Select all

sudo apt-get install python3-pip
I get python 3.5 back
Is there a way to install pip3 for lower Phython?
Thanks for any advice and Sorry I’m noob in this stuff.
Domoticz on Raspi 3 and slave on ZeroW (running only with Broadlink plugin), Serial Mysensors GW on Arduino nano, Broadlink RM2, Rehau CO2 USB Stick, RF link 433 MHz, 2x Amazon Echo Dot (Controlicz), ESP2866 witk Espeasy, Sonoff
mistak1992
Posts: 7
Joined: Sunday 01 July 2018 6:34
Target OS: Linux
Domoticz version:
Contact:

Re: Python Plugin : Broadlink RM2 V4

Post by mistak1992 »

michaldobrotka wrote: Monday 02 July 2018 7:51 Hallo Everybody,
I was using Broadlink plugin on separate Raspberry pi zero w running on stretch and stable Domoticz 3.8153 with Python 3.4.2 for months. My main system was on Betas.
Last week I wanted to upgrade both to stable 4.9. Main system is working (no Python), but Zero with Broadling not.
I backed up command library and made DB backup, but Im back in time and fighting with Python again. As mentioned here in this thread – im trying to install Python 3.4.3 instead 3.5.
I have installed it with:

Code: Select all

sudo apt-get install python3.4 libpython3.4 python3.4-dev
but pip3 is missing :( and with :

Code: Select all

sudo apt-get install python3-pip
I get python 3.5 back
Is there a way to install pip3 for lower Phython?
Thanks for any advice and Sorry I’m noob in this stuff.
you can use

Code: Select all

python3 -m pip
instead of

Code: Select all

pip3
pip3 just a alias of "python3 -m pip"
for example

Code: Select all

python3 -m pip install broadlink
:| :| :|
User avatar
michaldobrotka
Posts: 50
Joined: Sunday 01 November 2015 17:21
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Python Plugin : Broadlink RM2 V4

Post by michaldobrotka »

Thanks for your reply, but unfortunately, I was not able to use it, and did spent third evening with fighting with it without any progress. I red dozens of discussions about python but I got lost in it.
When I’m on Phyton 3.5 + 0.9 broadlink + 4.1.0 plugin.py, Domoticz brakes down, and starts only by renaming plugin.py
When I install 3.4.3 I can’t go further with broadlink instalation, because pip3 is missing.

Isn’t it possible to make stretch+domoticz+python+broadlink image, so i would load it on sd card?
If yes, is somebody able to do it for me? (Ill pay for it ;)), I cant sit all evening in front of computer, my wife is mad allredy :lol:
Domoticz on Raspi 3 and slave on ZeroW (running only with Broadlink plugin), Serial Mysensors GW on Arduino nano, Broadlink RM2, Rehau CO2 USB Stick, RF link 433 MHz, 2x Amazon Echo Dot (Controlicz), ESP2866 witk Espeasy, Sonoff
devros
Posts: 183
Joined: Saturday 29 October 2016 20:55
Target OS: -
Domoticz version:
Contact:

Re: Python Plugin : Broadlink RM2 V4

Post by devros »

michaldobrotka wrote: Tuesday 03 July 2018 10:32 Thanks for your reply, but unfortunately, I was not able to use it, and did spent third evening with fighting with it without any progress. I red dozens of discussions about python but I got lost in it.
When I’m on Phyton 3.5 + 0.9 broadlink + 4.1.0 plugin.py, Domoticz brakes down, and starts only by renaming plugin.py
When I install 3.4.3 I can’t go further with broadlink instalation, because pip3 is missing.

Isn’t it possible to make stretch+domoticz+python+broadlink image, so i would load it on sd card?
If yes, is somebody able to do it for me? (Ill pay for it ;)), I cant sit all evening in front of computer, my wife is mad allredy :lol:
I also gave up, domoticz crashed on launch or plugin wasn't loaded, so i did few python scripts for my broadlink and all works
mistak1992
Posts: 7
Joined: Sunday 01 July 2018 6:34
Target OS: Linux
Domoticz version:
Contact:

Re: Python Plugin : Broadlink RM2 V4

Post by mistak1992 »

michaldobrotka wrote: Tuesday 03 July 2018 10:32 Thanks for your reply, but unfortunately, I was not able to use it, and did spent third evening with fighting with it without any progress. I red dozens of discussions about python but I got lost in it.
When I’m on Phyton 3.5 + 0.9 broadlink + 4.1.0 plugin.py, Domoticz brakes down, and starts only by renaming plugin.py
When I install 3.4.3 I can’t go further with broadlink instalation, because pip3 is missing.

Isn’t it possible to make stretch+domoticz+python+broadlink image, so i would load it on sd card?
If yes, is somebody able to do it for me? (Ill pay for it ;)), I cant sit all evening in front of computer, my wife is mad allredy :lol:
well, how do you install python 3.4.3? compile or apt-get? it should be able to install pip by script or apt-get...
User avatar
michaldobrotka
Posts: 50
Joined: Sunday 01 November 2015 17:21
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Python Plugin : Broadlink RM2 V4

Post by michaldobrotka »

@mistak1992
Hi, My last try from yesterday:
Fresh install Stretch+ domoticz
- sudo apt-get update
- sudo apt-get install libssl-dev openssl
- wget https://www.python.org/ftp/python/3.4.3 ... 4.3.tar.xz
- tar xvf Python-3.4.3.tar.xz
- cd Python-3.4.3/
- make
- sudo make install

than pip (in the same folder as Python-3.4.3):
- curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
- python get-pip.py

Then I got Error:
Could not install packages due to an EnviromentError: Permision denied: ` /usr/local/lib/Python2.7/dist-packages/pip-10.0.1.dist-info`

I stopped at tis point, Evening was over :lol: , installation took ages (make command)

Silly question, am I able to move Python installation directory?
Domoticz on Raspi 3 and slave on ZeroW (running only with Broadlink plugin), Serial Mysensors GW on Arduino nano, Broadlink RM2, Rehau CO2 USB Stick, RF link 433 MHz, 2x Amazon Echo Dot (Controlicz), ESP2866 witk Espeasy, Sonoff
mistak1992
Posts: 7
Joined: Sunday 01 July 2018 6:34
Target OS: Linux
Domoticz version:
Contact:

Re: Python Plugin : Broadlink RM2 V4

Post by mistak1992 »

michaldobrotka wrote: Wednesday 04 July 2018 7:26 @mistak1992
Hi, My last try from yesterday:
Fresh install Stretch+ domoticz
- sudo apt-get update
- sudo apt-get install libssl-dev openssl
- wget https://www.python.org/ftp/python/3.4.3 ... 4.3.tar.xz
- tar xvf Python-3.4.3.tar.xz
- cd Python-3.4.3/
- make
- sudo make install

than pip (in the same folder as Python-3.4.3):
- curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
- python get-pip.py

Then I got Error:
Could not install packages due to an EnviromentError: Permision denied: ` /usr/local/lib/Python2.7/dist-packages/pip-10.0.1.dist-info`

I stopped at tis point, Evening was over :lol: , installation took ages (make command)

Silly question, am I able to move Python installation directory?
1.pip is already installed when python3 was installed
it just at "/usr/local/python3.4.3/bin/pip"(if you not change the prefix before "make")
2.you can change the python installation directory before "make" by

Code: Select all

cd Python-3.4.3/
./configure --prefix=/the/absolute/path/you/want/to/install
forgive my bad english :| :| :|
mistak1992
Posts: 7
Joined: Sunday 01 July 2018 6:34
Target OS: Linux
Domoticz version:
Contact:

Re: Python Plugin : Broadlink RM2 V4

Post by mistak1992 »

hi zak45, i found something strange in your code
-------------device-------------------
CentOS 7 x64
RM Pro Plus
Python 3.6
Domoticz V4.9732
-------------environment--------------
broadlink 0.9
pip 10.0.1
pyaes 1.6.0
PyCRC 1.21
pycrypto 2.6.1
setuptools 28.8.0
------------------------------------------
notice:if i remove pycrypto, the method broadlink.auth() will throw Error like:

Code: Select all

Traceback (most recent call last):
  File "test.py", line 22, in <module>
    Discover()
  File "test.py", line 17, in Discover
    brodevices[index].auth()
  File "/usr/local/python3.6.1/lib/python3.6/broadlink/__init__.py", line 203, in auth
    response = self.send_packet(0x65, payload)
  File "/usr/local/python3.6.1/lib/python3.6/broadlink/__init__.py", line 258, in send_packet
    payload = self.encrypt(payload)
  File "/usr/local/python3.6.1/lib/python3.6/broadlink/__init__.py", line 162, in encrypt_pyaes
    return "".join([aes.encrypt(bytes(payload[i:i+16])) for i in range(0, len(payload), 16)])
TypeError: sequence item 0: expected str instance, bytes found
so i reinstall it and works...
than i locate the error in the plugin.py:752

Code: Select all

device = broadlink.rm(host=(Parameters["Address"],80), mac=bytearray.fromhex(Parameters["Mode1"]), devtype = Parameters["Mode3"])
it throw Error like:

Code: Select all

TypeError: __init__() got an unexpected keyword argument 'devtype'
maybe 'devtype' is wrong argument?
And i remove it

Code: Select all

device = broadlink.rm(host=(Parameters["Address"],80), mac=bytearray.fromhex(Parameters["Mode1"]))
after restart, it can run... :shock: :shock: :shock:

I'm confused...again...
zak45
Posts: 952
Joined: Sunday 22 January 2017 11:37
Target OS: Windows
Domoticz version: V2024.4
Contact:

Re: Python Plugin : Broadlink RM2 V4

Post by zak45 »

mistak1992 wrote: Wednesday 04 July 2018 17:16 hi zak45, i found something strange in your code
-------------device-------------------
CentOS 7 x64
RM Pro Plus
Python 3.6
Domoticz V4.9732
-------------environment--------------
broadlink 0.9
pip 10.0.1
pyaes 1.6.0
PyCRC 1.21
pycrypto 2.6.1
setuptools 28.8.0
------------------------------------------
notice:if i remove pycrypto, the method broadlink.auth() will throw Error like:
it throw Error like:

Code: Select all

TypeError: __init__() got an unexpected keyword argument 'devtype'
maybe 'devtype' is wrong argument?
And i remove it

Code: Select all

device = broadlink.rm(host=(Parameters["Address"],80), mac=bytearray.fromhex(Parameters["Mode1"]))
after restart, it can run... :shock: :shock: :shock:

I'm confused...again...
Code is valid for broadlink 0.9, this has been added as for 0.6 not necessary.

this is the help output :
Help on class rm in module broadlink:

class rm(device)
| Method resolution order:
| rm
| device
| builtins.object
|
| Methods defined here:
|
| __init__(self, host, mac, devtype)
| Initialize self. See help(type(self)) for accurate signature.
|
| check_data(self)
|
| check_temperature(self)
|
| enter_learning(self)
|
| send_data(self, data)
|
| ----------------------------------------------------------------------
| Methods inherited from device:

as you can see there is 3 arguments.

Now if for you only two works, this mean that the broadlink version retreived is not the right one.
mistak1992
Posts: 7
Joined: Sunday 01 July 2018 6:34
Target OS: Linux
Domoticz version:
Contact:

Re: Python Plugin : Broadlink RM2 V4

Post by mistak1992 »

zak45 wrote: Wednesday 04 July 2018 17:34
mistak1992 wrote: Wednesday 04 July 2018 17:16 hi zak45, i found something strange in your code
-------------device-------------------
CentOS 7 x64
RM Pro Plus
Python 3.6
Domoticz V4.9732
-------------environment--------------
broadlink 0.9
pip 10.0.1
pyaes 1.6.0
PyCRC 1.21
pycrypto 2.6.1
setuptools 28.8.0
------------------------------------------
notice:if i remove pycrypto, the method broadlink.auth() will throw Error like:
it throw Error like:

Code: Select all

TypeError: __init__() got an unexpected keyword argument 'devtype'
maybe 'devtype' is wrong argument?
And i remove it

Code: Select all

device = broadlink.rm(host=(Parameters["Address"],80), mac=bytearray.fromhex(Parameters["Mode1"]))
after restart, it can run... :shock: :shock: :shock:

I'm confused...again...
Code is valid for broadlink 0.9, this has been added as for 0.6 not necessary.

this is the help output :
Help on class rm in module broadlink:

class rm(device)
| Method resolution order:
| rm
| device
| builtins.object
|
| Methods defined here:
|
| __init__(self, host, mac, devtype)
| Initialize self. See help(type(self)) for accurate signature.
|
| check_data(self)
|
| check_temperature(self)
|
| enter_learning(self)
|
| send_data(self, data)
|
| ----------------------------------------------------------------------
| Methods inherited from device:

as you can see there is 3 arguments.

Now if for you only two works, this mean that the broadlink version retreived is not the right one.
thanks reply
i try to figure out which version i have installed, but in pip list, it's the broadlink 0.9
and there is no version attribute

Code: Select all

>>> broadlink.__version__
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'broadlink' has no attribute '__version__'
indeed, u r right, i have install a wrong version of broadlink

Code: Select all

class rm(device)
     |  Method resolution order:
     |      rm
     |      device
     |      builtins.object
     |
     |  Methods defined here:
     |
     |  __init__(self, host, mac)
     |      Initialize self.  See help(type(self)) for accurate signature.
     |
     |  check_data(self)
     |
     |  check_temperature(self)
     |
     |  enter_learning(self)
     |
     |  send_data(self, data)
     |
     |  ----------------------------------------------------------------------
     |  Methods inherited from device:
     |
     |  auth(self)
     |
     |  decrypt_pyaes(self, payload)
     |
     |  decrypt_pycrypto(self, payload)
     |
     |  encrypt_pyaes(self, payload)
     |
     |  encrypt_pycrypto(self, payload)
     |
     |  get_type(self)
     |
     |  send_packet(self, command, payload)
     |
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from device:
     |
     |  __dict__
     |      dictionary for instance variables (if defined)
     |
     |  __weakref__
     |      list of weak references to the object (if defined)
now, i have to find the right one ;) ;) ;)
thank you~
brain
Posts: 15
Joined: Saturday 03 March 2018 9:08
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin : Broadlink RM2 V4

Post by brain »

hi i have a problem
the broadlink plugin is crashing domoticz
if the hardware is disabled it does not crash but when i activate the hardware domoticz stops again...
please help i love the broadlink plugin in domoticz

cor
User avatar
michaldobrotka
Posts: 50
Joined: Sunday 01 November 2015 17:21
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Python Plugin : Broadlink RM2 V4

Post by michaldobrotka »

hi i have a problem
the broadlink plugin is crashing domoticz
if the hardware is disabled it does not crash but when i activate the hardware domoticz stops again...
please help i love the broadlink plugin in domoticz
Running on Python 3.5?
If yes, that is the problem. Need to downgrade to 3.4 – see previous posts.
Domoticz on Raspi 3 and slave on ZeroW (running only with Broadlink plugin), Serial Mysensors GW on Arduino nano, Broadlink RM2, Rehau CO2 USB Stick, RF link 433 MHz, 2x Amazon Echo Dot (Controlicz), ESP2866 witk Espeasy, Sonoff
brain
Posts: 15
Joined: Saturday 03 March 2018 9:08
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin : Broadlink RM2 V4

Post by brain »

michaldobrotka wrote: Monday 09 July 2018 7:54
hi i have a problem
the broadlink plugin is crashing domoticz
if the hardware is disabled it does not crash but when i activate the hardware domoticz stops again...
please help i love the broadlink plugin in domoticz
Running on Python 3.5?
If yes, that is the problem. Need to downgrade to 3.4 – see previous posts.
hi i think its a domoticz problem it happens after updating .
i have python 3.4
thanx for the reply
Jem101
Posts: 66
Joined: Saturday 02 May 2015 21:26
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Bexleyheath, SE London, UK
Contact:

Re: Python Plugin : Broadlink RM2 V4

Post by Jem101 »

Well, here's an interesting problem.

After quite a bit of messing about, I have managed to get this plugin working (sort of) with a fresh-installed copy of Stretch, python 3.5 and the latest beta version of domoticz. Switching devices on and off works perfectly every time.

The reason I say 'sort of working' is that I have an odd issue with the learning of new codes - it only works once! I put domoticz into the add new devices for five minutes mode, press the 'learn' button and the Broadlink RM2 will learn the IR code, testing works, I can save and the ini file is properly created and I can see the new device. However if I then try to learn a second device, it appears to work but when I then press the test button, I see that the LED on the Broadlink only comes on quite dim and only for a fraction of a second. If I press save then an ini file is created but the corresponding device doesn't work. If I check the logs then it claims that the learnt code is 00/00/00/ etc which naturally isn't right.

Now if I restart the Pi completely (it's not enough to restart the domoticz service), and go through the above procedure then, again I can successfully learn one new device but only one, again a second learn doesn't work.

Eventually I have managed to learn and save all the codes I need and executing all of them works perfectly every time - but it is a bit time-consuming.

Not a really major issue, as I'm not adding new codes every day, but a curious issue and I was wondering if anyone might have any ideas as to what is happening?
I firmly believe in having an open mind - although not so open that your brain falls out!

- sometimes attributed to Carl Sagan, but the original quote is much older than that
RedRaven
Posts: 21
Joined: Saturday 25 November 2017 4:00
Target OS: -
Domoticz version:
Contact:

Re: Python Plugin : Broadlink RM2 V4

Post by RedRaven »

So, I am also not able to use the Broadlink plugin anymore after upgrading to Domoticz 4. Was using v3 of plugin, upgraded to V4 plugin. But, Domoticz crashes when it it starts with the error:

2018-08-06 18:07:12.532 Error: Domoticz received fatal signal 11 (Segmentation fault)

Edit:
After remove pycryptodome and using beta version of Domoticz v4 it now throws a new error:

domoticz: malloc.c:3695: _int_malloc: Assertion `(unsigned long) (size) >= (unsigned long) (nb)' failed.


I have followed all instructions, using Python 3.4.2. It obviously is an issue with the plugin because after I disable the plugin Domoticz works without any issues.

Any clues?
User avatar
cbartetzko
Posts: 27
Joined: Sunday 25 December 2016 9:24
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.1
Location: Speyer/Germany
Contact:

Re: Python Plugin : Broadlink RM2 V4

Post by cbartetzko »

Same problem.
I'm also running Domoticz Beta and tried to install and run Broadlink Plugin.
It crashed my Domoticz immediately with "Segmentation Fault".
Domoticz can only be restarted after disabling this plugin.
I've seen a lot of discussions regarding this problem in this forum, but unfortunately not a simple working solution.

I think this is really a great plugin and I would love to use it.
So hopefully we get a solution soon.
fvdp80
Posts: 69
Joined: Tuesday 14 August 2018 8:22
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10303
Contact:

Re: Python Plugin : Broadlink RM2 V4

Post by fvdp80 »

After a lot of trial and error I got the RM mini up and running. Here's how I did it:

I started with a fresh install of Stretch on my RPI.
After that:

Code: Select all

sudo apt-get install libcurl4-gnutls-dev
sudo apt-get install libssl-dev
Then i installed Domoticz Beta.

Code: Select all

curl -L install.domoticz.com | sudo bash
cd domoticz
./updatebeta
Time to install the broadlink stuff:

Code: Select all

sudo apt-get install python3-pip
sudo pip3 install Crypto
sudo pip3 install broadlink
sudo pip3 install pyaes
sudo cp -r /usr/local/lib/python3.5/dist-packages/Crypto/ /usr/lib/python3.5/
sudo cp -r /usr/local/lib/python3.5/dist-packages/broadlink /usr/lib/python3.5/
Place these files in the plugins folder of Domoticz:
plugin_send.py
plugin_http.py
plugin.py
plugin_http.sh

Code: Select all

chmod +x plugin.py
chmod +x plugin_send.py
chmod +x plugin_http.py
chmod +x plugin_http.sh
sudo service domoticz restart
Done!
Now follow the broadlink wiki on how to add the device in Domoticz.
mantoz
Posts: 42
Joined: Sunday 12 November 2017 22:23
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin : Broadlink RM2 V4

Post by mantoz »

Hi,
I'm also trying to install the plugin, but Domoticz crashes with a Segmentation fault as soon as the plugin starts.
Using domoticz 4.9980 (upgraded on purpose to see if this solves the issue), Python 3.4.2 and "pip3 list" shows:

Code: Select all

Package     Version
----------- -------
broadlink   0.9
chardet     2.3.0
colorama    0.3.2
crypto      1.4.1
html5lib    0.999
miflora     0.1.15
Naked       0.1.31
pip         18.0
pyaes       1.6.1
PyCRC       1.21
PyYAML      3.13
requests    2.4.3
setuptools  39.0.1
shellescape 3.4.1
six         1.8.0
smbus       1.1
urllib3     1.9.1
virtualenv  15.2.0
wheel       0.24.0
Has anyone found a solution to this issue?
I don't want to upgrade to Stretch only for this plugin...

Thanks
mantoz
User avatar
michaldobrotka
Posts: 50
Joined: Sunday 01 November 2015 17:21
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Python Plugin : Broadlink RM2 V4

Post by michaldobrotka »

@fvdp80, Thanks. I gave up while ago, but you are right!
With latest beta Im on (over 24 hours now) :)
Hopefully its gonna be stable.
Domoticz on Raspi 3 and slave on ZeroW (running only with Broadlink plugin), Serial Mysensors GW on Arduino nano, Broadlink RM2, Rehau CO2 USB Stick, RF link 433 MHz, 2x Amazon Echo Dot (Controlicz), ESP2866 witk Espeasy, Sonoff
fvdp80
Posts: 69
Joined: Tuesday 14 August 2018 8:22
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10303
Contact:

Re: Python Plugin : Broadlink RM2 V4

Post by fvdp80 »

I got it running for 2 weeks now and no problems so far.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest