Page 13 of 27

Re: Python Plugin : Broadlink

Posted: Sunday 03 January 2021 22:05
by garycooper
zak45 wrote: Sunday 03 January 2021 0:19
garycooper wrote: Saturday 02 January 2021 22:37 Hy ! Could you tell me how updating the plugin without loosing devices please ?

Thks
What's your actual version ?
Hello, I'm on version 1.6.1

Re: Python Plugin : Broadlink

Posted: Monday 04 January 2021 13:59
by zak45
So....
With Gdrive do not have feature I like...
With DropBox ... from time to time.. do not work.. maybe too much download, or spam or free account.

Had already done some test to implement my own Cloud share, so decided to go in this way with the help of NextCloud : https://nextcloud.com/

New source for Broadliink files is here : https://synnas.publicvm.com:32701/s/gmt22Ad7TyYJGdN
Used a self signed certificat, so you need to accept it.

Happy new year to all !

Re: Python Plugin : Broadlink

Posted: Monday 04 January 2021 18:51
by mojso
zak45 wrote: Monday 04 January 2021 13:59 So....
With Gdrive do not have feature I like...
With DropBox ... from time to time.. do not work.. maybe too much download, or spam or free account.

Had already done some test to implement my own Cloud share, so decided to go in this way with the help of NextCloud : https://nextcloud.com/

New source for Broadliink files is here : https://synnas.publicvm.com:32701/s/gmt22Ad7TyYJGdN
Used a self signed certificat, so you need to accept it.

Happy new year to all !
perhaps Github is the best solution

Re: Python Plugin : Broadlink

Posted: Wednesday 06 January 2021 0:02
by torM6
zak45 wrote: Monday 04 January 2021 13:59
New source for Broadliink files is here : https://synnas.publicvm.com:32701/s/gmt22Ad7TyYJGdN
Used a self signed certificat, so you need to accept it.
bug: setup.py fail in the end because there is no *.sh files in scr/ directory

Re: Python Plugin : Broadlink

Posted: Wednesday 06 January 2021 11:55
by zak45
torM6 wrote: Wednesday 06 January 2021 0:02
zak45 wrote: Monday 04 January 2021 13:59
New source for Broadliink files is here : https://synnas.publicvm.com:32701/s/gmt22Ad7TyYJGdN
Used a self signed certificat, so you need to accept it.
bug: setup.py fail in the end because there is no *.sh files in scr/ directory
Thanks, *.sh file back :)

Re: Python Plugin : Broadlink

Posted: Thursday 07 January 2021 12:53
by torM6
another problem with current version and installation of domoticz into docker container.
I have the following setup of network:
NAS (Synology) with main address 192.168.1.216
container with bridge network, address of inside-container interface is 172.17.0.2
I have mapping of the following TCP ports from container to NAS local ports: 6144, 1443, 8080 and 9000.

my first attempt to configure of plugin was to setup its address and web admin (in web interface of dotomicz device) as 192.168.1.216:9000, and during start of Domoticz it fail check that port is in use (250 line in python.py). It always return for this (only this) port that it is in use in function is_open(192.168.1.216,9000)?

I try to make address and web admin as 192.168.1.216:9001 and map internal port 9000 to local 9001 in container setup. it fail in check around 939 line saying that 192.168.1.216:9000 != 192.168.1.216:9001

ok, next attempt- in plugin config I setup address of Domoticz as 172.17.0.2 and port as 9000
now it pass checks, but always say in the same line 939 that 172.17.0.2:9000 != 192.168.1.216:9000
and throw error "Not implemented"...

I am stuck...

I restore config (192.168.1.216:9000), container port mapping 9000/tcp -> 0.0.0.0:9000 and disable correctness check in plugin (call of is_open() in the place above). does not work, no admin web interface on 9000 port (no response, seems that no-one listen for 9000 port )
output of log (add translation for simplicity)
Spoiler: show
STEP ==: remotePlugin --- 2021-01-07 14:57:03
Мы загружаем файл плагина в: /config/plugins/Broadlink/tst-plugin
>> Bytes downloaded -->remotePlugin213466remotePlugin: 100% Done
мы скачали файл плагина для проверки версии (we have downloaded plugin file for version test)
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 665, in urlopen
httplib_response = self._make_request(
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 421, in _make_request
six.raise_from(e, None)
File "<string>", line 3, in raise_from
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 416, in _make_request
httplib_response = conn.getresponse()
File "/usr/lib/python3.8/http/client.py", line 1347, in getresponse
response.begin()
File "/usr/lib/python3.8/http/client.py", line 307, in begin
version, status, reason = self._read_status()
File "/usr/lib/python3.8/http/client.py", line 268, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/usr/lib/python3.8/socket.py", line 669, in readinto
return self._sock.recv_into(b)
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/requests/adapters.py", line 439, in send
resp = conn.urlopen(
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 719, in urlopen
retries = retries.increment(
File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 400, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/usr/lib/python3/dist-packages/six.py", line 702, in reraise
raise value.with_traceback(tb)
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 665, in urlopen
httplib_response = self._make_request(
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 421, in _make_request
six.raise_from(e, None)
File "<string>", line 3, in raise_from
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 416, in _make_request
httplib_response = conn.getresponse()
File "/usr/lib/python3.8/http/client.py", line 1347, in getresponse
response.begin()
File "/usr/lib/python3.8/http/client.py", line 307, in begin
version, status, reason = self._read_status()
File "/usr/lib/python3.8/http/client.py", line 268, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/usr/lib/python3.8/socket.py", line 669, in readinto
return self._sock.recv_into(b)
urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/config/plugins/Broadlink/Dombroadlink.py", line 271, in send_data
requests.post(urlo, data=idata.encode('utf-8'), headers={'Content-type': 'text/plain; charset=utf-8'},
File "/usr/lib/python3/dist-packages/requests/api.py", line 116, in post
return request('post', url, data=data, json=json, **kwargs)
File "/usr/lib/python3/dist-packages/requests/api.py", line 60, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "/usr/lib/python3/dist-packages/requests/adapters.py", line 498, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))

send_data Ошибка отправки (Error sending data)
Конец тестирования версии удаленного плагина (End of remote plugin version test)
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 665, in urlopen
httplib_response = self._make_request(
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 421, in _make_request
six.raise_from(e, None)
File "<string>", line 3, in raise_from
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 416, in _make_request
httplib_response = conn.getresponse()
File "/usr/lib/python3.8/http/client.py", line 1347, in getresponse
response.begin()
File "/usr/lib/python3.8/http/client.py", line 307, in begin
version, status, reason = self._read_status()
File "/usr/lib/python3.8/http/client.py", line 268, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/usr/lib/python3.8/socket.py", line 669, in readinto
return self._sock.recv_into(b)
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/requests/adapters.py", line 439, in send
resp = conn.urlopen(
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 719, in urlopen
retries = retries.increment(
File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 400, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/usr/lib/python3/dist-packages/six.py", line 702, in reraise
raise value.with_traceback(tb)
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 665, in urlopen
httplib_response = self._make_request(
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 421, in _make_request
six.raise_from(e, None)
File "<string>", line 3, in raise_from
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 416, in _make_request
httplib_response = conn.getresponse()
File "/usr/lib/python3.8/http/client.py", line 1347, in getresponse
response.begin()
File "/usr/lib/python3.8/http/client.py", line 307, in begin
version, status, reason = self._read_status()
File "/usr/lib/python3.8/http/client.py", line 268, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/usr/lib/python3.8/socket.py", line 669, in readinto
return self._sock.recv_into(b)
urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/config/plugins/Broadlink/Dombroadlink.py", line 271, in send_data
requests.post(urlo, data=idata.encode('utf-8'), headers={'Content-type': 'text/plain; charset=utf-8'},
File "/usr/lib/python3/dist-packages/requests/api.py", line 116, in post
return request('post', url, data=data, json=json, **kwargs)
File "/usr/lib/python3/dist-packages/requests/api.py", line 60, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "/usr/lib/python3/dist-packages/requests/adapters.py", line 498, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))

send_data Ошибка отправки (Error sending data)
---------------------------------------END--------------------------------------

Re: Python Plugin : Broadlink

Posted: Thursday 07 January 2021 13:56
by zak45
torM6 wrote: Thursday 07 January 2021 12:53 another problem with current version and installation of domoticz into docker container.

ok, next attempt- in plugin config I setup address of Domoticz as 172.17.0.2 and port as 9000
now it pass checks, but always say in the same line 939 that 172.17.0.2:9000 != 192.168.1.216:9000
and throw error "Not implemented"...

I am stuck...
You fall in security check....
Do not use docker but could try to see possible workaround.
Put your browser in devloper mode and provide a screen shot with network details when error occurs
e.g.:
Capture.PNG
Capture.PNG (163.18 KiB) Viewed 1783 times

Re: Python Plugin : Broadlink

Posted: Thursday 07 January 2021 14:05
by torM6
zak45 wrote: Thursday 07 January 2021 13:56 You fall in security check....
Do not use docker but could try to see possible workaround.
Put your browser in devloper mode and provide a screen shot with network details when error occurs
e.g.:
Capture.PNG
with what address in config of plugin? 192.168.1.216 (NAS external address) or internal address of container 172.17.0.2?
PS I do add 192.168 and 172.17.*.* networks to Domoticz no-passwprd access, it is allowed from both network.

Re: Python Plugin : Broadlink

Posted: Thursday 07 January 2021 14:12
by torM6
zak45 wrote: Thursday 07 January 2021 13:56 You fall in security check....
Do not use docker but could try to see possible workaround.
Put your browser in devloper mode and provide a screen shot with network details when error occurs
e.g.:
Capture.PNG
developer mode in safari show only content of error message like "192.168.1.216:9000 server reset connection, could be busy, try again later"
no any messages inside log of Domoticz
like below
here I drop check and print args in this line (message is "port in use"):
2021-01-07 14:57:02.958 Error: (mRM Pro+) Уже используется192.168.1.216 9000
Spoiler: show
2021-01-07 14:57:02.952 Status: (mRM Pro+) Initialized version 1.6.2, author 'zak45'
2021-01-07 14:57:02.957 (mRM Pro+) lang file: /config/plugins/Broadlink/lng/en_ru.lng
2021-01-07 14:57:02.957 (mRM Pro+) Язык загружен для: ru
2021-01-07 14:57:02.958 Error: (mRM Pro+) Уже используется192.168.1.216 9000
2021-01-07 14:57:02.966 (mRM Pro+) Количество подключаемых устройств начинается с: 9
2021-01-07 14:57:02.968 (mRM Pro+) __Command line file updated: /config/plugins/Broadlink/log/9RM2.txt__
2021-01-07 14:57:02.968 (mRM Pro+) Установка соединения:
2021-01-07 14:57:02.978 Status: dzVents: Debug: Dumping domoticz data to /config/scripts/dzVents/domoticzData.lua
2021-01-07 14:57:02.999 Status: dzVents: Debug: Processing device-adapter for RM Pro+ - ИК команды: Switch device adapter
2021-01-07 14:57:03.000 Status: dzVents: Debug: dzVents version: 3.0.2
2021-01-07 14:57:03.000 Status: dzVents: Debug: Event triggers:
2021-01-07 14:57:03.000 Status: dzVents: Debug: - Device: RM Pro+ - ИК команды
2021-01-07 14:57:03.018 Status: dzVents: Debug: Dumping domoticz data to /config/scripts/dzVents/domoticzData.lua
2021-01-07 14:57:03.045 Status: dzVents: Debug: Processing device-adapter for RM Pro+ - RF команды: Switch device adapter
2021-01-07 14:57:03.045 Status: dzVents: Debug: dzVents version: 3.0.2
2021-01-07 14:57:03.045 Status: dzVents: Debug: Event triggers:
2021-01-07 14:57:03.045 Status: dzVents: Debug: - Device: RM Pro+ - RF команды
2021-01-07 14:57:03.415 (mRM Pro+) Подключено к устройству Broadlink: 192.168.1.97 RM2
2021-01-07 14:57:03.417 (mRM Pro+) Html файл администратора создан: /usr/share/domoticz/www/templates/Broadlink-RM2-9.html
nohup: appending output to '/config/nohup.out'
2021-01-07 14:58:00.151 Status: dzVents: Debug: Dumping domoticz data to /config/scripts/dzVents/domoticzData.lua
2021-01-07 14:58:00.167 Status: dzVents: Debug: Event triggers:
2021-01-07 14:58:00.167 Status: dzVents: Debug: - Timer
2021-01-07 14:59:00.179 Status: dzVents: Debug: Dumping domoticz data to /config/scripts/dzVents/domoticzData.lua
2021-01-07 14:59:00.195 Status: dzVents: Debug: Event triggers:
2021-01-07 14:59:00.195 Status: dzVents: Debug: - Timer
2021-01-07 15:00:00.297 Status: Starting automatic database backup procedure...
2021-01-07 15:00:00.961 Status: dzVents: Debug: Dumping domoticz data to /config/scripts/dzVents/domoticzData.lua
2021-01-07 15:00:00.980 Status: dzVents: Debug: Event triggers:
2021-01-07 15:00:00.980 Status: dzVents: Debug: - Timer
2021-01-07 15:00:01.017 Status: Ending automatic database backup procedure...
in opera it just show
ERR_CONNECTION_RESET
and no response

Re: Python Plugin : Broadlink

Posted: Thursday 07 January 2021 14:26
by zak45
@torM6
do not have docker for test.
try this version, some check has been changed.
plugin.zip
(35.26 KiB) Downloaded 91 times

Re: Python Plugin : Broadlink

Posted: Thursday 07 January 2021 14:44
by torM6
zak45 wrote: Thursday 07 January 2021 14:26 @torM6
do not have docker for test.
try this version, some check has been changed.
plugin.zip
same, no response to 9000 port...
no messages in log - seems that requests do not goto web server
will try with config with 172 address

yes, with config like 172:9000, mapping 9000->9000 it start working with attached plugin.py!
will check other functionality

no, except header nothing shown (like list of devices, list of ini files).
and I do not see anything about this access in Domoticz log.

found error when try to use opera...
seems that bottom of page is not created because it use to access directly address 172!
error message is
can't access the site
Сайт 172.17.0.2 не позволяет установить соединение.
can't setup connection to...

so, this is not a solution.
need to fix a problem with access to myself via NAT server, the root of problem is here...

Re: Python Plugin : Broadlink

Posted: Thursday 07 January 2021 15:37
by zak45
torM6 wrote: Thursday 07 January 2021 14:44 found error when try to use opera...
seems that bottom of page is not created because it use to access directly address 172!
error message is
can't access the site
Сайт 172.17.0.2 не позволяет установить соединение.
can't setup connection to...

so, this is not a solution.
need to fix a problem with access to myself via NAT server, the root of problem is here...
No more idea for the moment and without test platform not easy... will try to see that in future.

Re: Python Plugin : Broadlink

Posted: Friday 08 January 2021 12:46
by zak45
@torM6

tested in docker env and have it working.
made few modifications to avoid errors.

My test env:
docker in synology 6.2
docker image used : linuxserver-domoticz
Capture.PNG
Capture.PNG (180.42 KiB) Viewed 1754 times


domoticz plugin settings:

Capture2.PNG
Capture2.PNG (88.13 KiB) Viewed 1754 times


you need the new plugin.py and Dombroadlink.py

Re: Python Plugin : Broadlink

Posted: Saturday 09 January 2021 0:15
by torM6
zak45 wrote: Friday 08 January 2021 12:46 @torM6

tested in docker env and have it working.
made few modifications to avoid errors.

My test env:
docker in synology 6.2
docker image used : linuxserver-domoticz

you need the new plugin.py and Dombroadlink.py
@zak45 - seems that I still unable to find webadmin interface even after complete reinstall of plugin using setup.py. Do you use bridged network for container?
I found the same problem - message that "port in use" for port 9000
and later due to this web admin page do not created.

I make very small test and run it inside docker

Code: Select all

import socket
import os
import sys

#
# check if port is already opened or not
#
def is_open(ip, port):
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.settimeout(1.0)
    try:
        s.connect((ip, int(port)))
        s.shutdown(2)

        return True

    except (ValueError, Exception):

        return False

if is_open("192.168.1.216", 9000):
   print("opened")

else:
   print("closed")
if I run it inside docker container without anything on 9000 port -it say closed
if I map port 9000 to outside (still nothing inside container for port 9000) - it say opened

therefore test in your plugin failed...

Re: Python Plugin : Broadlink

Posted: Saturday 09 January 2021 0:26
by zak45
torM6 wrote: Saturday 09 January 2021 0:15 @zak45 - seems that I still unable to find webadmin interface even after complete reinstall of plugin using setup.py. Do you use bridged network for container?
if I run it inside docker container without anything on 9000 port -it say closed
if I map port 9000 to outside (still nothing inside container for port 9000) - it say opened

therefore test in your plugin failed...
yep, bridged network.
try with another port number.

Re: Python Plugin : Broadlink

Posted: Saturday 09 January 2021 19:05
by torM6
zak45 wrote: Saturday 09 January 2021 0:26
yep, bridged network.
try with another port number.
tried with 7000, with freshly created container with ubuntu.
the only port mapped is 7000
same result - if mapped, your test return opened, if not mapped - return "not".
I even make telnet tcpdump in both cases (for 9000 which is mapped and 9001 is not), different response from socket:
Spoiler: show
root@test:/# telnet 192.168.1.216 9000
Trying 192.168.1.216...
Connected to 192.168.1.216.
Escape character is '^]'.
Connection closed by foreign host.
root@test:/# telnet 192.168.1.216 9001
Trying 192.168.1.216...
telnet: Unable to connect to remote host: Connection refused

Code: Select all

admin@stormain:~$ sudo tcpdump -nvv host 192.168.1.216
tcpdump: listening on docker0, link-type EN10MB (Ethernet), capture size 262144 bytes
01:31:20.517342 IP (tos 0x10, ttl 64, id 42615, offset 0, flags [DF], proto TCP (6), length 60)
    172.17.0.3.40440 > 192.168.1.216.7000: Flags [S], cksum 0x6ec3 (incorrect -> 0x763e), seq 1427778998, win 29200, options [mss 1460,sackO0
01:31:20.517384 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto TCP (6), length 60)
    192.168.1.216.7000 > 172.17.0.3.40440: Flags [S.], cksum 0x6ec3 (incorrect -> 0xce9a), seq 2384749922, ack 1427778999, win 28960, option0
01:31:20.517404 IP (tos 0x10, ttl 64, id 42616, offset 0, flags [DF], proto TCP (6), length 52)
    172.17.0.3.40440 > 192.168.1.216.7000: Flags [.], cksum 0x6ebb (incorrect -> 0x6da2), seq 1, ack 1, win 229, options [nop,nop,TS val 6910
01:31:20.517684 IP (tos 0x0, ttl 64, id 61090, offset 0, flags [DF], proto TCP (6), length 52)
    192.168.1.216.7000 > 172.17.0.3.40440: Flags [F.], cksum 0x6ebb (incorrect -> 0x6da3), seq 1, ack 1, win 227, options [nop,nop,TS val 690
01:31:20.517767 IP (tos 0x10, ttl 64, id 42617, offset 0, flags [DF], proto TCP (6), length 52)
    172.17.0.3.40440 > 192.168.1.216.7000: Flags [.], cksum 0x6ebb (incorrect -> 0x6da0), seq 1, ack 2, win 229, options [nop,nop,TS val 6910
01:31:20.517816 IP (tos 0x10, ttl 64, id 42618, offset 0, flags [DF], proto TCP (6), length 52)
    172.17.0.3.40440 > 192.168.1.216.7000: Flags [F.], cksum 0x6ebb (incorrect -> 0x6d9f), seq 1, ack 2, win 229, options [nop,nop,TS val 690
01:31:20.517826 IP (tos 0x0, ttl 64, id 18465, offset 0, flags [DF], proto TCP (6), length 52)
    192.168.1.216.7000 > 172.17.0.3.40440: Flags [.], cksum 0x6da0 (correct), seq 2, ack 2, win 227, options [nop,nop,TS val 691702722 ecr 60

01:31:28.225011 IP (tos 0x10, ttl 64, id 34718, offset 0, flags [DF], proto TCP (6), length 60)
    172.17.0.3.44540 > 192.168.1.216.7001: Flags [S], cksum 0x6ec3 (incorrect -> 0x2353), seq 2035756611, win 29200, options [mss 1460,sackO0
01:31:28.225051 IP (tos 0x10, ttl 64, id 22136, offset 0, flags [DF], proto TCP (6), length 40)
    192.168.1.216.7001 > 172.17.0.3.44540: Flags [R.], cksum 0xd04a (correct), seq 0, ack 2035756612, win 0, length 0

Re: Python Plugin : Broadlink

Posted: Sunday 10 January 2021 13:02
by zak45
torM6 wrote: Saturday 09 January 2021 19:05 tried with 7000, with freshly created container with ubuntu.
the only port mapped is 7000
same result - if mapped, your test return opened, if not mapped - return "not".
I even make telnet tcpdump in both cases (for 9000 which is mapped and 9001 is not), different response from socket:
Do not know your net infrastructure but here it is how this suppose to work:

outside docker IP / host with docker installed : 192.168.1.216
Domiticz inside docker IP: 172.17.0.3

let suppose we want port 9000 for the listener.
outside docker :
telnet 192.168.1.216 9000 >> unable to connect

inside docker :
telnet 172.17.0.3 9000 >> unable to connect

you need to map (NAT) from 192.168.1.216:9000 to 172.17.0.3:9000
you need to map (NAT) from 192.168.1.216:8080 to 172.17.0.3:8080 (suppose Domoticz is on port 8080)
Broadlink plugin need to have as IP for Domoticz : 192.168.1.216 and for Listener port : 9000

Once the plugin start, inside docker, plugin check to see if 0.0.0.0:9000 is open (this include 172.17.0.3)
if yes ==> error else
this will create a listener inside the docker : 172.17.0.3:9000
you should be able to connect now using this command inside docker : telnet 172.17.0.3 9000
you should be able to connect now using this command outside docker : telnet 192.168.1.216 9000

if this not work, verify any fw/av or something else that could block/disable ports.

Re: Python Plugin : Broadlink

Posted: Monday 11 January 2021 11:13
by torM6
to @zak45
Thank you for reply!
zak45 wrote: Sunday 10 January 2021 13:02
Do not know your net infrastructure but here it is how this suppose to work:

outside docker IP / host with docker installed : 192.168.1.216
Domiticz inside docker IP: 172.17.0.3

let suppose we want port 9000 for the listener.
outside docker :
telnet 192.168.1.216 9000 >> unable to connect

inside docker :
telnet 172.17.0.3 9000 >> unable to connect

you need to map (NAT) from 192.168.1.216:9000 to 172.17.0.3:9000
you need to map (NAT) from 192.168.1.216:8080 to 172.17.0.3:8080 (suppose Domoticz is on port 8080)
Broadlink plugin need to have as IP for Domoticz : 192.168.1.216 and for Listener port : 9000

Once the plugin start, inside docker, plugin check to see if 0.0.0.0:9000 is open (this include 172.17.0.3)
if yes ==> error else
this will create a listener inside the docker : 172.17.0.3:9000
you should be able to connect now using this command inside docker : telnet 172.17.0.3 9000
you should be able to connect now using this command outside docker : telnet 192.168.1.216 9000

if this not work, verify any fw/av or something else that could block/disable ports.
this is exactly as I have in my setup.
And seems that I found a problem (talking with one of docker core developer).

Problem that docker start dedicated proxy for internal container processes to be mapped later.
In particular, if we map 9000 (NAT) port for container (e.g. docker command -p option, or using Synology web interface),
it will create automatically internal proxy which accept connection to port 9000 even if we do not have any process inside.
This docker feature created to allow connection to the docker internal processes right after start of docker itself (not waiting for particular process inside).

So, in case of docker function is_open() will always give wrong result (as I see in my example).

Suggestion from developer - try to bind() this address:port (instead of socket.socket) and if it fail then it is not in use...

another option - use code below to detect that we are in docker and make different check...

Code: Select all

import os
def is_docker():
    path = '/proc/self/cgroup'
    return (
        os.path.exists('/.dockerenv') or
        os.path.isfile(path) and any('docker' in line for line in open(path))
    )

Re: Python Plugin : Broadlink

Posted: Thursday 21 January 2021 18:46
by THBR
henk99 wrote: Thursday 19 November 2020 23:36 I have 4 Broadcom SP3S smartplugs which used to work fine with the older plugin.
Due to a system fail I installed domoticz completely new, with the 2020.2 version (instead of the old V3.8) and also with the new V4 plugin. The installing went fine, and according to description. Then:
1. Added one of the plugs in 'Hardware' with all the data needed
2. Three new devices can be seen in the list
3. Switch fuction works, current wattage works

At this point I go into the settings for the usage, and set it to 'usage' and select 'computed', as these are also the settings in my old version to be able to see the used energy (KWh). As soon as I update this, domoticz freezes and doesn't come out of it.

I restarted the domoticz service and when it is back I have 30 seconds or so to do anything. So, by doing that a few times, I was able to remove the item in 'hardware' and domoticz is back to normal again.

What is going wrong here? As soon as I set the usage to computional, domoticz goes crazy. By the way, this is a brand new install from scratch with Debian 10 (buster) and domoticz 2020.2.
Hi Henk,

I posted after yours that I had the exact same problem. Did you already found any solution for this?

Gr. Theo.

Re: Python Plugin : Broadlink

Posted: Monday 25 January 2021 16:11
by rjblake
Updated my install to Buster, and now it no longer works. I keep getting the following:

Code: Select all

2021-01-25 15:56:02.067 Error: Python Plugin System: (Broadlink) failed to load 'plugin.py', Python Path used was '/home/pi/domoticz/plugins/Broadlink/:/usr/lib/python37.zip:/usr/lib/python3.7:/usr/lib/python3.7/lib-dynload:/usr/local/lib/python3.7/dist-packages:/usr/lib/python3/dist-packages:/usr/lib/python3.7/dist-packages'.
2021-01-25 15:56:02.067 Error: Python Plugin System: (BroadlinkRM2-New) Module Import failed, exception: 'AttributeError'
2021-01-25 15:56:02.067 Error: Python Plugin System: (BroadlinkRM2-New) Error Line details not available.
2021-01-25 15:57:08.876 Error: BroadlinkRM2-New hardware (28) thread seems to have ended unexpectedly
I have installed Python3.7 and set as system default, installed all the modules, they show as listed in

Code: Select all

/usr/local/lib/python3.7/dist-packages
.

I'm guessing something is messed up with Python; but I've set Python3.7 as system wide version using

Code: Select all

sudo update-alternatives --config python
If I run the

Code: Select all

./broadlink_discovery.py
from the /home/pi/domoticz/plugins/Broadlink directory, it responds correctly:

Code: Select all

# broadlink_cli --type 0x2787 --host 192.168.178.17 --mac AABBCCDDEEFF
Device file data (to be used with --device @filename in broadlink_cli) : 
0x2787 192.168.178.17 AABBCCDDEEFF
temperature = 22.1
Anyone got any thoughts aside from complete fresh install?