Components require additional python code/library

I’m having the same problem, I think i need to add this module: https://github.com/clach04/python-tuya to hass.io. I’m trying to use tuya devices using this https://github.com/sean6541/tuya-homeassistant, but i’m not sure how to do this.

Any help would be appreciated.
Thanks,
Nathan

1 Like

When you switch to hassbian, how much of configuration did you managed to preserve?

if you have z-wave device, do you have to remove all nodes in z-wave network first?

I think hass.io is, along with home assistant cloud, how home assistant making their money in the future. Nothing wrong with that per se, just that the reason why i am using home assistant is precisely because its flexibility and control over convenience. Hass.io represents the worse of both world: i no longer have all the control over the underlying platform, while the GUI and other configuration is still very painful to get it right.

All I did was copy all my config files, build a new Hassbian system and restore all the config files. I didn’t have much going on to begin with, just a few lights, switches and an alarm component, so everything came right up. Your mileage may very.

1 Like

Same here, just copied over my .config file. I had a few yaml errors, just stuff that changed with newer versions of HA. Getting it up and going was a breeze especially with the addons.

I just dont know how to get a python module added :face_with_raised_eyebrow:

For hassio, you might be able to just copy the folder for python-tuya into the same directory as your custom component for tuya-homeassistant, i.e.
- custom_components
| - switch
| - | - tuya.py
| - | - pytuya
| - | - | - __init__.py
That might be enough for the tuya component to find the pytuya library.

For hassbian: pip install python-tuya

1 Like

I’ll give that a try, I didn’t think about that.

Thanks for your help, but that didnt work. :frowning_face:

Try also changing this line from

import pytuya

to

from . import pytuya

I was able to import a local test module I made from a custom component that way.

Edit: Worked to import pytuya as well. I was actually able to create a switch with the tuya custom component. Of course, I get an error when I try to turn it on/off because I don’t actually have a device to control, but at least it doesn’t fail trying to use the module.

1 Like

Thanks for the suggestion! Here is my modified version of tuya.py
image

but i get the following error

I think maybe i have formatting wrong?
I also have pytuya init.py copied to your suggested folder

  • custom_components
    | - switch
    | - | - tuya.py
    | - | - pytuya
    | - | - | - init.py

Thanks agan

Yeah, just a formatting error. The code is indented with spaces and your editor likely inserted a tab. Just replace any tabs it added with spaces and it should be good.

1 Like

Specify the package name and version inside the custom component - see https://home-assistant.io/developers/component_deps_and_reqs/

1 Like

Thanks you.
I’ll take a look at both suggestions later tonight.

The custom component already has

REQUIREMENTS = ['pytuya==5.0']

But it obviously doesn’t install it automatically. Is there something special needed to get it to install automatically on hassio?

I thing i got it installed?! but Im getting an error:

Is this the error you got without a switch connected?

Traceback (most recent call last): File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 201, in async_update_ha_state yield from self.async_device_update() File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 308, in async_device_update yield from self.hass.async_add_job(self.update) File "/usr/lib/python3.6/asyncio/futures.py", line 332, in __iter__ yield self # This tells Task to wait for completion. File "/usr/lib/python3.6/asyncio/tasks.py", line 250, in _wakeup future.result() File "/usr/lib/python3.6/asyncio/futures.py", line 245, in result raise self._exception File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/switch/tuya.py", line 79, in update self._state = status['dps'][self._switchid] KeyError: 1

Nope that’s different. Looks like it’s not getting the data it expects. I did notice that the custom component was updated to use a newer version of the pytuya library. So maybe try pulling down the 5.0 release of pytuya, get the updated custom component, make that tweak for the import and try again?

I added a tuya/smart life plug using the resource you mentioned and didn’t need to install the python-tuya module. Only problem I’m having is that hass.io doesn’t seem to be able to retrieve (or the plug isn’t reporting) the current on/off state so the toggle in hass doesn’t work. See my recent post. I’d be happy to help you out with the process I used if you haven’t got it going yet.

Yeah I till haven’t got it going, I still get the errors above. pytuya is getting installed, but i see the above error repeating in my log.

Thanks,
Nathan

Can’t help with the errors, but I will mention that I connected the device with and app called efamilyhome and pulled the device and local keys using tuya key grabber.

I haven’t gotten mine working yet but I did eliminate the KeyError. I needed to keep the “id: 1” line in the config. After that I was able to start up HassIO with no error, however, I still can’t get it to control my device. When I try to turn it on I get the following error…

2018-02-04 14:45:08 ERROR (MainThread) [homeassistant.core] Error executing service <ServiceCall switch.turn_on: entity_id=[‘switch.plug_213’]>
This is followed by a bunch of other stuff that I didn’t include here.

tuya is the reason I asked this question!