Python Zigbee plugin, deCONZ bridge (Using Conbee or Raspbee) Topic is solved

Xiaomi, Ikea TRÅDFRI, Philips Hue and more.

Moderator: leecollings

Harald777
Posts: 48
Joined: Thursday 01 June 2017 8:44
Target OS: Raspberry Pi / ODroid
Domoticz version: Latest
Location: Netherlands
Contact:

Re: Python Zigbee plugin, deCONZ bridge (Using Conbee or Raspbee)

Post by Harald777 »

Thorgal789 wrote: Friday 18 October 2019 19:25 Lol, np the tool is easy to use, you need same parameters than in the plugin.

Go in the plugin directory

Code: Select all

cd /home/pi/domoticz/plugins/Domoticz-deCONZ
You can have a different folder.
Thanks for the reply.

Unfortunately I really don't know how to use the python3 API_KEY.py function.

As a result I get:
Exemples of use
python3 API_KEY.py <ip>:<port> <command> <Api key> <data>

python3 API_KEY.py 127.0.0.1:80 create
python3 API_KEY.py 127.0.0.1:80 info B4B018AA61
python3 API_KEY.py 127.0.0.1:80 list B4B018AA61
python3 API_KEY.py 127.0.0.1:80 delete B4B018AA61 CA606DA036
python3 API_KEY.py 127.0.0.1:80 clean B4B018AA61

Which really don't mean anything to me.
Pffffff.
Think I will throw my plan to use Zigbee via the Dresden Electronic in the wastebin an by a Xiaomi acces point :oops:

Harald
Thorgal789
Posts: 815
Joined: Wednesday 15 August 2018 14:38
Target OS: -
Domoticz version:
Contact:

Re: Python Zigbee plugin, deCONZ bridge (Using Conbee or Raspbee)

Post by Thorgal789 »

To create a key

Code: Select all

python3 API_KEY.py <ip>:<port> create
With same ip and port you have set in the plugin.
Harald777
Posts: 48
Joined: Thursday 01 June 2017 8:44
Target OS: Raspberry Pi / ODroid
Domoticz version: Latest
Location: Netherlands
Contact:

Re: Python Zigbee plugin, deCONZ bridge (Using Conbee or Raspbee)

Post by Harald777 »

Thorgal789 wrote: Saturday 19 October 2019 19:11 To create a key

Code: Select all

python3 API_KEY.py <ip>:<port> create
With same ip and port you have set in the plugin.
Did that, the reply was:

pi@RaspberryPI-Domoticz:~/domoticz/plugins/Domoticz-deCONZ $ python3 API_KEY.py 127.0.0.1:80 create
Traceback (most recent call last):
File "/usr/lib/python3.4/urllib/request.py", line 1174, in do_open
h.request(req.get_method(), req.selector, req.data, headers)
File "/usr/lib/python3.4/http/client.py", line 1142, in request
self._send_request(method, url, body, headers)
File "/usr/lib/python3.4/http/client.py", line 1180, in _send_request
self.endheaders(body)
File "/usr/lib/python3.4/http/client.py", line 1138, in endheaders
self._send_output(message_body)
File "/usr/lib/python3.4/http/client.py", line 963, in _send_output
self.send(msg)
File "/usr/lib/python3.4/http/client.py", line 898, in send
self.connect()
File "/usr/lib/python3.4/http/client.py", line 875, in connect
self.timeout, self.source_address)
File "/usr/lib/python3.4/socket.py", line 509, in create_connection
raise err
File "/usr/lib/python3.4/socket.py", line 500, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "API_KEY.py", line 25, in <module>
response = request.urlopen(req,timeout=3).read()
File "/usr/lib/python3.4/urllib/request.py", line 153, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib/python3.4/urllib/request.py", line 455, in open
response = self._open(req, data)
File "/usr/lib/python3.4/urllib/request.py", line 473, in _open
'_open', req)
File "/usr/lib/python3.4/urllib/request.py", line 433, in _call_chain
result = func(*args)
File "/usr/lib/python3.4/urllib/request.py", line 1202, in http_open
return self.do_open(http.client.HTTPConnection, req)
File "/usr/lib/python3.4/urllib/request.py", line 1176, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [Errno 111] Connection refused>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "API_KEY.py", line 33, in <module>
elif e.code == 403:
AttributeError: 'URLError' object has no attribute 'code'
00luke
Posts: 14
Joined: Thursday 28 December 2017 23:47
Target OS: OS X
Domoticz version:
Contact:

Re: Python Zigbee plugin, deCONZ bridge (Using Conbee or Raspbee)

Post by 00luke »

Thanks Thorgal789, I'll try updating my python version and let you know if it helps to solve things. Can't see it would make much difference though? Seems Domoticz just not talking to python.. couldn't be something as simple as an access / rights problem could it??
Thorgal789
Posts: 815
Joined: Wednesday 15 August 2018 14:38
Target OS: -
Domoticz version:
Contact:

Re: Python Zigbee plugin, deCONZ bridge (Using Conbee or Raspbee)

Post by Thorgal789 »

00luke wrote: Sunday 20 October 2019 9:41 Thanks Thorgal789, I'll try updating my python version and let you know if it helps to solve things. Can't see it would make much difference though? Seems Domoticz just not talking to python.. couldn't be something as simple as an access / rights problem could it??
I think no, I had take a look on your error message on previous issue, and It seem It seem it only occur because a domoticz problem, it was corrected after a domoticz update or a recompilation (for exemple https://www.domoticz.com/forum/viewtopic.php?t=29257)
A new version can change something perhaps ...
Harald777 wrote: Saturday 19 October 2019 19:21
Did that, the reply was:

pi@RaspberryPI-Domoticz:~/domoticz/plugins/Domoticz-deCONZ $ python3 API_KEY.py 127.0.0.1:80 create
You have a problem with ip or port (or both).
127.0.0.1 only work if you are making the command on the same machine, so it mean you are on the same machine you have installed deconz ?
This Url need to work on a browser, wich one url are you using to use Phoscon (you can use same ip and port) ?

If you have used the good parameter it mean if you go on a browser and use

Code: Select all

http://127.0.0.1:80/
You will have something ( the old phoscon version)

127.0.0.1 is the local host, so it's the IP of the machine you are using the command, so If you use a browser on other machine than the one where is installed deconz, you won't have same result.
Harald777
Posts: 48
Joined: Thursday 01 June 2017 8:44
Target OS: Raspberry Pi / ODroid
Domoticz version: Latest
Location: Netherlands
Contact:

Re: Python Zigbee plugin, deCONZ bridge (Using Conbee or Raspbee)

Post by Harald777 »

Harald777 wrote: Saturday 19 October 2019 19:21
Did that, the reply was:

pi@RaspberryPI-Domoticz:~/domoticz/plugins/Domoticz-deCONZ $ python3 API_KEY.py 127.0.0.1:80 create
You have a problem with ip or port (or both).
127.0.0.1 only work if you are making the command on the same machine, so it mean you are on the same machine you have installed deconz ?
This Url need to work on a browser, wich one url are you using to use Phoscon (you can use same ip and port) ?

If you have used the good parameter it mean if you go on a browser and use

Code: Select all

http://127.0.0.1:80/
You will have something ( the old phoscon version)

127.0.0.1 is the local host, so it's the IP of the machine you are using the command, so If you use a browser on other machine than the one where is installed deconz, you won't have same result.
[/quote]

http://127.0.0.1:80/ will give me no reply, hmmmmmmm.
I ran the RaspBee installation again, same result.
Thorgal789
Posts: 815
Joined: Wednesday 15 August 2018 14:38
Target OS: -
Domoticz version:
Contact:

Re: Python Zigbee plugin, deCONZ bridge (Using Conbee or Raspbee)

Post by Thorgal789 »

It's not an installation problem. Are you sure deconz is running ?
What is the url when you go on phoscon ?

If you don't have url, are you using headless or GUI version ? Have you the IP of the machine where is deconz ? Are you using docker or Virtual machine ?
Harald777
Posts: 48
Joined: Thursday 01 June 2017 8:44
Target OS: Raspberry Pi / ODroid
Domoticz version: Latest
Location: Netherlands
Contact:

Re: Python Zigbee plugin, deCONZ bridge (Using Conbee or Raspbee)

Post by Harald777 »

Thorgal789 wrote: Sunday 20 October 2019 19:29 It's not an installation problem. Are you sure deconz is running ?
What is the url when you go on phoscon ?

If you don't have url, are you using headless or GUI version ? Have you the IP of the machine where is deconz ? Are you using docker or Virtual machine ?
Yes, it looks like it is not running.

I am using a raspberry py 3 with the latest Domoticz.
Pyton version is 3.4.2.
Installed it as instructed here:
https://phoscon.de/en/raspbee/install
and here:
https://github.com/Smanar/Domoticz-deCONZ
All with no errors.

Greetings,

Harald
Thorgal789
Posts: 815
Joined: Wednesday 15 August 2018 14:38
Target OS: -
Domoticz version:
Contact:

Re: Python Zigbee plugin, deCONZ bridge (Using Conbee or Raspbee)

Post by Thorgal789 »

Nice, so you have choose the desktop version ?

After the installation deCONZ can be started via the application menu.
Menu > Programming > deCONZ

IDK wich one VNC appliation you are using, but don't install one, use the Raspian built in one.

After that on deconz on top right, you have a button "phoscon app", just clic on it and it will open your browser with good ip and good port (invisible port = port 80)

If it's that, you need to set your install to run deconz at startup, I can explain my method if you don't have one.
salopette
Posts: 187
Joined: Tuesday 07 March 2017 21:03
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Germany
Contact:

Re: Python Zigbee plugin, deCONZ bridge (Using Conbee or Raspbee)

Post by salopette »

-----
Last edited by salopette on Monday 21 October 2019 17:40, edited 1 time in total.
salopette
Posts: 187
Joined: Tuesday 07 March 2017 21:03
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Germany
Contact:

Re: Python Zigbee plugin, deCONZ bridge (Using Conbee or Raspbee)

Post by salopette »

Thorgal789 wrote: Friday 26 July 2019 22:38 Ha nice ^^, I can't try it on my side.
I don't see how to implement it on the plugin, but It's easy to make a switch to do that.

- Make a virtual sensor type switch on/off called 'colorloop'
- Use this script

Code: Select all

-- Color loop test

commandArray = {}

function SendJson(url,json)
	local curl = "/usr/bin/curl"
	local cmd = curl .. ' -X PUT -d '..json..' '..url
	local vac = os.execute(cmd)
	if vac ~= true then
		print('Send JSON Error')
	end
end

--color loop switch
if devicechanged['colorloop'] then
    if devicechanged['colorloop'] == 'On' then
        print('Start colorloop')
        SendJson('http://192.168.178.93/api/D279EE0F45/lights/50/state','\'{"effect":"colorloop","on":true}\'')
    else
        print('Stop colorloop')
        SendJson('http://192.168.178.93/api/D279EE0F45/lights/50/state','\'{"effect":"none","on":true}\'')
    end
end

return commandArray
I can't test it but I think I m not so far from the reality. For information you can add in json "colorloopspeed":255

"Specifies the speed of a colorloop. 1 = very fast, 255 = very slow (default: 15). This parameter only has an effect when it is called together with effect colorloop."
Hi, is it possible to make a selector for Colorloop?

If you enter a url for each select?
Harald777
Posts: 48
Joined: Thursday 01 June 2017 8:44
Target OS: Raspberry Pi / ODroid
Domoticz version: Latest
Location: Netherlands
Contact:

Re: Python Zigbee plugin, deCONZ bridge (Using Conbee or Raspbee)

Post by Harald777 »

Thorgal789 wrote: Monday 21 October 2019 16:39 Nice, so you have choose the desktop version ?

After the installation deCONZ can be started via the application menu.
Menu > Programming > deCONZ

IDK wich one VNC appliation you are using, but don't install one, use the Raspian built in one.

After that on deconz on top right, you have a button "phoscon app", just clic on it and it will open your browser with good ip and good port (invisible port = port 80)

If it's that, you need to set your install to run deconz at startup, I can explain my method if you don't have one.
Thanks for the reply.

Just have been building my PI / Domoticz from scratch.
Installed the Raspbee software and successfully created the api key.

The Domoticz log now shows:

2019-10-21 17:43:10.204 Error: WebServer(SSL) startup failed on address 0.0.0.0 with port: 443: bind: Address already in use
2019-10-21 17:43:10.204 Error: WebServer(SSL) check privileges for opening ports below 1024
2019-10-21 17:43:47.851 Error: (deConz) Device creation failed, Domoticz settings prevent accepting new devices.
2019-10-21 17:43:47.851 Error: (deConz) Can't Update Unit > 1 (sensors)
2019-10-21 17:47:17.585 Error: (deConz) Can't Update Unit > 1 (sensors)
2019-10-21 17:53:10.302 Error: CConnection_disconnect, disconnection request from 'deConz' ignored. Transport does not exist.
2019-10-21 17:53:21.350 Error: (deConz) Device creation failed, Domoticz settings prevent accepting new devices.
2019-10-21 17:53:21.350 Error: (deConz) Can't Update Unit > 1 (sensors)

So I cannot access Domoticz via 443 port anymore and sensor creation fails.
Don't now is 443 port issue is normal now and perhaps I should allow new sensor discovery to "always"now.

Greetings,

Harald
Thorgal789
Posts: 815
Joined: Wednesday 15 August 2018 14:38
Target OS: -
Domoticz version:
Contact:

Re: Python Zigbee plugin, deCONZ bridge (Using Conbee or Raspbee)

Post by Thorgal789 »

Harald777 wrote: Monday 21 October 2019 18:02 So I cannot access Domoticz via 443 port anymore and sensor creation fails.
Don't now is 443 port issue is normal now and perhaps I should allow new sensor discovery to "always"now.

Greetings,

Harald
Hello again ^^,

Code: Select all

2019-10-21 17:43:47.851 Error: (deConz) Device creation failed, Domoticz settings prevent accepting new devices.
Have you enabled "accept new device" in domoticz setup ?

Code: Select all

2019-10-21 17:43:10.204 Error: WebServer(SSL) startup failed on address 0.0.0.0 with port: 443: bind: Address already in use
It's not the deconz webserver, but the domoticz webserver, do you need it, deconz will work without it.
Thorgal789
Posts: 815
Joined: Wednesday 15 August 2018 14:38
Target OS: -
Domoticz version:
Contact:

Re: Python Zigbee plugin, deCONZ bridge (Using Conbee or Raspbee)

Post by Thorgal789 »

salopette wrote: Monday 21 October 2019 17:40
Hi, is it possible to make a selector for Colorloop?

If you enter a url for each select?
An url for each select ? You mean for temporistation ? because you can't choose color. And url are post command, not sure we can use them as it in domoticz
Harald777
Posts: 48
Joined: Thursday 01 June 2017 8:44
Target OS: Raspberry Pi / ODroid
Domoticz version: Latest
Location: Netherlands
Contact:

Re: Python Zigbee plugin, deCONZ bridge (Using Conbee or Raspbee)

Post by Harald777 »


Thorgal789 wrote:
Harald777 wrote: Monday 21 October 2019 18:02 So I cannot access Domoticz via 443 port anymore and sensor creation fails.
Don't now is 443 port issue is normal now and perhaps I should allow new sensor discovery to "always"now.

Greetings,

Harald
Hello again ^^,

Code: Select all

2019-10-21 17:43:47.851 Error: (deConz) Device creation failed, Domoticz settings prevent accepting new devices.
Have you enabled "accept new device" in domoticz setup ?
Thorgal789,

Everything is working fine now on the deConz and Phoscon side, great.
Thank for all your advice, much appreciated and very learning full.
Zigbee running now on my domoticz next to my RFLink gateway, great.

The 433 port issue still exists, will sort that out asap but no item for this forum.

Thanks again for the help.

Greetings Harald

Verstuurd vanaf mijn Nexus 5X met Tapatalk

Thorgal789
Posts: 815
Joined: Wednesday 15 August 2018 14:38
Target OS: -
Domoticz version:
Contact:

Re: Python Zigbee plugin, deCONZ bridge (Using Conbee or Raspbee)

Post by Thorgal789 »

NP, But take care, use the deconz app to launch phoscon create an API key (for the browser) every time, so the good way, it's using this method one time, register, and put the link in bookmark just after.
Like this you can launch phoscon without registration the next time (1 registration = 1 new api key).
salopette
Posts: 187
Joined: Tuesday 07 March 2017 21:03
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Germany
Contact:

Re: Python Zigbee plugin, deCONZ bridge (Using Conbee or Raspbee)

Post by salopette »

Thorgal789 wrote: Monday 21 October 2019 21:33
salopette wrote: Monday 21 October 2019 17:40
Hi, is it possible to make a selector for Colorloop?

If you enter a url for each select?
An url for each select ? You mean for temporistation ? because you can't choose color. And url are post command, not sure we can use them as it in domoticz
it works with // http and // script.
Maybe with script?
Thorgal789
Posts: 815
Joined: Wednesday 15 August 2018 14:38
Target OS: -
Domoticz version:
Contact:

Re: Python Zigbee plugin, deCONZ bridge (Using Conbee or Raspbee)

Post by Thorgal789 »

Yep, you can make shell script *.sh and use them with script://, but I m not sure it will be more easy than use a lua script (Put the script at good path and use the good synthax is just an horror in domoticz)
Something like that

Code: Select all

commandArray = {}

if (devicechanged['Selector']) then
    if (devicechanged['Selector'] == 'aaa') then
        print ("aaa")
    end
    if (devicechanged['Selector'] == 'bbb') then
        print ("bbbb") 
    end
    if (devicechanged['Selector'] == 'ccc') then
            print ("cccc")
    end
znd

return commandArray
But what do you want to put in the selector ? temporisation, device ?
You ca too make a scenario by device ?
00luke
Posts: 14
Joined: Thursday 28 December 2017 23:47
Target OS: OS X
Domoticz version:
Contact:

Re: Python Zigbee plugin, deCONZ bridge (Using Conbee or Raspbee)

Post by 00luke »

So I managed to get python working with that link you sent me to other thread, thank you Thorgal :)

Now however I've run in to this problem when I try to turn on / off a synced device:

Code: Select all

2019-10-24 22:09:34.318 Status: User: luke initiated a switch command (178/DeCONZ - Kitchen Spots 3/On)
2019-10-24 22:09:34.369 Error: (DeCONZ) Connexion problem (3) with Gateway, check your API key
API key is working to sync the devices, but not to turn them on / off - am I missing something?
Thorgal789
Posts: 815
Joined: Wednesday 15 August 2018 14:38
Target OS: -
Domoticz version:
Contact:

Re: Python Zigbee plugin, deCONZ bridge (Using Conbee or Raspbee)

Post by Thorgal789 »

Yep, it's strange.
Can you enable logs "debug info only" pls, juste before the error message you will have something like

Code: Select all

2019-10-25 16:30:16.041 (deCONZ) Making Request : http://127.0.0.1:80/api/36E138295E/lights/2/state with params {'bri': 254, 'xy': [0.496236, 0.352735], 'transitiontime': 0, 'on': True}
Can you show me this line or compare the url with the working one (you will have 3 of them at startup for config).
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest