make-all / tuya-local

Local support for Tuya devices in Home Assistant
MIT License
1.12k stars 456 forks source link

Showing up as a switch - TR9B Thermostat with external sensor #103

Closed miannelli516 closed 2 years ago

miannelli516 commented 2 years ago

Hello, i've been trying for the past 2 months to get my thermostat to work in Home Assistant. No matter what i try, i can get these thermostats i purchased to work. I was however able to get it to work with the built in Tuya integration however, the temperature was showing 10-20 times the amount in Home Assistant. I came across this integration which looks extremely promising however, when i try to add the device, its only allowing me to add it as a "Simple_Switch" (see attached screen shot). below is the information i was able to pull using tinytuya. Can someone please point me in the right direction as to how i can resolve this? Any assistant anyone can provide is extremely apricated!!

Thanks Mike

"name": "Master Bath Radiant", "ip": "192.168.XX.XX", "ver": "3.3", "id": "XXXXXXXXXXXXXXXXXXXXX", "key": "XXXXXXXXXXXXXX Untitled ", "dps": { "dps": { "1": true, "2": "manual", "10": false, "16": 700, "19": 990, "23": "f", "24": 708, "26": 410, "31": "5_2", "36": "open", "40": false, "45": 0, "101": 1313, "102": 10

miannelli516 commented 2 years ago

Hello i was also able to pull this information from tinytuya. not sure if this helps?

"active_time": 1636757671, "biz_type": 0, "category": "wk", "create_time": 1636757671, "icon": "smart/icon/ay1547209623516pqlXf/010b3328b726f7547fbdba8d74f192fb.png", "id": "XXXXXXXXXXXXX", "ip": "172.58.227.111", "lat": "40.8074", "local_key": "XXXXXXXXXXXXXXXX", "lon": "-73.3344", "model": "", "name": "Master Bath Radiant ", "online": true, "owner_id": "XXXXXXXX", "product_id": "7qx0q329p61h1ace", "product_name": "Floor Heating", "status": [ { "code": "switch", "value": true }, { "code": "mode", "value": "manual" }, { "code": "frost", "value": false }, { "code": "temp_set", "value": 700 }, { "code": "upper_temp", "value": 990 }, { "code": "temp_unit_convert", "value": "f" }, { "code": "temp_current", "value": 704 }, { "code": "lower_temp", "value": 410 }, { "code": "work_days", "value": "5_2" }, { "code": "valve_state", "value": "open" }, { "code": "child_lock", "value": false }, { "code": "fault", "value": 0 } ], "sub": false, "time_zone": "-05:00", "uid": "XXXXXXXXXXXXXXX", "update_time": 1640645794, "uuid": "XXXXXXXXXXXXXX2"

miannelli516 commented 2 years ago

This is the error im getting in HA's logs:

This error originated from a custom integration.

Logger: custom_components.tuya_local.config_flow Source: custom_components/tuya_local/config_flow.py:73 Integration: Tuya Local (documentation, issues) First occurred: 2:38:34 PM (1 occurrences) Last logged: 2:38:34 PM

Device matches simple_switch with quality of 7%. DPS: {'1': True, '2': 'manual', '10': True, '16': 590, '19': 990, '23': 'f', '24': 666, '26': 410, '31': '5_2', '36': 'close', '40': False, '45': 0, '101': 1313, '102': 10, 'updated_at': 1640979513.9095514}

miannelli516 commented 2 years ago

Hi i found these in the debug logs. not sure if this is helpful

Thanks! Mike

STANDARD STATUS SET

Code | Type | Values -- | -- | -- switch | Boolean | "{true,false}" mode | Enum | { "range": [ "auto", "manual" ] } frost | Boolean | "{true,false}" temp_set | Integer | { "unit": "℃", "min": 50, "max": 10000, "scale": 1, "step": 5 } upper_temp | Integer | { "unit": "", "min": 50, "max": 10000, "scale": 1, "step": 10 } temp_unit_convert | Enum | { "range": [ "c", "f" ] } temp_current | Integer | { "unit": "℃", "min": -300, "max": 10000, "scale": 1, "step": 1 } lower_temp | Integer | { "unit": "", "min": 50, "max": 10000, "scale": 1, "step": 10 } work_days | Enum | { "range": [ "5_2", "6_1", "7" ] } valve_state | Enum | { "range": [ "close", "open" ] } child_lock | Boolean | "{true,false}" fault | Bitmap | {}

STANDARD INSTRUCTION SET

Code | Type | Values -- | -- | -- switch | Boolean | "{true,false}" mode | Enum | { "range": [ "auto", "manual" ] } frost | Boolean | "{true,false}" temp_set | Integer | { "unit": "℃", "min": 50, "max": 10000, "scale": 1, "step": 5 } upper_temp | Integer | { "unit": "", "min": 50, "max": 10000, "scale": 1, "step": 10 } temp_unit_convert | Enum | { "range": [ "c", "f" ] } lower_temp | Integer | { "unit": "", "min": 50, "max": 10000, "scale": 1, "step": 10 } work_days | Enum | { "range": [ "5_2", "6_1", "7" ] } child_lock | Boolean | "{true,false}"
make-all commented 2 years ago

Yes, that is very useful, thanks. Do you have a brand and/or product name/code that can be used to identify this thermostat? Better still, a link to the manual, even if only in another language. The command set seems completely different than other BHT-002 thermostats, so I have my doubts (I suspect some small manufacturer selling through aliexpress, using that name for marketing without actually being compatible, at least at the protocol level - maybe the electrical interface is compatible).

miannelli516 commented 2 years ago

Tuya Thermostat Program Instructions.pdf

Hello, attached is the manual that came with the device does this help? Does it mean that this device cannot be integrated?

make-all commented 2 years ago

Thanks, the manual helps with identifying the device. The model number TR9B appears at the bottom of the last page, and a search finds Beok TR9B and some other brands that all appear to match the pictures in the manual.

miannelli516 commented 2 years ago

IT WORKS PERFECTLY!!!! YOU ARE THE BEST!!! THANK YOU SO MUCH!!! you have no idea how long i have been trying to get this to work!!! THANK YOU SOOOOO MUCH FOR THE QUICK REPONSE!!!!

miannelli516 commented 2 years ago

Hi I noticed one small bug. if I accidently set the temperature to xx.5 it causes the device in HA to change to unavailable state. a minute or two later it goes back to available state with the temperature set either one degree higher or lower in HA however on the thermostat itself, its always exactly 1 degree lower. not a big detail at all! I figured id let you know. for the most part its working perfectly! and i never need to set the temperature .5 at a time. I always use 1 degree at a time. here are some logs I pulled from HA...hopefully they help

Thanks Mike image

Traceback (most recent call last): File "/config/custom_components/localtuya/common.py", line 145, in _make_connection self._interface = await pytuya.connect( File "/config/customcomponents/localtuya/pytuya/init.py", line 669, in connect , protocol = await loop.create_connection( File "/usr/local/lib/python3.9/asyncio/base_events.py", line 1056, in create_connection raise exceptions[0] File "/usr/local/lib/python3.9/asyncio/base_events.py", line 1041, in create_connection sock = await self._connect_sock( File "/usr/local/lib/python3.9/asyncio/base_events.py", line 955, in _connect_sock await self.sock_connect(sock, address) File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 502, in sock_connect return await fut File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 537, in _sock_connect_cb raise OSError(err, f'Connect call failed {address}') OSError: [Errno 113] Connect call failed ('192.168.16.58', 6668) 2022-01-03 18:57:02 ERROR (MainThread) [custom_components.localtuya.common] [eb7...f17] Connect to 192.168.16.33 failed Traceback (most recent call last): File "/config/custom_components/localtuya/common.py", line 145, in _make_connection self._interface = await pytuya.connect( File "/config/customcomponents/localtuya/pytuya/init.py", line 669, in connect , protocol = await loop.create_connection( File "/usr/local/lib/python3.9/asyncio/base_events.py", line 1056, in create_connection raise exceptions[0] File "/usr/local/lib/python3.9/asyncio/base_events.py", line 1041, in create_connection sock = await self._connect_sock( File "/usr/local/lib/python3.9/asyncio/base_events.py", line 955, in _connect_sock await self.sock_connect(sock, address) File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 502, in sock_connect return await fut File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 537, in _sock_connect_cb raise OSError(err, f'Connect call failed {address}') OSError: [Errno 113] Connect call failed ('192.168.16.33', 6668) 2022-01-03 18:57:02 ERROR (MainThread) [custom_components.localtuya.common] [eb1...ksu] Connect to 192.168.16.19 failed Traceback (most recent call last): File "/config/custom_components/localtuya/common.py", line 145, in _make_connection self._interface = await pytuya.connect( File "/config/customcomponents/localtuya/pytuya/init.py", line 669, in connect , protocol = await loop.create_connection( File "/usr/local/lib/python3.9/asyncio/base_events.py", line 1056, in create_connection raise exceptions[0] File "/usr/local/lib/python3.9/asyncio/base_events.py", line 1041, in create_connection sock = await self._connect_sock( File "/usr/local/lib/python3.9/asyncio/base_events.py", line 955, in _connect_sock await self.sock_connect(sock, address) File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 502, in sock_connect return await fut File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 537, in _sock_connect_cb raise OSError(err, f'Connect call failed {address}') OSError: [Errno 113] Connect call failed ('192.168.16.19', 6668) 2022-01-03 18:57:02 ERROR (MainThread) [custom_components.localtuya.common] [eb6...goe] Connect to 192.168.16.35 failed Traceback (most recent call last): File "/config/custom_components/localtuya/common.py", line 145, in _make_connection self._interface = await pytuya.connect( File "/config/customcomponents/localtuya/pytuya/init.py", line 669, in connect , protocol = await loop.create_connection( File "/usr/local/lib/python3.9/asyncio/base_events.py", line 1056, in create_connection raise exceptions[0] File "/usr/local/lib/python3.9/asyncio/base_events.py", line 1041, in create_connection sock = await self._connect_sock( File "/usr/local/lib/python3.9/asyncio/base_events.py", line 955, in _connect_sock await self.sock_connect(sock, address) File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 502, in sock_connect return await fut File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 537, in _sock_connect_cb raise OSError(err, f'Connect call failed {address}') OSError: [Errno 113] Connect call failed ('192.168.16.35', 6668)

make-all commented 2 years ago

You seem to have localtuya configured for the same device. It may be competing for control. According to the device info, it should be settable in 0.5 increments, but if localtuya cannot handle that, it may be "correcting" the adjustments made by tuya-local behind the scenes.

miannelli516 commented 2 years ago

ahh that makes sense. yes that was the old integration that never worked! ill remove it now and see how it goes. As always, thank you for the prompt response!!

miannelli516 commented 2 years ago

i just checked and i don't see the same device being used via another integration in home assistant... i just tried adding a brand new Tuya device using your local tuya integration and the same thing happens. not sure what other integration could be competing for control.... is their anyway i can set the increments to 1

make-all commented 2 years ago

I see your temperature graph is in Fahrenheit. It is quite common for devices to be only adjustable by half degrees in C. I can make that change.

miannelli516 commented 2 years ago

that would be awesome thank you!!!

miannelli516 commented 2 years ago

Hello i noticed you made the code change so that the temp increments using increments of 1. In order for the new code change to apply in my HA environment, besides copying all of the updated files you posted into the custom_components\tuya_local and restarting HA, is their anything else i need to do for the new code change to apply?

make-all commented 2 years ago

If you restart HA after copying the new versions of the files (or if you installed via HACS, you can select "Redownload" from the menu on the tuya-local panel in HACS, and select "main" as the version to install), then it will pick up the new versions of those files.