Page 19 of 35

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

Posted: Wednesday 13 November 2019 20:11
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

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

Posted: Thursday 21 November 2019 15:25
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.

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

Posted: Thursday 21 November 2019 17:17
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.

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

Posted: Friday 22 November 2019 19:22
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.

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

Posted: Tuesday 26 November 2019 21:54
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.

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

Posted: Wednesday 27 November 2019 17:00
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 ?

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

Posted: Wednesday 27 November 2019 21:30
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

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

Posted: Monday 02 December 2019 15:12
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 1695 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 1695 times
Can somebody point me in the right direction?

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

Posted: Monday 02 December 2019 17:44
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

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

Posted: Tuesday 03 December 2019 20:12
by havnegata
Thanks for responding! If I run python -V I get Python 2.7.13 as output and Im running Raspbian Buster

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

Posted: Tuesday 03 December 2019 21:04
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.

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

Posted: Tuesday 03 December 2019 22:15
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?

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

Posted: Wednesday 04 December 2019 17:43
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

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

Posted: Thursday 05 December 2019 14:54
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)

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

Posted: Thursday 05 December 2019 18:27
by Thorgal789
What is the result of "sudo pip3 install requests", if you have installed pip before ofc ?

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

Posted: Thursday 05 December 2019 19:55
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 1644 times

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

Posted: Friday 06 December 2019 17:46
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')

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

Posted: Saturday 07 December 2019 2:51
by havnegata
Thanks! Working night shift so will try when getting home in the morning!

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

Posted: Sunday 08 December 2019 16:34
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!!

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

Posted: Sunday 08 December 2019 16:54
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)