Koenkk / zigbee-herdsman-converters

Collection of device converters to be used with zigbee-herdsman
MIT License
882 stars 2.93k forks source link

TuYa BAC-002 #7154

Closed robvanoostenrijk closed 6 months ago

robvanoostenrijk commented 6 months ago

While updating the TuYa BAC-002 converter to the new datapoint approach, there is a behavioral difference. The new convertor has a separate on/off switch and System Mode (Cool, Heat, Fan_Only).

The older convertor added 'Off' in the SystemMode enum using this following code: https://github.com/Koenkk/zigbee-herdsman-converters/blob/master/src/lib/legacy.ts#L6497

For 'Off' it calls dp: 1 to switch off, any other mode sends a zigbee message to both dp: 1 and dp: 2 to turn both the device on and set the relevant mode.

I am not sure how to write this action using the converter approach below:

 {
      fingerprint: tuya.fingerprint('TS0601', ['_TZE204_dzuqwsyg']),
      model: 'BAC-002',
      vendor: 'TuYa',
      description: 'Central air conditioner thermostat temperature controller',
      fromZigbee: [tuya.fz.datapoints],
      toZigbee: [tuya.tz.datapoints],
      onEvent: tuya.onEventSetTime,
      configure: tuya.configureMagicPacket,
      exposes: [
          e.binary('state', ea.STATE_SET, 'ON', 'OFF').withDescription('Turn the thermostat ON/OFF'),
          e.child_lock(),
          e.climate()
              .withLocalTemperature(ea.STATE)
              .withSetpoint('current_heating_setpoint', 5, 35, 1, ea.STATE_SET)
              .withSystemMode(['cool', 'heat', 'fan_only'], ea.STATE_SET)
              .withFanMode(['low', 'medium', 'high', 'auto'], ea.STATE_SET)
              .withLocalTemperatureCalibration(-3, 3, 1, ea.STATE_SET),
          e.binary('manual_mode', ea.STATE_SET, 'ON', 'OFF').withDescription('Manual = ON or Schedule = OFF'),
      ],
      meta: {
          tuyaDatapoints: [
              [1, 'state', tuya.valueConverter.onOff],
              [2, 'system_mode', tuya.valueConverterBasic.lookup({'cool': tuya.enum(0), 'heat': tuya.enum(1), 'fan_only': tuya.enum(2)})],
              [4, 'manual_mode', tuya.valueConverter.onOff],
              [16, 'current_heating_setpoint', tuya.valueConverter.raw],
              [24, 'local_temperature', tuya.valueConverter.divideBy10],
              [27, 'local_temperature_calibration', tuya.valueConverter.localTemperatureCalibration],
              [28, 'fan_mode', tuya.valueConverterBasic.lookup(
                  {'low': tuya.enum(0), 'medium': tuya.enum(1), 'high': tuya.enum(2), 'auto': tuya.enum(3)})],
              [40, 'child_lock', tuya.valueConverter.lockUnlock],
          ]
      }
  },
Koenkk commented 6 months ago

You can find an example how to send multiple requests in on valueConverter here

robvanoostenrijk commented 6 months ago

Thanks, I used this approach in https://github.com/Koenkk/zigbee-herdsman-converters/pull/7173.