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

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

Moderator: leecollings

WimV
Posts: 7
Joined: Wednesday 06 November 2019 15:46
Target OS: Linux
Domoticz version:
Contact:

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

Post by WimV »

So what I would do on my side.
- At domoticz startup, you can see the python version it will use, I will compare it with the one I m using on the system with "python3 -- version"
- If it's not the same I will switch the version with "update-alternatives"
- Then I will test if request library is working on my system

Code: Select all

pi@raspberrypi:~ $ python3
Python 3.5.3 (default, Sep 27 2018, 17:25:39)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
>>> exit()
- Then I will test it in a plugin, for exemple the deconz one removing the except loop (with adding requests in the import line a second time)

Code: Select all

import json,urllib, time,requests
- If I have an error, an import error I think, hopping for more information from domoticz.
- I will search where is the lib is on my system, looking with a file browser and add the path in the python code

Code: Select all

import sys
sys.path.append('/usr/local/lib/python3.6/site-packages')
On this exemple, I realy have a folder called "requests" in '/usr/local/lib/python3.6/site-packages' and it's the one that is working for the version I m using.
- If it's not working yet, ask on domoticz forum why the "requests" lib can't be used on python 3.x.x with domoticz
[/quote]

Ok, I will try dis.
I let you know

Thanks
gemas
Posts: 7
Joined: Saturday 07 October 2017 14:07
Target OS: -
Domoticz version:
Contact:

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

Post by gemas »

First of all sorry if this question has been asked/answered before. I couldn't find any reference to this question.
I'm wondering if you dim your lights with a ikea/hue device in domoticz while keeping the upper/lower button pressed.
So that you gradually dim your lights with 1 button press.
Now I'm dimming with every button press 10% using dzvents. So going from 0 to 100% needs 10 button clicks.
Thorgal789
Posts: 849
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 »

Good question.
The plugin can trigger an event for long press is starting, an other for button release, but I don't see a way to make the luminosity increase by one during this period.

Need to check.
Thorgal789
Posts: 849
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 »

gemas wrote: Thursday 21 November 2019 15:25 First of all sorry if this question has been asked/answered before. I couldn't find any reference to this question.
I'm wondering if you dim your lights with a ikea/hue device in domoticz while keeping the upper/lower button pressed.
So that you gradually dim your lights with 1 button press.
Now I'm dimming with every button press 10% using dzvents. So going from 0 to 100% needs 10 button clicks.
Ok so I have found 2 ways
- using phoscon
- with domoticz using this script

Code: Select all

--Ikea remote
if (devicechanged['deCONZ - TRÅDFRI remote control'] == 'L +')  then
    a = otherdevices_svalues['deCONZ - chambre']
    a = tonumber(a) + 5
    commandArray['deCONZ - chambre'] = 'Set Level: '..a
end
-- bulb
if (devicechanged['deCONZ - chambre'])  then
    if (otherdevices['deCONZ - TRÅDFRI remote control'] == 'L +') then
        a = otherdevices_svalues['deCONZ - chambre']
        a = tonumber(a) + 5
        commandArray['deCONZ - chambre'] = 'Set Level: '..a
    end
end
The script is not finished, and can be optimised, but this method is working, I think you can do same with dzevent.
WimV
Posts: 7
Joined: Wednesday 06 November 2019 15:46
Target OS: Linux
Domoticz version:
Contact:

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

Post by WimV »

Hi Thorgal789
I can not use the plugin in a docker container because i do not install python inside the container.
But i have now install the plugin on a normal domoticz and the plugin works oké.
Thanks.
Thorgal789
Posts: 849
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 possible to install python on the container that contain domoticz ?
So it mean it's not possible to install domoticz on a container ? Or it's your choice ?
WimV
Posts: 7
Joined: Wednesday 06 November 2019 15:46
Target OS: Linux
Domoticz version:
Contact:

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

Post by WimV »

It is possible, but I do not have time for that yet.
I try it another time for myself, and when it works I share it here.
For now it works well
User avatar
havnegata
Posts: 114
Joined: Wednesday 10 September 2014 11:05
Target OS: Raspberry Pi / ODroid
Domoticz version: V4.10162
Location: Norway
Contact:

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

Post by havnegata »

I'm on Domoticz V4.10162 and python version 2.7.13

I'm getting this error:
Screen Shot 12-02-19 at 03.05 PM.PNG
Screen Shot 12-02-19 at 03.05 PM.PNG (12.68 KiB) Viewed 1590 times

Then I'm trying to install the missing libs: sudo -H pip install requests
Screen Shot 12-02-19 at 03.10 PM.PNG
Screen Shot 12-02-19 at 03.10 PM.PNG (13.64 KiB) Viewed 1590 times
Can somebody point me in the right direction?
Thorgal789
Posts: 849
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 »

There is so much possibilities, but wich one raspbian version have you, to have missing command here ?

I think it will be usefull to install pip.

Code: Select all

sudo apt install python3-pip
BTW, domoticz use only python3 (and no python 2.X) so better to use sudo -H pip3 install requests
User avatar
havnegata
Posts: 114
Joined: Wednesday 10 September 2014 11:05
Target OS: Raspberry Pi / ODroid
Domoticz version: V4.10162
Location: Norway
Contact:

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

Post by havnegata »

Thanks for responding! If I run python -V I get Python 2.7.13 as output and Im running Raspbian Buster
Thorgal789
Posts: 849
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 »

And pip isn"t installed by defaut on Buster ?
To have python3 version use

Code: Select all

python3 -V
Try installing pip for python3

Code: Select all

sudo apt-get install python3-pip
and then install requests

Code: Select all

sudo pip3 install requests
With "-H" option if needed.
User avatar
havnegata
Posts: 114
Joined: Wednesday 10 September 2014 11:05
Target OS: Raspberry Pi / ODroid
Domoticz version: V4.10162
Location: Norway
Contact:

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

Post by havnegata »

Sorry, I was wrong about the Raspbian version, it's Stretch. I think the reason I installed python 2.7.13 was that I had problems running python plugins under python3, it always seemed to crash domoticz. But do you think this will not be a problem for me?
Thorgal789
Posts: 849
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 »

Bad luck for you, I think you are in same situation than them > https://www.domoticz.com/forum/viewtopi ... 7&p=229684 , crash with message "fatal signal X" ?
And I m sorry for you, but domoticz NEED python 3 to use plugin > https://www.domoticz.com/wiki/Using_Python_plugins
User avatar
havnegata
Posts: 114
Joined: Wednesday 10 September 2014 11:05
Target OS: Raspberry Pi / ODroid
Domoticz version: V4.10162
Location: Norway
Contact:

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

Post by havnegata »

Thorgal789 wrote: Tuesday 03 December 2019 21:04 And pip isn"t installed by defaut on Buster ?
To have python3 version use

Code: Select all

python3 -V
Try installing pip for python3

Code: Select all

sudo apt-get install python3-pip
and then install requests

Code: Select all

sudo pip3 install requests
With "-H" option if needed.
I did as you described, but how do I force Domoticz to use Python V3 instead of V2.7.13?

Edit: now it's using python v 3.5.3, but the errors are the same (missing requests library)
Thorgal789
Posts: 849
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 »

What is the result of "sudo pip3 install requests", if you have installed pip before ofc ?
User avatar
havnegata
Posts: 114
Joined: Wednesday 10 September 2014 11:05
Target OS: Raspberry Pi / ODroid
Domoticz version: V4.10162
Location: Norway
Contact:

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

Post by havnegata »

Screen Shot 12-05-19 at 07.54 PM.PNG
Screen Shot 12-05-19 at 07.54 PM.PNG (17.41 KiB) Viewed 1539 times
Thorgal789
Posts: 849
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 »

Arf, an other user had exectly same problem, without solution (just previous page)

So, when you start domoticz on log you will see the python3 version domoticz will use, check if it's the same than your : python 3.5.3

You can try with the -H flag > sudo -H pip3 install requests

Or add this at the start of the plugin code, line 48

Code: Select all

import sys
sys.path.append('/usr/local/lib/python3.5/dist-packages')
User avatar
havnegata
Posts: 114
Joined: Wednesday 10 September 2014 11:05
Target OS: Raspberry Pi / ODroid
Domoticz version: V4.10162
Location: Norway
Contact:

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

Post by havnegata »

Thanks! Working night shift so will try when getting home in the morning!
User avatar
havnegata
Posts: 114
Joined: Wednesday 10 September 2014 11:05
Target OS: Raspberry Pi / ODroid
Domoticz version: V4.10162
Location: Norway
Contact:

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

Post by havnegata »

Thorgal789 wrote: Friday 06 December 2019 17:46
Or add this at the start of the plugin code, line 48

Code: Select all

import sys
sys.path.append('/usr/local/lib/python3.5/dist-packages')
Thanks for your support! This code seemed to be success, although I still only have my Conbee installed and no sensors or switches, but at least no errors are showing! Great support!!
Thorgal789
Posts: 849
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 »

No problem, but just for confirmation, if you remove theses 2 lines, you have again the error message about request lib ? (You are the first one that this solution have worked)
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest