WiFi thermostat discussion #139
Replies: 12 comments 40 replies
-
Brilliant work on this @uzlonewolf ! Thanks for posting this for the community. I would like to add this to the end of the Tuya Data Points - DPS Table section the list the basic DPS values you identified with a link to the detailed breakdown you posted above. Would you want to submit a pull request for that? Thanks again! Great research and very helpful. And I love "unobtanium". ❤️ |
Beta Was this translation helpful? Give feedback.
-
Done, #141 . What are your thoughts on adding classes for this? There are enough quirks with setting temperatures and modes that I think it would be helpful, and managing the sensor data list without parsing it into a class would be difficult. |
Beta Was this translation helpful? Give feedback.
-
Initial code committed to my fork. Only handles sensors at the moment, there's a lot left to do. https://github.com/uzlonewolf/tinytuya/blob/thermostat/tinytuya/ThermostatDevice.py |
Beta Was this translation helpful? Give feedback.
-
Finally got around to looking at the schedule. Was pretty easy to decode, though I'm not sure if I care enough to add a class for it. It's Bas64 encoded and in DPS 118. A packet looks something like In the above I have: The first day (Sunday) has Wake set to "cool to 80" but is otherwise the same. After Base64 decoding and wrapping at 70 chars (35 bytes) you get:
Despite there being 4 schedule slots per day, there are actually 5 in the data block. Wrapping every 14 chars (7 bytes) gives:
Where: |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Another day, another quirk discovered. It turns out that even if the schedule is completely disabled, it is still followed to control how sensor averaging is done. During the 'Sleep' period, the occupancy detectors are ignored and all enabled sensors are averaged. |
Beta Was this translation helpful? Give feedback.
-
I got a homenex wi-fi thermostat from Amazon - seems to be the same device. It also reports a DPS 101 - anyone knows what that may be? |
Beta Was this translation helpful? Give feedback.
-
And some more quirks. As of right now I cannot recommend using these thermostats with a heat pump. A traditional furnace + A/C system is fine, however with heat pumps it de-energizes the O/B wire much too quickly thereby causing the reversing valve to cycle under pressure every time it satisfies. This might actually be fine, however I am concerned with excessive/premature reversing valve wear. I plan on talking with the manufacturer about this to see if they will change this behavior, but I have not gotten around to it yet. The other quirk is it really, really does not like receiving setpoint and system mode changes too close to each other. If you set them both in the same packet or separate but back-to-back packets, it will tell you the setpoint has been updated but will not actually use the updated setpoint. I've had to change my code so it sends the new setpoint, receives until it gets a timeout, and then sends the system mode update. Fun times. |
Beta Was this translation helpful? Give feedback.
-
They just pushed a firmware update, the main MCU firmware was updated from 1.5.6 to 1.5.7. The message just said "bug fixes." So far the only change I have noticed is with the sensor data - the "temp" field is now in 0.5 degree increments to match the setpoints and the first 2 bytes of the "unk3" field is the full-resolution (0.01 degree) temperature. |
Beta Was this translation helpful? Give feedback.
-
Hi! I bought also WiFi thermostat for electrical floor heating (TGR85WII-EP, Beok) and it looks like it has different DPS. Here are my findings Device status: {'dps': I haven't checked any broadcast traffic, but this is just for sharing information. |
Beta Was this translation helpful? Give feedback.
-
Any idea where I can buy the PIR323-915 ? |
Beta Was this translation helpful? Give feedback.
-
I would be happy with one. Of course I will pay for it. I have got the pct513, but the pir323 now fails to pair. It blinks slowly, after pressing reset it blinks a few seconds fast and then again blinks slowly. It does no longer pair with the pct513. |
Beta Was this translation helpful? Give feedback.
-
I recently picked up a WiFi thermostat off Amazon, the "Wi-Fi Smart Color Thermostat, 7 Day Programmable and 4 Modes, Touch Screen Home Thermostat with Zone Remote Sensor, Smart Thermostat Compatible with Alexa and Google Assistant, 2.4GHz" by MoesHouse (ASIN B09WV347GJ). It seems to be a rebranded PCT513-TY. Searching Tuya's developer portal for both the product ID as well as the category code brings up a DPS list which isn't even close to what this thing is using. I was able to reverse engineer almost every DPS it uses however.
Some of these DPS' are returned on poll request while others are only broadcasted periodically.
'2': 'cool', # system mode [ auto cool heat off ]
'16': 2100, # setpoint C
'17': 70, # setpoint F
'23': 'f', # display units (C or F)
'24': 2050, # cur temp C
'29': 69, # cur temp F
'34': 64, # cur humidity
'45': 0, # fault flags
'107': '4', # system type: 0 = cool only, 2 = heat only, 4 = cool&heat or heatpump, 5 = heatpump with aux/emergency heat
'108': 2100, # cool setpoint C
'109': 1650, # heat setpoint C
'110': 70, # cool setpoint F
'111': 62, # heat setpoint F
'115': 'auto', # fan mode [ auto cycle on ]
'116': '1',
'118': [base64 blob], # schedule
'119': False, # schedule enabled
'120': 'permhold', # [ permhold temphold followschedule ]
'121': [base64 blob], # vacation data
'122': [base64 blob], # sensor data
'123': 25, # minimum fan run time
125-128: [base64 blob] # number of sensors
'129': 'alloff' # system state [ fanon coolfanon alloff ]
107 and 116 have not changed for me and I have no idea what they mean. Inspecting the network traffic in the developer portal says 107 is 温控系统类型 (Goog translate: "Type of temperature control system"); my system type is a 1-stage heatpump. 116 says 在家/离家 ("at home/away from home"); I have never seen this change from a "1". Of the 7 base64 binary blobs, I have not even looked at
118 or121 (edit: 118 discussed in a post below). 125-128 base64-decode to a single byte which matches the number of sensors installed (0x01 = base only, 0x02 = base plus a remote sensor). 122 is the sensor data packet and is broadcast approx. once every 62 seconds if something has changed, otherwise it is not broadcast. The 62-second timer is per sensor, so if you have multiple sensors you will get multiple broadcasts, however even though the broadcast includes data for every sensor only the data for 1 sensor will have changed. The developer portal says 122 is 外部温度传感器信息列表1 ("External temperature sensor information list 1") and 125-128 are 外部温度传感器信息列表2 ("External temperature sensor information list 2") - 外部温度传感器信息列表5 ("External temperature sensor information list 5").122 Broadcasts when I first installed the system without any remote sensors installed:
After installing a remote sensor:
That 'AQ==' decodes to 0x01 and 'Ag==' is 0x02 so I suspect they are some sort of sensor count for something. Changing the Wake/Away/Home/Sleep sensor participation flags does not change them at all.
Base64-decoding the data and displaying it as hex results in
0200005ED6000000000000000000000000000000004D7920446576696365206E616D65010108C3010F00010001000000000000000052030383000000000000000000000000000053656E736F725F35323033303338330001010959010046010A000000000000000000
That very first 02 is the number of sensors installed in the system. The rest breaks down as:
Where "Sens.ID#" is the sensor ID number
"NUL-padded name" is the human-readable name displayed in the app
en - Enabled flag, 0 = Disabled, 1 = Enabled
oc - Occupied flag, 0 = Unoccupied, 1 = Occupied
temp - Temperature in degrees C multiplied by 100 (0x08C3 = 2243 = 22.43°C)
on - Online, 0 = sensor offline, 1 = sensor online. A sensor is marked offline if it hasn't been heard from in approx. 4 minutes
pa - Wake/Away/Home/Sleep Participation bitmask. 1 = Wake, 2 = Away, 4 = Home, 8 = Sleep
ba - Battery %. 0x63 = 99 = 99%, 0x46 = 70 = 70%
u2 - Unknown # 2, I have no idea what this is
fw - Firmware Version, 01 = V0.1
av - Sensor is participating in temperature averaging. 0 = not participating (either Participation bit for the current mode is 0 or it is marked Unoccupied), 1 = participating in the average (Participation bit for the current mode is 1 and it is marked Occupied)
u3 - Unknown # 3, I have no idea what this is
I'm not sure what "u2" is for. One possibility could be update rate: 0x0A = 10 = every 1.0 minutes. Not sure how I'll be able to test that though.
The name field is a bit interesting. Originally the name for sensor # 1 was left-justified, but after changing it in the app it became right-justified. Sensor # 2 was initially almost right-justified (there was a single NUL after it) but changing it in the app made it completely right-justified.
The remote sensor is a PIR323-915 temperature+occupancy sensor. My research leads me to believe it is Zigbee in the 915MHz band. I would like to add more to see what it does, however Zigbee temperature sensors in the 915MHz band seem to be unobtanium.
Edit: through the magic of buying 2 complete sets, I have acquired a 2nd remote sensor. It simply tacked it onto the end of DPS 122 and changed the first byte of 122 and 125-128 from a 2 to a 3.
Assuming it simply keeps adding them like this, it can hold 15 sensors in a 1500-byte packet. My guess is after 15 (or some lower number) it would then start putting them into the next DPS.It turns out the sensor lists for lists 2-5 are slightly different than I expected. When there are no sensors in the list, the list contains a single byte which matches the total number of sensors. When the list does contain sensors then that first byte is removed and the list contains nothing but the sensor data. Each list contains a maximum of 4 sensors (so list 1 has a max of 209 bytes while lists 2-5 have a max of 208 bytes).Beta Was this translation helpful? Give feedback.
All reactions