Page 11 of 33
Re: Python Plugin : Broadlink RM2 V4
Posted: Thursday 03 May 2018 12:42
by zak45
Jufo wrote: ↑Thursday 03 May 2018 9:46
zak45 wrote: ↑Wednesday 02 May 2018 22:43
What you need to do:
Do not use the plugin until you do not have been able to connect to your RM Mini 3 manually.
You will found all information on Github.
Once you have been able to connect manually, lets reconfigure the plugin, this should work.. this work for others.
Can you give a link to github?
see wiki
Re: Python Plugin : Broadlink RM2 V4
Posted: Thursday 03 May 2018 13:37
by Jufo
HarleyZard wrote: ↑Thursday 03 May 2018 11:12
I tried to install Python 3.6, but when I start domoticz, it only load library 3.5 in the log ; I don't understand to load library 3.6 in Domoticz... perhaps it's the solution...
Hi HarleyZard,
I also installed python 3.6 the same symptom as yours. Domoticz could not load python plugins.
Re: Python Plugin : Broadlink RM2 V4
Posted: Thursday 03 May 2018 15:58
by Jufo
@zak45
I did a simple test. It looks like the discover works:
Code: Select all
robert@domoticz:~$ sudo python3
Python 3.5.3 (default, Jan 19 2017, 14:11:04)
[GCC 6.3.0 20170118] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import broadlink
>>> broadlink.discover(timeout=5)
[<broadlink.rm object at 0x7ff9da213828>]
>>>
Re: Python Plugin : Broadlink RM2 V4
Posted: Thursday 03 May 2018 17:29
by zak45
Jufo wrote: ↑Thursday 03 May 2018 15:58
I did a simple test. It looks like the discover works:
Perfect, so we can focus now on Domoticz. THis should be problem with python framework and maybe some imported modules
can you modify plugin.py in this way :
Code: Select all
#
# Main Import
import Domoticz
#import configparser
#import datetime
#import time
#import codecs
#import subprocess
#import socket
#
#
# Required for import: path is OS dependent
# Python framework in Domoticz do not include OS dependent path
#
import site
import sys
import os
path=''
path=site.getsitepackages()
for i in path:
sys.path.append(i)
#
#import broadlink
#
Re: Python Plugin : Broadlink RM2 V4
Posted: Thursday 03 May 2018 18:10
by Jufo
@zak45
It's better, I modified the code.
1. Discovery version, in logs:
Code: Select all
2018-05-03 17:40:49.713 (RM mini 3) Initialized version 4.1.0, author 'zak45'
2018-05-03 17:40:49.713 (RM mini 3) Debug logging mask set to: PYTHON PLUGIN QUEUE IMAGE DEVICE CONNECTION MESSAGE ALL
2018-05-03 17:40:49.713 (RM mini 3) Creating device 'Discovery'.
2018-05-03 17:40:49.713 (RM mini 3) Creating device 'Discovery Info'.
2018-05-03 17:40:49.714 (RM mini 3) 'Author':'zak45'
2018-05-03 17:40:49.714 (RM mini 3) 'Name':'RM mini 3'
2018-05-03 17:40:49.714 (RM mini 3) 'Key':'BroadlinkRM2'
2018-05-03 17:40:49.714 (RM mini 3) 'DomoticzVersion':'3.9389'
2018-05-03 17:40:49.714 (RM mini 3) 'Mode5':'9000'
2018-05-03 17:40:49.714 (RM mini 3) 'Mode1':'000000000000'
2018-05-03 17:40:49.714 (RM mini 3) 'Mode4':'yes'
2018-05-03 17:40:49.714 (RM mini 3) 'Port':'0'
2018-05-03 17:40:49.714 (RM mini 3) 'HardwareID':'14'
2018-05-03 17:40:49.714 (RM mini 3) 'Mode3':'DIS'
2018-05-03 17:40:49.714 (RM mini 3) 'Address':'127.0.0.1'
2018-05-03 17:40:49.714 (RM mini 3) 'Mode2':'/home/robert/domoticz/plugins/BroadlinkRM2/import'
2018-05-03 17:40:49.714 (RM mini 3) 'HomeFolder':'/home/robert/domoticz/plugins/BroadlinkRM2/'
2018-05-03 17:40:49.714 (RM mini 3) 'Mode6':'Debug'
2018-05-03 17:40:49.714 (RM mini 3) 'Version':'4.1.0'
2018-05-03 17:40:49.714 (RM mini 3) 'DomoticzHash':'28d24885'
2018-05-03 17:40:49.714 (RM mini 3) 'DomoticzBuildTime':'2018-05-01 00:17:26'
2018-05-03 17:40:49.714 (RM mini 3) Device count: 2
2018-05-03 17:40:49.714 (RM mini 3) Device: 1 - ID: 41, Name: 'RM mini 3 - Discovery', nValue: 0, sValue: ''
2018-05-03 17:40:49.714 (RM mini 3) Device ID: '41'
2018-05-03 17:40:49.714 (RM mini 3) Device Name: 'RM mini 3 - Discovery'
2018-05-03 17:40:49.714 (RM mini 3) Device nValue: 0
2018-05-03 17:40:49.714 (RM mini 3) Device sValue: ''
2018-05-03 17:40:49.714 (RM mini 3) Device LastLevel: 0
2018-05-03 17:40:49.714 (RM mini 3) Device: 2 - ID: 42, Name: 'RM mini 3 - Discovery Info', nValue: 0, sValue: ''
2018-05-03 17:40:49.714 (RM mini 3) Device ID: '42'
2018-05-03 17:40:49.714 (RM mini 3) Device Name: 'RM mini 3 - Discovery Info'
2018-05-03 17:40:49.714 (RM mini 3) Device nValue: 0
2018-05-03 17:40:49.714 (RM mini 3) Device sValue: ''
2018-05-03 17:40:49.714 (RM mini 3) Device LastLevel: 0
2018-05-03 17:40:49.714 (RM mini 3) Pushing 'PollIntervalDirective' on to queue
2018-05-03 17:40:49.714 (RM mini 3) Connecting to: 127.0.0.1:000000000000
2018-05-03 17:40:49.714 (RM mini 3) Device Number begin to : 1
2018-05-03 17:40:49.714 (RM mini 3) Processing 'PollIntervalDirective' message
2018-05-03 17:40:49.714 (RM mini 3) Heartbeat interval set to: 30.
2018-05-03 17:40:59.215 (RM mini 3) Pushing 'onHeartbeatCallback' on to queue
2018-05-03 17:40:59.233 (RM mini 3) Processing 'onHeartbeatCallback' message
2018-05-03 17:40:59.233 (RM mini 3) Calling message handler 'onHeartbeat'.
2018-05-03 17:40:59.233 Error: (RM mini 3) 'onHeartbeat' failed 'NameError':'name 'datetime' is not defined'.
2018-05-03 17:40:59.233 Error: (RM mini 3) ----> Line 364 in /home/robert/domoticz/plugins/BroadlinkRM2/plugin.py, function onHeartbeat
2018-05-03 17:41:29.221 (RM mini 3) Pushing 'onHeartbeatCallback' on to queue
2018-05-03 17:41:29.245 (RM mini 3) Processing 'onHeartbeatCallback' message
2018-05-03 17:41:29.245 (RM mini 3) Calling message handler 'onHeartbeat'.
2018-05-03 17:41:29.245 Error: (RM mini 3) 'onHeartbeat' failed 'NameError':'name 'datetime' is not defined'.
2018-05-03 17:41:29.245 Error: (RM mini 3) ----> Line 364 in /home/robert/domoticz/plugins/BroadlinkRM2/plugin.py, function onHeartbeat
2018-05-03 17:41:59.228 (RM mini 3) Pushing 'onHeartbeatCallback' on to queue
2018-05-03 17:41:59.257 (RM mini 3) Processing 'onHeartbeatCallback' message
2018-05-03 17:41:59.257 (RM mini 3) Calling message handler 'onHeartbeat'.
A virtual device has also been added but it does not work (switching to discovery):
2. Version configured with RM mini 3, in logs:
Code: Select all
2018-05-03 17:46:24.691 (Rm mini 3) Started.
2018-05-03 17:46:24.728 (Rm mini 3) Entering work loop.
2018-05-03 17:46:24.728 (Rm mini 3) Initialized version 4.1.0, author 'zak45'
2018-05-03 17:46:24.729 (Rm mini 3) Debug logging mask set to: PYTHON PLUGIN QUEUE IMAGE DEVICE CONNECTION MESSAGE ALL
2018-05-03 17:46:24.729 (Rm mini 3) Creating device 'Command'.
2018-05-03 17:46:24.747 (Rm mini 3) Creating device 'Remote'.
2018-05-03 17:46:24.747 (Rm mini 3) Creating device 'Import'.
2018-05-03 17:46:24.747 (Rm mini 3) 'Author':'zak45'
2018-05-03 17:46:24.747 (Rm mini 3) 'Name':'Rm mini 3'
2018-05-03 17:46:24.747 (Rm mini 3) 'Key':'BroadlinkRM2'
2018-05-03 17:46:24.747 (Rm mini 3) 'DomoticzVersion':'3.9389'
2018-05-03 17:46:24.747 (Rm mini 3) 'Mode5':'9000'
2018-05-03 17:46:24.747 (Rm mini 3) 'Mode1':'b4430df91287'
2018-05-03 17:46:24.747 (Rm mini 3) 'Mode4':'yes'
2018-05-03 17:46:24.747 (Rm mini 3) 'Port':'0'
2018-05-03 17:46:24.747 (Rm mini 3) 'HardwareID':'14'
2018-05-03 17:46:24.747 (Rm mini 3) 'Mode3':'RM2'
2018-05-03 17:46:24.747 (Rm mini 3) 'Address':'192.168.3.9'
2018-05-03 17:46:24.747 (Rm mini 3) 'Mode2':'/home/robert/domoticz/plugins/BroadlinkRM2/import'
2018-05-03 17:46:24.747 (Rm mini 3) 'HomeFolder':'/home/robert/domoticz/plugins/BroadlinkRM2/'
2018-05-03 17:46:24.747 (Rm mini 3) 'Mode6':'Debug'
2018-05-03 17:46:24.747 (Rm mini 3) 'Version':'4.1.0'
2018-05-03 17:46:24.747 (Rm mini 3) 'DomoticzHash':'28d24885'
2018-05-03 17:46:24.747 (Rm mini 3) 'DomoticzBuildTime':'2018-05-01 00:17:26'
2018-05-03 17:46:24.747 (Rm mini 3) Device count: 3
2018-05-03 17:46:24.747 (Rm mini 3) Device: 1 - ID: 41, Name: 'Rm mini 3 - Command', nValue: 0, sValue: ''
2018-05-03 17:46:24.747 (Rm mini 3) Device ID: '41'
2018-05-03 17:46:24.747 (Rm mini 3) Device Name: 'Rm mini 3 - Command'
2018-05-03 17:46:24.747 (Rm mini 3) Device nValue: 0
2018-05-03 17:46:24.747 (Rm mini 3) Device sValue: ''
2018-05-03 17:46:24.747 (Rm mini 3) Device LastLevel: 0
2018-05-03 17:46:24.747 (Rm mini 3) Device: 254 - ID: 42, Name: 'Rm mini 3 - Remote', nValue: 0, sValue: ''
2018-05-03 17:46:24.747 (Rm mini 3) Device ID: '42'
2018-05-03 17:46:24.747 (Rm mini 3) Device Name: 'Rm mini 3 - Remote'
2018-05-03 17:46:24.747 (Rm mini 3) Device nValue: 0
2018-05-03 17:46:24.747 (Rm mini 3) Device sValue: ''
2018-05-03 17:46:24.747 (Rm mini 3) Device LastLevel: 0
2018-05-03 17:46:24.747 (Rm mini 3) Device: 255 - ID: 43, Name: 'Rm mini 3 - Import', nValue: 0, sValue: ''
2018-05-03 17:46:24.747 (Rm mini 3) Device ID: '43'
2018-05-03 17:46:24.747 (Rm mini 3) Device Name: 'Rm mini 3 - Import'
2018-05-03 17:46:24.747 (Rm mini 3) Device nValue: 0
2018-05-03 17:46:24.747 (Rm mini 3) Device sValue: ''
2018-05-03 17:46:24.747 (Rm mini 3) Device LastLevel: 0
2018-05-03 17:46:24.747 (Rm mini 3) Pushing 'PollIntervalDirective' on to queue
2018-05-03 17:46:24.747 (Rm mini 3 - Import) Updating device from 0:'' to have values 0:'Off'.
2018-05-03 17:46:24.763 (Rm mini 3) Update 0:'Off' (Rm mini 3 - Import)
2018-05-03 17:46:24.763 (Rm mini 3) Connecting to: 192.168.3.9:b4430df91287
2018-05-03 17:46:24.763 Error: (Rm mini 3) Error Connecting to Broadlink device....192.168.3.9
2018-05-03 17:46:24.763 (Rm mini 3 - Command) Updating device from 0:'' to have values 0:'Off'.
2018-05-03 17:46:24.764 (Rm mini 3) Update 0:'Off' (Rm mini 3 - Command)
2018-05-03 17:46:24.764 (Rm mini 3) No ini file :/home/robert/domoticz/plugins/BroadlinkRM2/import/remote/plugin_remote_14.ini
2018-05-03 17:46:24.764 (Rm mini 3) Custom Commands for Remote not managed
2018-05-03 17:46:24.764 (Rm mini 3) Device Number begin to : 1
2018-05-03 17:46:24.764 (Rm mini 3) Processing 'PollIntervalDirective' message
2018-05-03 17:46:24.764 (Rm mini 3) Heartbeat interval set to: 30.
2018-05-03 17:46:34.230 (Rm mini 3) Pushing 'onHeartbeatCallback' on to queue
2018-05-03 17:46:34.234 (Rm mini 3) Processing 'onHeartbeatCallback' message
2018-05-03 17:46:34.234 (Rm mini 3) Calling message handler 'onHeartbeat'.
2018-05-03 17:46:34.234 Error: (Rm mini 3) 'onHeartbeat' failed 'NameError':'name 'datetime' is not defined'.
2018-05-03 17:46:34.234 Error: (Rm mini 3) ----> Line 364 in /home/robert/domoticz/plugins/BroadlinkRM2/plugin.py, function onHeartbeat
2018-05-03 17:47:04.237 (Rm mini 3) Pushing 'onHeartbeatCallback' on to queue
2018-05-03 17:47:04.246 (Rm mini 3) Processing 'onHeartbeatCallback' message
2018-05-03 17:47:04.246 (Rm mini 3) Calling message handler 'onHeartbeat'.
2018-05-03 17:47:04.246 Error: (Rm mini 3) 'onHeartbeat' failed 'NameError':'name 'datetime' is not defined'.
2018-05-03 17:47:04.246 Error: (Rm mini 3) ----> Line 364 in /home/robert/domoticz/plugins/BroadlinkRM2/plugin.py, function onHeartbeat
2018-05-03 17:47:34.243 (Rm mini 3) Pushing 'onHeartbeatCallback' on to queue
2018-05-03 17:47:34.260 (Rm mini 3) Processing 'onHeartbeatCallback' message
A virtual device has also been added but it does not work:
Logs indicate that the plugin can not connect to the device (device works without any problems with the e-Control application), it responds to pings. IP reservation in DHCP and MAC address correct.
Re: Python Plugin : Broadlink RM2 V4
Posted: Thursday 03 May 2018 18:24
by zak45
Jufo wrote: ↑Thursday 03 May 2018 18:10
It's better, I modified the code.
OK, now just remove this HW, modify the plugin.py by removing # in front of #import one by one.. we need to found which module made trouble in your system ( i would begin by the end, this mean #import broadlink) and create a new HW
Re: Python Plugin : Broadlink RM2 V4
Posted: Thursday 03 May 2018 18:39
by Jufo
zak45 wrote: ↑Thursday 03 May 2018 18:24
OK, now just remove this HW, modify the plugin.py by removing # in front of #import one by one.. we need to found which module made trouble in your system ( i would begin by the end, this mean #import broadlink) and create a new HW
Problem is with broadlink module, others are working.
I found a nice search script:
Code: Select all
# File: locate.py
# Script to locate RM mini 3
# python locate.py
#!/usr/bin/python
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 ("...............")
As a result, I received:
Code: Select all
sudo python3 test.py
************************************************
Using python library created by Matthew Garrett
https://github.com/mjg59/python-broadlink
************************************************
Scanning network for Broadlink devices....
Found 1 broadlink devices
...............
Device 1 Host address = '192.168.3.9', 80)
Device 1 MAC address = b4 43 0d f9 12 87
...............
Re: Python Plugin : Broadlink RM2 V4
Posted: Thursday 03 May 2018 23:17
by zak45
Jufo wrote: ↑Thursday 03 May 2018 18:39
Problem is with broadlink module, others are working.
So.. very bad situation: if trouble with module broadlink, this mean no way for you to use the plugin if we do not found why on some OS this work and not on your...
Another way to investigate: try to compile from source and not use the pre-build version, you should found all information on wiki.
Re: Python Plugin : Broadlink RM2 V4
Posted: Friday 04 May 2018 9:13
by Jufo
zak45 wrote: ↑Thursday 03 May 2018 23:17
Another way to investigate: try to compile from source and not use the pre-build version, you should found all information on wiki.
Compile Brodlink module or Domoticz ? I use clean Debian 9 Stretch x86_64.
Re: Python Plugin : Broadlink RM2 V4
Posted: Friday 04 May 2018 13:13
by zak45
Jufo wrote: ↑Friday 04 May 2018 9:13
Compile Brodlink module or Domoticz ? I use clean Debian 9 Stretch x86_64.
Domoticz
Re: Python Plugin : Broadlink RM2 V4
Posted: Saturday 05 May 2018 10:09
by Jufo
@zak45
I made a new Domoticz compilation + new database did not help
Re: Python Plugin : Broadlink RM2 V4
Posted: Saturday 05 May 2018 12:32
by zak45
Jufo wrote: ↑Saturday 05 May 2018 10:09
@zak45
I made a new Domoticz compilation + new database did not help
That's bad
give output of this command:
sudo pip3 list
Re: Python Plugin : Broadlink RM2 V4
Posted: Saturday 05 May 2018 12:41
by Jufo
zak45 wrote: ↑Saturday 05 May 2018 12:32
give output of this command:
sudo pip3 list
Code: Select all
broadlink (0.9)
cryptography (1.7.1)
idna (2.2)
keyring (10.1)
keyrings.alt (1.3)
pip (9.0.1)
pyaes (1.6.1)
pyasn1 (0.1.9)
PyCRC (1.21)
pycrypto (2.6.1)
pycryptodome (3.4.11)
pygobject (3.22.0)
pyserial (3.2.1)
pyxdg (0.25)
SecretStorage (2.3.1)
setuptools (33.1.1)
six (1.10.0)
wheel (0.29.0)
Re: Python Plugin : Broadlink RM2 V4
Posted: Saturday 05 May 2018 13:29
by zak45
Jufo wrote: ↑Saturday 05 May 2018 12:41
Code: Select all
broadlink (0.9)
cryptography (1.7.1)
idna (2.2)
keyring (10.1)
keyrings.alt (1.3)
pip (9.0.1)
pyaes (1.6.1)
pyasn1 (0.1.9)
PyCRC (1.21)
pycrypto (2.6.1)
pycryptodome (3.4.11)
pygobject (3.22.0)
pyserial (3.2.1)
pyxdg (0.25)
SecretStorage (2.3.1)
setuptools (33.1.1)
six (1.10.0)
wheel (0.29.0)
If you do not need them, try to remove pycrypto & pycryptodome
Re: Python Plugin : Broadlink RM2 V4
Posted: Saturday 05 May 2018 15:57
by Jufo
@zak45
It works!
Are these packages needed (pycrypto & pycryptodome)?
Re: Python Plugin : Broadlink RM2 V4
Posted: Saturday 05 May 2018 15:58
by zak45
Jufo wrote: ↑Saturday 05 May 2018 15:57
@zak45
It works!
Are these packages needed (pycrypto & pycryptodome)?
On the last version, no more, you just need pyaes.
Great that this work now.
enjoy!
Re: Python Plugin : Broadlink RM2 V4
Posted: Saturday 05 May 2018 16:28
by Jufo
@zak45
I analyzed the problem deeper (I did tests on a clean copy of a virtual machine).
You would have to add to the domoticz's manual to uninstall (only) pycryptodome-3.4.11. This package is installed by default with the broadlink.
Best Regards,
Robert
Re: Python Plugin : Broadlink RM2 V4
Posted: Saturday 05 May 2018 19:57
by Jufo
I have one question I'd like to make a toggle button (on / off), but what should be the syntax on Linux?, under Windows it looks like this:
I do not want to work the following version:
Code: Select all
script:///home/robert/domoticz/plugins/BroadlinkRM2/plugin_send.py /home/robert/domoticz/plugins/BroadlinkRM2/RM_mini_3/BroadlinkRM2-14-4.ini
script:///home/robert/domoticz/plugins/BroadlinkRM2/plugin_send.py /home/robert/domoticz/plugins/BroadlinkRM2/RM_mini_3/BroadlinkRM2-14-2.ini
Re: Python Plugin : Broadlink RM2 V4
Posted: Sunday 06 May 2018 1:11
by zak45
Jufo wrote: ↑Saturday 05 May 2018 19:57
I have one question I'd like to make a toggle button (on / off), but what should be the syntax on Linux?
Code: Select all
script:///home/robert/domoticz/plugins/BroadlinkRM2/plugin_send.py /home/robert/domoticz/plugins/BroadlinkRM2/RM_mini_3/BroadlinkRM2-14-4.ini
script:///home/robert/domoticz/plugins/BroadlinkRM2/plugin_send.py /home/robert/domoticz/plugins/BroadlinkRM2/RM_mini_3/BroadlinkRM2-14-2.ini
Something like that:
create a plugin_send.sh under plugin folder.
put on it
nohup python3 /home/robert/domoticz/plugins/BroadlinkRM2/plugin_send.py $1 &
And on the on action :
script:///home/robert/domoticz/plugins/BroadlinkRM2/plugin_send.sh /home/robert/domoticz/plugins/BroadlinkRM2/RM_mini_3/BroadlinkRM2-14-4.ini
Re: Python Plugin : Broadlink RM2 V4
Posted: Monday 14 May 2018 16:31
by henk99
I hope this is not a silly question, but I'm uncertain about the Python role in all of this. I have ordered two SP3S units and would like to use them in Domoticz, so I ended up here. I have Domoticz running on a RP. However, the domoticz dashboard is only accessed through windows machines or my phone.
Do I need to install Python on my windows pc to be able to get this to work on my domoticz, or do I need to do something on the RP? I have already checked my domoticz dashboard, but I can't find any Broadlink in 'hardware' yet.
Is it possible that someone explains it to me in 'dummy' terms? It's fine by me if that goes through Private messages