Try delete all files in “_pycache” folder.
I’ve reinstalled my Homeassistant, now I’m getting another error.
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 178, in _async_setup_platform
await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for
return fut.result()
File "/config/custom_components/localtuya/climate.py", line 91, in async_setup_platform
protocol_version
File "/config/custom_components/localtuya/climate.py", line 159, in __init__
status = self._device.status()
File "/config/custom_components/localtuya/climate.py", line 132, in status
self._cached_status = self.__get_status()
File "/config/custom_components/localtuya/climate.py", line 112, in __get_status
status = self._device.status()
File "/config/custom_components/localtuya/pytuya/__init__.py", line 279, in status
payload = self.generate_payload('status')
File "/config/custom_components/localtuya/pytuya/__init__.py", line 219, in generate_payload
json_payload = self.cipher.encrypt(json_payload, False)
File "/config/custom_components/localtuya/pytuya/__init__.py", line 64, in encrypt
cipher = AES.new(self.key, mode=AES.MODE_ECB)
File "/usr/local/lib/python3.7/site-packages/Crypto/Cipher/AES.py", line 232, in new
return _create_cipher(sys.modules[__name__], key, mode, *args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/Crypto/Cipher/__init__.py", line 79, in _create_cipher
return modes[mode](factory, **kwargs)
File "/usr/local/lib/python3.7/site-packages/Crypto/Cipher/_mode_ecb.py", line 215, in _create_ecb_cipher
cipher_state = factory._create_base_cipher(kwargs)
File "/usr/local/lib/python3.7/site-packages/Crypto/Cipher/AES.py", line 93, in _create_base_cipher
raise ValueError("Incorrect AES key length (%d bytes)" % len(key))
ValueError: Incorrect AES key length (20 bytes)
Nevermind, I have switched local key
and device id
, it’s all working properly now, thanks for your help
Hi, I’m trying to start your thermostat with local control. Unfortunately, this ends with an error
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 178, in _async_setup_platform
await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for
return fut.result()
File "/config/custom_components/localtuya/climate.py", line 91, in async_setup_platform
protocol_version
File "/config/custom_components/localtuya/climate.py", line 159, in __init__
status = self._device.status()
File "/config/custom_components/localtuya/climate.py", line 132, in status
self._cached_status = self.__get_status()
File "/config/custom_components/localtuya/climate.py", line 112, in __get_status
status = self._device.status()
File "/config/custom_components/localtuya/pytuya/__init__.py", line 307, in status
result = cipher.decrypt(result, False)
File "/config/custom_components/localtuya/pytuya/__init__.py", line 87, in decrypt
raw = cipher.decrypt(enc)
File "/usr/local/lib/python3.7/site-packages/Crypto/Cipher/_mode_ecb.py", line 195, in decrypt
raise ValueError("Data must be aligned to block boundary in ECB mode")
ValueError: Data must be aligned to block boundary in ECB mode
Can you help me?
I have the same error: Platform error climate.localtuya - Integration ‘localtuya’ not found.
- platform: localtuya
host: 192.168.0.130
local_key: 'mykey'
device_id: 'myid'
name: 'moes'
scan_interval: 5
min_temp: 5
max_temp: 35
protocol_version: 3.3
I have downloaded localtuya from github.
Hey Guys!
If you want perfect HASS integration with yout BHT-002 use my open source firmware replacement: https://github.com/fashberg/WThermostatBeca
Including home assistant auto-discovery.
Kind Regards
Folke
I am wondering about external sensor is it possible to monitor in HA both temperatures.
I read in manual that only one sensor can be used to control relay by thermostat.
Hey Mario1,
i have an explanation for this:
Section: External Temperature Sensor
Short: In AL Mode my firmware reports both values (in other modes the MCU module does not report two temperatures to ESP-Module).
Internal Sensor controls temperature, external controls overheating protection.
Tipp: Long press to most right button for 5 seconds (while device switched on) shows external temperature in thermostate.
Kind Regards
Folke
Did you add auto discovery for alw heat cool fan_only already?
Hi fashberg,
Many thanks for pointng me to your GitHub project. I not catch that at the beginning. I read about external sensor so now it is clear for me about reporting. Today I have ordered my first BHT-002-GCLW to handle water heating in my room, after test I will buy 14 of them.
I’ve choose that one because I always can put netutral to dry connect to handle standard NC Actuator Valve but still I could handle low voltage relay.
In you github manual I not see option to set external sensor temperature to control overheating. Could you tell me how it is handled?
In my use case I see different best usage of external sensor. It will be nice to have control to minimum value of floor temperature. If it is belowe of set value than relay should be on to heat floor. What do you think about it?
Thanks
Hi Mario,
i have 8 BHT-002-GALW. They have two relais, not potential free.
The first relay gives contact to “L” if the valve should open, the other one gives contact to “L” if the valve should close; i don’t use the second one.
See that image: https://github.com/fashberg/WThermostatBeca/blob/405351e9a7d23e2132ea8358fa76349f02210d5d/docs/install-003.jpg
You can also use GCLW with dry contact. In my case i would had to bridge L to the input of dry contact with GC version, so i’ve ordered GA. You hear click/clack every mode-change, with GC you only have one click.
Regarding the temperature sensors:
In my readme.md you can read:
Hardware
The Hardware itself has two Microcontrollers:
- The MCU, the Main Controlling Unit.
- It controls Temperature, Display, the Relay, Scheduling, has RTC, etc.
- The software on the MCU gets not upgraded with WThermostat, so no changes here.
- The ESP8266-based Tuya-Wifi-Module.
- WThermostat replaces the Software on this ESP-Module
- There is a serial connection between MCU and ESP. Via this connection the we can control the MCU
- Only the Wifi-Verisons of thermostats have the ESP-Module.
This means reading the temperature and controlling the relay is inside the MCU.
The ESP chip (which runs my firmware) can’t neither control the relay, nor can it read it’s current status!
So my software knows the current temperature (internal sensor (IN-Mode) or external sensor (OU-Mode) or both in AL mode), knows also the target temperature, know current mode (off/manual/schedule) and knows date/time and schedule.
But my software/the ESP-Chip does not know if the relay has turned on the heating (state not provided by MCU). But there is a hardware hack: you can solder two resistors to an GPIO pin of ESP chip and then you can see the current heating state. But we can’t control!
I have never soldered anything to my 8 thermostates (flashed with tuya-convert).
External Sensor
Check out the BHT-002 manual https://github.com/fashberg/WThermostatBeca/blob/405351e9a7d23e2132ea8358fa76349f02210d5d/docs/BHT-002-Manual.pdf
Read section 6. System settings , Code 4 and Code 9.
I think that Code 9 (Overheat Protection) is controlled by External Sensor if Code 4 is set to AL.
If you need a minimum floor-temperature you can read the external sensor’s temperature in homeassistant and set the heating to manual ON and to manual temperature of 30 degrees (room temperature) to ensure the floor gets heated with an automation.
In theory this behaviour could also be programmed into my firmware (set target temperature to X if external temp is below Y).
I also have water floor heating with wood-floor. It takes 1.5 - 3 hours until you have an warm floor.
I don’t have floor temperature sensors (only one for testing). I want to have a warm floor in the bathrooms in the moring.
So i’m just using the scheduler to set target room temperature to 30 degrees at 5:30 in the morning and switch back to 20 degrees after two hours. Works great.
I start heating the living room by setting a very high target temperature in the late afternoon hours to have there a warm floor in the evening hours.
Because of the good heat-isolation of the house most the times the forced-heating periods are enough to have a comfortable temperature. So the time scheduling is the best advantage compared to the old bi-metal thermostates.
Maybe with external floor sensors you have better control depending on temperature, but the temperature reaction is so slow that i do not longer react most time to temperature changes but i act with scheduled heating periods depending on weekdays, weekends or vacation.
Kind Regards
Folke
Hi Folke,
Many thanks for detail explanation. Now I uderstand how it works and it is harder to add this feature to achieve minimum floor temperature directly to device because it is controlled by MCU. It is pitty that MCU not provide current status of heating and it needs hardware soldering. Do you have any instruction how to do it? It will be nice to have in HA information when heating occured.
Your suggestion is very good if mode = Auto and ext.sensor temperature < setFloorMinTemp then set target temperature 30. When min floor temp is achieved then switch back to previous target value. However now it seems to me that this feature should only be activated on manual mode therefore maybe only it should be controlled by HA where anyone can put as many conditions as he wants.
Scheduling probably is best way to achieve good rate economy to comfort temperature. I will wait until my unit come to me and try your local version and perform tests
Hi Folke,
I have recived today my first from 14.
It tooked to my 1h to flash with tuya-convert. To be able to use tuya-convert you need to enter thermostat to wifi blinking (turn off device and then press down arrow for at least 8s). I did not find that in your installation readme you could add it it will be easier for next person who would like to use your firmware.
Could you point me to some information how to make reporting current heating state. You wrote that it has to be connected some pins with resistior could you write me which one?
Best Regards
Mariusz
Hello,
Where will the following values be written?
an existing file or a new file to be created?
- platform: localtuya
host: 192.168.0.130
local_key: ‘mykey’
device_id: ‘myid’
name: ‘moes’
scan_interval: 5
min_temp: 5
max_temp: 35
protocol_version: 3.3
In your configuration yaml file climate section.
Hello Renat,
I have 7 thermostats, I have operated them with the homebridge with minimal problems (although there are some problems, of course). I could not control the thermostats in any way with homeeassistanta localtuya. I could only download tuya with adds-on and add it from there, of course, it doesn’t work like this.
How can I add tuyalan to my homeassitant? You can write starting from 0. what should I do?
Also, I need to control the thermostats on the homekit.
Hello
I have one of this thermostat, I have de local key and device_id
My thermostat is in the app Tuya
I put in HA the integration TUYA and see my thermostat , but with the temperature multiplicates X2
I put directory localtuya in custom_components and write in configuration.yaml this
But I think that the thermostat that I see in HA is other than the localtuya
What can I do for resolve it?
climate:
- platform: localtuya
host: 192.168.1.48
local_key: ‘mykey’
device_id: ‘myid’
name: ‘moes’
scan_interval: 5
min_temp: 5
max_temp: 35
protocol_version: 3.3
Does anyone have a solution for this? I’m stuck in the same point.
Tried to flash BHT-002 series 3, BHT-002GBLW Series 3/16A- with tuya-convert. Device did not appear with the intermediate firmware. Can someone please help me since many of you have done this.
smarthack-psk.log
https://justpaste.it/4qewo
I have done so many tasmotaising using TuyaConvert or Tasmotizer (UART). So if you are an experienced HAee in that area, I can confirm that you can get one of these BHT-002 devices converted in less than 5 mins using TuyaConvert (without soldering). Of course, the special thanks goes to @fashberg. Now the device is visible and available in HA, using a few Zigbee Temperature sensors I have got around the house, I have to put a logic in place to control the heating of the whole house in a smart way . If you know where I can start (e.g. a blueprint, or example etc) that would be much appreciated in advance.