Closed charlietomo closed 4 years ago
Hmm, that's unfortunate. Especially considering HA is going all-in with Hass.io with release of HassOS. I'm not using Hass.io yet (I have a manual installation) but I'm planning on moving soon so I'll need it as well.
I'm keen on getting this into HA core, so hopefully that's the solution. I need to investigate the contribution requirements and how specs are written for other components and then make a PR. First though, I want to explore some more options that may change the structure - I'd rather settle on the structure before I raise a PR.
3 may be an option if you could modify the Hass.io environment after you've installed it?
pytuya
is also pure python, so they may very well be open to adding it to the core list of requirements. Tuya smart devices are pretty prevalent and I'm sure they'll find other uses for it in the future.
I am exploring if I can change the hass.io environment. Will keep this updated as I am no expert in HA, unix, or python - so you may be able to point out where I am making simple mistakes...
Progress!
Following this thread I tried the following.
Downloaded pytuya (7.0) on my desktop and uploaded to /config/custom_components/pytuya/__init__.py
and then in /config/custom_components/climate/goldair_heater.py
changed line 213 from import pytuya
to import custom_components.pytuya as pytuya
Then when I clear my log and reboot I see a climate component for my configured heater :-)
Log says Failed to update device state.
and the heater is unavailable, but after a short (<1min) time it pops up as configured.
However I cannot control the heater - anything I try results in Failed to update device state.
. I'm using a GPPH610 heater and hope I'm just making a "silly" mistake somewhere.
Getting pytuya to the core list of requirements sounds a great option because it took a bunch of reading and trial and error in order to get to the above (and I'm still not working!).
Hiya! I was considering playing around with the method you've tried, but wasn't confident enough with Python imports to really know what to do.
On a similar note, looks like someone has had success with pip on a Docker installation here, maybe it will work for you as well?
With regards to device compatibility, I test this on the GPPH630 and GPPH730; the only difference between the GPPH630 and your GPPH610 should be the wattage, so you should be fine once we figure out how to get the integration running.
I don't think I can do a Pip install on Hass.io :-(
Have you seen that the very recent Home Assistant release (0.74) has support for Tuya? Although this looks very different i.e. a logon to a cloud service - which isn't what I am after.
With my above setup I was getting status of heater but not able to control. I have just seen you released a new version and I have tried that (including the configuration changes, and removing my old manual pytuya file), but now get a different error, which I am unsure how to troubleshoot further.
Unexpected status() payload=b'json obj data unvalid'
However it does look like pytuya is now included in hass.io deps/lib/python3.6/site-packages/pytuya/__init__.py (ERROR)
(although I'm not sure what version).
Additionally a couple of bits I can't work out:
I will keep experimenting but any advice appreciated.
Yeah, I saw that a generic Tuya component was in the latest release. However like you say, it's for cloud switches and lights, whereas the Goldair heaters are not cloud-enabled and need a different library.
Interesting that you found pytuya
in hass.io - can you point me to the GitHub repository?
The most puzzling thing is that you're getting the status but you're unable to make any changes. That almost sounds like a credentials issue than a connection issue, because I've read that you can get the heater's status without the key but can't update it.
Like you say it does get turned off when you start HA, which is interesting. Is that an automation you've written? Because mine stay on when I restart HA, and only turn off when I specifically tell them to.
If you like I could take a look at your device id and local key to see if they look correct - if you're on Twitter you could tweet me @nikrolls
and I'll follow you so you can DM me.
I haven't found any reference to pytuya
in hass.io except before (0.73.x) I got an error (re pytuya
) when trying to load your code, unless I manually added it to the custom_components as outlined above.
With 0.74 I have totally replaced the custom_components folder, with no manually added pytuya
, and it doesn't give me errors and the reference shown above (deps/lib/python3.6/site-packages/pytuya/__init__.py
) looks like it is within the main system, not a hack done by me.
I agree my issue sounds like a credential issue and I think it must have been something at my end. I have two heaters and I have just unplugged one and checked all the settings for the other, and it now seems to work! I could turn the heater on and off using your code, so that is great progress. I will try with the other heater later.
I have no automations written and was having an issue with the heaters turning off - which I could only put down to me playing with HA and this code.
I will do some further testing but things are looking good.
As a improvement can you tweak the error message below? I think this is because I have one heater that is unplugged, so it can't get the state. It would be useful to have the device name in the title of the error message, and then it would be obvious which device is causing the issue!
Failed to refresh device state.
xx:xx custom_components/goldair_heater.py (ERROR)
Ah, I see - the reference to deps/lib/python3.6/site-packages/pytuya/__init__.py
may be where it's looking for the file, not necessarily where it is. I'm not very familiar with this part of Python though, being new to it myself.
Glad you got one working! Great idea about the logging. That's left over from the first version where the name was only on the HA side, and the logging was done in a device-specific class. Now I have the name in the device-specific class as well (so it can be shared across platforms) and I could absolutely add that and some extra information to the logging. I'll do that shortly!
Sounds good re the logging.
I'm no Python expert, but I removed the files I previously added, so I understood it to be a "standard" Hass.io installation before I added your code. For me the only real way to check would be to delve into hass.io (which I am not sure where to look) or to start from a new, stock hass.io install.
Next step for me will be to see if I can get it to play nicely with the homekit part of HA so I can control it from iOS Home app.
Just a quick update. Turns out I did have the wrong credentials for one of my heaters, which was likely the source of an error posted earlier.
I'm still running Hassio and have just upgraded to 0.75.1
and both my heaters are working great with your code (I'm just using the control, haven't tried display or child lock features).
Look forward to you submitting as an official part of Home Assistant :)
Great to hear! I'll update this issue with my progress as I make it.
If you need any more testing or help of a non-coding variety just let us know @nikrolls happy to help if I can.
Closing this as there has been no activity and many updates since. Installation via HACS works on Hass.io without any issues. If there is still an issue, please open a new ticket. Thanks!
First of all this looks great and I'm excited about getting my Goldair heaters linked into Home Assistant.
I run Home Assistant via Hass.io and have followed your instructions to get setup, however get the below error which from googling looks like it will be because hass.io doesn't support custom components with dependencies :-(
Looks like the relevant code from
goldair_heater.py
isREQUIREMENTS = ['pytuya==7.0']
Trying to think through my options:
pytuya
on my hass.io setup manually.pytuya
gets included in Hass.ioAny thoughts or other ideas?