DeConz integration fail: "No module named 'pydeconz'"

I installed Home Assistant on Raspbian following the instructions on the web page. I then installed the marthoc/deconz Docker image. I can successfully connect to the Phoscon app, and go to Settings/Gateway/Advanced/Authenticate App. However, when I go to the HomeAssistant DeCONZ integration configurator, and click on “Configure”, nothing happens. Looking at syslog, I see the following error:

Oct 13 18:16:17 raspberrypi hass[1522]: INFO:homeassistant.core:Bus:Handling <Event system_log_event[L]: timestamp=1602612977.7396617, message=Error handling request, source=components/deconz/__init__.py, level=ERROR, exception=Traceback (most recent call last):
Oct 13 18:16:17 raspberrypi hass[1522]:   File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/aiohttp/web_protocol.py", line 381, in start
Oct 13 18:16:17 raspberrypi hass[1522]:     resp = await self._request_handler(request)
Oct 13 18:16:17 raspberrypi hass[1522]:   File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/aiohttp/web_app.py", line 322, in _handle
Oct 13 18:16:17 raspberrypi hass[1522]:     resp = await handler(request)
Oct 13 18:16:17 raspberrypi hass[1522]:   File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/aiohttp/web_middlewares.py", line 88, in impl
Oct 13 18:16:17 raspberrypi hass[1522]:     return await handler(request)
Oct 13 18:16:17 raspberrypi hass[1522]:   File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/homeassistant/components/http/static.py", line 68, in staticresource_middleware
Oct 13 18:16:17 raspberrypi hass[1522]:     return await handler(request)
Oct 13 18:16:17 raspberrypi hass[1522]:   File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/homeassistant/components/http/real_ip.py", line 27, in real_ip_middleware
Oct 13 18:16:17 raspberrypi hass[1522]:     return await handler(request)
Oct 13 18:16:17 raspberrypi hass[1522]:   File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/homeassistant/components/http/ban.py", line 68, in ban_middleware
Oct 13 18:16:17 raspberrypi hass[1522]:     return await handler(request)
Oct 13 18:16:17 raspberrypi hass[1522]:   File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/homeassistant/components/http/auth.py", line 28, in auth_middleware
Oct 13 18:16:17 raspberrypi hass[1522]:     return await handler(request)
Oct 13 18:16:17 raspberrypi hass[1522]:   File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/homeassistant/components/http/view.py", line 104, in handle
Oct 13 18:16:17 raspberrypi hass[1522]:     result = await result
Oct 13 18:16:17 raspberrypi hass[1522]:   File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/homeassistant/components/http/data_validator.py", line 47, in wrapper
Oct 13 18:16:17 raspberrypi hass[1522]:     result = await method(view, request, *args, **kwargs)
Oct 13 18:16:17 raspberrypi hass[1522]:   File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/homeassistant/components/config/config_entries.py", line 110, in post
Oct 13 18:16:17 raspberrypi hass[1522]:     data['domain'])
Oct 13 18:16:17 raspberrypi hass[1522]:   File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/homeassistant/config_entries.py", line 405, in async_init
Oct 13 18:16:17 raspberrypi hass[1522]:     return await self._async_handle_step(flow, step, data)
Oct 13 18:16:17 raspberrypi hass[1522]:   File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/homeassistant/config_entries.py", line 437, in _async_handle_step
Oct 13 18:16:17 raspberrypi hass[1522]:     result = await getattr(flow, method)(user_input)
Oct 13 18:16:17 raspberrypi hass[1522]:   File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/homeassistant/components/deconz/__init__.py", line 206, in async_step_init
Oct 13 18:16:17 raspberrypi hass[1522]:     from pydeconz.utils import async_discovery
Oct 13 18:16:17 raspberrypi hass[1522]: ImportError: No module named 'pydeconz'

I then installed pydeconz using pip3 install pydeconz, which made no difference. I saw that pydeconz was installed in /usr/local/lib/python3.7/site-packages/pydeconz, whereas Home Assistant was looking for it in /srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/pydeconz. I created a symlink from /srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/pydeconz to /usr/local/lib/python3.7/site-packages/pydeconz, but Python then reported a syntax error in syslog. So now I am stumped. Any advice would be appreciated. Thank you.

Which instructions did you follow and how long ago was this? What version of Home Assistant are you running?

The info page on my installation says Home Assistant 0.67.1. At a guess, I first installed it about a year ago and followed the instructions on the home-assistant.io web site, but I am not 100% certain. However, I know what the install procedure was: after installing Raspbian, I ran:

wget http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key
apt-key add mosquitto-repo.gpg.key
apt-get update
apt-get upgrade
pip3 install --upgrade pip
apt-get dist-upgrade
apt-get install python3-yaml
wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tgz
tar xzvf Python-3.7.3.tgz
cd Python-3.7.3/
./configure
make install
python3 -V
python3 -m pip install --upgrade pip
pip3 install --upgrade homeassistant
curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh
usermod -aG docker homeassistant
usermod -aG dialout homeassistant
mkdir /opt/deconz
chmod 777 /opt/deconz
su homeassistant
docker pull marthoc/deconz@sha256:aee666c930955d7563c0db586e6c4b9730f86b8121075e1969027a59f3c1908f
docker run -d --name=deconz --net=host --restart=always -v /etc/localtime:/etc/localtime:ro -v /opt/deconz:/root/.local/share/dresden-elektronik/deCONZ --device=/dev/ttyACM0 marthoc/deconz@sha256:aee666c930955d7563c0db586e6c4b9730f86b8121075e1969027a59f3c1908f


Etc.

You need to update your install. Do you have a lot of things setup? If not it’s probably best to start over with a fresh install.
Also why do you run home assistant in a venv, but deconz in a docker container? Are you using the Pi for other stuff as well or only Hone Assistant?

Thanks. I thought I did that - I ran pip3 install --upgrade homeassistant. Does that not upgrade to the latest version? Reinstalling from scratch unfortunately is not an option. I am trialing the system to run a house, so there has to be a way for me to add integrations (and/or update the live system to the latest version of Home Assistant if it’s necessary for that purpose) without breaking an existing install and without having to reinstall, which is live and runs things like lights, hot water and the hearing system, and has to continue running without anything but the briefest of interruptions, or I can’t use it.

I am running custom software on the Pi which uses the sensor data collected by the Home Assistant Recorder in complex ways currently to display information, but the hope is it will drive actuators based on those decisions. Again, it is a complex install and config and reinstalling in order to upgrade the Home Assistant is not an option.

I’m running deconz in a Docker container because … I had already installed the Home Assistant on bare metal Raspberry Pi and used Z-Wave hardware which was not working well enough to deploy, so I bought some Zigbee hardware, bought the ConBee II stick because it was recommended by the Home Assistant, then found at the time I could not get it to work at all, because configuration was too difficult, so I gave up on the Home Assistant and parked the whole project. I recently found out about the marthoc/deconz container and tried to use it, but now can’t get that to work either.

If you set up hass inside of a virtual env you have to go into the venv before you can update hass. Docker is easier to manage so I also suggest you move over to that over virtual env, since you’re not too familiar with linux it seems and you will have to manually update python in your venv every once in a while.

You are right, I have only been using Linux for a few decades and Unix-like operating systems for 40 years, so I haven’t had much time to become very familiar with them yet, but I’m looking to fix my current setup, not move anything to another environment or reinstall anything. As I say, I need to be convinced that once I’ve deployed the system, I will be able to update/upgrade and maintain it live, and not have to reinstall and migrate to a different environment all the time, otherwise this is not the system for me and I’ll have to look at other options. Thanks.

You can certainly update the venv to the newest version, but you’ll need to work through every update (around 50 updates) and read the breaking changes and adapt your system. That’s what you get when you don’t keep beta software updated.
Robban and I only wanted to give you an advice that it’s easier and less time consuming to start from scratch. And you may have a lot of experience with Linux, but it seems not soo much with Python. Therefore a docker install might be a better fit for you, especially when you are running docker anyways for deconz (I don’t underatand why you don’t install deconz directly on the Pi and instead add the docker “overhead” just for deconz).

If you run 0.67 you most certainly have a too old python version (probably 3.4/3.5) anyway, so you’re gonna need to upgrade python along as you bump hass version. You would not need to bother with that compatibility running in docker.

I have never used Python. My installed Python version is 3.7.3.

I did initially install Deconz directly from Phoscon, but it didn’t work. I was following instructions on the home-assistant.io web site which recommended installing it in Docker. Since I had no Docker experience either and the process looked too complicated, I gave up. The fact that Home Assistant was recommending hardware (ConBee II) which I then bought but turned out to be too complicated to actually deploy was one of the reasons I decided at the time that HomeAssistant was not yet for me.

As I said, I am evaluating HomeAssistant as a deployment option and some of my constraints are that (i) I must be able to use it, (ii) I must be able to upgrade and maintain a live system once deployed, without having to reinstall everything any time I need to change something e.g. in order to add new hardware (iii) I am not interested in this becoming my full time job - although I have other computer experience, when it comes to Home Assistant, I am, and wish only to remain, a mere end user. I need to satisfy myself I can deploy within these constraints, otherwise the system is not for me.

I evaluated it a year ago and concluded that it was not yet ready for me to use. I am trying again now, prompted by the fact that the marthoc/deconz image is now available. If you have any suggestions as to how to get my system to work with the ConBee II (it does not need to be the latest version, it just needs to work), I would be grateful. I may also give up again, because it all does not look ready for use by end users like me yet.

Thanks.

pip3 install --upgrade homeassistant says:

Requirement already up-to-date: homeassistant in /usr/local/lib/python3.7/site-packages (0.116.2)

So 0.116.2 appears already to be installed, but the Home Assistant web server is showing 0.67.1.

Yes, because you’re not updating in the proper place, look up how you update packages in virtual environment

Take a look here on how to upgrade home assistant in a venv.

Thanks for the suggestion.

I don’t want to mess up my existing setup, so I made a fresh new installation in a venv as per these instructions but in a new virtual machine (VirtualBox, Linux host, Linux(Debian x86_64) guest) rather than overwriting my Raspberry Pi installation. I have version 0.116.2 running. But when I try to add the Z-Wave integration, it fails with homeassistant.requirements.RequirementsNotFound: Requirements for zwave not found: ['homeassistant-pyozw=0.1.10']. I’m using an Aeotec Gen5 Z-Stick in the VM as opposed to a Razberry board on the Pi.

I then tried python3 -m pip install homeassistant-pyozw and that failed with a ton of errors.

So it looks like I can’t get the new version to work at all, I’m glad I did not try to overwrite my existing installation, as badly as that works.

When you are not so familiar with pyton and venvs, why did you again use a venv install for the fresh install and not one of the more user friendly installs like home assistant Container or Home Assistant Supervised, here’s an excellent overview of the available install methods. With the other install types you don’t need to worry about dependencies this will be handled automatically by docker.

Did you execute this inside the venv? I don’t think you should need to add this anyway, this should be already included.

I haven’t use a venv install of HA for a long time. I don’t like to tag people, and I hope @Tinkerer will forgive me. But he uses a venv and was always helpful in regards to venv questions here on the forum.

1 Like

Yeah, HA should auto-install almost everything. There’s some exceptions, but that’s not one of them.

However, Python 3.7.3 is about to be unsupported, time to move to 3.8.6 :wink:

Honestly then, Docker (aka Home Assistant Container) is 100% the way you want to go. It removes the need for you to worry about things like this, or Python versions, or many other things that running in a venv brings.

Or, if you’re using VMs, consider Home Assistant OS. That moves the dial even further over, though it does remove some of your ability to “fiddle” under the hood - but it sounds like you don’t want to do that anyway.

1 Like

Is there way to get either my original installation, or the new virtual machine installation I just installed using venv to work well enough so I can evaluate it? I.e. at this stage, is there a way for me to either get pyozw to work in 0.116.2, or to get deconz to work in 0.67.1? Presumably at least the former must be possible, since 0.116.2 is the latest version. I used Python 3.8.6, not 3.7.3, to do the venv install. I used venv because this was recommended by Burningstone. It may be that homeassistant-pyozw should already be installed, but it doesn’t seem to be.

At this point, I am just evaluating which option (HomeAssistant, OpenHAB, etc.) to spend more time on and then deploy to run parts of a house and then spend more effort becoming familiar with and eventually run the whole house, if it proves stable enough. I just spent many hours installing 0.116.2 and it’s not a good investment of my time to keep installing more and more new versions, only to find out that each new version I install breaks in a different way which can’t be fixed. Is there a way to fix the venv installation so it works with pyozw? If it’s too difficult even to get HomeAssistant to work with my Zigbee and Z-Wave controllers, it’s probably not ready for prime time yet.

Thanks for all your advice.

Docker based install, or Home Assistant OS based install. That removes any issues with your Python build or venv.

You unfortunately used the second most complicated/advanced install method. If you’d gone with something simpler you’d be up and running by now :man_shrugging:

I’ve been running Z-Wave with HA since about 0.32, and Zigbee for over a year now, no issues with either :wink:

The recommendation is for you to use one of the easier installs which in it self will leave you with less issues regarding future upgrading.

Deconz was introduced with 0.61 but it was handled in a different way back then, so the integration documentation does not reflect the way it used to be working, so you’d have to delve into the GitHub history of the documentation to find the corresponding version.

Sorry, I apparently did not phrase my question clearly enough. I tried to fix my original install. I was advised to do a new install using vdev on this forum, which I did. Is there a way to fix either of those installs? I’m not interested in doing yet another install. I’ve got enough on my hands installing OpenHAB as well and then comparing the two solutions. Thanks.