Python Plugin : Broadlink RM2 V4

Python and python framework
User avatar
michaldobrotka
Posts: 77
Joined: Sunday 01 November 2015 18:21
Target OS: Raspberry Pi
Domoticz version: Beta
Contact:

Re: Python Plugin : Broadlink RM2 V4

Post by michaldobrotka » 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.
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 » Monday 02 July 2018 8:21

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: 77
Joined: Sunday 01 November 2015 18:21
Target OS: Raspberry Pi
Domoticz version: Beta
Contact:

Re: Python Plugin : Broadlink RM2 V4

Post by michaldobrotka » 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:
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: 175
Joined: Saturday 29 October 2016 20:55
Target OS: -
Domoticz version:
Contact:

Re: Python Plugin : Broadlink RM2 V4

Post by devros » Tuesday 03 July 2018 11:25

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 » Tuesday 03 July 2018 14:27

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: 77
Joined: Sunday 01 November 2015 18:21
Target OS: Raspberry Pi
Domoticz version: Beta
Contact:

Re: Python Plugin : Broadlink RM2 V4

Post by michaldobrotka » 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?
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 » Wednesday 04 July 2018 15:44

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 » 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:

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: 512
Joined: Sunday 22 January 2017 12:37
Target OS: Windows
Domoticz version: V3.9056
Contact:

Re: Python Plugin : Broadlink RM2 V4

Post by zak45 » 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.

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 » Thursday 05 July 2018 3:37

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: 12
Joined: Saturday 03 March 2018 10:08
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Python Plugin : Broadlink RM2 V4

Post by brain » Sunday 08 July 2018 13:00

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: 77
Joined: Sunday 01 November 2015 18:21
Target OS: Raspberry Pi
Domoticz version: Beta
Contact:

Re: Python Plugin : Broadlink RM2 V4

Post by michaldobrotka » 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.
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: 12
Joined: Saturday 03 March 2018 10:08
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Python Plugin : Broadlink RM2 V4

Post by brain » Tuesday 10 July 2018 20:54

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: 93
Joined: Saturday 02 May 2015 21:26
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Bexleyheath, SE London, UK
Contact:

Re: Python Plugin : Broadlink RM2 V4

Post by Jem101 » Saturday 21 July 2018 9:59

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: 23
Joined: Saturday 25 November 2017 5:00
Target OS: -
Domoticz version:
Contact:

Re: Python Plugin : Broadlink RM2 V4

Post by RedRaven » Monday 06 August 2018 15:17

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?

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests