milo526 / homebridge-tuya-web

Hoobs and Homebridge plugin for Tuya devices using Home Assistant Tuya Web Api
MIT License
218 stars 93 forks source link

Climate/Thermostat not working #442

Closed binfe closed 2 years ago

binfe commented 2 years ago

Describe the bug

I installed the latest version of the plugin. The zigbee based switch works fine (as in, being able to show correct state, and toggle correctly), but the wifi based thermostat device is always showing Not Responding in Home app and therefore I can't control it.

Not sure what else is needed to debug. But please let me know if anything. Thank you!

Steps To Reproduce

  1. Installed the homebridge-tuya-web plugin in homebridge and restart homebridge service.
  2. See the Air Conditioner device showing up in Home app, but always in 'Not Responding' state.

Plugin Version

v1.1.2

Homebridge Config

 {
     "name": "TuyaWebPlatform",
     "options": {
         "username": REDACTED,
         "password": REDACTED,
         "countryCode": REDACTED,
         "platform": "smart_life",
         "pollingInterval": 600
     },
     "defaults": [],
     "scenes": false,
     "platform": "TuyaWebPlatform"
 }

Device Config

Getting credentials
Got credentials
{   'access_token': REDACTED,
    'expires_in': 864000,
    'refresh_token': REDACTED,
    'token_type': 'bearer'}
Getting devices
Got devices
{   'header': {'code': 'SUCCESS', 'payloadVersion': 1},
    'payload': {   'devices': [   {   'data': {   'online': True,
                                                  'state': 'false'},
                                      'dev_type': 'climate',
                                      'ha_type': 'climate',
                                      'icon': 'https://images.tuyaeu.com/smart/product_icon2/wk_1.png',
                                      'id': 'bfce7c77e0ccee29dbbvwl',
                                      'name': 'Air Conditioner'},
                                  {   'data': {'online': True, 'state': False},
                                      'dev_type': 'switch',
                                      'ha_type': 'switch',
                                      'icon': 'https://images.tuyaeu.com/smart/solution/331001/4772fad51dca8c64_cover.png',
                                      'id': 'bf3c90074bf5c437c3rsit',
                                      'name': 'Fan Switch'},
],
                   'scenes': []}}
!!! NOW REMOVE THIS FILE, SO YOUR CREDENTIALS (username, password) WON'T LEAK !!!

Additional Context

I can control the Air Conditioner device perfectly fine in the Smart Life app. I've also tried to follow the https://github.com/milo526/homebridge-tuya-web#thermostatclimate section to add explicit settings for the air conditioner, but it didn't help.

binfe commented 2 years ago

FWIW, there is one thing I found suspicious, which is that the climate device has the state in the device config payload in plain string like 'state': 'false', as opposed to boolean like the rest.

milo526 commented 2 years ago

Is there any information in the logs when you start homebridge/hoobs regarding this device?
Everything seems like it should work 🤔

binfe commented 2 years ago

@milo526 unfortunately no log at all, as if it was working fine.

Lately I tried to dig into it, and found that it may be because of the missing dps for current temperature from the thermostat. So I tried to modify the file accessories/characteristics/currentTemperature.js file's public getRemoteValue(callback: CharacteristicGetCallback) method to return a fixed value (e.g. 15), that got it out of the always not responding state.

Also, I tried to play with the tuya-cli command to figure out what's supported by this thermostat, and these are all the dps and their values supported (which correspond to Smart Life app's interface):

 - On/off (dps index '1'): true, false
 - Mode (dps index '2'): 'cold', 'hot', 'wind', 'dry'
 - Target Temp (dps index '16'): [numerical, e.g. 23.0]
 - Level (fan speed, dps index '28'): 'auto', 'low', 'middle', 'high'
 - Child Lock (dps index '40'): true, false
 - Program (dps index '58'): 'manual', 'program'

for example, the tuya-cli command output for this device is like:

$ tuya-cli get --ip {ip_addr} --id {tuya_id} --key {tuya_key} --full --protocol-version 3.3

{
    "1": false,
    "2": "hot",
    "16": 22,
    "28": "middle",
    "40": false,
    "58": "manual",
}
binfe commented 2 years ago

I'm wondering if it's possible to combine this thermostat and another temperature sensor device in the same tuya account to have a full function thermostat (that shows current temp)? 🤔

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.