BHT-6000 Thermostat (tuya) support

If I try to install CLI TOOL with command sudo npm i @tuyapi/cli - g I have this error(on command line of raspberry)
(node:8042) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
npm ERR! git clone [email protected]:tuyapi/cli Clone nel repository spoglio ‘/home/pi/.npm/_git-remotes/git-github-com-tuyapi-cli-3083bead’…
npm ERR! git clone [email protected]:tuyapi/cli Permission denied (publickey).
npm ERR! git clone [email protected]:tuyapi/cli fatal: Could not read from remote repository.
npm ERR! git clone [email protected]:tuyapi/cli
npm ERR! git clone [email protected]:tuyapi/cli Please make sure you have the correct access rights
npm ERR! git clone [email protected]:tuyapi/cli and the repository exists.
npm ERR! addLocal Could not install tuyapi/cli
npm ERR! Error: ENOENT: no such file or directory, stat ‘tuyapi/cli’
npm ERR! If you need help, you may report this entire log,
npm ERR! including the npm and node versions, at:
npm ERR! http://github.com/npm/npm/issues

npm ERR! System Linux 4.14.82-v7+
npm ERR! command “/usr/bin/node” “/usr/bin/npm” “i” “@tuyapi/cli” “-g”
npm ERR! cwd /home/pi
npm ERR! node -v v8.11.1
npm ERR! npm -v 1.4.21
npm ERR! path tuyapi/cli
npm ERR! syscall stat
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/pi/npm-debug.log
npm ERR! not ok code 0
pi@hdjweb:~ $
pi@hdjweb:~ $ sudo npm i @tuyapi/cli -g
(node:8060) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
npm ERR! git clone [email protected]:tuyapi/cli Clone nel repository spoglio ‘/root/.npm/_git-remotes/git-github-com-tuyapi-cli-3083bead’…
npm ERR! git clone [email protected]:tuyapi/cli Permission denied (publickey).
npm ERR! git clone [email protected]:tuyapi/cli fatal: Could not read from remote repository.
npm ERR! git clone [email protected]:tuyapi/cli
npm ERR! git clone [email protected]:tuyapi/cli Please make sure you have the correct access rights
npm ERR! git clone [email protected]:tuyapi/cli and the repository exists.
npm ERR! addLocal Could not install tuyapi/cli
npm ERR! Error: ENOENT: no such file or directory, stat ‘tuyapi/cli’
npm ERR! If you need help, you may report this entire log,
npm ERR! including the npm and node versions, at:
npm ERR! http://github.com/npm/npm/issues

npm ERR! System Linux 4.14.82-v7+
npm ERR! command “/usr/bin/node” “/usr/bin/npm” “i” “@tuyapi/cli” “-g”
npm ERR! cwd /home/pi
npm ERR! node -v v8.11.1
npm ERR! npm -v 1.4.21
npm ERR! path tuyapi/cli
npm ERR! syscall stat
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/pi/npm-debug.log
npm ERR! not ok code 0
How can I solve?

Retry the same command,
i’ve made now two tries, first failed like yours, second goes well

first update node

sudo npm cache clean -f

sudo npm install -g n

sudo n stable

It is 5 times the same error
Sudo npm cache clean

(node:8883) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
bash: errore di sintassi vicino al token non atteso “[DEP0022]”

with node --version what you get?
With v11.6.0 I didn’t get any error

Otherwise:

git clone https://github.com/TuyaAPI/cli.git
cd cli 

try run

node cli.js list-app

if you get an error about missing module

npm install <module name>

if you get an error about anyproxy install anyproxy and run it, as in the instruction

ps: node cli.js list-app is the equivalent to tuya-cli list-app

Node version 8.11.1

ok now i have all but i cannot see on home assistant so also in google local tuya climate. why??
i put localtuya.py in folder you say but i cannot understand. i cannot see entity climate. please help me
climate:
- platform: localtuya
host: deviceIp
local_key: ‘localKey’
device_id: ‘deviceId’
name: ‘name’
scan_interval: 20

In hass log do you see something about localtuya?

ok i have solved but it will be a mistake in update 3. Because if you replace with:

def status(self):
“”“Get state of Tuya switch and cache the results.”""
self._lock.acquire()
try:
now = time()
_LOGGER.debug(“UPDATING status”)
#if not self._cached_status or now - self._cached_status_time > 30:
self._cached_status = self.__get_status()
self._cached_status_time = time()
return self._cached_status
finally:
self._lock.release()
component doesn’t go
and if you see in original file there is not this line:
_LOGGER.debug(“UPDATING status”)

