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 »

Hi All,

All running great on my Raspberry Pi 3 with Domoticz after all the help on this forum.

I have a question about the Phoscon - Domoticz integration:

I have two of Ikea TRÅDFRI lamps + remotes.
All show up nicely in the Phoscon app and later on in Domoticz.
I assigned 2x remotes to 2 separate ikea bulbs in the Phoscon app and the remotes operate the lamps fine.
Closed app, all okay only after visiting the Phoscon app again the assignments are gone but still working normal.
Is that normal behaviour?

I also noticed that when you add a Ikea remote is shows up in the Phoscon app.
After you assign switch functions to the switch the same switch shows up twice in domotics and you cannot find the assignments back in the Phoscon app when you re-visit the app again.
Is that also normal behaviour?

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 »

Hello,
Hu,...., them I can't answer ^^.
First some remote/switch have special features, they can speak to "group" and can work even without deconz. Theses devices have automaticly a group created when you add them in phoscon.This group is special.
Putting a bulb in the device group, will not have the same result than putting the device on another group with a bulb.

IDK what you have done with phoscon (lot of possibilities), but if yours manipulations have created a group or a scene, you will see them in domoticz too.
the same switch shows up twice in domotics
It s a switch for a device or a scene/group ? If you can make a screenshoot, will be helpfull. Remember the plugin never delete device, so if you have make 3 tries, you can have 3 time the same device. To check that, just restart the plugin and take a look in log, if you have dead device in domoticz (without link with deconz) you will see then on a message and can delete them.
you cannot find the assignments back in the Phoscon app when you re-visit the app again
And no this is not normal. Perhaps. you don't see them on devices section, but take a look on mainpage, where you have all groups, I think you will find your setup here (use the edit icon)
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 Thorgal..

At startup:

Code: Select all

2019-10-25 17:29:24.976 (DeCONZ) Making Request : http://192.168.0.192:80/api/2828FD8FB1/config/ with params None
2019-10-25 17:29:25.035 (DeCONZ) Request Return : {"UTC":"2019-10-25T16:28:40","apiversion":"1.16.0","backup":{"errorcode":0,"status":"idle"},"bridgeid":"00212EFFFF04D493","datastoreversion":"60","devicename":"ConBee II","dhcp":true,"factorynew":false,"fwversion":"0x264a0700","gateway":"192.168.0.1","internetservices":{"remoteaccess":"disconnected"},"ipaddress":"192.168.0.192","linkbutton":false,"localtime":"2019-10-25T16:28:40","mac":"b8:27:eb:ac:f7:8b","modelid":"deCONZ","name":"Phoscon-GW","netmask":"255.255.255.0","networkopenduration":60,"ntp":"synced","panid":81,"portalconnection":"disconnected","portalservices":false,"portalstate":{"communication":"disconnected","incoming":false,"outgoing":false,"signedon":false},"proxyaddress":"none","proxyport":0,"replacesbridgeid":null,"rfconnected":true,"starterkitid":"","swupdate":{"checkforupdate":false,"devicetypes":{"bridge":false,"lights":[],"sensors":[]},"notify":false,"text":"","updatestate":0,"url":""},"swupdate2":{"autoinstall":{"on":false,"updatetime":""},"bridge":{"lastinstall":"2019-09-
When I try to turn on / off a light:

Code: Select all

2019-10-25 17:29:45.398 (DeCONZ) onCommand called for Unit 7: Parameter 'Off', Level: 0, Hue:
2019-10-25 17:29:45.398 (DeCONZ) Send Command /api/2828FD8FB1/lights/3/state with {'on': False} (0 in buffer)
2019-10-25 17:29:45.398 (DeCONZ) Making Request : http://192.168.0.192:80/api/2828FD8FB1/lights/3/state with params {'on': False}
2019-10-25 17:29:45.372 Status: User: luke initiated a switch command (180/DeCONZ - Kitchen Spots 1/Off)
2019-10-25 17:29:45.399 Error: (DeCONZ) Connexion problem (3) with Gateway, check your API key
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 »

Lol, ok, so where is the trick ?
Where have you find your API key ? It like you have a restricted key.

Can you try on a browser the both url

Code: Select all

http://192.168.0.192:80/api/2828FD8FB1/config/
http://192.168.0.192:80/api/2828FD8FB1/lights/3/state
You will have a json (you can have error "not available", it's normal)

BTW have you domoticz and deconz on the same machine ?

Edit:
It's perhaps a problem with POST feature with your requests library version. If you still haven't something usefull, can you try this python code. Just make a file called test.py with

Code: Select all

import requests

url = 'http://192.168.0.192:80/api/2828FD8FB1/lights/3/state'
param = {'on': False}
headers={'Content-Type': 'application/json' }

result=requests.put(url , headers=headers, json = param, timeout=1)

data = result.content

print (data.decode("utf-8", "ignore"))
and execute it with

Code: Select all

python3 test.py
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 »

Domoticz and deCONZ are on separate machines, hence specifying IP address of deCONZ (192.168.0.192) Domoticz is on 192.168.0.11.

So first URL gives me this:

Code: Select all

{"UTC":"2019-10-25T17:51:21","apiversion":"1.16.0","backup":{"errorcode":0,"status":"idle"},"bridgeid":"00212EFFFF04D493","datastoreversion":"60","devicename":"ConBee II","dhcp":true,"factorynew":false,"fwversion":"0x264a0700","gateway":"192.168.0.1","internetservices":{"remoteaccess":"disconnected"},"ipaddress":"192.168.0.192","linkbutton":false,"localtime":"2019-10-25T17:51:21","mac":"b8:27:eb:ac:f7:8b","modelid":"deCONZ","name":"Phoscon-GW","netmask":"255.255.255.0","networkopenduration":60,"ntp":"synced","panid":81,"portalconnection":"disconnected","portalservices":false,"portalstate":{"communication":"disconnected","incoming":false,"outgoing":false,"signedon":false},"proxyaddress":"none","proxyport":0,"replacesbridgeid":null,"rfconnected":true,"starterkitid":"","swupdate":{"checkforupdate":false,"devicetypes":{"bridge":false,"lights":[],"sensors":[]},"notify":false,"text":"","updatestate":0,"url":""},"swupdate2":{"autoinstall":{"on":false,"updatetime":""},"bridge":{"lastinstall":"2019-09-05T09:55:43","state":"allreadytoinstall"},"checkforupdate":false,"install":false,"lastchange":"","lastinstall":"","state":"allreadytoinstall"},"swversion":"2.5.67","timeformat":"12h","timezone":"Etc/GMT","uuid":"3d06d300-4c40-46aa-9584-8da7ac10ea93","websocketnotifyall":true,"websocketport":443,"whitelist":{"2828FD8FB1":{"create date":"2019-10-24T20:19:30","last use date":"2019-10-25T17:51:21","name":"Domoticz"},"48809C0BA9":{"create date":"2019-10-18T22:39:29","last use date":"2019-10-24T21:47:01","name":"Phoscon#B412x342"},"80081DFAE9":{"create date":"2019-10-18T18:13:10","last use date":"2019-10-19T13:35:23","name":"Phoscon#B1440x630"},"BAD120A5B6":{"create date":"2019-10-18T18:12:39","last use date":"2019-10-18T18:13:10","name":"Phoscon#B1440x630"},"D3F1706895":{"create date":"2019-10-19T13:36:03","last use date":"2019-10-25T17:51:21","name":"Phoscon#B1440x630"}},"zigbeechannel":25}
Second URL gives me this:

Code: Select all

[{"error":{"address":"/lights/3/state","description":"resource, /lights/3/state, not available","type":3}}]
Creating and executing test.py gives me this:

Code: Select all

luke@Holly:~/dev-domoticz/plugins/Domoticz-deCONZ$ python3 test.py
Traceback (most recent call last):
  File "test.py", line 7, in <module>
    result=requests.put(url , headers=headers, json = param, timeout=1)
  File "/usr/lib/python3/dist-packages/requests/api.py", line 99, in put
    return request('put', url, data=data, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/api.py", line 44, in request
    return session.request(method=method, url=url, **kwargs)
TypeError: request() got an unexpected keyword argument 'json'
luke@Holly:~/dev-domoticz/plugins/Domoticz-deCONZ$ 
I'm completely lost with it all! Thanks for your help Thorgal
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 »

The problem is that Amazon Linux/2.8.1 (and probably other releases) have requests==1.2.3 installed by default. According to the release notes for the requests module, the 'json' parameter was only added in 2.4.2 (2014-10-05)

You can check your installed version and upgrade to the latest version like so:

$ pip show requests | grep Version
Version: 1.2.3

$ sudo /usr/local/bin/pip install --upgrade requests

$ pip show requests | grep Version
Version: 2.8.1
Try to upgrade with
pip3 install --upgrade requests
Perhaps you need too the argument -H
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 »

Hmm, so I'm getting this:

Code: Select all

luke@Holly:~/dev-domoticz/plugins/Domoticz-deCONZ$ sudo -H /usr/local/bin/pip install --upgrade requests
Collecting requests
  Using cached https://files.pythonhosted.org/packages/7d/e3/20f3d364d6c8e5d2353c72a67778eb189176f08e873c9900e10c0287b84b/requests-2.21.0-py2.py3-none-any.whl
Collecting urllib3<1.25,>=1.21.1
  Using cached https://files.pythonhosted.org/packages/01/11/525b02e4acc0c747de8b6ccdab376331597c569c42ea66ab0a1dbd36eca2/urllib3-1.24.3-py2.py3-none-any.whl
Requirement already satisfied, skipping upgrade: certifi>=2017.4.17 in /usr/local/lib/python3.4/dist-packages (from requests) (2019.9.11)
Requirement already satisfied, skipping upgrade: chardet<3.1.0,>=3.0.2 in /usr/local/lib/python3.4/dist-packages (from requests) (3.0.4)
Requirement already satisfied, skipping upgrade: idna<2.9,>=2.5 in /usr/local/lib/python3.4/dist-packages (from requests) (2.8)
Installing collected packages: urllib3, requests
  Found existing installation: urllib3 1.7.1
ERROR: Cannot uninstall 'urllib3'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
luke@Holly:~/dev-domoticz/plugins/Domoticz-deCONZ$ pip show requests | grep Version
Version: 2.2.1
Looks like it won't upgrade beyond 2.2.1. Is that because I'm using such an outdated release (Ubuntu 14.04.6)?
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 »

pip3 pour python3
pip3 install --upgrade requests
Last edited by Thorgal789 on Friday 25 October 2019 21:30, edited 2 times in total.
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 »

Code: Select all

luke@Holly:~/dev-domoticz/plugins/Domoticz-deCONZ$ sudo -H pip3 install --upgrade requests
[sudo] password for luke: 
Collecting requests
  Using cached https://files.pythonhosted.org/packages/7d/e3/20f3d364d6c8e5d2353c72a67778eb189176f08e873c9900e10c0287b84b/requests-2.21.0-py2.py3-none-any.whl
Requirement already satisfied, skipping upgrade: chardet<3.1.0,>=3.0.2 in /usr/local/lib/python3.4/dist-packages (from requests) (3.0.4)
Collecting urllib3<1.25,>=1.21.1
  Using cached https://files.pythonhosted.org/packages/01/11/525b02e4acc0c747de8b6ccdab376331597c569c42ea66ab0a1dbd36eca2/urllib3-1.24.3-py2.py3-none-any.whl
Requirement already satisfied, skipping upgrade: idna<2.9,>=2.5 in /usr/local/lib/python3.4/dist-packages (from requests) (2.8)
Requirement already satisfied, skipping upgrade: certifi>=2017.4.17 in /usr/local/lib/python3.4/dist-packages (from requests) (2019.9.11)
Installing collected packages: urllib3, requests
  Found existing installation: urllib3 1.7.1
ERROR: Cannot uninstall 'urllib3'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
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 »

Somes answer here > https://stackoverflow.com/questions/538 ... t/53807588

A solution to try

Code: Select all

sudo -i pip3 install --upgrade requests
There is a solution with remove urllib3
sudo apt-get remove python-urllib3
sudo apt-get purge python-urllib3
But you can need it later, and you can have an instable installation of python.
User avatar
bitjeverkeerd
Posts: 30
Joined: Monday 13 April 2015 20:39
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Contact:

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

Post by bitjeverkeerd »

Is it possible to display long press of the up or down button with the Ikea tradfri remote?
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 Thorgal - I'll have a look at maybe doing a private python installation / environment, as I'm worried that removing urllib3 may cause problems further down the line! (And as I don't understand all this, I won't know how to fix it!)

I'll look in to it all (don't even understand what a private python install is at the moment!) and let you know how I get on.

Thanks again for your help
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, doing a private python installation is not a good solution for me
- the system will be more complicate
- your request version is old ( and surely other libs)
- Not sure domoticz will be compatible with this kind of install

Have you tried "sudo -i pip3 install --upgrade requests" ?

Don't worry, If you realy can do nothing, I can just modify the plugin code to use the old request library, I just need to edit 2/3 lines. But it can be a good thing to update your system. I can do it tommorow just tell me your choice.

@bitjeverkeerd Wich one ikea remote ? I think no, From my memory ikea don't have this feature, it's Xiaomi that use them.
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: Friday 25 October 2019 21:57 Thanks Thorgal - I'll have a look at maybe doing a private python installation / environment, as I'm worried that removing urllib3 may cause problems further down the line! (And as I don't understand all this, I won't know how to fix it!)

I'll look in to it all (don't even understand what a private python install is at the moment!) and let you know how I get on.

Thanks again for your help
as patch, file plugin.py line 913
Replace

Code: Select all

result=requests.put(url , headers=headers, json = param, timeout=1)
by

Code: Select all

result=requests.put(url , headers=headers, data = json.dumps(param), timeout=1)
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 »

Aw, thanks Thorgal - I've decided to take the plunge and upgrade, hopefully it'll all work without too many problems! I'll keep you posted. If any problems I'll roll back and try your patch.

Thanks again for all your help, you've been amazing!
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 »

Crikey, that was the easiest upgrade I've ever done! All completed and all working beautifully, including the deCONZ bridge plugin!! :D

I may even be able to move deCONZ itself to the same machine now! Didn't do it before because wouldn't work on my outdated version :roll:

Thank you Thorgal! :mrgreen:
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 »

Lol, I can understand, I m afraid for update to buster ^^

json parameter is working since at least 5 years, so for me it's a realy good idea to upgrade your system.
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 25 October 2019 18:04 Hello,
Hu,...., them I can't answer ^^.
First some remote/switch have special features, they can speak to "group" and can work even without deconz. Theses devices have automaticly a group created when you add them in phoscon.This group is special.
Putting a bulb in the device group, will not have the same result than putting the device on another group with a bulb.

IDK what you have done with phoscon (lot of possibilities), but if yours manipulations have created a group or a scene, you will see them in domoticz too.
the same switch shows up twice in domotics
It s a switch for a device or a scene/group ? If you can make a screenshoot, will be helpfull. Remember the plugin never delete device, so if you have make 3 tries, you can have 3 time the same device. To check that, just restart the plugin and take a look in log, if you have dead device in domoticz (without link with deconz) you will see then on a message and can delete them.
Its a Ikea remote switch. Once you register a switch in Phoscon it is added in Domoticz with typical address shown.
As soon as you change the key assignment it shows up as an new switch.
I assume this is correct, observed same behaviour when I added a second ikea remote switch

Schakelaar.png
Schakelaar.png (6.37 KiB) Viewed 1688 times
you cannot find the assignments back in the Phoscon app when you re-visit the app again
And no this is not normal. Perhaps. you don't see them on devices section, but take a look on mainpage, where you have all groups, I think you will find your setup here (use the edit icon).
This item is okay now, think I made an operating fault in the Phoscon app. Can find the switch assignments now when selecting a Group.

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 »

Ok so it's that.
The device 199 is the remote device, with the same buton than the remote itself.
The device 200 is the group associed to the remote (the special group for "group" command)

The first one is an transmitter, you can only see wich one button are pressed.
The second one is a receiver, you can only send order to this group (don't use it to check a state, not reliable)
User avatar
bitjeverkeerd
Posts: 30
Joined: Monday 13 April 2015 20:39
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Contact:

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

Post by bitjeverkeerd »

@Thorgal789, It is the ikea remote with 5 buttons.
Ikea Tradfri and DeConz support the long press of the light intensity button.
It is only now not visible in Domoticz if you hold down the button for a long time.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests