make-all / tuya-local

Local support for Tuya devices in Home Assistant
MIT License
1.23k stars 490 forks source link

Request support for Pioneer WYT Diamante Mini-Split AC/Heat Pump #820

Closed backcountrymountains closed 1 year ago

backcountrymountains commented 1 year ago

This is just a mini-split type air conditioner/heat pump. I think it's very similar to the daizuki_heatpump.yaml that tuya-local suggested. But there are some settings that I'd like to add that I need help with: There are two bytes at DPid: 123 that seem to be a string of binary booleans. I don't think I'm saying that right but:

Display   Display off/Beep Off Display On/Beep Off Display off/Beep on Display On/Beep on
Display/Beep/Evap Clean? 123 0x0000 0x0008 0x0010 0x0018
 Binary for DPid 123 00000000 00001000 00010000 00011000

So Display on/off is in position 5 from the left: 01000. Beep on/off is position 6 from the left: 10000 and if they are both on it's: 11000

Looking at the devices/README.md it seems like this is a bitfield, but I don't see any info on how to deal with mapping the bitfield to switches to control the display or beeping of the air conditioner.

I have no idea what I'm doing.

Please help! Thanks!

Log Message

[custom_components.tuya_local.device] Test refreshed device state: {
    "devId": "75767832c45bbeda0fa3",
    "dps": {
        "1": true,
        "2": 720,
        "3": 23,
        "4": "cold",
        "5": "auto",
        "18": 0,
        "20": 0,
        "101": 0,
        "105": "off",
        "110": 2228796,
        "113": "0",
        "114": "1",
        "119": "0",
        "120": "off",
        "123": "0000",
        "125": "great",
        "126": "0",
        "127": "0",
        "128": "0",
        "129": "1",
        "130": 26,
        "131": false,
        "132": false,
        "133": "1",
        "134": "{\"t\":1686163210,\"s\":false,\"clr\":true}"
    }
}
2023 - 06 - 19 16: 50: 39.921 DEBUG(SyncWorker_6)[custom_components.tuya_local.device] new state(incl pending): {
    "updated_at": 1687215039.9212573,
    "1": true,
    "2": 720,
    "3": 23,
    "4": "cold",
    "5": "auto",
    "18": 0,
    "20": 0,
    "101": 0,
    "105": "off",
    "110": 2228796,
    "113": "0",
    "114": "1",
    "119": "0",
    "120": "off",
    "123": "0000",
    "125": "great",
    "126": "0",
    "127": "0",
    "128": "0",
    "129": "1",
    "130": 26,
    "131": false,
    "132": false,
    "133": "1",
    "134": "{\"t\":1686163210,\"s\":false,\"clr\":true}"
}

Information about DPS mappings

{
  "result": {
    "category": "kt",
    "functions": [
      {
        "code": "switch",
        "desc": "switch",
        "name": "switch",
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "temp_set",
        "desc": "temp set",
        "name": "temp set",
        "type": "Integer",
        "values": "{\"unit\":\"℃\",\"min\":160,\"max\":880,\"scale\":1,\"step\":5}"
      },
      {
        "code": "mode",
        "desc": "mode",
        "name": "mode",
        "type": "Enum",
        "values": "{\"range\":[\"cold\",\"hot\",\"wet\",\"wind\",\"auto\"]}"
      },
      {
        "code": "temp_set_f",
        "desc": "temp set f",
        "name": "temp set f",
        "type": "Integer",
        "values": "{\"unit\":\"℉\",\"min\":61,\"max\":88,\"scale\":0,\"step\":1}"
      }
    ]
  },
  "success": true,
  "t": 1687215255744,
  "tid": "3740b7f60ef411ee9d71220dd637f8d3"
}

{
  "result": {
    "category": "kt",
    "functions": [
      {
        "code": "switch",
        "desc": "{}",
        "name": "开关",
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "temp_set",
        "desc": "{\"unit\":\"℃\",\"min\":160,\"max\":880,\"scale\":1,\"step\":5}",
        "name": "设置温度",
        "type": "Integer",
        "values": "{\"unit\":\"℃\",\"min\":160,\"max\":880,\"scale\":1,\"step\":5}"
      },
      {
        "code": "mode",
        "desc": "{\"range\":[\"cold\",\"hot\",\"wet\",\"wind\",\"auto\"]}",
        "name": "工作模式",
        "type": "Enum",
        "values": "{\"range\":[\"cold\",\"hot\",\"wet\",\"wind\",\"auto\"]}"
      },
      {
        "code": "temp_set_f",
        "desc": "{\"unit\":\"℉\",\"min\":61,\"max\":88,\"scale\":0,\"step\":1}",
        "name": "设置华氏温度",
        "type": "Integer",
        "values": "{\"unit\":\"℉\",\"min\":61,\"max\":88,\"scale\":0,\"step\":1}"
      }
    ],
    "status": [
      {
        "code": "switch",
        "name": "开关",
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "temp_set",
        "name": "设置温度",
        "type": "Integer",
        "values": "{\"unit\":\"℃\",\"min\":160,\"max\":880,\"scale\":1,\"step\":5}"
      },
      {
        "code": "temp_current",
        "name": "当前温度",
        "type": "Integer",
        "values": "{\"unit\":\"℃\",\"min\":-20,\"max\":100,\"scale\":0,\"step\":1}"
      },
      {
        "code": "mode",
        "name": "工作模式",
        "type": "Enum",
        "values": "{\"range\":[\"cold\",\"hot\",\"wet\",\"wind\",\"auto\"]}"
      },
      {
        "code": "humidity_current",
        "name": "当前湿度",
        "type": "Integer",
        "values": "{\"unit\":\"%\",\"min\":0,\"max\":100,\"scale\":0,\"step\":1}"
      },
      {
        "code": "temp_set_f",
        "name": "设置华氏温度",
        "type": "Integer",
        "values": "{\"unit\":\"℉\",\"min\":61,\"max\":88,\"scale\":0,\"step\":1}"
      }
    ]
  },
  "success": true,
  "t": 1687215316527,
  "tid": "5b7e8e5f0ef411eebfceda94faf43880"
}

I went through iot.tuya.com and translated the Chinese words and added some description, just to get an idea:

DPid Modes
1' main power
2' set temp x10 in F
3' current temp in C
4' AC Mode
5' Fan Mode
18' Chinese: Humidity
20' Error Code
101' PM2.5
105' Sleep Mode
110' Identification Bits
113' Up/Down swinging Chinese: Sweep the wind up and down
114' left/right swinging Chinese: Sweep the wind left and right
115 Chinese: Electricity Integer
116 Chinese: Fractional number of batteries: Maybe some kind of power/btu proxy?
119' Eco Mode: Electricity management
120' Gen Mode
123' Display/Beep/Evaporator Clean? Chinese: Boolean type
125' Chinese: Air Quality
126' up/down flow: fixed. Chinese: Freeze frame up and down
127' side to side flow: fixed. Chinese: Freeze frame left and right
128' Chinese: Models?
129' Tuya IOT Says 129 is power/energy? comes back as 2kwh?
130' Chinese: constant temp?
131' Japanese: filter is dirty
132' Chinese: Hot wind/cool wind
133' Changes between 0,1,2,3. Chinese: Horizontal pendulum/vertical pendulum
134' Chinese: Running status time. Epoch time
135? Chinese: Elapsed Time

Product ID

Listen, I keep getting "permission deny" so something is not working with IoT tuya connecting to my device.

Information about how the device functions

Just a mini-split

make-all commented 1 year ago

There is a mask attribute to help with pulling individual values from a bitfield. But so far it has only been used in read-only sensors.

make-all commented 1 year ago

The permission denied may just be that you are using the wrong server (selected at top), or the specific API call you are trying to use requires special permission (most of the calls under General Devices Management and everything under Industrial General Device System is in that category, but"Get Device Information" about halfway down the General Devices Management section returns product_id, local_key and other info about the device itself)

aeozyalcin commented 1 year ago

@backcountrymountains I am also playing around with a good integration for the Pioneer WYT. I actually found that the existing Starlight Heatpump is pretty dang good, and the latest additions to it (not in a release build yet), introduces display/buzzer switches. While they appear to show whether these options are on or off, I can't actually seem to be able to "write".

Unrelated note, I have an actual power monitor to measure the power usage of my 18K BTU WYT mini split. I have been struggling with bad temperature regulation/erratic compressor duty cycle behavior on my unit, so I have been digging deep logging room temperature, and my mini split power. I figured out that with id 116, and a scale of 30, there is really dang good correlation between actual measured power, and reported power.

  - entity: sensor
    class: power
    category: diagnostic
    name: Power
    dps:
      - id: 116
        type: integer
        name: sensor
        unit: "W"
        class: measurement
        mapping:
          - scale: 30

If you don't mind giving it a try and reporting back with a similar 1 day plot of your power usage, that would be awesome! I am trying to understand what kind of compressor duty cycle behavior is normal when these WYT mini splits are working to maintain room temperature. In the image below, pink is the "calculated power" (ignore the beginning where it's much higher than blue, I was trying to figure out the correct scale), and blue is the actual power I am measuring with a clamp current sensor.

image
make-all commented 1 year ago

30 seems like an odd factor, but if the unit is BTU/h, then a factor of 29.3 would match with the dp being 0.01 BTU/h readings.

aeozyalcin commented 1 year ago

30 seems like an odd factor, but if the unit is BTU/h, then a factor of 29.3 would match with the dp being 0.01 BTU/h readings.

That's an interesting point. I was also confused by how odd 30 was, but you bring up a good point. However, if this dp is "requested BTU/h", it's unlikely to match the exact electrical power like it seems to, since that would assume 100% efficiency. Not really sure what the relationship is, but it seems to track actual measured electrical power surprisingly well.

backcountrymountains commented 1 year ago

@aeozyalcin I tried adding the sensor you posted but tuya-local doesn't seem to recognize DP 116 on my device. I went to iot.tuya.com and I can get logged values from DP 116 (it's written in Chinese in the drop-down the website). The values do seem to correspond to the requested BTU/h or watts of the device (the values range from 246 when off and 4000 - 20000 when on).

How do I force tuya-local to query DP 116? Right now it just says "Unknown". I had to add optional: true to the config to even be able to select the modified device template because tuya-local kept saying missing required DPs: [{'116': 'int'}] The logs I posted above show that tuya-local doesn't see DP 116, even though iot.tuya.com is collecting that data. I don't know if I should open up a separate issue for that.

aeozyalcin commented 1 year ago

@aeozyalcin I tried adding the sensor you posted but tuya-local doesn't seem to recognize DP 116 on my device. I went to iot.tuya.com and I can get logged values from DP 116 (it's written in Chinese in the drop-down the website). The values do seem to correspond to the requested BTU/h or watts of the device (the values range from 246 when off and 4000 - 20000 when on).

How do I force tuya-local to query DP 116? Right now it just says "Unknown". I had to add optional: true to the config to even be able to select the modified device template because tuya-local kept saying missing required DPs: [{'116': 'int'}] The logs I posted above show that tuya-local doesn't see DP 116, even though iot.tuya.com is collecting that data. I don't know if I should open up a separate issue for that.

I think you forgot to attach your logs. But here is a rough template of how I have the power in my yaml. Once you save the yaml, make sure to reload the integration. And let me know! I am still struggling with bizarre/bad temperature regulation with my WYT, looking forward to seeing how your heat pump power varies throughout the day.

name: Pioneer heatpump
primary_entity:
  entity: climate
  translation_key: aircon_extra
  dps:
    - id: 1
    ...
    ...
    ...
secondary_entities:
  - entity: sensor
    class: power
    category: diagnostic
    name: Power
    dps:
      - id: 116
        type: integer
        name: sensor
        unit: "W"
        class: measurement
        mapping:
          - scale: 30
backcountrymountains commented 1 year ago

My logs are in the first comment. My device config is like this for DP 116. I had to add the optional: true because tuya-local doesn't see DP 116 and won't let me select a config that requires DP 116 without the optional tag:

name: Pioneer WYT Mini Split AC/Heat Pump
primary_entity:
  entity: climate
  translation_key: aircon_extra
  dps:
    - id: 116
      name: unknown_116
      type: integer
      optional: true
secondary_entities:
  - entity: sensor
    class: power
    category: diagnostic
    name: Power
    dps:
      - id: 116
        optional: true
        type: integer
        name: sensor
        unit: "W"
        class: measurement
        mapping:
          - scale: 30

This config creates a sensor for DP 116 but doesn't get the values from the device. I don't understand why tuya-local doesn't get the values but iot.tuya.com does have extensive logs of the values for DP 116.

Does your device report humidity on DP 18? My device doesn't show humidity either.

aeozyalcin commented 1 year ago

I don't have a humidity reporting either. Actually, I don't think the WYT series has a humidity sensor fitted at all.

Have you seen @make-all's suggestion on this issue?

The permission denied may just be that you are using the wrong server (selected at top), or the specific API call you are trying to use requires special permission (most of the calls under General Devices Management and everything under Industrial General Device System is in that category, but"Get Device Information" about halfway down the General Devices Management section returns product_id, local_key and other info about the device itself)

backcountrymountains commented 1 year ago

Yeah, that was an issue I was having with iot.tuya.com but was probably just due to multiple apps trying to query the device, which it doesn't like.

I've been playing around with the device and everything seems to be connecting working but I have no DP 116. I think I might be facing an issue similar to this tinytuya problem, where the energy or BTU/h is calculated from a different DP on my device, which is then logged in the tuya cloud on DP 116, but is not accessible on the device itself.

Can you check the Device Update section of the Tuya app for your mini-split? Mine says Main Module: V1.0.0 MCU Module: V1.0.0 Maybe we have slightly different devices. I know Pioneer very similar but slightly different models of mini-split.

aeozyalcin commented 1 year ago

The Tuya IOT project I have is in the Western American Data Center. I have these services authorized for the project.

image

My main module is v1.1.14 and MCU module is V1.0.0. This is on a brand new Pioneer WYT Diamante Ultra 18K BTU unit I installed just last month.

backcountrymountains commented 1 year ago

Maybe I have an old module. I installed the mini split last year but only got the tuya module this year. When you first ran the tuya-local add device integration, did you make a log of the DPs like in my first post? Does yours show DP 116 in that list? the integration might even show you that information if you set the log level to debug:

service: logger.set_level
data: 
  custom_components.tuya_local: debug

and check the logs.

aeozyalcin commented 1 year ago

So your Tuya module is not a USB stick then? My unit came with the Tuya USB stick, but I think the non diamante ultra units require a different module that plugs directly into the mainboard through a connector, rather than through USB. I will report back with the logs.

backcountrymountains commented 1 year ago

Yes, mine is a unit that plugs into the mainboard: image https://www.homedepot.com/p/Pioneer-Wireless-Internet-Access-and-Control-Module-For-WYT-Model-Mini-Split-System-TST-DIAWIFITPD/314610125#overlay

backcountrymountains commented 1 year ago

Hey, @aeozyalcin, can you post the result of querying DpID 110? It is a bitmask that shows what functionalities are available on the device. I wrote about it in jasonacox/tinytuya#391.

If you set custom_components.tuya_local: debug it should be in the HA log output.

[custom_components.tuya_local.device] Pioneer WYT Mini Split AC/Heat Pump received {"1": false, "2": 780, "3": 25, "4": "cold", "5": "high", "18": 0, "20": 0, "101": 0, "105": "off", "110": 2228796, "113": "0", "114": "0", "119": "0", "120": "off", "123": "0010", "125": "great", "126": "0", "127": "0", "128": "0", "129": "1", "130": 26, "131": false, "132": false, "133": "0", "134": "{\"t\":1690814535,\"s\":false,\"clr\":true}", "full_poll": true}

The value of DpID 110 on mine, 2228796, seems to indicate that it doesn't support power logging, despite iot.tuya.com having power logs. It's pretty weird.

Thanks.

aeozyalcin commented 1 year ago

Here is my log entry @backcountrymountains :

Living Room Heat Pump received {"1": true, "2": 740, "3": 22, "4": "cold", "5": "auto", "18": 0, "20": 0, "101": 0, "105": "off", "110": 2241084, "113": "1", "114": "1", "116": 2806, "119": "0", "120": "off", "123": "0000", "125": "great", "126": "0", "127": "0", "128": "0", "129": "1", "130": 26, "131": false, "132": false, "133": "3", "134": "{\"t\":16,\"s\":false,\"clr\":true}", "135": 1, "full_poll": true}
backcountrymountains commented 1 year ago

Thanks @aeozyalcin. That's definitely a different output than what I get from my WYT. I can't believe that the Pioneer people have different versions of Tuya integrations for such similar equipment. I also can't understand how iot.tuya.com can see DPiD 116 but I have no access to it. I think hacking the Tuya module is outside my skill level.

make-all commented 1 year ago

I've made some changes to the Daizuki config based on your findings, thanks.

aeozyalcin commented 1 year ago

@make-all the problem I have been facing is that the heat pump always reports current temperature in Celcius, while the set temperature unit depends on whether the heat pump remote is set to Celcius or Fahrenheit. Most Pioneer units will be Fahrenheit, since the brand is North American.

I haven't figured out a way to tell tuya-local/home assistant that the units are different between set temperature and current temperature. So when my heat pump is in Fahrenheit, the climate entity in HA accepts set temp in Fahrenheit correctly, but also incorrectly assumes current temperature is reported in Fahrenheit, so it shows "22 F", when it should say something like "71.6F". Declaring different units for DP ID 1 & 2 did not fix this issue.

make-all commented 1 year ago

The Daizuki config splits out current temperature into its own sensor to work around this. It is basically the only difference between Daizuki and starlight, which should also be compatible with the pioneer when set to Celsius

backcountrymountains commented 1 year ago

@aeozyalcin I just did a mapping of C to F in my config for the DpID 3, which is the current temperature on mine:

- id: 3
      name: current_temperature
      type: integer
      mapping:
        - dps_val: 15
          value: 59 
        - dps_val: 16
          value: 61 
        - dps_val: 17
          value: 63 
        - dps_val: 18
          value: 64 
        - dps_val: 19
          value: 66 
        - dps_val: 20
          value: 68 
        - dps_val: 21
          value: 70 
        - dps_val: 22
          value: 72 
        - dps_val: 23
          value: 73 
        - dps_val: 24
          value: 75 
        - dps_val: 25
          value: 77 
        - dps_val: 26
          value: 79 
        - dps_val: 27
          value: 81 
        - dps_val: 28
          value: 82 
        - dps_val: 29
          value: 84 
        - dps_val: 30
          value: 86 
        - dps_val: 31
          value: 88
        - dps_val: 32
          value: 90
      unit: F

Since the values are integer I'm not sure how exactly to make them more accurate with a decimal using the scale mapping (is it possible?) but it works well enough for me since it's just a sensor reading, not the setpoint.