make-all / tuya-local

Local support for Tuya devices in Home Assistant
MIT License
1.32k stars 516 forks source link

Add support for Beca BAC-002-ALW #84

Closed shakin89 closed 2 years ago

shakin89 commented 2 years ago

Hi, first of all thank you for this fantastic integration! If there is a way i can help to support this new device let me know how i can help.

I've bought a brand new Beca Smart BAC-002-ALW

I've been able to obtain the key and add it to local tuya, but the thermostat is not recognized. The log reports this

2021-11-27 10:35:06 WARNING (MainThread) [custom_components.tuya_local.config_flow] Device matches arlec_fan with quality of 62%. DPS: {'1': True, '2': 44, '3': 41, '4': '1', '5': False, '6': False, '102': '1', '103': '2', 'updated_at': 1638005704.286728} 2021-11-27 10:40:17 WARNING (MainThread) [custom_components.tuya_local.config_flow] Device matches arlec_fan with quality of 62%. DPS: {'1': True, '2': 44, '3': 43, '4': '1', '5': False, '6': False, '102': '1', '103': '2', 'updated_at': 1638006015.372264} 2021-11-27 10:41:33 WARNING (MainThread) [custom_components.tuya_local.config_flow] Device matches arlec_fan with quality of 62%. DPS: {'1': True, '2': 44, '3': 43, '4': '1', '5': False, '6': False, '102': '1', '103': '2', 'updated_at': 1638006090.981737}

the DPS is { '1': true, '2': 39, '3': 45, '4': '1', '5': false, '6': false, '102': '1', '103': '2' }

the mapped sensor states:

1: powered 'true'/'false' -> sting 2: target temperature -> int 3: actual temperature -> int 4: manual mode / program mode 0=program, 1= manual 5: eco mode: 'true'/'false' -> sting 6: lock mode 'true'/'false' -> sting 102: operation '0'=cool, '1'=heat, '2'=fan (string) 103: fan speed '0'=auto, '1'=high, '2'=med, '3'=low (string)

vampywiz17 commented 2 years ago

@shakin89

You able to control it via tuya-cli?

I think it need a bit modification this config and it is enought. Today i try to make a test yaml file.

https://github.com/make-all/tuya-local/blob/main/custom_components/tuya_local/devices/beca_bht002_thermostat_c.yaml

vampywiz17 commented 2 years ago

@shakin89 you able to answer me that what type of 102 and 103? integer maybe...

vampywiz17 commented 2 years ago

@shakin89 it is a rough test. Please try it!

https://pastebin.com/4nNedWTG

shakin89 commented 2 years ago

@vampywiz17 thank for your reply. Searching on the repo i was landed on the same file and was trying to figure out how to modify it.

  1. while trying to control it via tuya-cli i get this error tuya-cli set --id xxx --key xxx --dps 3 --set 50 Error [ERR_UNHANDLED_ERROR]: Unhandled error. ('Timeout waiting for status response from device id: acxm') at TuyaDevice.emit (events.js:303:17) at /usr/local/lib/node_modules/@tuyapi/cli/node_modules/tuyapi/index.js:369:12 at Timeout._onTimeout (/usr/local/lib/node_modules/@tuyapi/cli/node_modules/p-timeout/index.js:25:13) at listOnTimeout (internal/timers.js:554:17) at processTimers (internal/timers.js:497:7) { code: 'ERR_UNHANDLED_ERROR', context: 'Timeout waiting for status response from device id: ..acxm'
  2. 102 and 103 are integer
  3. thanks i will try it.

Am i doing something wrong with tuya-cli command?

vampywiz17 commented 2 years ago

@shakin89 to use tuya-cli you need the device IP address.

shakin89 commented 2 years ago

no luck at all even with the ip address... does it mean it's not compatible? tuya-cli set --ip 192.168.1.81 --set 50 --dps 3 --key xx --id ...acxm Error [ERR_UNHANDLED_ERROR]: Unhandled error. ('Timeout waiting for status response from device id: ...acxm')

P.S. the ip address is assigned statically with the dhcp server from the router

vampywiz17 commented 2 years ago

With get command, it work?

shakin89 commented 2 years ago

yes, with the get command i've obtained all the values posted above. I changed them from the app and read them from tuya-cli get command.

well, actually it works the tuya-cli get command specifing id and key, but w hen i specify the ip address it returns "parse data error"

shakin89 commented 2 years ago

@vampywiz17 firts of all thank you for your support. i've tried setting some parameters and this is the debug output. it "seems" to work imho.

DEBUG= tuya-cli set --id bacxm --ip 192.168.1.81 --key xxx --protocol-version 3.3 --dps 3 --set 60 TuyAPI IP and ID are already both resolved. +0ms TuyAPI Connecting to 192.168.1.81... +10ms TuyAPI Socket connected. +54ms TuyAPI SET Payload: +3ms TuyAPI { TuyAPI devId: 'bacxm', TuyAPI gwId: 'bacxm', TuyAPI uid: '', TuyAPI t: 1638026870, TuyAPI dps: { '3': 60 } TuyAPI } +0ms TuyAPI Received data: 000055aa00000001000000070000000c00000000a505a9140000aa55 +115ms TuyAPI Parsed: +3ms TuyAPI { payload: false, leftover: false, commandByte: 7, sequenceN: 1 } +0ms TuyAPI Got SET ack. +2ms Error [ERR_UNHANDLED_ERROR]: Unhandled error. ('Timeout waiting for status response from device id: b*acxm')

vampywiz17 commented 2 years ago

The id is good? Check it in tuya app! Yesterday the tuya-cli show wrong id to me... I get same error, if I use set command. The get worked...(strange)

try tinytuya!

Other people also affect this problem:

https://github.com/jasonacox/tinytuya/issues/83

make-all commented 2 years ago

@shakin89 you able to answer me that what type of 102 and 103? integer maybe...

It looks like they are strings. Usually this means they are a selection between a fixed list of values (which are given in the original request under mapped sensor states). The quotes around them are probably important to get the device to accept the values when setting (there is some logic to send integers in quotes when they are being received from the device in quotes, but I am not sure whether that works when there are mappings since mappings are designed to map between types).

shakin89 commented 2 years ago

hi @make-all and @vampywiz17 and thank you for your patience and great work. sorry for the late reply. i've had a too busy weekend. i have edited the DPS value reported in the first post, i had switched dps 2 with 3, that's why i couldn't set anything.

UPDATE from tuya cli i'm able to send command to the thermostat. sorry, it was the first time i used tuya-cli and had no knowledge about its commands and how i functions. till now i can set: (in order of "DPS" value)

  1. switch on/off sending 'true'/'false'
  2. set target temperature
  3. read actual temperature
  4. set manual/program mode using string and passing --raw-value to tuya-cli
  5. set eco mode sending string 'true'/'false'
  6. set lock mode sending string 'true'/'false'
  7. set values of cool/heat/fan using string and passing --raw-value to tuya-cli
  8. s et values of fan speed using string and passing --raw-value to tuyacli

with this i think the thermostat is completely usable from tuya-local. tomorrow i will reflect the values reported above in the yaml given from vampiz and will report here what happens Thanks in advance.

shakin89 commented 2 years ago

Hi all, added bac-002-alw.yaml in custom components/tuya-local/devices. The device works partially. Probably i don't know how to set properly the yaml config file. I can set the heat mode, but not screenshot 2 From HA i can turn on/off the display and the thermostat, i can select only heat mode. I have no fan or cool. do i have to change the lovelace card or is a configuration problem?

i have no option to select dps 102 and 103, can you suggest me a way to do it? Thanks in advance

vampywiz17 commented 2 years ago

@shakin89

Please make a screenshot on device page in HA

Are you use my config or that make-all added it? (make-all config is better i think)

ID 102 is hidden, i think it not possible to map in HA. (it only help the better identification) and it mirrored to ID 1 (that able to show the correct installation type, but it is read only param.)

I think it is similar reason: https://github.com/make-all/tuya-local#siswell-c19-thermostat-gotchas

103 maybe only show when you set different mode.

make-all commented 2 years ago

Fan speed is not part of the main climate card in HA, you need to either click the menu button at top right, or add some separate buttons to control it. Or you might be able to find a custom card that contains those controls.

In the config installed in 0.13.4, the dps 102 selection is available as a separate select control. I did it this way because I assumed this was a configuration option that you set to match what is connected to the thermostat, but you don't change during normal operation, so you don't want all the options appearing on the climate card. If I have misunderstood and the thermostat is designed to control a full function heatpump, then the configuration may need to be different.

shakin89 commented 2 years ago

well, this evening i have played a little bit with the configuration. Now the config attached is fully functional. I've read the docs of tuya local for the device configuration, and i hope i've done all correctly. Pherhaps the yaml can be written better.

@make-all as you can see, in this thermostat (that has no external sensor) the dps 102 is the hvac_mode. dps 4 you had mapped as hvac, is a switch between manual mode, and programmed mode (only from the app, sadly the time table is not exposed via tuya-cli). Only a last question: is there a way to adjust the temperature sensor readings? i.e. real room temp is 24, the thermostat reads 25.5. Thanks for all your work.

screenshot 4

screenshot 5

beca_bac002_thermostat_c.yaml.txt

shakin89 commented 2 years ago

Hi @make-all, installed and everithing working except temperature and current_temperature are inverted. Plese invert dps 2 with dps 3 in beca_bac002_thermostat_c.yaml I've done it manually in my yaml, but for everyone else it would be inverted. That's all very thank you for your work

zigul commented 2 years ago

@shakin89 I have same problem

shakin89 commented 2 years ago

@shakin89 I have same problem

in the mean time you can solve this way. go to /config/custom_components/tuya_local/devices and search for file beca_bac002_thermostat_c.yaml Edit it and replace this

  - id: 2
      type: integer
      name: current_temperature
      mapping:
        - scale: 2
    - id: 3
      type: integer
      name: temperature
      unit: C
      range:
        min: 10
        max: 70
      mapping:
        - scale: 2

with this

    - id: 2
      type: integer
      name: temperature
      unit: C
      range:
        min: 10
        max: 70
      mapping:
        - scale: 2
    - id: 3
      type: integer
      name: current_temperature
      mapping:
        - scale: 2

it'll work like a charm

make-all commented 2 years ago

Sorry, I didn't notice you'd edited the original request, and interpretted the later comments about them being reversed as reinforcing the original request where they were reversed compared to other BACS branded thermostats.

I have made the change now, which is available for testing if you select "main" from the reinstall menu on the integration.

shakin89 commented 2 years ago

@make-all don't worry, not a big issue! 😃 Thanks for the change