please check because i had problem whe i replaced as you wrote

  1. _LOGGER.debug(“UPDATING status”) is a log write (debug level) to check if the updates starts when scan interval triggers it

  2. the code works in my environment. As writed in first post, those are mod for test purpouse, not to be intended for plug&play

  3. when posting code format it correctly with indentation. How can I see if something is wrong?

  4. check the log and see if there’s something about

  5. explain what’s the problem. “doesn’t go” what? enitity is not showed? temperature is not updated? I don’t have a crystal ball

No I have solved all and I update every 5 second without changing nothing… I hope only that tuya will update for climate as other thermostat with Google home.

With default tuya support google home works only for voice commands. Exposing the hass entitty to google (I’ve tried without cloud) enables also the Google Home App. Remember that the workaround for tuya.py are also applicable to localtuya.py (expecially the way a status off/heat is reported).

If Your previous issues are related at uncomprensible explanation on first post or difficulty you have found, please add some details, that can be usefull at all

temperature set doesn’t work

2019-01-27 17:50:29 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/service.py", line 289, in _handle_service_platform_call await func(entity, data) File "/usr/local/lib/python3.6/site-packages/homeassistant/components/climate/__init__.py", line 574, in async_service_temperature_set await entity.async_set_temperature(**kwargs) File "/config/custom_components/climate/localtuya.py", line 204, in async_set_temperature self._device.set_status(temperature, '2') File "/config/custom_components/climate/localtuya.py", line 111, in set_status return self._device.set_status(state, switchid) File "/config/deps/lib/python3.6/site-packages/pytuya/__init__.py", line 302, in set_status data = self._send_receive(payload) File "/config/deps/lib/python3.6/site-packages/pytuya/__init__.py", line 171, in _send_receive data = s.recv(1024) socket.timeout: timed out

Actually I’m using the latest uploaded localtuya.py without any issues (for now).

As seen in another post, yout thermostat is a BHT-002-GBLW and not a BHT-6000.
Probably the device dps are different and the code must be modified accordingly.
(If the set_temperature dps is different probably you can’t also see the set_temperature value in hass)

To get the list of all available dps make this simple script

import pytuya

d = pytuya.OutletDevice('<dev-id>','<dev-ip>', '<local-key>')
data = d.status()  # NOTE this does NOT require a valid key
print('Dictionary %r' % data)

Then modify the localtuya.py accordingly:

In the code all is done by interfacing directly with the dps:
so all the set command have that pattern: self._device.set_status( '1' , '4') where ‘1’ is the value to be set and ‘4’ the corresponding dps

The readings (all in status) are managed like this:

self._target_temperature = float(status['dps']['2']) /2
self._current_temperature = float(status['dps']['3']) /2
self._state = status['dps']['1']

Explanation: [‘dps’] is the dps data from the status matrix (pytuya handles the same data you get with the previous script), [‘1’] or ['2] or [‘3’] are the single dps from data. /2 is a correction because my device transmits temperature doubled (so can handle .5 resolution with integer data)

As seen till now all data is handled as number or true/false,
Example: temperature at ‘30’ in my device is 15°, Mode Auto is ‘1’ and Manual ‘0’, screen on/off is true/false

Hi where can I find the switch that command the start and stop of my boiler in home assistant? I think that I put 20© on thermostat. It read temperature if it is more of 20 stop boiler with a switch. If it is minus of 20 start boiler. Where I can find that switch, in home assistant?

@itmax86
Encountered same error, it happens (rarely, one time till now) when set-temperature is triggered when the read-status is already running. Now I’m trying this workaround:

async def async_set_temperature(self, **kwargs):
    while True:
       try:
           self._lock.acquire()
           temperature = int(float(kwargs[ATTR_TEMPERATURE])*2)
           _LOGGER.debug("Set Temperature: " + str(temperature))
           if ATTR_TEMPERATURE in kwargs:
               self._device.set_status(temperature, '2')
               sleep(1)
           self._lock.release()
       except:
           _LOGGER.warning("Set Temperature Retry")
           continue
       break

@hdjweb1
There is no way to control directly the relay, it’s done by the thermostat and not by homeassistant. If you want to trigger the device as on/off use home assistant automation or appdaemon. to turn on, set any temp over the ambient temp, and to turn off any temperature below.

Someone have migrated localtuya custom component to home assistant 0.88???

I’m on 0.86.4, by 0.88 changelog I didn’t see anything that can be related on how localtuya works, but i have to try it. What doesn’t work or what error do you get?

i have not tryed but i see thaht i must put in a folder but i don’t know what change

In 0.88 still works without modification, only a warning message is displayed. Anyway referring to https://developers.home-assistant.io/blog/
the localtuya.py must be renamed to climate.py
and placed in /custom_components/localtuya/ folder (that folder must be created)
then an empty files named __init__.py must be placed in the same above folder